Example #1
0
  public void onControlledActivityBack(String ActivityBackCode) {
    // get actual fragment on execute

    // Check if no view has focus:
    View view = this.getCurrentFocus();
    if (view != null) {
      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    String frgBackType = null;

    WalletRuntimeManager walletRuntimeManager = getWalletRuntimeManager();

    WalletNavigationStructure walletNavigationStructure = walletRuntimeManager.getLastWallet();

    Activity activity = walletNavigationStructure.getLastActivity();

    com.bitdubai.fermat_api.layer.all_definition.navigation_structure.Fragment fragment =
        activity.getLastFragment();

    if (fragment != null) frgBackType = fragment.getBack();

    if (frgBackType != null) {
      com.bitdubai.fermat_api.layer.all_definition.navigation_structure.Fragment fragmentBack =
          walletRuntimeManager.getLastWallet().getLastActivity().getFragment(fragment.getBack());
      changeWalletFragment(
          walletNavigationStructure.getWalletCategory(),
          walletNavigationStructure.getWalletType(),
          walletNavigationStructure.getPublicKey(),
          frgBackType);
    } else if (activity != null
        && activity.getBackActivity() != null
        && activity.getBackAppPublicKey() != null) {
      if (ActivityBackCode != null) {
        changeActivity(activity.getBackActivity().getCode(), activity.getBackAppPublicKey());
      } else changeActivity(activity.getBackActivity().getCode(), activity.getBackAppPublicKey());
    } else {
      Intent intent = new Intent(this, DesktopActivity.class);
      intent.setFlags(
          Intent.FLAG_ACTIVITY_NEW_TASK
              | Intent.FLAG_ACTIVITY_CLEAR_TASK
              | Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
      overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    }
  }
Example #2
0
  /** 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();
    }
  }