Skip to content

Commit

Permalink
codinguser#876 - Invert finish() and BookUtils.loadBook
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanGarf committed Jun 13, 2020
1 parent a1626c1 commit 5db92fb
Showing 1 changed file with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,45 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

@Override
public boolean onMenuItemClick(MenuItem item) {
long id = item.getItemId();
if (id == ID_MANAGE_BOOKS){

long itemId = item.getItemId();

if (itemId == ID_MANAGE_BOOKS){
// Click on "Manage books..." item

// Start "Manage books" Activity
Intent intent = new Intent(this, PreferenceActivity.class);
intent.setAction(PreferenceActivity.ACTION_MANAGE_BOOKS);
startActivity(intent);

mDrawerLayout.closeDrawer(mNavigationView);
return true;
}
BooksDbAdapter booksDbAdapter = BooksDbAdapter.getInstance();
String bookUID = booksDbAdapter.getUID(id);
if (!bookUID.equals(booksDbAdapter.getActiveBookUID())){
BookUtils.loadBook(bookUID);
finish();

} else {
// Click on an existing book item

BooksDbAdapter booksDbAdapter = BooksDbAdapter.getInstance();

String selectedBookUID = booksDbAdapter.getUID(itemId);

if (!selectedBookUID.equals(booksDbAdapter.getActiveBookUID())){
// Selected Book is not the active one

// Close current Activity
finish();

// load book and Start Account Activity and reset Activity Stack
BookUtils.loadBook(selectedBookUID);

} else {
// Selected Book is the current one

// Start Account Activity and reset Activity Stack
AccountsActivity.start(GnuCashApplication.getAppContext());
}

}
AccountsActivity.start(GnuCashApplication.getAppContext());


return true;
}

Expand Down

0 comments on commit 5db92fb

Please sign in to comment.