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.settings.R;
25 import com.android.settingslib.applications.ApplicationsState;
26 
27 // View Holder used when displaying views
28 public class AppViewHolder {
29     public ApplicationsState.AppEntry entry;
30     public View rootView;
31     public TextView appName;
32     public ImageView appIcon;
33     public TextView summary;
34     public TextView disabled;
35 
createOrRecycle(LayoutInflater inflater, View convertView)36     static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
37         if (convertView == null) {
38             convertView = inflater.inflate(R.layout.preference_app, null);
39 
40             // Creates a ViewHolder and store references to the two children views
41             // we want to bind data to.
42             AppViewHolder holder = new AppViewHolder();
43             holder.rootView = convertView;
44             holder.appName = convertView.findViewById(android.R.id.title);
45             holder.appIcon = convertView.findViewById(android.R.id.icon);
46             holder.summary = convertView.findViewById(android.R.id.summary);
47             holder.disabled = convertView.findViewById(R.id.appendix);
48             convertView.setTag(holder);
49             return holder;
50         } else {
51             // Get the ViewHolder back to get fast access to the TextView
52             // and the ImageView.
53             return (AppViewHolder) convertView.getTag();
54         }
55     }
56 }