blob: 941c39c3a21eb89562c48769c75116369c65ddf7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
package net.miz_hi.smileessence.statuslist;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import net.miz_hi.smileessence.Client;
import net.miz_hi.smileessence.R;
import net.miz_hi.smileessence.listener.StatusOnClickListener;
import net.miz_hi.smileessence.model.status.IStatusModel;
import net.miz_hi.smileessence.model.statuslist.StatusList;
import net.miz_hi.smileessence.status.StatusViewFactory;
import net.miz_hi.smileessence.util.CustomListAdapter;
import java.util.Collection;
public class StatusListAdapter extends CustomListAdapter<IStatusModel>
{
private StatusList statusList;
private IStatusModel[] statusArray;
private int count;
public StatusListAdapter(Activity activity, StatusList statusList)
{
super(activity, 0);
this.statusList = statusList;
}
@Deprecated
@Override
public void addAll(Collection<IStatusModel> collection)
{
}
@Deprecated
@Override
public void addFirst(IStatusModel element)
{
}
@Deprecated
@Override
public void addLast(IStatusModel element)
{
}
@Deprecated
@Override
public void removeElement(IStatusModel element)
{
}
@Deprecated
@Override
public void clear()
{
}
@Override
public View getView(int position, View convertedView, ViewGroup parent)
{
if (convertedView == null)
{
convertedView = getInflater().inflate(R.layout.status_layout, null);
}
IStatusModel model = (IStatusModel) getItem(position);
int colorBg;
if (position % 2 == 0)
{
colorBg = Client.getColor(R.color.White);
}
else
{
colorBg = Client.getColor(R.color.LightGray);
}
convertedView.setBackgroundColor(colorBg);
convertedView = StatusViewFactory.newInstance(getInflater(), convertedView).getStatusView(model);
convertedView.setOnClickListener(new StatusOnClickListener(getActivity(), model));
return convertedView;
}
@Override
public void notifyDataSetChanged()
{
statusArray = statusList.getStatusList();
count = statusArray.length;
super.notifyDataSetChanged();
}
@Override
public int getCount()
{
return count;
}
@Override
public Object getItem(int arg0)
{
if (statusArray != null && statusArray.length >= arg0)
{
return statusArray[arg0];
}
else
{
return null;
}
}
@Override
public long getItemId(int arg0)
{
return arg0;
}
}
|