commit fc35375232a80641b650537a7368e76afa579ad6
parent 8cdb28800844b6c9b6121a9133314ea3a3002d1c
Author: Jan Dankert <devnull@localhost>
Date: Wed, 25 Jan 2012 02:09:08 +0100
Fehlende Dateien versioniert.
Diffstat:
2 files changed, 144 insertions(+), 0 deletions(-)
diff --git a/src/de/mtbnews/android/adapter/MapExpandableContentAdapter.java b/src/de/mtbnews/android/adapter/MapExpandableContentAdapter.java
@@ -0,0 +1,114 @@
+/**
+ *
+ */
+package de.mtbnews.android.adapter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.mcsoxford.rss.RSSItem;
+
+import android.content.Context;
+import android.text.format.DateFormat;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import de.mtbnews.android.R;
+
+/**
+ * @author dankert
+ *
+ */
+public class MapExpandableContentAdapter extends BaseAdapter
+{
+
+ /** Remember our context so we can use it when constructing views. */
+ private Context mContext;
+
+ /**
+ * Hold onto a copy of the entire Contact List.
+ */
+
+ private LayoutInflater inflator;
+
+ private String dateKey;
+ private String titleKey;
+ private String descriptionKey;
+
+ private List<Map<String, Object>> map;
+
+ public MapExpandableContentAdapter(Context context, List<Map<String, Object>> map,
+ String dateKey, String titleKey, String descriptionKey)
+ {
+ mContext = context;
+ inflator = (LayoutInflater) context
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ this.map = map;
+ this.dateKey = dateKey;
+ this.titleKey = titleKey;
+ this.descriptionKey = descriptionKey;
+ }
+
+ public int getCount()
+ {
+ return map.size();
+ }
+
+ public Object getItem(int position)
+ {
+ return map.get(position);
+ }
+
+ /** Use the array index as a unique id. */
+ public long getItemId(int position)
+ {
+ return position;
+
+ }
+
+ /**
+ * @param convertView
+ * The old view to overwrite, if one is passed
+ * @returns a ContactEntryView that holds wraps around an ContactEntry
+ */
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
+
+ Map<String, Object> e = map.get(position);
+
+ final View view = inflator.inflate(R.layout.rss_item, null);
+
+ if (dateKey != null)
+ {
+ TextView datum = (TextView) view.findViewById(R.id.item_date);
+ datum.setText(DateFormat.getDateFormat(parent.getContext()).format(
+ e.get(dateKey))
+ + " "
+ + DateFormat.getTimeFormat(parent.getContext()).format(
+ e.get(dateKey)));
+ }
+
+ if (titleKey != null)
+ {
+
+ TextView name = (TextView) view.findViewById(R.id.item_title);
+ name.setText(new String((byte[]) e.get(titleKey)));
+ }
+
+ if (descriptionKey != null)
+ {
+ TextView desc = (TextView) view.findViewById(R.id.item_description);
+
+ if (e.get(descriptionKey) != null)
+ desc.setText(new String((byte[]) e.get(descriptionKey))
+ + " ...");
+ else
+ desc.setText("");
+ }
+
+ return view;
+ }
+
+}
diff --git a/src/de/mtbnews/android/tapatalk/TapatalkException.java b/src/de/mtbnews/android/tapatalk/TapatalkException.java
@@ -0,0 +1,30 @@
+/**
+ *
+ */
+package de.mtbnews.android.tapatalk;
+
+/**
+ * @author dankert
+ *
+ */
+public class TapatalkException extends Exception
+{
+
+ /**
+ * @param detailMessage
+ * @param throwable
+ */
+ public TapatalkException(String detailMessage, Throwable throwable)
+ {
+ super(detailMessage, throwable);
+ }
+
+ /**
+ * @param detailMessage
+ */
+ public TapatalkException(String detailMessage)
+ {
+ super(detailMessage);
+ }
+
+}