19244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornpackage com.android.settings.applications; 29244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn 39244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport com.android.settings.R; 49244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn 59244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.content.Context; 69244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.util.Log; 79244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.view.LayoutInflater; 89244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.view.View; 99244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.widget.CheckBox; 109244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.widget.ImageView; 119244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornimport android.widget.TextView; 129244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn 139244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn// View Holder used when displaying views 149244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackbornpublic class AppViewHolder { 159244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public ApplicationsState.AppEntry entry; 169244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public View rootView; 179244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public TextView appName; 189244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public ImageView appIcon; 199244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public TextView appSize; 209244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public TextView disabled; 219244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn public CheckBox checkBox; 229244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn 239244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) { 249244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn if (convertView == null) { 259244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn convertView = inflater.inflate(R.layout.manage_applications_item, null); 269244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn 279244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn // Creates a ViewHolder and store references to the two children views 289244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn // we want to bind data to. 299244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn AppViewHolder holder = new AppViewHolder(); 309244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn holder.rootView = convertView; 319244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn holder.appName = (TextView) convertView.findViewById(R.id.app_name); 329244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon); 339244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn holder.appSize = (TextView) convertView.findViewById(R.id.app_size); 349244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn holder.disabled = (TextView) convertView.findViewById(R.id.app_disabled); 359244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn holder.checkBox = (CheckBox) convertView.findViewById(R.id.app_on_sdcard); 369244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn convertView.setTag(holder); 379244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn return holder; 389244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } else { 399244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn // Get the ViewHolder back to get fast access to the TextView 409244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn // and the ImageView. 419244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn return (AppViewHolder)convertView.getTag(); 429244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } 439244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } 449244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn 45309c5dcee18ced447d049d5de882a9586694e04cDianne Hackborn void updateSizeText(CharSequence invalidSizeStr, int whichSize) { 469244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn if (ManageApplications.DEBUG) Log.i(ManageApplications.TAG, "updateSizeText of " + entry.label + " " + entry 479244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn + ": " + entry.sizeStr); 489244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn if (entry.sizeStr != null) { 499244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn switch (whichSize) { 509244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn case ManageApplications.SIZE_INTERNAL: 519244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn appSize.setText(entry.internalSizeStr); 529244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn break; 539244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn case ManageApplications.SIZE_EXTERNAL: 549244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn appSize.setText(entry.externalSizeStr); 559244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn break; 569244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn default: 579244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn appSize.setText(entry.sizeStr); 589244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn break; 599244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } 609244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } else if (entry.size == ApplicationsState.SIZE_INVALID) { 61309c5dcee18ced447d049d5de882a9586694e04cDianne Hackborn appSize.setText(invalidSizeStr); 629244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } 639244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn } 649244df4c6422931697a0cf6e327b15cd71b6d8c4Dianne Hackborn}