Notification improvements #1175

Merged
kekkyojin merged 3 commits from notification-improvements into master 2021-03-29 17:39:28 +02:00
2 changed files with 19 additions and 10 deletions
Showing only changes of commit e8eb2e6090 - Show all commits

View file

@ -2781,14 +2781,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
} }
private Fragment getCurrentFragment() { private Fragment getCurrentFragment() {
int backCount = getSupportFragmentManager().getBackStackEntryCount(); List<Fragment> fragmentList = getSupportFragmentManager().getFragments();
if (backCount > 0) {
try { if (fragmentList.size() > 0)
return getSupportFragmentManager().getFragments().get(backCount - 1); return fragmentList.get(fragmentList.size() - 1);
} catch (IndexOutOfBoundsException ex) { else
return null;
}
}
return null; return null;
} }
@ -3495,6 +3492,18 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
return; return;
} }
if (currentFragment != null && ((BaseFragment) currentFragment).getParams() != null
&& ((BaseFragment) currentFragment).getParams().containsKey("source")
&& ((BaseFragment) currentFragment).getParams().get("source").equals("notification")) {
Map<String, Object> currentParams = new HashMap<>(1);
if (((BaseFragment) currentFragment).getParams().containsKey("url"))
currentParams.put("url", ((BaseFragment) currentFragment).getParams().get("url"));
((BaseFragment) currentFragment).setParams(currentParams);
}
//fragment.setRetainInstance(true); //fragment.setRetainInstance(true);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment); FragmentTransaction transaction = manager.beginTransaction().replace(R.id.content_main, fragment);

View file

@ -64,7 +64,7 @@ public class BaseFragment extends Fragment {
} }
} }
if (params != null && params.containsKey("source") && "notification".equalsIgnoreCase(params.get("source").toString())) { if (params != null && params.containsKey("source") && params.get("source") != null && "notification".equalsIgnoreCase(params.get("source").toString())) {
Context context = getContext(); Context context = getContext();
if (context instanceof MainActivity) { if (context instanceof MainActivity) {
((MainActivity) context).navigateBackToNotifications(); ((MainActivity) context).navigateBackToNotifications();