use of io.github.hidroh.materialistic.widget.CommentItemDecoration in project materialistic by hidroh.
the class ThreadPreviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Item item = getIntent().getParcelableExtra(EXTRA_ITEM);
if (item == null) {
finish();
return;
}
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_thread_preview);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
// noinspection ConstantConditions
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new SnappyLinearLayoutManager(this, false));
recyclerView.addItemDecoration(new CommentItemDecoration(this));
recyclerView.setAdapter(new ThreadPreviewRecyclerViewAdapter(mItemManager, item));
mKeyDelegate.setScrollable(new KeyDelegate.RecyclerViewHelper(recyclerView, KeyDelegate.RecyclerViewHelper.SCROLL_ITEM), null);
}
use of io.github.hidroh.materialistic.widget.CommentItemDecoration in project materialistic by hidroh.
the class UserActivity method onCreate.
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUsername = getIntent().getStringExtra(EXTRA_USERNAME);
if (TextUtils.isEmpty(mUsername)) {
mUsername = AppUtils.getDataUriId(getIntent(), PARAM_ID);
}
if (TextUtils.isEmpty(mUsername)) {
finish();
return;
}
setTaskTitle(mUsername);
AppUtils.setStatusBarDim(getWindow(), true);
setContentView(R.layout.activity_user);
findViewById(R.id.touch_outside).setOnClickListener(v -> finish());
mBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch(newState) {
case BottomSheetBehavior.STATE_HIDDEN:
finish();
break;
case BottomSheetBehavior.STATE_EXPANDED:
AppUtils.setStatusBarDim(getWindow(), false);
mRecyclerView.setLayoutFrozen(false);
break;
case BottomSheetBehavior.STATE_COLLAPSED:
case BottomSheetBehavior.STATE_DRAGGING:
case BottomSheetBehavior.STATE_HALF_EXPANDED:
case BottomSheetBehavior.STATE_SETTLING:
default:
AppUtils.setStatusBarDim(getWindow(), true);
break;
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// no op
}
});
mTitle = (TextView) findViewById(R.id.title);
mTitle.setText(mUsername);
mInfo = (TextView) findViewById(R.id.user_info);
mAbout = (TextView) findViewById(R.id.about);
mEmpty = findViewById(R.id.empty);
mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
// no op
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
// no op
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
scrollToTop();
}
});
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(this, true));
mRecyclerView.addItemDecoration(new CommentItemDecoration(this));
mScrollableHelper = new KeyDelegate.RecyclerViewHelper(mRecyclerView, KeyDelegate.RecyclerViewHelper.SCROLL_ITEM);
if (savedInstanceState != null) {
mUser = savedInstanceState.getParcelable(STATE_USER);
}
if (mUser == null) {
load();
} else {
bind();
}
if (!AppUtils.hasConnection(this)) {
Snackbar.make(findViewById(R.id.content_frame), R.string.offline_notice, Snackbar.LENGTH_LONG).show();
}
}
use of io.github.hidroh.materialistic.widget.CommentItemDecoration in project materialistic by hidroh.
the class ItemFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable final Bundle savedInstanceState) {
if (isNewInstance()) {
mFragmentView = inflater.inflate(R.layout.fragment_item, container, false);
mEmptyView = mFragmentView.findViewById(R.id.empty);
mRecyclerView = (RecyclerView) mFragmentView.findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(getActivity(), true));
mItemDecoration = new CommentItemDecoration(getActivity());
mRecyclerView.addItemDecoration(mItemDecoration);
mSwipeRefreshLayout = (SwipeRefreshLayout) mFragmentView.findViewById(R.id.swipe_layout);
mSwipeRefreshLayout.setColorSchemeResources(R.color.white);
mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.redA200);
mSwipeRefreshLayout.setOnRefreshListener(() -> {
if (TextUtils.isEmpty(mItemId)) {
return;
}
mCacheMode = ItemManager.MODE_NETWORK;
if (mAdapter != null) {
mAdapter.setCacheMode(mCacheMode);
}
loadKidData();
});
}
return mFragmentView;
}
Aggregations