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(); } }
/** * This Method execute the navigation to an other fragment or activity Get button action of screen */ @Override public void changeScreen(String screen, int idContainer, Object[] objects) { try { SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware(); loadFragment(subAppRuntimeManager.getLastSubApp().getType(), idContainer, screen); } catch (Exception e) { getErrorManager() .reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, new IllegalArgumentException("Error in changeWalletFragment")); Toast.makeText( getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG) .show(); } }
/** This method catch de back bottom event and decide which screen load */ @Override public void onBackPressed() { // get actual fragment on execute String frgBackType = null; try { SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware(); com.bitdubai.fermat_api.layer.all_definition.navigation_structure.Fragment fragment = null; Activity activity = null; try { activity = subAppRuntimeManager.getLastSubApp().getLastActivity(); fragment = activity.getLastFragment(); } catch (NullPointerException nullPointerException) { fragment = null; } // get setting fragment to back // if not fragment to back I back to desktop if (fragment != null) frgBackType = fragment.getBack(); if (frgBackType != null) { Activity activities = getSubAppRuntimeMiddleware().getLastSubApp().getLastActivity(); com.bitdubai.fermat_api.layer.all_definition.navigation_structure.Fragment fragmentBack = activities.getFragment(frgBackType); // set back fragment to actual fragment to run // TODO: ver como hacer para obtener el id del container if (fragmentBack.getType().equals("CSADDTD") || fragmentBack.getType().equals("CSADDTT") || fragmentBack.getType().equals("CSADDTR") || fragmentBack.getType().equals("CSADDT")) { this.loadFragment( subAppRuntimeManager.getLastSubApp().getType(), R.id.logContainer, frgBackType); } else { this.loadFragment( subAppRuntimeManager.getLastSubApp().getType(), R.id.startContainer, frgBackType); } } else if (activity != null && activity.getBackActivity() != null) { changeActivity(activity.getBackActivity().getCode()); } else { // set Desktop current activity activity = getSubAppRuntimeMiddleware().getLastSubApp().getLastActivity(); if (activity.getType() != Activities.CWP_WALLET_MANAGER_MAIN) { resetThisActivity(); // getSubAppRuntimeMiddleware().getHomeScreen(); getSubAppRuntimeMiddleware().getSubApp(SubApps.CWP_WALLET_MANAGER); getSubAppRuntimeMiddleware() .getLastSubApp() .getActivity(Activities.CWP_WALLET_MANAGER_MAIN); // cleanWindows(); loadUI(createOrCallSubAppSession()); } else { super.onBackPressed(); } } } catch (Exception e) { getErrorManager() .reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.UNSTABLE, e); Toast.makeText( getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_LONG) .show(); } }