Commits

littledot5566 committed d4a27b2

*HistoryActivity now displays treasure info.

Comments (0)

Files changed (2)

res/layout/history_item.xml

             android:gravity="right" />
     </LinearLayout>
 
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal" >
+
+        <TextView
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="Treasure:" />
+
+        <ImageView
+            android:id="@+id/hItem_iv_treasure"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+
+        <TextView
+            android:id="@+id/hItem_tv_treasure"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="right" />
+    </LinearLayout>
+
 </LinearLayout>

src/nctuw/littledot/localtreasure/components/HistoryActivityAdapter.java

 import nctuw.littledot.localtreasure.database.Expedition;
 import nctuw.littledot.localtreasure.database.Profile;
 import nctuw.littledot.localtreasure.database.SPManager;
+import nctuw.littledot.localtreasure.database.Treasure;
 import nctuw.littledot.util.Leg;
 import android.content.ContentValues;
 import android.content.Context;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
+import android.widget.ImageView;
 import android.widget.TextView;
 
 public class HistoryActivityAdapter extends BaseAdapter {
 		}
 
 		long l;
+		int i;
 
 		ContentValues kv = mData.get(position);
 
 		TextView tvUser = (TextView) view.findViewById(R.id.hItem_tv_user);
 		TextView tvStTime = (TextView) view.findViewById(R.id.hItem_tv_stTime);
 		TextView tvEndTime = (TextView) view.findViewById(R.id.hItem_tv_endTime);
+		TextView tvTreasure = (TextView) view.findViewById(R.id.hItem_tv_treasure);
+		ImageView ivTreasure = (ImageView) view
+				.findViewById(R.id.hItem_iv_treasure);
 
 		tvTravelled.setText(NumberFormat.getInstance().format(
 				kv.getAsDouble(Expedition.KEY_TRAVELED)) + "m");
 		tvStTime.setText(new Date(kv.getAsLong(Expedition.KEY_START_TIMESTAMP))
 				.toLocaleString());
 		tvEndTime
-				.setText((l = kv.getAsLong(Expedition.KEY_END_TIMESTAMP)) > 0 ? new Date(
-						l).toLocaleString()
+				.setText((l = kv.getAsLong(Expedition.KEY_END_TIMESTAMP)) > 0
+						? new Date(l).toLocaleString()
 						: "");
 
+		if ((i = kv.getAsInteger(Expedition.KEY_TREASURE_ID)) > 0) {
+			Treasure t = Treasure.getTreasure(i);
+			tvTreasure.setText(t.getName());
+			ivTreasure.setImageResource(t.getDrawableID());
+		}
+
 		return view;
 	}
 }