diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index d7fac694..fc95070b 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -8,9 +8,11 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import androidx.navigation.NavController; +import androidx.navigation.NavOptions; import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.ui.NavigationUI; +import android.app.ActivityOptions; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; @@ -60,6 +62,19 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio assert navHostFragment != null; NavController navController = navHostFragment.getNavController(); NavigationUI.setupWithNavController(bottomNavigationView, navController); + + bottomNavigationView.setOnItemSelectedListener(item -> { + NavOptions navOptions = new NavOptions.Builder() + .setLaunchSingleTop(true) + .setEnterAnim(androidx.navigation.ui.R.anim.nav_default_enter_anim) + .setExitAnim(androidx.navigation.ui.R.anim.nav_default_exit_anim) + .setPopEnterAnim(androidx.navigation.ui.R.anim.nav_default_pop_enter_anim) + .setPopExitAnim(androidx.navigation.ui.R.anim.nav_default_pop_exit_anim) + .build(); + + navController.navigate(item.getItemId(), null, navOptions); + return true; + }); } catch (Exception e) { Log.e("Init", "Failed to init navigation"); @@ -83,7 +98,8 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio findViewById(R.id.scanFab).setOnClickListener(v -> { Toast.makeText(this, "Scan", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this.getApplicationContext(), ScannerManagerActivity.class); - startActivity(intent); +// startActivity(intent); + startActivity(intent, ActivityOptions.makeCustomAnimation(this, 0, 0).toBundle()); }); } diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java index 6c079c11..0b9a3e59 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.widget.Toast; import androidx.activity.EdgeToEdge; +import androidx.activity.OnBackPressedCallback; import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; @@ -41,6 +42,9 @@ public class ViewerMainActivity extends AppCompatActivity { return insets; }); +// // Transition +// overridePendingTransition(one.nem.lacerta.shared.ui.R.anim.nav_up_enter_anim, one.nem.lacerta.shared.ui.R.anim.nav_up_exit_anim); + Intent intent = getIntent(); try { documentId = intent.getStringExtra("documentId"); @@ -58,4 +62,5 @@ public class ViewerMainActivity extends AppCompatActivity { .replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName)) .commit(); } + } \ No newline at end of file diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java index 3f010479..8d757662 100644 --- a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java @@ -1,5 +1,6 @@ package one.nem.lacerta.feature.home; +import android.app.ActivityOptions; import android.content.Intent; import android.os.Bundle; import android.util.Log; @@ -89,7 +90,7 @@ public class HomeTopFragment extends Fragment { Log.d("HomeTopFragment", "onDocumentSelect: " + documentId + " " + documentName); intent.putExtra("documentId", documentId); intent.putExtra("documentName", documentName); - startActivity(intent); + startActivity(intent, ActivityOptions.makeCustomAnimation(getContext(), 0, 0).toBundle()); } }); recyclerView.setAdapter(listItemAdapter);