Browse Source

Add null annotations for fragments

master
Anthony Restaino 9 years ago
parent
commit
970ffbaca8
  1. 5
      app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java
  2. 45
      app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java
  3. 16
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  4. 5
      app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java
  5. 7
      app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java
  6. 7
      app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java
  7. 45
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

5
app/src/main/java/acr/browser/lightning/fragment/AdvancedSettingsFragment.java

@ -8,6 +8,7 @@ import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import java.util.Arrays; import java.util.Arrays;
@ -88,7 +89,7 @@ public class AdvancedSettingsFragment extends LightningPreferenceFragment implem
} }
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(@NonNull Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_RENDERINGMODE: case SETTINGS_RENDERINGMODE:
renderPicker(); renderPicker();
@ -105,7 +106,7 @@ public class AdvancedSettingsFragment extends LightningPreferenceFragment implem
} }
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
// switch preferences // switch preferences
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_NEWWINDOW: case SETTINGS_NEWWINDOW:

45
app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java

@ -12,6 +12,8 @@ import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import java.io.File; import java.io.File;
@ -27,8 +29,11 @@ import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.database.BookmarkLocalSync; import acr.browser.lightning.database.BookmarkLocalSync;
import acr.browser.lightning.database.BookmarkManager; import acr.browser.lightning.database.BookmarkManager;
import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.database.HistoryItem;
import com.anthonycr.grant.PermissionsManager; import com.anthonycr.grant.PermissionsManager;
import com.anthonycr.grant.PermissionsResultAction; import com.anthonycr.grant.PermissionsResultAction;
import acr.browser.lightning.utils.Preconditions;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;
public class BookmarkSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener { public class BookmarkSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
@ -37,12 +42,13 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
private static final String SETTINGS_IMPORT = "import_bookmark"; private static final String SETTINGS_IMPORT = "import_bookmark";
private static final String SETTINGS_IMPORT_BROWSER = "import_browser"; private static final String SETTINGS_IMPORT_BROWSER = "import_browser";
private Activity mActivity; @Nullable private Activity mActivity;
@Inject
BookmarkManager mBookmarkManager; @Inject BookmarkManager mBookmarkManager;
private File[] mFileList; private File[] mFileList;
private String[] mFileNameList; private String[] mFileNameList;
private BookmarkLocalSync mSync; @Nullable private BookmarkLocalSync mSync;
private static final String[] REQUIRED_PERMISSIONS = new String[]{ private static final String[] REQUIRED_PERMISSIONS = new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE Manifest.permission.WRITE_EXTERNAL_STORAGE
@ -52,7 +58,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
private class ImportBookmarksTask extends AsyncTask<Void, Void, Integer> { private class ImportBookmarksTask extends AsyncTask<Void, Void, Integer> {
private final WeakReference<Activity> mActivityReference; @NonNull private final WeakReference<Activity> mActivityReference;
public ImportBookmarksTask(Activity activity) { public ImportBookmarksTask(Activity activity) {
mActivityReference = new WeakReference<>(activity); mActivityReference = new WeakReference<>(activity);
@ -61,10 +67,10 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
@Override @Override
protected Integer doInBackground(Void... params) { protected Integer doInBackground(Void... params) {
List<HistoryItem> list = null; List<HistoryItem> list = null;
if (mSync.isStockSupported()) { if (getSync().isStockSupported()) {
list = mSync.getBookmarksFromStockBrowser(); list = getSync().getBookmarksFromStockBrowser();
} else if (mSync.isChromeSupported()) { } else if (getSync().isChromeSupported()) {
list = mSync.getBookmarksFromChrome(); list = getSync().getBookmarksFromChrome();
} }
int count = 0; int count = 0;
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
@ -86,6 +92,16 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
} }
} }
@NonNull
private BookmarkLocalSync getSync() {
Preconditions.checkNonNull(mActivity);
if (mSync == null) {
mSync = new BookmarkLocalSync(mActivity);
}
return mSync;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -94,6 +110,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
addPreferencesFromResource(R.xml.preference_bookmarks); addPreferencesFromResource(R.xml.preference_bookmarks);
mActivity = getActivity(); mActivity = getActivity();
mSync = new BookmarkLocalSync(mActivity);
initPrefs(); initPrefs();
@ -117,8 +134,6 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
Preference exportpref = findPreference(SETTINGS_EXPORT); Preference exportpref = findPreference(SETTINGS_EXPORT);
Preference importpref = findPreference(SETTINGS_IMPORT); Preference importpref = findPreference(SETTINGS_IMPORT);
mSync = new BookmarkLocalSync(mActivity);
exportpref.setOnPreferenceClickListener(this); exportpref.setOnPreferenceClickListener(this);
importpref.setOnPreferenceClickListener(this); importpref.setOnPreferenceClickListener(this);
@ -129,13 +144,13 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
@Override @Override
public void run() { public void run() {
Preference importStock = findPreference(SETTINGS_IMPORT_BROWSER); Preference importStock = findPreference(SETTINGS_IMPORT_BROWSER);
importStock.setEnabled(mSync.isStockSupported() || mSync.isChromeSupported()); importStock.setEnabled(getSync().isStockSupported() || getSync().isChromeSupported());
importStock.setOnPreferenceClickListener(BookmarkSettingsFragment.this); importStock.setOnPreferenceClickListener(BookmarkSettingsFragment.this);
} }
}; };
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(@NonNull Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_EXPORT: case SETTINGS_EXPORT:
PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS, PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(), REQUIRED_PERMISSIONS,
@ -175,7 +190,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
} }
} }
private void loadFileList(File path) { private void loadFileList(@Nullable File path) {
File file; File file;
if (path != null) { if (path != null) {
file = path; file = path;
@ -208,7 +223,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
private static class SortName implements Comparator<File> { private static class SortName implements Comparator<File> {
@Override @Override
public int compare(File a, File b) { public int compare(@NonNull File a, @NonNull File b) {
if (a.isDirectory() && b.isDirectory()) if (a.isDirectory() && b.isDirectory())
return a.getName().compareTo(b.getName()); return a.getName().compareTo(b.getName());

16
app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java

@ -146,7 +146,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.bookmark_drawer, container, false); final View view = inflater.inflate(R.layout.bookmark_drawer, container, false);
mBookmarksListView = (ListView) view.findViewById(R.id.right_drawer_list); mBookmarksListView = (ListView) view.findViewById(R.id.right_drawer_list);
mBookmarksListView.setOnItemClickListener(mItemClickListener); mBookmarksListView.setOnItemClickListener(mItemClickListener);
@ -187,14 +187,14 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
} }
@Subscribe @Subscribe
public void addBookmark(final BrowserEvents.BookmarkAdded event) { public void addBookmark(@NonNull final BrowserEvents.BookmarkAdded event) {
updateBookmarkIndicator(event.url); updateBookmarkIndicator(event.url);
String folder = mBookmarkManager.getCurrentFolder(); String folder = mBookmarkManager.getCurrentFolder();
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false); setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false);
} }
@Subscribe @Subscribe
public void currentPageInfo(final BrowserEvents.CurrentPageUrl event) { public void currentPageInfo(@NonNull final BrowserEvents.CurrentPageUrl event) {
updateBookmarkIndicator(event.url); updateBookmarkIndicator(event.url);
String folder = mBookmarkManager.getCurrentFolder(); String folder = mBookmarkManager.getCurrentFolder();
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false); setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false);
@ -227,7 +227,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
} }
@Subscribe @Subscribe
public void bookmarkDeleted(final BookmarkEvents.Deleted event) { public void bookmarkDeleted(@NonNull final BookmarkEvents.Deleted event) {
mBookmarks.remove(event.item); mBookmarks.remove(event.item);
if (event.item.isFolder()) { if (event.item.isFolder()) {
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(null, true), false); setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(null, true), false);
@ -236,7 +236,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
} }
} }
private void setBookmarkDataSet(List<HistoryItem> items, boolean animate) { private void setBookmarkDataSet(@NonNull List<HistoryItem> items, boolean animate) {
mBookmarks.clear(); mBookmarks.clear();
mBookmarks.addAll(items); mBookmarks.addAll(items);
mBookmarkAdapter.notifyDataSetChanged(); mBookmarkAdapter.notifyDataSetChanged();
@ -294,7 +294,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
} }
private void handleLongPress(final HistoryItem item) { private void handleLongPress(@NonNull final HistoryItem item) {
if (item.isFolder()) { if (item.isFolder()) {
mBookmarksDialogBuilder.showBookmarkFolderLongPressedDialog(getContext(), item); mBookmarksDialogBuilder.showBookmarkFolderLongPressedDialog(getContext(), item);
} else { } else {
@ -303,7 +303,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
} }
@Override @Override
public void onClick(View v) { public void onClick(@NonNull View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.action_add_bookmark: case R.id.action_add_bookmark:
mEventBus.post(new BookmarkEvents.ToggleBookmarkForCurrentPage()); mEventBus.post(new BookmarkEvents.ToggleBookmarkForCurrentPage());
@ -338,7 +338,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
final Context context; final Context context;
public BookmarkViewAdapter(Context context, List<HistoryItem> data) { public BookmarkViewAdapter(Context context, @NonNull List<HistoryItem> data) {
super(context, R.layout.bookmark_list_item, data); super(context, R.layout.bookmark_list_item, data);
this.context = context; this.context = context;
} }

5
app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java

@ -8,6 +8,7 @@ import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -83,7 +84,7 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(@NonNull Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_THEME: case SETTINGS_THEME:
themePicker(); themePicker();
@ -97,7 +98,7 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
// switch preferences // switch preferences
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_HIDESTATUSBAR: case SETTINGS_HIDESTATUSBAR:

7
app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java

@ -10,6 +10,7 @@ import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.text.Editable; import android.text.Editable;
@ -503,7 +504,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(@NonNull Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_PROXY: case SETTINGS_PROXY:
proxyChoicePicker(); proxyChoicePicker();
@ -526,7 +527,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
boolean checked = false; boolean checked = false;
if (newValue instanceof Boolean) { if (newValue instanceof Boolean) {
checked = (Boolean) newValue; checked = (Boolean) newValue;
@ -586,7 +587,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
public void onTextChanged(CharSequence s, int start, int before, int count) {} public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(@NonNull Editable s) {
if (!DownloadHandler.isWriteAccessAvailable(s.toString())) { if (!DownloadHandler.isWriteAccessAvailable(s.toString())) {
this.getDownload.setTextColor(this.errorColor); this.getDownload.setTextColor(this.errorColor);
} else { } else {

7
app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java

@ -11,6 +11,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.Preference; import android.preference.Preference;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.webkit.WebView; import android.webkit.WebView;
@ -114,7 +115,7 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(@NonNull Message msg) {
switch (msg.what) { switch (msg.what) {
case 1: case 1:
Utils.showSnackbar(mHandlerContext, R.string.message_clear_history); Utils.showSnackbar(mHandlerContext, R.string.message_clear_history);
@ -128,7 +129,7 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(@NonNull Preference preference) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_CLEARCACHE: case SETTINGS_CLEARCACHE:
clearCache(); clearCache();
@ -209,7 +210,7 @@ public class PrivacySettingsFragment extends LightningPreferenceFragment impleme
} }
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
switch (preference.getKey()) { switch (preference.getKey()) {
case SETTINGS_LOCATION: case SETTINGS_LOCATION:
mPreferenceManager.setLocationEnabled((Boolean) newValue); mPreferenceManager.setLocationEnabled((Boolean) newValue);

45
app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

@ -69,8 +69,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
private boolean mColorMode = true; private boolean mColorMode = true;
private boolean mShowInNavigationDrawer; private boolean mShowInNavigationDrawer;
private RecyclerView mRecyclerView; @Nullable private LightningViewAdapter mTabsAdapter;
private LightningViewAdapter mTabsAdapter;
private UIController mUiController; private UIController mUiController;
@Inject TabsManager tabsManager; @Inject TabsManager tabsManager;
@ -99,7 +98,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view; final View view;
final LayoutManager layoutManager; final LayoutManager layoutManager;
if (mShowInNavigationDrawer) { if (mShowInNavigationDrawer) {
@ -114,11 +113,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
view = inflater.inflate(R.layout.tab_strip, container, false); view = inflater.inflate(R.layout.tab_strip, container, false);
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
} }
mRecyclerView = (RecyclerView) view.findViewById(R.id.tabs_list); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.tabs_list);
mRecyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer); mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer);
mRecyclerView.setAdapter(mTabsAdapter); recyclerView.setAdapter(mTabsAdapter);
mRecyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
return view; return view;
} }
@ -134,7 +133,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
mRecyclerView = null;
mTabsAdapter = null; mTabsAdapter = null;
} }
@ -148,8 +146,10 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
// Force adapter refresh // Force adapter refresh
if (mTabsAdapter != null) {
mTabsAdapter.notifyDataSetChanged(); mTabsAdapter.notifyDataSetChanged();
} }
}
@Override @Override
public void onStop() { public void onStop() {
@ -165,7 +165,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
} }
@Override @Override
public void onClick(View v) { public void onClick(@NonNull View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.new_tab_button: case R.id.new_tab_button:
mBus.post(new TabEvents.NewTab()); mBus.post(new TabEvents.NewTab());
@ -184,7 +184,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
} }
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(@NonNull View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.action_new_tab: case R.id.action_new_tab:
mBus.post(new TabEvents.NewTabLongPress()); mBus.post(new TabEvents.NewTabLongPress());
@ -198,9 +198,9 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> { public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> {
private final int mLayoutResourceId; private final int mLayoutResourceId;
private final Drawable mBackgroundTabDrawable; @Nullable private final Drawable mBackgroundTabDrawable;
private final Drawable mForegroundTabDrawable; @Nullable private final Drawable mForegroundTabDrawable;
private final Bitmap mForegroundTabBitmap; @Nullable private final Bitmap mForegroundTabBitmap;
private ColorMatrix mColorMatrix; private ColorMatrix mColorMatrix;
private Paint mPaint; private Paint mPaint;
private ColorFilter mFilter; private ColorFilter mFilter;
@ -229,15 +229,16 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
} }
} }
@NonNull
@Override @Override
public LightningViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public LightningViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
View view = inflater.inflate(mLayoutResourceId, viewGroup, false); View view = inflater.inflate(mLayoutResourceId, viewGroup, false);
return new LightningViewHolder(view); return new LightningViewHolder(view);
} }
@Override @Override
public void onBindViewHolder(final LightningViewHolder holder, int position) { public void onBindViewHolder(@NonNull final LightningViewHolder holder, int position) {
holder.exitButton.setTag(position); holder.exitButton.setTag(position);
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton); ViewCompat.jumpDrawablesToCurrentState(holder.exitButton);
@ -293,7 +294,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
return tabsManager.size(); return tabsManager.size();
} }
public Bitmap getDesaturatedBitmap(Bitmap favicon) { public Bitmap getDesaturatedBitmap(@NonNull Bitmap favicon) {
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(), Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(),
favicon.getHeight(), Bitmap.Config.ARGB_8888); favicon.getHeight(), Bitmap.Config.ARGB_8888);
@ -312,7 +313,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public class LightningViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { public class LightningViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
public LightningViewHolder(View view) { public LightningViewHolder(@NonNull View view) {
super(view); super(view);
txtTitle = (TextView) view.findViewById(R.id.textTab); txtTitle = (TextView) view.findViewById(R.id.textTab);
favicon = (ImageView) view.findViewById(R.id.faviconTab); favicon = (ImageView) view.findViewById(R.id.faviconTab);
@ -326,11 +327,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
layout.setOnLongClickListener(this); layout.setOnLongClickListener(this);
} }
final TextView txtTitle; @NonNull final TextView txtTitle;
final ImageView favicon; @NonNull final ImageView favicon;
final ImageView exit; @NonNull final ImageView exit;
final FrameLayout exitButton; @NonNull final FrameLayout exitButton;
final LinearLayout layout; @NonNull final LinearLayout layout;
@Override @Override
public void onClick(View v) { public void onClick(View v) {

Loading…
Cancel
Save