- if (editingProfilesObserver == null) {
- editingProfilesObserver = (o, arg) -> {
- if (mProfileListAdapter.isEditingProfiles()) {
- profileListHeadMore.setVisibility(View.GONE);
- profileListHeadMore
- .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
- profileListHeadCancel.setVisibility(View.VISIBLE);
- profileListHeadCancel
- .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
- profileListHeadAddProfile.setVisibility(View.VISIBLE);
- profileListHeadAddProfile
- .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
- }
- else {
- profileListHeadCancel.setVisibility(View.GONE);
- profileListHeadCancel
- .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
- profileListHeadMore.setVisibility(View.VISIBLE);
- profileListHeadMore
- .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
- profileListHeadAddProfile.setVisibility(View.GONE);
- profileListHeadAddProfile
- .startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
- }
- };
- mProfileListAdapter.addEditingProfilesObserver(editingProfilesObserver);
- }
+ mProfileListAdapter.editingProfiles
+ .observe(this, newValue -> {
+ if (newValue) {
+ profileListHeadMore.setVisibility(View.GONE);
+ profileListHeadCancel.setVisibility(View.VISIBLE);
+ profileListHeadAddProfile.setVisibility(View.VISIBLE);
+ if (drawer.isDrawerOpen(GravityCompat.START)) {
+ profileListHeadMore.startAnimation(AnimationUtils
+ .loadAnimation(MainActivity.this, R.anim.fade_out));
+ profileListHeadCancel.startAnimation(AnimationUtils
+ .loadAnimation(MainActivity.this, R.anim.fade_in));
+ profileListHeadAddProfile.startAnimation(AnimationUtils
+ .loadAnimation(MainActivity.this, R.anim.fade_in));
+ }
+ }
+ else {
+ profileListHeadCancel.setVisibility(View.GONE);
+ profileListHeadMore.setVisibility(View.VISIBLE);
+ profileListHeadAddProfile.setVisibility(View.GONE);
+ if (drawer.isDrawerOpen(GravityCompat.START)) {
+ profileListHeadCancel.startAnimation(AnimationUtils
+ .loadAnimation(MainActivity.this, R.anim.fade_out));
+ profileListHeadMore.startAnimation(AnimationUtils
+ .loadAnimation(MainActivity.this, R.anim.fade_in));
+ profileListHeadAddProfile.startAnimation(AnimationUtils
+ .loadAnimation(MainActivity.this, R.anim.fade_out));
+ }
+ }
+
+ mProfileListAdapter.notifyDataSetChanged();
+ });