Search in sources :

Example 1 with BaseFragment

use of com.odysee.app.ui.BaseFragment in project odysee-android by OdyseeTeam.

the class MainActivity method openFragment.

public void openFragment(Class fragmentClass, boolean allowNavigateBack, @Nullable Map<String, Object> params) {
    try {
        Fragment fragment = (Fragment) fragmentClass.newInstance();
        if (fragment instanceof BaseFragment) {
            ((BaseFragment) fragment).setParams(params);
        }
        Fragment currentFragment = getCurrentFragment();
        if (currentFragment != null && currentFragment.equals(fragment)) {
            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);
        FragmentManager manager = getSupportFragmentManager();
        if (fragment instanceof FileViewFragment || fragment instanceof ChannelFragment)
            findViewById(R.id.fragment_container_search).setVisibility(View.GONE);
        FragmentTransaction transaction;
        if (fragment instanceof FileViewFragment) {
            transaction = manager.beginTransaction().replace(R.id.main_activity_other_fragment, fragment, FILE_VIEW_TAG);
        } else {
            transaction = manager.beginTransaction().replace(R.id.main_activity_other_fragment, fragment);
        }
        if (allowNavigateBack) {
            transaction.addToBackStack(null);
        }
        getSupportActionBar().setDisplayHomeAsUpEnabled(!(fragment instanceof FileViewFragment) && allowNavigateBack);
        transaction.commit();
        currentDisplayFragment = fragment;
        findViewById(R.id.main_activity_other_fragment).setVisibility(View.VISIBLE);
        findViewById(R.id.fragment_container_main_activity).setVisibility(View.GONE);
        findViewById(R.id.bottom_navigation).setVisibility(View.GONE);
        findViewById(R.id.toolbar_balance_and_tools_layout).setVisibility(View.GONE);
    } catch (Exception ex) {
    // pass
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) FileViewFragment(com.odysee.app.ui.findcontent.FileViewFragment) HashMap(java.util.HashMap) JSONObject(org.json.JSONObject) SpannableString(android.text.SpannableString) FileViewFragment(com.odysee.app.ui.findcontent.FileViewFragment) DialogFragment(androidx.fragment.app.DialogFragment) SettingsFragment(com.odysee.app.ui.other.SettingsFragment) FollowingFragment(com.odysee.app.ui.findcontent.FollowingFragment) LibraryFragment(com.odysee.app.ui.library.LibraryFragment) ContentScopeDialogFragment(com.odysee.app.dialog.ContentScopeDialogFragment) SearchFragment(com.odysee.app.ui.findcontent.SearchFragment) Fragment(androidx.fragment.app.Fragment) PublishFragment(com.odysee.app.ui.publish.PublishFragment) InvitesFragment(com.odysee.app.ui.wallet.InvitesFragment) PlaylistFragment(com.odysee.app.ui.library.PlaylistFragment) RewardsFragment(com.odysee.app.ui.wallet.RewardsFragment) WalletFragment(com.odysee.app.ui.wallet.WalletFragment) BaseFragment(com.odysee.app.ui.BaseFragment) AddToListsDialogFragment(com.odysee.app.dialog.AddToListsDialogFragment) AllContentFragment(com.odysee.app.ui.findcontent.AllContentFragment) PublishesFragment(com.odysee.app.ui.publish.PublishesFragment) BaseFragment(com.odysee.app.ui.BaseFragment) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) ExecutionException(java.util.concurrent.ExecutionException) SQLiteException(android.database.sqlite.SQLiteException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException) AuthTokenInvalidatedException(com.odysee.app.exceptions.AuthTokenInvalidatedException) ParseException(java.text.ParseException)

Aggregations

SQLiteException (android.database.sqlite.SQLiteException)1 SpannableString (android.text.SpannableString)1 DialogFragment (androidx.fragment.app.DialogFragment)1 Fragment (androidx.fragment.app.Fragment)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 AddToListsDialogFragment (com.odysee.app.dialog.AddToListsDialogFragment)1 ContentScopeDialogFragment (com.odysee.app.dialog.ContentScopeDialogFragment)1 ApiCallException (com.odysee.app.exceptions.ApiCallException)1 AuthTokenInvalidatedException (com.odysee.app.exceptions.AuthTokenInvalidatedException)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)1 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)1 BaseFragment (com.odysee.app.ui.BaseFragment)1 AllContentFragment (com.odysee.app.ui.findcontent.AllContentFragment)1 FileViewFragment (com.odysee.app.ui.findcontent.FileViewFragment)1 FollowingFragment (com.odysee.app.ui.findcontent.FollowingFragment)1 SearchFragment (com.odysee.app.ui.findcontent.SearchFragment)1 LibraryFragment (com.odysee.app.ui.library.LibraryFragment)1 PlaylistFragment (com.odysee.app.ui.library.PlaylistFragment)1