• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     public View widget;
36 
createOrRecycle(LayoutInflater inflater, View convertView)37     static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
38         if (convertView == null) {
39             convertView = inflater.inflate(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 = convertView.findViewById(R.id.appendix);
49             holder.widget = convertView.findViewById(android.R.id.widget_frame);
50             convertView.setTag(holder);
51             return holder;
52         } else {
53             // Get the ViewHolder back to get fast access to the TextView
54             // and the ImageView.
55             return (AppViewHolder) convertView.getTag();
56         }
57     }
58 }