[tor-commits] [orbot/master] improve UI setup here for list to reduce NPE crashes

n8fr8 at torproject.org n8fr8 at torproject.org
Mon Nov 7 05:29:23 UTC 2016


commit e7443890c5cd694acba2ccc07d3210378948d1dd
Author: Nathan Freitas <nathan at freitas.net>
Date:   Sun Nov 6 23:58:50 2016 -0500

    improve UI setup here for list to reduce NPE crashes
---
 .../java/org/torproject/android/ui/AppManager.java | 47 +++++++++++++---------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/ui/AppManager.java b/app/src/main/java/org/torproject/android/ui/AppManager.java
index 9a15dae..8ba26f2 100644
--- a/app/src/main/java/org/torproject/android/ui/AppManager.java
+++ b/app/src/main/java/org/torproject/android/ui/AppManager.java
@@ -190,31 +190,40 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
                     entry.icon = (ImageView) convertView.findViewById(R.id.itemicon);
                     entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
                     entry.text = (TextView) convertView.findViewById(R.id.itemtext);
-                    
-                    entry.text.setOnClickListener(AppManager.this);
-                    entry.text.setOnClickListener(AppManager.this);
-                    
+
+
                     convertView.setTag(entry);
-                
-                    entry.box.setOnCheckedChangeListener(AppManager.this);
+
+
                 }
 
                 final TorifiedApp app = mApps.get(position);
 
-                if (app.getIcon() != null && entry.icon != null)
-                    entry.icon.setImageDrawable(app.getIcon());
-                else
-                    entry.icon.setVisibility(View.GONE);
+                if (entry.icon != null) {
+                    if (app.getIcon() != null)
+                        entry.icon.setImageDrawable(app.getIcon());
+                    else
+                        entry.icon.setVisibility(View.GONE);
+                }
+
+                if (entry.text != null) {
+                    entry.text.setText(app.getName());
+                    entry.text.setOnClickListener(AppManager.this);
+                    entry.text.setOnClickListener(AppManager.this);
+
+                    if (entry.box != null)
+                        entry.text.setTag(entry.box);
+                }
+
+
+                if (entry.box != null) {
+                    entry.box.setOnCheckedChangeListener(AppManager.this);
+                    entry.box.setTag(app);
+                    entry.box.setChecked(app.isTorified());
+
+
+                }
 
-                entry.text.setText(app.getName());
-                
-                final CheckBox box = entry.box;
-                box.setTag(app);
-                box.setChecked(app.isTorified());
-                
-                entry.text.setTag(box);
-                entry.icon.setTag(box);
-                
                 return convertView;
             }
         };





More information about the tor-commits mailing list