Created
October 30, 2014 12:53
-
-
Save valokafor/0ff0339935e877ee2807 to your computer and use it in GitHub Desktop.
Customer Adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.valokafor.billduedateazure.Adapters; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import com.valokafor.billduedateazure.Model.Bill; | |
import com.valokafor.billduedateazure.R; | |
import com.valokafor.billduedateazure.Utilities.DateFunctions; | |
import com.valokafor.billduedateazure.Utilities.Utility; | |
import java.util.List; | |
/** | |
* Created by Valentine on 8/31/2014. | |
*/ | |
public class UpcomingBillAdapter extends BaseAdapter { | |
private Context mContext; | |
private List<Bill> mBillList; | |
DateFunctions mDateFunctions = new DateFunctions(); | |
int mLayoutResourceId; //Adapter View Layout | |
public UpcomingBillAdapter(Context context, int layoutResourceId, List<Bill> bills) { | |
this.mContext = context; | |
this.mBillList = bills; | |
mLayoutResourceId = layoutResourceId; | |
} | |
//Get the size of the array | |
@Override | |
public int getCount() { | |
if (mBillList == null) | |
return 0; | |
return mBillList.size(); | |
} | |
//Return a Bill at the specified location | |
@Override | |
public Object getItem(int i) { | |
return mBillList.get(i); | |
} | |
//Return the ID of the Bill in the specified location | |
@Override | |
public long getItemId(int i) { | |
return Long.parseLong(mBillList.get(i).getId()); | |
} | |
//Returns the view for a specific item in the list | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
BillSummaryHolder viewHolder = null; | |
//final Bill currentBill = getItem(position); | |
if (convertView == null) { | |
LayoutInflater inflater = LayoutInflater.from(mContext); | |
convertView = inflater.inflate(R.layout.row_upcoming_bill, null); | |
viewHolder = new BillSummaryHolder(); | |
viewHolder.txtBillName = (TextView) convertView.findViewById(R.id.txtBillName); | |
viewHolder.txtNumberDays = (TextView) convertView.findViewById(R.id.txtNumberOfDay); | |
viewHolder.txtDueIn = (TextView) convertView.findViewById(R.id.txtDue); | |
viewHolder.txtdays = (TextView) convertView.findViewById(R.id.txtDay); | |
viewHolder.txtBillAmount = (TextView) convertView.findViewById(R.id.txtAmount); | |
viewHolder.imgProviderLogo = (ImageView) convertView.findViewById(R.id.imgProviderLogo); | |
viewHolder.billSummary = mBillList.get(position); | |
convertView.setTag(viewHolder); | |
} else { | |
viewHolder = (BillSummaryHolder)convertView.getTag(); | |
} | |
viewHolder.txtBillName.setText(viewHolder.billSummary.getBillName()); | |
viewHolder.txtNumberDays.setText(viewHolder.billSummary.getDaysBeforeDueDate() + ""); | |
viewHolder.txtBillAmount.setText(Utility.getFormattedCurrencyWithSymbol(viewHolder.billSummary.getBillAmount())); | |
viewHolder.imgProviderLogo.setBackgroundResource(R.drawable.img_ae); | |
return convertView; | |
} | |
static class BillSummaryHolder { | |
protected TextView txtBillName; | |
protected TextView txtNumberDays; | |
protected TextView txtDueIn; | |
protected TextView txtdays; | |
protected TextView txtBillAmount; | |
protected ImageView imgProviderLogo; | |
protected Bill billSummary; | |
} | |
public void add(Bill bill) | |
{ | |
mBillList.add(bill); | |
notifyDataSetChanged(); | |
} | |
// public void clear() | |
// { | |
// mBillList.clear(); | |
// notifyDataSetChanged(); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment