1 |
/**
|
2 |
* ZANavi, Zoff Android Navigation system.
|
3 |
* Copyright (C) 2011 - 2012 Zoff <zoff@zoff.cc>
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* version 2 as published by the Free Software Foundation.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
* Boston, MA 02110-1301, USA.
|
18 |
*/
|
19 |
|
20 |
package com.zoffcc.applications.zanavi;
|
21 |
|
22 |
import java.util.List;
|
23 |
|
24 |
import android.content.Context;
|
25 |
import android.graphics.ColorFilter;
|
26 |
import android.graphics.ColorMatrixColorFilter;
|
27 |
import android.graphics.drawable.Drawable;
|
28 |
import android.view.LayoutInflater;
|
29 |
import android.view.View;
|
30 |
import android.view.ViewGroup;
|
31 |
import android.widget.BaseAdapter;
|
32 |
import android.widget.ImageView;
|
33 |
import android.widget.TextView;
|
34 |
|
35 |
public class NavitArrayAdapter extends BaseAdapter
|
36 |
{
|
37 |
List<String> l;
|
38 |
List<String> a;
|
39 |
Context c;
|
40 |
|
41 |
public NavitArrayAdapter(Context context, List<String> objects, List<String> addons)
|
42 |
{
|
43 |
this.l = objects;
|
44 |
this.a = addons;
|
45 |
this.c = context;
|
46 |
}
|
47 |
|
48 |
@Override
|
49 |
public int getCount()
|
50 |
{
|
51 |
return l.size();
|
52 |
}
|
53 |
|
54 |
@Override
|
55 |
public Object getItem(int i)
|
56 |
{
|
57 |
return l.get(i);
|
58 |
}
|
59 |
|
60 |
@Override
|
61 |
public long getItemId(int position)
|
62 |
{
|
63 |
return position;
|
64 |
}
|
65 |
|
66 |
@Override
|
67 |
public View getView(int position, View convertView, ViewGroup parent)
|
68 |
{
|
69 |
View itemView = null;
|
70 |
|
71 |
if (convertView == null)
|
72 |
{
|
73 |
LayoutInflater inflater = (LayoutInflater) this.c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
74 |
itemView = inflater.inflate(R.layout.recentdest_list, null);
|
75 |
}
|
76 |
else
|
77 |
{
|
78 |
itemView = convertView;
|
79 |
}
|
80 |
TextView text = (TextView) itemView.findViewById(R.id.text);
|
81 |
text.setText(l.get(position));
|
82 |
|
83 |
try
|
84 |
{
|
85 |
ImageView imv = (ImageView) itemView.findViewById(R.id.icon_recent_dest);
|
86 |
if (a.get(position).equals("1"))
|
87 |
{
|
88 |
if (Navit.p.PREF_current_theme == Navit.DEFAULT_THEME_OLD_LIGHT)
|
89 |
{
|
90 |
imv.setImageResource(R.drawable.homeicon);
|
91 |
}
|
92 |
else
|
93 |
{
|
94 |
Drawable drawable_homeicon = imv.getResources().getDrawable(R.drawable.homeicon);
|
95 |
float[] colorMatrix_Negative = { -1.0f, 0, 0, 0, 255, //red
|
96 |
0, -1.0f, 0, 0, 255, //green
|
97 |
0, 0, -1.0f, 0, 255, //blue
|
98 |
0, 0, 0, 1.0f, 0 //alpha
|
99 |
};
|
100 |
|
101 |
ColorFilter colorFilter_Negative = new ColorMatrixColorFilter(colorMatrix_Negative);
|
102 |
drawable_homeicon.setColorFilter(colorFilter_Negative);
|
103 |
imv.setImageDrawable(drawable_homeicon);
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
catch (Exception e)
|
108 |
{
|
109 |
// remove icon for other location type (empty icon space!)
|
110 |
try
|
111 |
{
|
112 |
ImageView imv = (ImageView) itemView.findViewById(R.id.icon_recent_dest);
|
113 |
imv.setImageDrawable(null);
|
114 |
}
|
115 |
catch (Exception e2)
|
116 |
{
|
117 |
}
|
118 |
}
|
119 |
|
120 |
return itemView;
|
121 |
}
|
122 |
}
|