]> git.ktnx.net Git - mobile-ledger.git/commitdiff
handle back arrow tap in patterns activity
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 1 Feb 2021 06:38:09 +0000 (08:38 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 1 Feb 2021 06:38:09 +0000 (08:38 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/patterns/PatternsActivity.java

index 793a2be207f52cf8619ec3019e66c2f4c75698bd..945123d95e32c5990be4d6ae305f510623383db0 100644 (file)
@@ -19,6 +19,7 @@ package net.ktnx.mobileledger.ui.patterns;
 
 import android.os.Bundle;
 import android.view.Menu;
+import android.view.MenuItem;
 
 import androidx.appcompat.app.ActionBar;
 import androidx.lifecycle.ViewModelProvider;
@@ -78,6 +79,20 @@ public class PatternsActivity extends CrashReportingActivity
         b.fabAdd.setOnClickListener(v -> onEditPattern(null));
         b.fabSave.setOnClickListener(v -> onSavePattern());
     }
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (item.getItemId() == android.R.id.home) {
+            if (navController.getCurrentDestination()
+                             .getId() == R.id.patternDetailsFragment)
+                navController.popBackStack();
+            else
+                finish();
+
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
     @Override
     public void onEditPattern(Long id) {
         if (id == null) {