/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitArrayAdapter.java
ZANavi

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitArrayAdapter.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations) (download)
Sat Mar 8 17:10:49 2014 UTC (10 years, 1 month ago) by zoff99
File size: 2522 byte(s)
new market version, lots of new features
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.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.widget.BaseAdapter;
29 import android.widget.ImageView;
30 import android.widget.TextView;
31
32 public class NavitArrayAdapter extends BaseAdapter
33 {
34 List<String> l;
35 List<String> a;
36 Context c;
37
38 public NavitArrayAdapter(Context context, List<String> objects, List<String> addons)
39 {
40 this.l = objects;
41 this.a = addons;
42 this.c = context;
43 }
44
45 @Override
46 public int getCount()
47 {
48 return l.size();
49 }
50
51 @Override
52 public Object getItem(int i)
53 {
54 return l.get(i);
55 }
56
57 @Override
58 public long getItemId(int position)
59 {
60 return position;
61 }
62
63 @Override
64 public View getView(int position, View convertView, ViewGroup parent)
65 {
66 View itemView = null;
67
68 if (convertView == null)
69 {
70 LayoutInflater inflater = (LayoutInflater) this.c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
71 itemView = inflater.inflate(R.layout.recentdest_list, null);
72 }
73 else
74 {
75 itemView = convertView;
76 }
77 TextView text = (TextView) itemView.findViewById(R.id.text);
78 text.setText(l.get(position));
79
80 try
81 {
82 ImageView imv = (ImageView) itemView.findViewById(R.id.icon_recent_dest);
83 if (a.get(position).equals("1"))
84 {
85 imv.setImageResource(R.drawable.homeicon);
86 }
87 }
88 catch (Exception e)
89 {
90 // remove icon for other location type (empty icon space!)
91 try
92 {
93 ImageView imv = (ImageView) itemView.findViewById(R.id.icon_recent_dest);
94 imv.setImageDrawable(null);
95 }
96 catch (Exception e2)
97 {
98 }
99 }
100
101 return itemView;
102 }
103 }

   
Visit the ZANavi Wiki