Home | History | Annotate | Download | only in applications
      1 package com.android.settings.applications;
      2 
      3 import com.android.settings.R;
      4 
      5 import android.content.Context;
      6 import android.util.Log;
      7 import android.view.LayoutInflater;
      8 import android.view.View;
      9 import android.widget.CheckBox;
     10 import android.widget.ImageView;
     11 import android.widget.TextView;
     12 
     13 // View Holder used when displaying views
     14 public class AppViewHolder {
     15     public ApplicationsState.AppEntry entry;
     16     public View rootView;
     17     public TextView appName;
     18     public ImageView appIcon;
     19     public TextView appSize;
     20     public TextView disabled;
     21     public CheckBox checkBox;
     22 
     23     static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
     24         if (convertView == null) {
     25             convertView = inflater.inflate(R.layout.manage_applications_item, null);
     26 
     27             // Creates a ViewHolder and store references to the two children views
     28             // we want to bind data to.
     29             AppViewHolder holder = new AppViewHolder();
     30             holder.rootView = convertView;
     31             holder.appName = (TextView) convertView.findViewById(R.id.app_name);
     32             holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
     33             holder.appSize = (TextView) convertView.findViewById(R.id.app_size);
     34             holder.disabled = (TextView) convertView.findViewById(R.id.app_disabled);
     35             holder.checkBox = (CheckBox) convertView.findViewById(R.id.app_on_sdcard);
     36             convertView.setTag(holder);
     37             return holder;
     38         } else {
     39             // Get the ViewHolder back to get fast access to the TextView
     40             // and the ImageView.
     41             return (AppViewHolder)convertView.getTag();
     42         }
     43     }
     44 
     45     void updateSizeText(CharSequence invalidSizeStr, int whichSize) {
     46         if (ManageApplications.DEBUG) Log.i(ManageApplications.TAG, "updateSizeText of " + entry.label + " " + entry
     47                 + ": " + entry.sizeStr);
     48         if (entry.sizeStr != null) {
     49             switch (whichSize) {
     50                 case ManageApplications.SIZE_INTERNAL:
     51                     appSize.setText(entry.internalSizeStr);
     52                     break;
     53                 case ManageApplications.SIZE_EXTERNAL:
     54                     appSize.setText(entry.externalSizeStr);
     55                     break;
     56                 default:
     57                     appSize.setText(entry.sizeStr);
     58                     break;
     59             }
     60         } else if (entry.size == ApplicationsState.SIZE_INVALID) {
     61             appSize.setText(invalidSizeStr);
     62         }
     63     }
     64 }