Hide FAB and BottomAppBar in anonymous mode.

This commit is contained in:
Alex Ning 2019-12-18 18:41:23 +08:00
parent 5097919a36
commit dafd0796e9
2 changed files with 13 additions and 12 deletions

View File

@ -329,14 +329,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
getCurrentAccountAndBindView(); getCurrentAccountAndBindView();
} }
fab.setOnClickListener(view -> { fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()));
if (mAccessToken == null) {
Toast.makeText(MainActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
}
postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag());
});
} }
@Override @Override
@ -453,8 +446,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (mAccessToken == null) { if (mAccessToken == null) {
bottomNavigationView.setVisibility(View.GONE); bottomNavigationView.setVisibility(View.GONE);
fab.setVisibility(View.GONE);
} else { } else {
bottomNavigationView.setVisibility(View.VISIBLE); bottomNavigationView.setVisibility(View.VISIBLE);
fab.setVisibility(View.VISIBLE);
subscriptionsBottomAppBar.setOnClickListener(view -> { subscriptionsBottomAppBar.setOnClickListener(view -> {
Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
startActivity(intent); startActivity(intent);
@ -924,13 +919,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} }
public void postScrollUp() { public void postScrollUp() {
bottomNavigationView.performShow(); if (mAccessToken != null) {
fab.show(); bottomNavigationView.performShow();
fab.show();
}
} }
public void postScrollDown() { public void postScrollDown() {
fab.hide(); if (mAccessToken != null) {
bottomNavigationView.performHide(); fab.hide();
bottomNavigationView.performHide();
}
} }
@Subscribe @Subscribe

View File

@ -62,6 +62,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:gravity="center" android:gravity="center"
android:visibility="gone"
app:backgroundTint="?attr/backgroundColor" app:backgroundTint="?attr/backgroundColor"
app:layout_anchorGravity="start" app:layout_anchorGravity="start"
app:fabAnimationMode="scale" app:fabAnimationMode="scale"
@ -110,6 +111,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone"
app:backgroundTint="?attr/backgroundColor" app:backgroundTint="?attr/backgroundColor"
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
app:tint="@null" app:tint="@null"