X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fadapters%2FHistoryArrayAdapter.java;h=33fa6e5af0e5a61bc538db626ecd7e3a2a8be24c;hp=1135638c7058945f6c771a15abd828a32418ae40;hb=6ea3e4ebd779594b45ad8f51cc40761bb6d89030;hpb=ae2ee09aa7a2afc19f5603c9bc021f98888d7b78 diff --git a/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java b/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java index 1135638c..33fa6e5a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java +++ b/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java @@ -1,5 +1,5 @@ -/** - * Copyright 2016 Soren Stoutner . +/* + * Copyright © 2016-2019,2021 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -21,7 +21,6 @@ package com.stoutner.privacybrowser.adapters; import android.content.Context; import android.graphics.Typeface; -import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -29,18 +28,20 @@ import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; + import com.stoutner.privacybrowser.R; -import com.stoutner.privacybrowser.definitions.History; +import com.stoutner.privacybrowser.dataclasses.History; import java.util.ArrayList; public class HistoryArrayAdapter extends ArrayAdapter { // `currentPage` is used in `HistoryArrayAdapter` and `getView()`. - private int currentPage; + private final int currentPage; public HistoryArrayAdapter(Context context, ArrayList historyArrayList, int currentPageId) { - // We need to call `super` from the base `ArrayAdapter`. `0` is the `textViewResourceId`. + // `super` must be called from the base `ArrayAdapter`. `0` is the `textViewResourceId`, which is unused. super(context, 0, historyArrayList); // Store `currentPageId` in the class variable. @@ -50,15 +51,15 @@ public class HistoryArrayAdapter extends ArrayAdapter { @Override @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { - // Inflate the view if it is `null`. + // Inflate the view if it is null. if (convertView == null) { // `false` does not attach `url_history_item_linearlayout` to `parent`. convertView = LayoutInflater.from(getContext()).inflate(R.layout.url_history_item_linearlayout, parent, false); } // Get handles for `favoriteIconImageView` and `urlTextView`. - ImageView favoriteIconImageView = (ImageView) convertView.findViewById(R.id.history_favorite_icon_imageview); - TextView urlTextView = (TextView) convertView.findViewById(R.id.history_url_textview); + ImageView favoriteIconImageView = convertView.findViewById(R.id.history_favorite_icon_imageview); + TextView urlTextView = convertView.findViewById(R.id.history_url_textview); // Get the URL history for this position. History history = getItem(position); @@ -67,8 +68,8 @@ public class HistoryArrayAdapter extends ArrayAdapter { assert history != null; // Set `favoriteIconImageView` and `urlTextView`. - favoriteIconImageView.setImageBitmap(history.entryFavoriteIcon); - urlTextView.setText(history.entryUrl); + favoriteIconImageView.setImageBitmap(history.favoriteIcon); + urlTextView.setText(history.url); // Set the URL text for `currentPage` to be bold. if (position == currentPage) {