Home | History | Annotate | Download | only in filtershow
      1 /*
      2  * Copyright (C) 2012 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.gallery3d.filtershow;
     18 
     19 import android.content.Context;
     20 import android.view.LayoutInflater;
     21 import android.view.View;
     22 import android.view.ViewGroup;
     23 import android.widget.ArrayAdapter;
     24 import android.widget.TextView;
     25 
     26 import com.android.gallery3d.R;
     27 import com.android.gallery3d.filtershow.filters.ImageFilter;
     28 
     29 public class ImageStateAdapter extends ArrayAdapter<ImageFilter> {
     30     private static final String LOGTAG = "ImageStateAdapter";
     31 
     32     public ImageStateAdapter(Context context, int textViewResourceId) {
     33         super(context, textViewResourceId);
     34     }
     35 
     36     @Override
     37     public View getView(int position, View convertView, ViewGroup parent) {
     38         View view = convertView;
     39         if (view == null) {
     40             LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
     41                     Context.LAYOUT_INFLATER_SERVICE);
     42             view = inflater.inflate(R.layout.filtershow_imagestate_row, null);
     43         }
     44         ImageFilter filter = getItem(position);
     45         if (filter != null) {
     46             TextView itemLabel = (TextView) view.findViewById(R.id.imagestate_label);
     47             itemLabel.setText(filter.getName());
     48             TextView itemParameter = (TextView) view.findViewById(R.id.imagestate_parameter);
     49             itemParameter.setText("" + filter.getParameter());
     50         }
     51         return view;
     52     }
     53 }
     54