Browse Source

Cleaning up new suggestions class

master
Anthony Restaino 8 years ago
parent
commit
d5c8479a41
  1. 27
      app/src/main/java/acr/browser/lightning/search/Suggestions.java

27
app/src/main/java/acr/browser/lightning/search/Suggestions.java

@ -23,7 +23,6 @@ import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Inject; import javax.inject.Inject;
@ -70,10 +69,10 @@ public class Suggestions extends BaseAdapter implements Filterable {
private final List<HistoryItem> mAllBookmarks = new ArrayList<>(5); private final List<HistoryItem> mAllBookmarks = new ArrayList<>(5);
private boolean mDarkTheme; private final boolean mDarkTheme;
private boolean mUseGoogle = true; private boolean mUseGoogle = true;
private boolean mIsIncognito = true; private boolean mIsIncognito = true;
@NonNull private Context mContext; @NonNull private final Context mContext;
public Suggestions(@NonNull Context context, boolean dark, boolean incognito) { public Suggestions(@NonNull Context context, boolean dark, boolean incognito) {
super(); super();
@ -124,15 +123,15 @@ public class Suggestions extends BaseAdapter implements Filterable {
private static class SuggestionHolder { private static class SuggestionHolder {
public SuggestionHolder(View view) { public SuggestionHolder(@NonNull View view) {
mTitle = (TextView) view.findViewById(R.id.title); mTitle = (TextView) view.findViewById(R.id.title);
mUrl = (TextView) view.findViewById(R.id.url); mUrl = (TextView) view.findViewById(R.id.url);
mImage = (ImageView) view.findViewById(R.id.suggestionIcon); mImage = (ImageView) view.findViewById(R.id.suggestionIcon);
} }
ImageView mImage; final ImageView mImage;
TextView mTitle; final TextView mTitle;
TextView mUrl; final TextView mUrl;
} }
@ -154,29 +153,25 @@ public class Suggestions extends BaseAdapter implements Filterable {
holder.mTitle.setText(web.getTitle()); holder.mTitle.setText(web.getTitle());
holder.mUrl.setText(web.getUrl()); holder.mUrl.setText(web.getUrl());
if (mDarkTheme) {
holder.mTitle.setTextColor(Color.WHITE);
}
Drawable image; Drawable image;
switch (web.getImageId()) { switch (web.getImageId()) {
case R.drawable.ic_bookmark: { case R.drawable.ic_bookmark: {
if (mDarkTheme)
holder.mTitle.setTextColor(Color.WHITE);
image = mBookmarkDrawable; image = mBookmarkDrawable;
break; break;
} }
case R.drawable.ic_search: { case R.drawable.ic_search: {
if (mDarkTheme)
holder.mTitle.setTextColor(Color.WHITE);
image = mSearchDrawable; image = mSearchDrawable;
break; break;
} }
case R.drawable.ic_history: { case R.drawable.ic_history: {
if (mDarkTheme)
holder.mTitle.setTextColor(Color.WHITE);
image = mHistoryDrawable; image = mHistoryDrawable;
break; break;
} }
default: default:
if (mDarkTheme)
holder.mTitle.setTextColor(Color.WHITE);
image = mSearchDrawable; image = mSearchDrawable;
break; break;
} }
@ -312,7 +307,7 @@ public class Suggestions extends BaseAdapter implements Filterable {
private static class SearchFilter extends Filter { private static class SearchFilter extends Filter {
@NonNull private Suggestions mSuggestions; @NonNull private final Suggestions mSuggestions;
public SearchFilter(@NonNull Suggestions suggestions) { public SearchFilter(@NonNull Suggestions suggestions) {
mSuggestions = suggestions; mSuggestions = suggestions;

Loading…
Cancel
Save