Exemplo n.º 1
0
  @Override
  public void onStart() {
    super.onStart();

    // Do we have an application list already? is it valid?
    if (appList == null || !prefs.getIsApplicationListCacheValid()) {
      // Either we don't have an app list, or it isn't valid
      if (!prefs.getIsApplicationListCacheValid()) {
        // The app list isn't valid, so we need to rebuild it
        rebuildApplicationList();
      } else {
        loadApplicationObjects();
        loadApplicationList();
      }
    } else {
      if (this.appListAdapter == null) {
        this.appListAdapter =
            new AppListAdapter(context, R.layout.application_list_row, this.appList);
      }
      listView.setAdapter(appListAdapter);
    }

    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            callback.onApplicationSelected(appList.get(position));
          }
        });

    listView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            showPopupMenu(view, position);
            return true;
          }
        });
  }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // get handle to the application preferences
    prefs = new Preferences(context);

    // get the most recently selected option from the 'App Type' list, and set as current
    currentAppType = prefs.getLastAppListType();

    /*
     * If the database version has changed, we will need to rebuild the application cache
     */
    if (prefs.getLastRunDatabaseVersion() != DBInterface.DBHelper.DATABASE_VERSION) {
      Log.d(
          "PDroidAlternative",
          "Defined database version has changed since last run; we need to rebuild the cache");
      // this will force the application list to be rebuilt from the application package manager
      prefs.setIsApplicationListCacheValid(false);
      prefs.setLastRunDatabaseVersion(DBInterface.DBHelper.DATABASE_VERSION);
    }

    setHasOptionsMenu(true);
  }