Using butterknife to bind views in fragments
This commit is contained in:
parent
89caf33f46
commit
5f8470c577
@ -45,10 +45,6 @@ import acr.browser.lightning.utils.Utils;
|
||||
*/
|
||||
public class BrowserDialog {
|
||||
|
||||
public interface Listener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
public interface EditorListener {
|
||||
void onClick(String text);
|
||||
}
|
||||
@ -58,12 +54,12 @@ public class BrowserDialog {
|
||||
private final int mTitle;
|
||||
private boolean mCondition = true;
|
||||
|
||||
public Item(@StringRes int title, boolean condition) {
|
||||
Item(@StringRes int title, boolean condition) {
|
||||
this(title);
|
||||
mCondition = condition;
|
||||
}
|
||||
|
||||
public Item(@StringRes int title) {
|
||||
protected Item(@StringRes int title) {
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,8 @@ import acr.browser.lightning.dialog.LightningDialogBuilder;
|
||||
import acr.browser.lightning.preference.PreferenceManager;
|
||||
import acr.browser.lightning.utils.ThemeUtils;
|
||||
import acr.browser.lightning.view.LightningView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class BookmarksFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener, BookmarksView {
|
||||
|
||||
@ -90,8 +92,9 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
||||
private final List<HistoryItem> mBookmarks = new ArrayList<>();
|
||||
|
||||
// Views
|
||||
private ListView mBookmarksListView;
|
||||
private ImageView mBookmarkTitleImage, mBookmarkImage;
|
||||
@Bind(R.id.right_drawer_list) ListView mBookmarksListView;
|
||||
@Bind(R.id.starIcon) ImageView mBookmarkTitleImage;
|
||||
@Bind(R.id.icon_star) ImageView mBookmarkImage;
|
||||
|
||||
// Colors
|
||||
private int mIconColor, mScrollIndex;
|
||||
@ -173,12 +176,10 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View view = inflater.inflate(R.layout.bookmark_drawer, container, false);
|
||||
mBookmarksListView = (ListView) view.findViewById(R.id.right_drawer_list);
|
||||
ButterKnife.bind(this, view);
|
||||
mBookmarksListView.setOnItemClickListener(mItemClickListener);
|
||||
mBookmarksListView.setOnItemLongClickListener(mItemLongClickListener);
|
||||
mBookmarkTitleImage = (ImageView) view.findViewById(R.id.starIcon);
|
||||
mBookmarkTitleImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||
mBookmarkImage = (ImageView) view.findViewById(R.id.icon_star);
|
||||
final View backView = view.findViewById(R.id.bookmark_back_button);
|
||||
backView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -205,6 +206,12 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
ButterKnife.unbind(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
@ -48,6 +48,8 @@ import acr.browser.lightning.utils.ThemeUtils;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
import acr.browser.lightning.view.BackgroundDrawable;
|
||||
import acr.browser.lightning.view.LightningView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* A fragment that holds and manages the tabs and interaction with the tabs.
|
||||
@ -74,7 +76,8 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
|
||||
@Nullable private LightningViewAdapter mTabsAdapter;
|
||||
private UIController mUiController;
|
||||
private RecyclerView mRecyclerView;
|
||||
|
||||
@Bind(R.id.tabs_list) RecyclerView mRecyclerView;
|
||||
|
||||
private TabsManager mTabsManager;
|
||||
@Inject Bus mBus;
|
||||
@ -126,7 +129,9 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
}
|
||||
});
|
||||
}
|
||||
mRecyclerView = (RecyclerView) view.findViewById(R.id.tabs_list);
|
||||
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
SimpleItemAnimator animator;
|
||||
if (mShowInNavigationDrawer) {
|
||||
animator = new VerticalItemAnimator();
|
||||
@ -144,9 +149,17 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer);
|
||||
mRecyclerView.setAdapter(mTabsAdapter);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
ButterKnife.unbind(this);
|
||||
mTabsAdapter = null;
|
||||
}
|
||||
|
||||
private TabsManager getTabsManager() {
|
||||
if (mTabsManager == null) {
|
||||
mTabsManager = mUiController.getTabModel();
|
||||
@ -163,12 +176,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
mTabsAdapter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
Loading…
x
Reference in New Issue
Block a user