/* update app into */ private void updateAppList(boolean bool) { ApplicationListAdapter adapter = (ApplicationListAdapter) mAppInfoList.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { AppListInfo tempAppListInfo = (AppListInfo) adapter.getItem(i); tempAppListInfo.checked = bool; } mAppInfoAdapter.updateList(); }
@Override protected void onListItemClick(ListView l, View v, int position, long id) { ApplicationListAdapter adapter = (ApplicationListAdapter) mAppInfoList.getAdapter(); AppListInfo tempAppInfo = (AppListInfo) adapter.getItem(position); /* change check of list item */ tempAppInfo.checked = !tempAppInfo.checked; mAppInfoAdapter.updateList(); return; }
/* update app into */ private void updateAppList() { ArrayList<ApplicationInfo> appInfos = LauncherModel.mApplicationsAdapter.allItems; /* app info */ final List<AppListInfo> savedAppInfos = new ArrayList<AppListInfo>(); TextView t = (TextView) findViewById(R.id.left_title_text); mCatalogue.setTitleView(t); SharedPreferences curAppGrp = mCatalogue.getPreferences(); for (int i = 0; i < appInfos.size(); i++) { AppListInfo tempAppListInfo = new AppListInfo(); /* get App info */ ApplicationInfo tempAppInfo = appInfos.get(i); tempAppListInfo.className = tempAppInfo.intent.getComponent().flattenToString(); tempAppListInfo.icon = tempAppInfo.icon; tempAppListInfo.title = tempAppInfo.title.toString(); if (curAppGrp != null) tempAppListInfo.checked = curAppGrp.getBoolean(tempAppListInfo.className, false); else tempAppListInfo.checked = false; savedAppInfos.add(tempAppListInfo); if (DBG) Log.d(TAG, tempAppListInfo.className + " " + tempAppListInfo.checked); } mAppInfoAdapter.updateList(savedAppInfos); }
/* * Method implementing functionality of buttons clicked * * @see android.view.View.OnClickListener#onClick(android.view.View) */ public void onClick(View v) { if (v == mOkButton) { SharedPreferences curAppGrp = mCatalogue.getPreferences(); if (curAppGrp == null) return; // should not go here. SharedPreferences.Editor editor = curAppGrp.edit(); // editor.clear(); ApplicationListAdapter adapter = (ApplicationListAdapter) mAppInfoList.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { AppListInfo tempAppListInfo = (AppListInfo) adapter.getItem(i); boolean checked = tempAppListInfo.checked; // ADW: Change to only store hidden apps if (checked) editor.putBoolean(tempAppListInfo.className, true); else editor.remove(tempAppListInfo.className); if (DBG && checked) Log.v("-----", tempAppListInfo.className); } editor.commit(); setResult(RESULT_OK); finish(); } }