コード例 #1
0
  private void setOneFragmentInScreen() throws InvalidParameterException {

    SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware();
    SubApps subAppType = subAppRuntimeManager.getLastSubApp().getType();

    com.bitdubai.fermat_android_api.layer.definition.wallet.interfaces.SubAppFragmentFactory
        subAppFragmentFactory = SubAppFragmentFactory.getFragmentFactoryBySubAppType(subAppType);
    String fragment =
        subAppRuntimeManager.getLastSubApp().getLastActivity().getLastFragment().getType();
    SubAppsSession subAppsSession = getSubAppSessionManager().getSubAppsSession(subAppType);

    try {
      if (subAppFragmentFactory != null) {

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.GONE);

        ViewPager pagertabs = (ViewPager) findViewById(R.id.pager);
        pagertabs.setVisibility(View.VISIBLE);

        adapter =
            new TabsPagerAdapter(
                getFragmentManager(),
                getApplicationContext(),
                subAppFragmentFactory,
                fragment,
                subAppsSession,
                getSubAppResourcesProviderManager(),
                getResources());
        pagertabs.setAdapter(adapter);

        final int pageMargin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        pagertabs.setPageMargin(pageMargin);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  /**
   * This method replaces the current fragment by the next in navigation
   *
   * @param fragmentType Type Id of fragment to show
   */
  private void loadFragment(SubApps subApp, int idContainer, String fragmentType)
      throws InvalidParameterException {

    SubAppSessionManager subAppSessionManager =
        ((ApplicationSession) getApplication()).getSubAppSessionManager();
    SubAppsSession subAppsSession =
        subAppSessionManager.getSubAppsSession(
            getSubAppRuntimeMiddleware().getLastSubApp().getType());

    try {
      getSubAppRuntimeMiddleware().getLastSubApp().getLastActivity().getFragment(fragmentType);
      com.bitdubai.fermat_android_api.layer.definition.wallet.interfaces.SubAppFragmentFactory
          subAppFragmentFactory = SubAppFragmentFactory.getFragmentFactoryBySubAppType(subApp);

      android.app.Fragment fragment =
          subAppFragmentFactory.getFragment(
              fragmentType,
              subAppsSession,
              null, // getSubAppSettingsManager().getSettings(xxx),
              getSubAppResourcesProviderManager());

      FragmentTransaction FT = this.getFragmentManager().beginTransaction();
      FT.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);

      FT.replace(idContainer, fragment);

      FT.commit();
    } catch (Exception e) {
      getErrorManager()
          .reportUnexpectedUIException(
              UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, e);
      Toast.makeText(
              getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG)
          .show();
    }
  }