HomeFragmentに戻される原因を修正, SettingFragmentではFabを隠すように

This commit is contained in:
ろむねこ 2024-01-17 18:24:29 +09:00
parent 272931c037
commit b8caf9abf4
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -110,16 +110,19 @@ public class MainActivity extends AppCompatActivity {
{ {
if (v.getItemId() == findViewById(R.id.navigation_home).getId()) { if (v.getItemId() == findViewById(R.id.navigation_home).getId()) {
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.VISIBLE);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.replace(findViewById(R.id.fragmentContainerView).getId(), this.homeFragment) .replace(findViewById(R.id.fragmentContainerView).getId(), this.homeFragment)
.addToBackStack(null) .addToBackStack(null)
.commit(); .commit();
} else if (v.getItemId() == findViewById(R.id.navigation_notification).getId()) { } else if (v.getItemId() == findViewById(R.id.navigation_notification).getId()) {
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.VISIBLE);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.replace(findViewById(R.id.fragmentContainerView).getId(), NotificationFragment.newInstance("test", "test")) .replace(findViewById(R.id.fragmentContainerView).getId(), NotificationFragment.newInstance("test", "test"))
.addToBackStack(null) .addToBackStack(null)
.commit(); .commit();
} else if (v.getItemId() == findViewById(R.id.navigation_settings).getId()) { } else if (v.getItemId() == findViewById(R.id.navigation_settings).getId()) {
findViewById(R.id.fab_scan_qr_code).setVisibility(FrameLayout.GONE);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.replace(findViewById(R.id.fragmentContainerView).getId(), SettingFragment.newInstance()) .replace(findViewById(R.id.fragmentContainerView).getId(), SettingFragment.newInstance())
.addToBackStack(null) .addToBackStack(null)
@ -203,9 +206,6 @@ public class MainActivity extends AppCompatActivity {
E.apply(); E.apply();
} }
HomeFragment fragment = new HomeFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, fragment).commit();
homeFragment.onEvent(!isInCar); homeFragment.onEvent(!isInCar);
} }
} }