Skip to content
Browse files

reuse view or we end up running out of memory.

I think this is a combination of icons being 96*96 on ICS and me having
200+ apps installed. I was getting out of memory if I open up blacklist
and scrolled to the end.
  • Loading branch information...
1 parent 0de788a commit efaec034548e6d305efc41743f49904d84d563f4 @garthy committed Mar 9, 2012
Showing with 8 additions and 9 deletions.
  1. +8 −9 src/org/metawatch/manager/AppBlacklist.java
View
17 src/org/metawatch/manager/AppBlacklist.java
@@ -86,8 +86,7 @@ protected void onPostExecute(List<AppInfo> appInfos) {
ListView listView = (ListView) findViewById(android.R.id.list);
// listView.setAdapter(new ArrayAdapter<String>(this,
// android.R.layout.simple_list_item_1, menuList));
- listView.setAdapter(new BlacklistAdapter(AppBlacklist.this,
- appInfos));
+ listView.setAdapter(new BlacklistAdapter(appInfos));
AppBlacklist.this.appInfos = appInfos;
pdWait.dismiss();
@@ -107,20 +106,20 @@ public int compareTo(AppInfo another) {
}
class BlacklistAdapter extends ArrayAdapter<AppInfo> {
- private final Activity context;
private final List<AppInfo> apps;
- public BlacklistAdapter(Activity context, List<AppInfo> apps) {
- super(context, R.layout.app_blacklist_list_item, apps);
- this.context = context;
+ public BlacklistAdapter( List<AppInfo> apps) {
+ super(AppBlacklist.this, R.layout.app_blacklist_list_item, apps);
this.apps = apps;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- View view = null;
- LayoutInflater inflater = context.getLayoutInflater();
- view = inflater.inflate(R.layout.app_blacklist_list_item, null);
+ View view = convertView;
+ LayoutInflater inflater = AppBlacklist.this.getLayoutInflater();
+ if(view == null) {
+ view = inflater.inflate(R.layout.app_blacklist_list_item, null);
+ }
ImageView icon = (ImageView) view
.findViewById(R.id.app_blacklist_list_item_icon);
TextView appName = (TextView) view

0 comments on commit efaec03

Please sign in to comment.
Something went wrong with that request. Please try again.