profileListHeadCancel.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
profileListHeadMoreAndCancel
.setOnClickListener((v) -> mProfileListAdapter.flipEditingProfiles());
-
+ if (drawerListener == null) {
+ drawerListener = new DrawerLayout.SimpleDrawerListener() {
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ mProfileListAdapter.setAnimationsEnabled(false);
+ mProfileListAdapter.editingProfiles.setValue(false);
+ }
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ mProfileListAdapter.setAnimationsEnabled(true);
+ }
+ };
+ drawer.addDrawerListener(drawerListener);
+ }
setupProfile();
}
private void scheduleDataRetrievalIfStale(Date lastUpdate) {
public MutableLiveData<Boolean> editingProfiles = new MutableLiveData<>(false);
private RecyclerView recyclerView;
private ItemTouchHelper rearrangeHelper;
+ private boolean animationsEnabled = true;
public ProfilesRecyclerViewAdapter() {
debug("flow", "ProfilesRecyclerViewAdapter.new()");
};
rearrangeHelper = new ItemTouchHelper(cb);
}
+ public void setAnimationsEnabled(boolean animationsEnabled) {
+ this.animationsEnabled = animationsEnabled;
+ }
@Override
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
rearrangeHelper.attachToRecyclerView(null);
public void startEditingProfiles() {
if (editingProfiles.getValue()) return;
this.editingProfiles.setValue(true);
- notifyDataSetChanged();
rearrangeHelper.attachToRecyclerView(recyclerView);
}
public void stopEditingProfiles() {
if (!editingProfiles.getValue()) return;
this.editingProfiles.setValue(false);
- notifyDataSetChanged();
rearrangeHelper.attachToRecyclerView(null);
}
public void flipEditingProfiles() {
boolean wasHidden = holder.mEditButton.getVisibility() == View.GONE;
holder.mRearrangeHandle.setVisibility(View.VISIBLE);
holder.mEditButton.setVisibility(View.VISIBLE);
- if (wasHidden) {
+ if (wasHidden && animationsEnabled) {
Animation a = AnimationUtils
.loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_in);
holder.mRearrangeHandle.startAnimation(a);
boolean wasShown = holder.mEditButton.getVisibility() == View.VISIBLE;
holder.mRearrangeHandle.setVisibility(View.INVISIBLE);
holder.mEditButton.setVisibility(View.GONE);
- if (wasShown) {
+ if (wasShown && animationsEnabled) {
Animation a = AnimationUtils
.loadAnimation(holder.mRearrangeHandle.getContext(), R.anim.fade_out);
holder.mRearrangeHandle.startAnimation(a);