aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/cgGPXListAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgeo/geocaching/cgGPXListAdapter.java')
-rw-r--r--src/cgeo/geocaching/cgGPXListAdapter.java97
1 files changed, 49 insertions, 48 deletions
diff --git a/src/cgeo/geocaching/cgGPXListAdapter.java b/src/cgeo/geocaching/cgGPXListAdapter.java
index 0c2b10d..df1933c 100644
--- a/src/cgeo/geocaching/cgGPXListAdapter.java
+++ b/src/cgeo/geocaching/cgGPXListAdapter.java
@@ -1,8 +1,5 @@
package cgeo.geocaching;
-import java.io.File;
-import java.util.List;
-
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
@@ -11,64 +8,68 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
+import java.io.File;
+import java.util.List;
+
public class cgGPXListAdapter extends ArrayAdapter<File> {
- private cgGPXView holder = null;
- private cgeogpxes parent = null;
- private LayoutInflater inflater = null;
+ private cgGPXView holder = null;
+ private cgeogpxes parent = null;
+ private LayoutInflater inflater = null;
- public cgGPXListAdapter(cgeogpxes parentIn, cgSettings settingsIn, List<File> listIn) {
- super(parentIn, 0, listIn);
+ public cgGPXListAdapter(cgeogpxes parentIn, cgSettings settingsIn, List<File> listIn) {
+ super(parentIn, 0, listIn);
- parent = parentIn;
- }
+ parent = parentIn;
+ }
@Override
public View getView(int position, View rowView, ViewGroup parent) {
- if (inflater == null) inflater = ((Activity)getContext()).getLayoutInflater();
-
- if (position > getCount()) {
- Log.w(cgSettings.tag, "cgGPXListAdapter.getView: Attempt to access missing item #" + position);
- return null;
- }
-
- File file = getItem(position);
+ if (inflater == null)
+ inflater = ((Activity) getContext()).getLayoutInflater();
- if (rowView == null) {
- rowView = (View)inflater.inflate(R.layout.gpx_item, null);
+ if (position > getCount()) {
+ Log.w(cgSettings.tag, "cgGPXListAdapter.getView: Attempt to access missing item #" + position);
+ return null;
+ }
- holder = new cgGPXView();
- holder.filepath = (TextView)rowView.findViewById(R.id.filepath);
- holder.filename = (TextView)rowView.findViewById(R.id.filename);
+ File file = getItem(position);
- rowView.setTag(holder);
- } else {
- holder = (cgGPXView)rowView.getTag();
- }
+ if (rowView == null) {
+ rowView = (View) inflater.inflate(R.layout.gpx_item, null);
- final touchListener touchLst = new touchListener(file);
- rowView.setOnClickListener(touchLst);
+ holder = new cgGPXView();
+ holder.filepath = (TextView) rowView.findViewById(R.id.filepath);
+ holder.filename = (TextView) rowView.findViewById(R.id.filename);
- holder.filepath.setText(file.getParent());
- holder.filename.setText(file.getName());
+ rowView.setTag(holder);
+ } else {
+ holder = (cgGPXView) rowView.getTag();
+ }
- return rowView;
- }
+ final touchListener touchLst = new touchListener(file);
+ rowView.setOnClickListener(touchLst);
- @Override
- public void notifyDataSetChanged() {
- super.notifyDataSetChanged();
- }
+ holder.filepath.setText(file.getParent());
+ holder.filename.setText(file.getName());
- private class touchListener implements View.OnClickListener {
- private File file = null;
+ return rowView;
+ }
- public touchListener(File fileIn) {
- file = fileIn;
- }
-
- // tap on item
- public void onClick(View view) {
- parent.loadGPX(file);
- }
- }
+ @Override
+ public void notifyDataSetChanged() {
+ super.notifyDataSetChanged();
+ }
+
+ private class touchListener implements View.OnClickListener {
+ private File file = null;
+
+ public touchListener(File fileIn) {
+ file = fileIn;
+ }
+
+ // tap on item
+ public void onClick(View view) {
+ parent.loadGPX(file);
+ }
+ }
}