Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit efaec034548e6d305efc41743f49904d84d563f4 1 parent 0de788a
garthy authored

Showing 1 changed file with 8 additions and 9 deletions. Show diff stats Hide diff stats

  1. +8 9 src/org/metawatch/manager/AppBlacklist.java
17 src/org/metawatch/manager/AppBlacklist.java
@@ -86,8 +86,7 @@ protected void onPostExecute(List<AppInfo> appInfos) {
86 86 ListView listView = (ListView) findViewById(android.R.id.list);
87 87 // listView.setAdapter(new ArrayAdapter<String>(this,
88 88 // android.R.layout.simple_list_item_1, menuList));
89   - listView.setAdapter(new BlacklistAdapter(AppBlacklist.this,
90   - appInfos));
  89 + listView.setAdapter(new BlacklistAdapter(appInfos));
91 90 AppBlacklist.this.appInfos = appInfos;
92 91 pdWait.dismiss();
93 92
@@ -107,20 +106,20 @@ public int compareTo(AppInfo another) {
107 106 }
108 107
109 108 class BlacklistAdapter extends ArrayAdapter<AppInfo> {
110   - private final Activity context;
111 109 private final List<AppInfo> apps;
112 110
113   - public BlacklistAdapter(Activity context, List<AppInfo> apps) {
114   - super(context, R.layout.app_blacklist_list_item, apps);
115   - this.context = context;
  111 + public BlacklistAdapter( List<AppInfo> apps) {
  112 + super(AppBlacklist.this, R.layout.app_blacklist_list_item, apps);
116 113 this.apps = apps;
117 114 }
118 115
119 116 @Override
120 117 public View getView(int position, View convertView, ViewGroup parent) {
121   - View view = null;
122   - LayoutInflater inflater = context.getLayoutInflater();
123   - view = inflater.inflate(R.layout.app_blacklist_list_item, null);
  118 + View view = convertView;
  119 + LayoutInflater inflater = AppBlacklist.this.getLayoutInflater();
  120 + if(view == null) {
  121 + view = inflater.inflate(R.layout.app_blacklist_list_item, null);
  122 + }
124 123 ImageView icon = (ImageView) view
125 124 .findViewById(R.id.app_blacklist_list_item_icon);
126 125 TextView appName = (TextView) view

0 comments on commit efaec03

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