| 21478 |
rajender |
1 |
package com.saholic.profittill.navigationdrawer;
|
|
|
2 |
|
|
|
3 |
import android.app.Activity;
|
|
|
4 |
import android.content.Context;
|
|
|
5 |
import android.view.LayoutInflater;
|
|
|
6 |
import android.view.View;
|
|
|
7 |
import android.view.ViewGroup;
|
|
|
8 |
import android.widget.BaseAdapter;
|
|
|
9 |
import android.widget.ImageView;
|
|
|
10 |
import android.widget.TextView;
|
|
|
11 |
|
|
|
12 |
import com.saholic.profittill.R;
|
|
|
13 |
|
|
|
14 |
import java.util.ArrayList;
|
|
|
15 |
|
|
|
16 |
public class NavDrawerListAdapter extends BaseAdapter {
|
|
|
17 |
|
|
|
18 |
private Context context;
|
|
|
19 |
private ArrayList<NavDrawerItem> navDrawerItems;
|
|
|
20 |
|
|
|
21 |
public NavDrawerListAdapter(Context context, ArrayList<NavDrawerItem> navDrawerItems){
|
|
|
22 |
this.context = context;
|
|
|
23 |
this.navDrawerItems = navDrawerItems;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
@Override
|
|
|
27 |
public int getCount() {
|
|
|
28 |
return navDrawerItems.size();
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
@Override
|
|
|
32 |
public Object getItem(int position) {
|
|
|
33 |
return navDrawerItems.get(position);
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
@Override
|
|
|
37 |
public long getItemId(int position) {
|
|
|
38 |
return position;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
@Override
|
|
|
42 |
public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
43 |
if (convertView == null) {
|
|
|
44 |
LayoutInflater mInflater = (LayoutInflater)
|
|
|
45 |
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
|
|
46 |
convertView = mInflater.inflate(R.layout.drawer_list_item, null);
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
|
|
|
50 |
TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
|
|
|
51 |
TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
|
|
|
52 |
|
|
|
53 |
imgIcon.setImageResource(navDrawerItems.get(position).getIcon());
|
|
|
54 |
txtTitle.setText(navDrawerItems.get(position).getTitle());
|
|
|
55 |
|
|
|
56 |
// displaying count
|
|
|
57 |
// check whether it set visible or not
|
|
|
58 |
if(navDrawerItems.get(position).getCounterVisibility()){
|
|
|
59 |
txtCount.setText(navDrawerItems.get(position).getCount());
|
|
|
60 |
}else{
|
|
|
61 |
// hide the counter view
|
|
|
62 |
txtCount.setVisibility(View.GONE);
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
return convertView;
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
}
|