Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_list);
    context = AppListActivity.this;
    appList = (ListView) findViewById(R.id.appList);
    btnMobileApps = (TextView) findViewById(R.id.btnMobileApps);
    btnWebApps = (TextView) findViewById(R.id.btnWebApps);
    txtError = (TextView) findViewById(R.id.txtError);
    btnSignOut = (TextView) findViewById(R.id.btnSignOut);
    etSearch = (EditText) findViewById(R.id.etSearch);
    mobileApps = new ArrayList<>();
    webApps = new ArrayList<>();
    appList.setVisibility(View.GONE);
    txtError.setVisibility(View.GONE);

    btnMobileApps.setVisibility(View.GONE);
    btnMobileApps.setTag(TAG_BTN_MOBILE_APPS);
    btnMobileApps.setOnClickListener(onClickListener);

    btnWebApps.setVisibility(View.GONE);
    btnWebApps.setTag(TAG_BTN_WEB_APPS);
    btnWebApps.setOnClickListener(onClickListener);

    if (CommonUtils.isNetworkAvailable(context)) {
      getAppList();
    } else {
      CommonDialogUtils.showNetworkUnavailableMessage(AppListActivity.this);
    }
  }
Пример #2
0
        @Override
        public void onClick(View view) {

          int iTag = (Integer) view.getTag();

          switch (iTag) {
            case TAG_BTN_MOBILE_APPS:
              initiateListView(mobileApps);
              btnMobileApps.setBackgroundColor(Color.parseColor(ACTIVE_BUTTON_COLOR));
              btnWebApps.setBackgroundColor(Color.parseColor(INACTIVE_BUTTON_COLOR));
              break;
            case TAG_BTN_WEB_APPS:
              initiateListView(webApps);
              btnMobileApps.setBackgroundColor(Color.parseColor(INACTIVE_BUTTON_COLOR));
              btnWebApps.setBackgroundColor(Color.parseColor(ACTIVE_BUTTON_COLOR));
              break;
            case TAG_BTN_SIGN_OUT:
              try {
                CommonUtils.unRegisterClientApp(context);
              } catch (AppCatalogException e) {
                Log.e(TAG, "Dynamic client unregistration failed." + e);
              }
              break;
          }
        }
Пример #3
0
  private void getAppList() {
    DialogInterface.OnCancelListener cancelListener =
        new DialogInterface.OnCancelListener() {

          @Override
          public void onCancel(DialogInterface arg0) {
            CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(
                context,
                getResources().getString(R.string.error_app_fetch_failed_detail),
                getResources().getString(R.string.app_list_failed),
                getResources().getString(R.string.button_ok),
                null);
          }
        };

    progressDialog =
        CommonDialogUtils.showProgressDialog(
            context,
            getResources().getString(R.string.dialog_app_list),
            getResources().getString(R.string.dialog_please_wait),
            cancelListener);

    // Check network connection availability before calling the API.
    if (CommonUtils.isNetworkAvailable(context)) {
      ApplicationManager applicationManager = new ApplicationManager(context);
      if (applicationManager.isPackageInstalled(Constants.AGENT_PACKAGE_NAME)) {
        btnSignOut.setVisibility(View.GONE);
        IntentFilter filter = new IntentFilter(Constants.AGENT_APP_ACTION_RESPONSE);
        filter.addCategory(Intent.CATEGORY_DEFAULT);
        AgentServiceResponseReceiver receiver = new AgentServiceResponseReceiver();
        registerReceiver(receiver, filter);
        CommonUtils.callAgentApp(context, Constants.Operation.GET_APPLICATION_LIST, null, null);
      } else {
        btnSignOut.setVisibility(View.VISIBLE);
        btnSignOut.setTag(TAG_BTN_SIGN_OUT);
        btnSignOut.setOnClickListener(onClickListener);
        getAppListFromServer();
      }
    } else {
      CommonDialogUtils.stopProgressDialog(progressDialog);
      CommonDialogUtils.showNetworkUnavailableMessage(context);
    }
  }
Пример #4
0
  /** Retriever application list from the server. */
  private void getAppListFromServer() {
    String ipSaved =
        Preference.getString(context.getApplicationContext(), Constants.PreferenceFlag.IP);

    if (ipSaved != null && !ipSaved.isEmpty()) {
      ServerConfig utils = new ServerConfig();
      utils.setServerIP(ipSaved);
      CommonUtils.callSecuredAPI(
          AppListActivity.this,
          utils.getAPIServerURL(context) + Constants.APP_LIST_ENDPOINT,
          HTTP_METHODS.GET,
          null,
          AppListActivity.this,
          Constants.APP_LIST_REQUEST_CODE);
    } else {
      Log.e(TAG, "There is no valid IP to contact the server");
    }
  }