Commit 7616b8b9 authored by mahendri.md's avatar mahendri.md

Merge branch 'aku'

parents 7e656252 b33bb731
......@@ -119,8 +119,8 @@ public class DataDownloadActivity extends AppCompatActivity
public void onPostDownload(boolean successDownload, NotifData notifData) {
progressDialog.dismiss();
if (successDownload)
Toast.makeText(this, "Gagal mengunduh", Toast.LENGTH_SHORT).show();
else
Toast.makeText(this, "Isian sukses diunduh", Toast.LENGTH_SHORT).show();
else
Toast.makeText(this, "Gagal mengunduh", Toast.LENGTH_SHORT).show();
}
}
......@@ -26,25 +26,34 @@ public class NotifDataDao {
String selectionArgs[] = {values.get(NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID).toString(),
values.get(NotifDataProviderAPI.NotifDataColumns.LAST_UPDATE_DATE).toString()};
Cursor lebih = getNotifDataCursor(selection, selectionArgs);
/*
* untuk menghindari isian lama yang di download tampil pada list notifikasi, maka
* isian lama tersebut harus ditandai 0 (bukan terbaru)
*/
if(lebih.getCount()==0){
lebih.close();
/*
* tandai isian yang tersimpan pada database menjadi bukan terbaru, jika data yang akan
* disimpan ternyata lebih baru
*/
String selection2 = NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID + " =? and " +
NotifDataProviderAPI.NotifDataColumns.LAST_UPDATE_DATE + " < ? ";
String selectionArgs2[] = {values.get(NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID).toString(),
values.get(NotifDataProviderAPI.NotifDataColumns.LAST_UPDATE_DATE).toString()};
ContentValues valuesUpdate = new ContentValues();
valuesUpdate.put(NotifDataProviderAPI.NotifDataColumns.LATEST,"0");
valuesUpdate.put(NotifDataProviderAPI.NotifDataColumns.LATEST,NotifDataColumns.DATA_NOT_LATEST);
Collect.getInstance().getContentResolver().update(NotifDataProviderAPI.NotifDataColumns.CONTENT_URI,valuesUpdate, selection2, selectionArgs2);
if(values.containsKey(NotifDataProviderAPI.NotifDataColumns.LATEST)){
values.put(NotifDataProviderAPI.NotifDataColumns.LATEST,"1");
values.put(NotifDataProviderAPI.NotifDataColumns.LATEST, NotifDataColumns.DATA_LATEST);
}
return Collect.getInstance().getContentResolver().insert(NotifDataProviderAPI.NotifDataColumns.CONTENT_URI, values);
return Collect.getInstance().getContentResolver().insert(NotifDataColumns.CONTENT_URI, values);
}else{
lebih.close();
if(values.containsKey(NotifDataProviderAPI.NotifDataColumns.LATEST)){
values.put(NotifDataProviderAPI.NotifDataColumns.LATEST,"0");
values.put(NotifDataProviderAPI.NotifDataColumns.LATEST, NotifDataColumns.DATA_NOT_LATEST);
}
return Collect.getInstance().getContentResolver().insert(NotifDataProviderAPI.NotifDataColumns.CONTENT_URI, values);
}
......@@ -53,7 +62,7 @@ public class NotifDataDao {
//edit Mahendri
public Cursor getNotifDataCursor() {
String selection = NotifDataColumns.LATEST + " =? ";
String[] selectionArgs = new String[]{String.valueOf(NotifDataColumns.IS_LATEST)};
String[] selectionArgs = new String[]{NotifDataColumns.DATA_LATEST};
return getNotifDataCursor(null, selection, selectionArgs, null);
}
......
......@@ -41,6 +41,7 @@ public final class NotifDataProviderAPI {
public static final String LATEST = "mLatest";
//public static final String IS_DOWNLOADED = "mDownload";
public static final int IS_LATEST = 1;
public static final String DATA_LATEST = "1";
public static final String DATA_NOT_LATEST = "0";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment