From 274048dce38e8aa2ba47174e2adeb41fc0001be4 Mon Sep 17 00:00:00 2001 From: tokugawa Date: Sat, 26 Apr 2014 02:07:55 -0400 Subject: [PATCH] Added ability to check found locations --- .../res/drawable-mdpi/checkbox_checked.png | Bin 0 -> 6423 bytes .../res/drawable-mdpi/checkbox_unchecked.png | Bin 0 -> 5849 bytes .../src/edu/uncc/scavenger/MainActivity.java | 33 ++++++++++++++---- .../edu/uncc/scavenger/SearchActivity.java | 7 +--- .../database/LocationDatabaseHelper.java | 14 +++++++- 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 UNCCScavenger/res/drawable-mdpi/checkbox_checked.png create mode 100644 UNCCScavenger/res/drawable-mdpi/checkbox_unchecked.png diff --git a/UNCCScavenger/res/drawable-mdpi/checkbox_checked.png b/UNCCScavenger/res/drawable-mdpi/checkbox_checked.png new file mode 100644 index 0000000000000000000000000000000000000000..ef6028310d400b326075a785e5c497e666907289 GIT binary patch literal 6423 zcmcIo2{@E(_kT#%qGYM0cMM6ES?s2<&e*pwvQ-*0V+>}7nXy)0LPjY`Wf%2kC#6UT zWs8tX5t5M9i!V!5td)%*2*|Lgm%>+hO*9`}8pbAG@3+~=J8Tob#`#&o0Lc0m9D zHkzAZ?ZG#K^X2CSpHAGLVgNv3n1XX=Ia^zy2y`k8Po#U0V8K*Ba2){9`oVs9f)9xW z@gR{YG+pRaRV@@kA?iY%G^`QUei)J$#VnLTatO7-5kh?kIz*_xo*+6H1sb4|Sa?V< z)tAOZ1?xgr?4rQ`In!_`WJQGKqYE|U079It_dzgp1_`1LQ-!Ij5D=Pb5Dhh$nue;T zs=6{n6@k!(BedXZ2o;}Wsf!a1_zFGp$+bR8$6cZQXM}pgvnDhV!fn*#AZcugw^oNg8 zSUih_VUWNl7?P?8Btiv&1V4Y10wstP5R4NGWYCH)$rDc?!NBACo1kF;%Ztun?xQm) zoDcwmlfi;uDGU;UMQ5zYu00}@IgLf~^#vCL@V=%b8s}L3D4-~rfnT)@x&>to#yb(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ku;SywYBm z!sX8sqZYY0^8E&z^oWk|&1T`#2VK2l`PZLYjJ;UX*?f9GRuqNodSCDk{`i4wjeAWM z9vd|k2i(=k;R;87oQyerdZR$NZ`^UyL8YBLcKmt7IFtQ#3*zM5+?)#39(Wjh+nI68 zbzr`c+fz(1`kdiQ%a($I$*5lQ%=v5_=I?Ju9Mu4($H((&RViimbd9b!Uro1G z&$5u+BW1lsEv=F4Rx+76QbSKr6xU+04d0GDsrSzHO-9e|b z(=T0`5~Su9@2?XcXMGmg{Gh2!4U03+eey|wiFG=(exJl7U%H^#ReR5A#3}Fdk$zD3-&6#{tz6?ZaqE)1H77s{k7j#IW{@>nrkxU!r6gGizwTHPoF=#N`?gE z@pz%SyCHjZ{YA%)cD_xhnJU_DhkM>l2PbXAe5 zjc@dzyB;#-23~#q7`S))>Cin!)QY}7sEEmxuArqm1TNlIEbbq#ZW|Ng#Eo~Rr=>|9 z>3LNke6x=#T_?XepPSM}YncfA;w}2Ax3^bx^Pb_`l_d?}uSdU$Uw<;rit31MN?0xh zfVV6Z%{Xs>HeZprMcbVRFsSJ3j%|tMKg~XA!)9I<#{y1xt~4BH@;6{ zR+MRcWvrBepBoy&52Qzn0fD;ouJpFZ`Yd;tY=2|TbpyoK^X$A&-G=Y8Hd_eCV3xYM zy_oM ztvuWj#X%oDnAc^HO<`Pl+*$A)j!ixAret;4tKOjHs`f!Hz$H7=UvU8E1(qVf+}H+N JVs!ZUKLH;yW7z-z literal 0 HcmV?d00001 diff --git a/UNCCScavenger/res/drawable-mdpi/checkbox_unchecked.png b/UNCCScavenger/res/drawable-mdpi/checkbox_unchecked.png new file mode 100644 index 0000000000000000000000000000000000000000..7c6841930b8e7b8bcba8e15fc07fffcacd59d3e8 GIT binary patch literal 5849 zcmcIo2{@GP`hQV&QnpI^#z-V)wPcKKW^CEQ2+=ZTUSl$5#>`lYs4OiXNm(P>h-gt{ zD^yw((JEV6lKSX;=u-*joe`fpo%6rWxvsx!wB`~Ll&-*eyh^IQ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zay^@`4uAT~x&xX1NT;KEUpcYz^iBNr8nEDg^CMFW@)`0t`77CIq^;{3<;7=K>xkN} zn!gPGc-G-lGcjd;|3-(0h=lrOufyF?3Vm|{Rdn5yT9F-&iNRoFJ~m@@%xF!UQG@uqJL;Ys%K)g9PU-<;awNr zNIdy1RGqGl+)2n9&9cdM&zkh{^Qm%qXx{q#eRt$H+m7FsoG`$9M{FD;-)FoU+WRDx zKH73P=Xg$3G~!F=j*e61y9TMvJv*1MKUOL5-?UlJ92zvOF>Ur8z0M!K(lMaudEGPX zB5r%od;WX;bm|kAyVWPEvq~#{11m=&Yp?C{pBPfhHE!-2uZ{RqW#;*_Tobdd+ObIX z#GQ#xJt|$%Tx>m(Vw4vc+uRN z(VCw=nx1+yX!qHv_jMmuTKTOZZ(pfsjYQcVQG02eQCt%yRwJ^F zw8Kiay0ZSBvw>UL^2P)ghIVkbK@DH4_Hxjdn8^GpE9;q- z#hW8{d+U9Zdz_(r!0rsA>g$`W+mi40XSllZDFtSQBOqgw< z!HN#Rv2$d9`4LfOMTf8GC3o3NsUlCQdG}|icUEYp)pEK+^7Wdy$KRLfHQnTkg5Kpu zLrqt^Lh_9=9J9qA11n$e5qZoYS054lw(Jr6y81EVjEF&9MaK>l=eMGbzv; locations; - static String key; @Override protected void onCreate(Bundle savedInstanceState) { @@ -76,7 +75,7 @@ public class MainActivity extends Activity { // We don't yet have any locations... ((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.VISIBLE); ((ListView)findViewById(R.id.listLocations)).setVisibility(View.GONE); - Log.d("NoLocation", "NoLocations"); + //Log.d("NoLocation", "NoLocations"); } // And kick off contacting to server to see if there are any new ones @@ -86,8 +85,22 @@ public class MainActivity extends Activity { protected void onPostExecute(List result) { super.onPostExecute(result); // And update our adapter when done - LocationAdapter mLocationAdapter = new LocationAdapter(result); + for(int x=0; x parent, View view,int position, long id) { + Intent intent = new Intent(MainActivity.this, SearchActivity.class); + intent.putExtra("restLocation", locations.get(position)); + startActivity(intent); + } + }); // Always show the ListView and hide the TextView // We're back on the main thread at this point, so it's legal. @@ -95,11 +108,10 @@ public class MainActivity extends Activity { ((ListView)findViewById(R.id.listLocations)).setVisibility(View.VISIBLE); // And we're even kind enough to update the database - LocationDatabaseHelper.getInstance(MainActivity.this).persistAll(result); - locations = LocationDatabaseHelper.getInstance(getBaseContext()).fetchAll(); + LocationDatabaseHelper.getInstance(MainActivity.this).persistAll(locations); + locations = LocationDatabaseHelper.getInstance(MainActivity.this).fetchAll(); } }.execute(); - } @Override @@ -143,6 +155,15 @@ public class MainActivity extends Activity { holder.name = (TextView)v.findViewById(R.id.txtName); holder.riddle = (TextView)v.findViewById(R.id.txtRiddle); + if(locations.get(position).getKey()!=null) + { + holder.imgFound.setImageResource(R.drawable.checkbox_checked); + } + else + { + holder.imgFound.setImageResource(R.drawable.checkbox_unchecked); + } + v.setTag(holder); } else { holder = (Holder)v.getTag(); diff --git a/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java index 7a3c946..3f1056f 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java @@ -181,13 +181,8 @@ public class SearchActivity extends Activity { Toast.makeText(getApplicationContext(), key, Toast.LENGTH_SHORT).show(); if(key!= null) { - //Add found to the database - /*List locations = LocationDatabaseHelper.getInstance(this).fetchAll(); - if (locations != null && locations.size() > 0) - { - locations.get(restLocation.getId()-1); - }*/ restLocation.setKey(key); + LocationDatabaseHelper.getInstance(SearchActivity.this).updateRecord(restLocation); intent = new Intent(SearchActivity.this, FoundActivity.class); intent.putExtra("restLocation", restLocation); startActivity(intent); diff --git a/UNCCScavenger/src/edu/uncc/scavenger/database/LocationDatabaseHelper.java b/UNCCScavenger/src/edu/uncc/scavenger/database/LocationDatabaseHelper.java index 2a24073..6c2f75b 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/database/LocationDatabaseHelper.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/database/LocationDatabaseHelper.java @@ -113,7 +113,7 @@ public class LocationDatabaseHelper extends SQLiteOpenHelper { values.put(KEY_LOCATION_LAT, loc.getLocationLat()); values.put(KEY_VALIDATION_KEY, loc.getKey()); values.put(KEY_RIDDLE_IMAGE_URL, loc.getRiddleImageUrl()); - helper.getWritableDatabase().insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE); + helper.getWritableDatabase().insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE); } public void persistAll(List locs) { @@ -121,4 +121,16 @@ public class LocationDatabaseHelper extends SQLiteOpenHelper { persist(l); } } + + public void updateRecord(RestLocation loc){ + ContentValues values = new ContentValues(); + values.put(KEY_ID, loc.getId()); + values.put(KEY_NAME, loc.getName()); + values.put(KEY_RIDDLE, loc.getRiddle()); + values.put(KEY_LOCATION_LONG, loc.getLocationLong()); + values.put(KEY_LOCATION_LAT, loc.getLocationLat()); + values.put(KEY_VALIDATION_KEY, loc.getKey()); + values.put(KEY_RIDDLE_IMAGE_URL, loc.getRiddleImageUrl()); + helper.getWritableDatabase().insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE); + } }