use of com.winsonchiu.reader.accounts.AccountsAdapter in project Reader by TheKeeperOfPie.
the class ActivityMain method inflateNavigationDrawer.
private void inflateNavigationDrawer() {
// TODO: Adhere to guidelines by making the increment 56dp on mobile and 64dp on tablet
float standardIncrement = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics());
float screenWidth = getResources().getDisplayMetrics().widthPixels;
float navigationWidth = screenWidth - UtilsTheme.getAttributeDimension(this, R.attr.actionBarSize, standardIncrement);
if (navigationWidth > standardIncrement * 6) {
navigationWidth = standardIncrement * 6;
}
layoutNavigation.getLayoutParams().width = (int) navigationWidth;
textAccountName.setTextColor(colorFilterPrimary.getColor());
textAccountInfo.setTextColor(colorFilterPrimary.getColor());
buttonAccounts.setColorFilter(colorFilterPrimary);
View.OnClickListener onClickListener = v -> setAccountsVisible(!accountsVisible);
textAccountName.setOnClickListener(onClickListener);
textAccountInfo.setOnClickListener(onClickListener);
buttonAccounts.setOnClickListener(onClickListener);
adapterAccounts = new AccountsAdapter(colorFilterPrimary.getColor(), this);
recyclerAccounts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
recyclerAccounts.setAdapter(adapterAccounts);
resetAccountList();
final GestureDetectorCompat gestureDetector = new GestureDetectorCompat(this, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
loadHeaderImage(true);
return true;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
String permalink = sharedPreferences.getString(AppSettings.HEADER_PERMALINK, "");
if (!TextUtils.isEmpty(permalink)) {
Intent intentActivity = new Intent(ActivityMain.this, ActivityMain.class);
intentActivity.setAction(Intent.ACTION_VIEW);
intentActivity.setData(Uri.parse(Reddit.BASE_URL + permalink));
startActivity(intentActivity);
return true;
}
return super.onSingleTapConfirmed(e);
}
});
// Add an empty view to remove extra margin on top
viewNavigation.addHeaderView(new View(this));
viewNavigation.setNavigationItemSelectedListener(menuItem -> {
loadId = menuItem.getItemId();
layoutDrawer.closeDrawer(GravityCompat.START);
return true;
});
scrollHeaderVertical.setDispatchTouchListener((v, event) -> {
gestureDetector.onTouchEvent(event);
switch(MotionEventCompat.getActionMasked(event)) {
case MotionEvent.ACTION_DOWN:
layoutDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
layoutDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
break;
}
return false;
});
loadHeaderImage(false);
}
Aggregations