1 /* 2 * Copyright (C) 2008 Esmertec AG. 3 * Copyright (C) 2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package com.android.mms.ui; 18 19 import java.util.List; 20 21 import android.content.Context; 22 import android.view.LayoutInflater; 23 import android.view.View; 24 import android.view.ViewGroup; 25 import android.widget.ArrayAdapter; 26 27 import com.android.mms.LogTag; 28 import com.android.mms.R; 29 30 /** 31 * The back-end data adapter for DeliveryReportActivity. 32 */ 33 public class DeliveryReportAdapter extends ArrayAdapter<DeliveryReportItem> { 34 static final String LOG_TAG = LogTag.TAG; 35 36 public DeliveryReportAdapter(Context context, List<DeliveryReportItem> items) { 37 super(context, R.layout.delivery_report_list_item, R.id.recipient, items); 38 } 39 40 @Override 41 public View getView(int position, View view, ViewGroup viewGroup) { 42 DeliveryReportListItem listItem; 43 DeliveryReportItem item = this.getItem(position); 44 45 if (view == null) { 46 LayoutInflater factory = LayoutInflater.from(getContext()); 47 listItem = (DeliveryReportListItem) factory.inflate( 48 R.layout.delivery_report_list_item, viewGroup, false); 49 } else { 50 if (view instanceof DeliveryReportListItem) { 51 listItem = (DeliveryReportListItem) view; 52 } else { 53 return view; 54 } 55 } 56 57 listItem.bind(item.recipient, item.status, item.deliveryDate); 58 59 return listItem; 60 } 61 } 62