1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.development; 18 19 import android.view.LayoutInflater; 20 import android.view.View; 21 import android.widget.ImageView; 22 import android.widget.TextView; 23 24 import com.android.settingslib.applications.ApplicationsState; 25 26 // View Holder used when displaying views 27 public class AppViewHolder { 28 public ApplicationsState.AppEntry entry; 29 public View rootView; 30 public TextView appName; 31 public ImageView appIcon; 32 public TextView summary; 33 public TextView disabled; 34 public View widget; 35 createOrRecycle(LayoutInflater inflater, View convertView)36 static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) { 37 if (convertView == null) { 38 convertView = 39 inflater.inflate(com.android.settingslib.widget.preference.app.R.layout.preference_app, null); 40 41 // Creates a ViewHolder and store references to the two children views 42 // we want to bind data to. 43 AppViewHolder holder = new AppViewHolder(); 44 holder.rootView = convertView; 45 holder.appName = convertView.findViewById(android.R.id.title); 46 holder.appIcon = convertView.findViewById(android.R.id.icon); 47 holder.summary = convertView.findViewById(android.R.id.summary); 48 holder.disabled = 49 convertView.findViewById(com.android.settingslib.widget.preference.app.R.id.appendix); 50 holder.widget = convertView.findViewById(android.R.id.widget_frame); 51 convertView.setTag(holder); 52 return holder; 53 } else { 54 // Get the ViewHolder back to get fast access to the TextView 55 // and the ImageView. 56 return (AppViewHolder) convertView.getTag(); 57 } 58 } 59 }