@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_thread_list); // Setup toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null && toolbar != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setNavigationOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); } // Error Layout mErrorLayout = (RelativeLayout) findViewById(R.id.error_layout); if (mErrorLayout != null) { mErrorLayout.setVisibility(View.GONE); } mTvErrorMessage = (TextView) findViewById(R.id.error_message); mTvAction = (TextView) findViewById(R.id.action_text); if (mTvAction != null) { mTvAction.setVisibility(View.GONE); } // Get Extra information from intent getExtra(); // UI references mRecyclerView = (RecyclerView) findViewById(R.id.detail_recycler_view); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.home_swipe_refresh_layout); if (toolbar != null) { toolbar.setOnClickListener(CustomOnClickListener.doubleClickToListTop(this, mRecyclerView)); } setupRecyclerView(); setupSwipeRefreshLayout(); // FAB FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); if (fab != null) { fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(ThreadListActivity.this, NewPostActivity.class); intent.putExtra(NewPostActivity.ACTION_TAG, NewPostActivity.ACTION_NEW_THREAD); intent.putExtra(NewPostActivity.NEW_THREAD_FID_TAG, mFid); startActivityForResult(intent, PostListActivity.REQUEST_NEW_REPLY); } }); } }
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser && mContext != null && mRecyclerView != null) { getActivity() .findViewById(R.id.toolbar) .setOnClickListener(CustomOnClickListener.doubleClickToListTop(mContext, mRecyclerView)); } }
@Override protected void setupRecyclerView() { super.setupRecyclerView(); if (!isSetToolbar) { isSetToolbar = !isSetToolbar; getActivity() .findViewById(R.id.toolbar) .setOnClickListener(CustomOnClickListener.doubleClickToListTop(mContext, mRecyclerView)); } }