}
}));
- fab.show();
+ mActivity.fabShouldShow();
root.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (fab != null) {
- if (dy < 0) fab.show();
+ if (dy < 0) mActivity.fabShouldShow();
if (dy > 0) fab.hide();
}
}
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.ColorInt;
+import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
private LinearLayout progressLayout;
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
+ private FloatingActionButton fab;
@Override
protected void onStart() {
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
+ fab = findViewById(R.id.btn_add_transaction);
Data.profile.addObserver((o, arg) -> {
MobileLedgerProfile profile = Data.profile.get();
if (profile == null) setTitle(R.string.app_name);
else setTitle(profile.getName());
updateLastUpdateTextFromDB();
+ if (profile.isPostingPermitted()) fab.show();
+ else fab.hide();
});
});
return 2;
}
}
-
+ public void fabShouldShow() {
+ MobileLedgerProfile profile = Data.profile.get();
+ if (profile.isPostingPermitted()) fab.show();
+ }
}
FloatingActionButton fab = mActivity.findViewById(R.id.btn_add_transaction);
- fab.show();
+ mActivity.fabShouldShow();
root.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
- if (dy < 0) fab.show();
+ if (dy < 0) mActivity.fabShouldShow();
if (dy > 0) fab.hide();
}
});