X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fadapters%2FHistoryArrayAdapter.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fadapters%2FHistoryArrayAdapter.java;h=0000000000000000000000000000000000000000;hp=9eb81f84fad523bbf26ba7f9f9aaf52db26e4d2f;hb=b0f0322c62a5cd25e587f1760a33fcf60c279954;hpb=f0e5c878e1fda7007d674ea12104d957585d5964 diff --git a/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java b/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java deleted file mode 100644 index 9eb81f84..00000000 --- a/app/src/main/java/com/stoutner/privacybrowser/adapters/HistoryArrayAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright © 2016-2019,2021-2022 Soren Stoutner . - * - * This file is part of Privacy Browser Android . - * - * Privacy Browser Android is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Privacy Browser Android is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . - */ - -package com.stoutner.privacybrowser.adapters; - -import android.content.Context; -import android.graphics.Typeface; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -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.dataclasses.History; - -import java.util.ArrayList; - -public class HistoryArrayAdapter extends ArrayAdapter { - - // `currentPage` is used in `HistoryArrayAdapter` and `getView()`. - private final int currentPage; - - public HistoryArrayAdapter(Context context, ArrayList historyArrayList, int currentPageId) { - // `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. - currentPage = currentPageId; - } - - @Override - @NonNull - public View getView(int position, View convertView, @NonNull ViewGroup parent) { - // 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 = 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); - - // Remove the lint warning below that `history` might be `null`. - assert history != null; - - // Set `favoriteIconImageView` and `urlTextView`. - favoriteIconImageView.setImageBitmap(history.favoriteIcon); - urlTextView.setText(history.url); - - // Set the URL text for `currentPage` to be bold. - if (position == currentPage) { - urlTextView.setTypeface(Typeface.DEFAULT_BOLD); - } else { // Set the default typeface for all the other entries. - urlTextView.setTypeface(Typeface.DEFAULT); - } - - // Return the modified `convertView`. - return convertView; - } -} \ No newline at end of file