Skip to content

Commit

Permalink
Custom filters fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Ruesga <[email protected]>
  • Loading branch information
jruesga committed Oct 20, 2016
1 parent aea76b1 commit 7379fb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/com/ruesga/rview/ChangeListByFilterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return super.onPrepareOptionsMenu(menu);
}

private void openChangeListByFilterFragment(String filter) {
FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
Fragment fragment = ChangeListByFilterFragment.newInstance(filter);
Expand Down Expand Up @@ -184,6 +189,12 @@ private void performSaveCustomFilter(View v) {
CustomFilter cf = new CustomFilter(newValue, mQuery);
Account account = Preferences.getAccount(ctx);
Preferences.saveAccountCustomFilter(ctx, account, cf);

mDirty = false;
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(newValue);
}
invalidateOptionsMenu();
});
fragment.show(getSupportFragmentManager(), EditDialogFragment.TAG);
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/ruesga/rview/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ private void updateAccountCustomFilters() {
i++;
}
}

menu.setGroupVisible(R.id.category_my_filters,
!mModel.isAccountExpanded && mCustomFilters != null && !mCustomFilters.isEmpty());
}

private void updateAccountsDrawerInfo() {
Expand Down Expand Up @@ -711,9 +714,9 @@ private void performDeleteCustomFilter(int menuId) {
mCustomFilters.remove(filter);
Preferences.setAccountCustomFilters(this, mAccount, mCustomFilters);

if (mCustomFilters.isEmpty()) {
if (mModel.currentNavigationItemId == menuId) {
int defaultMenu = Preferences.getAccountHomePageId(this, mAccount);
performSelectItem(defaultMenu, false);
requestNavigateTo(defaultMenu, true);
}
updateAccountCustomFilters();
}
Expand Down

0 comments on commit 7379fb0

Please sign in to comment.