Commit 5b8e2c40 authored by mahendri.md's avatar mahendri.md

crash open notification

parent de8ae1ca
......@@ -54,12 +54,12 @@ public class DataDownloadActivity extends AppCompatActivity
recyclerView.setAdapter(adapter);
setSupportActionBar(toolbar);
if (null != getSupportActionBar()){
getSupportActionBar().setTitle("Unduh Pembaruan");
getSupportActionBar().setTitle("Unduh Pengembalian");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
notifDataDao = new NotifDataDao();
cursorData = notifDataDao.getAdditinalCursor();
cursorData = notifDataDao.getNotifDataCursor();
adapter.changeCursor(cursorData);
}
......
......@@ -2,6 +2,7 @@ package org.odk.collect.android.revalidasi.adapter;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
......@@ -12,6 +13,8 @@ import android.widget.TextView;
import org.odk.collect.android.R;
import org.odk.collect.android.revalidasi.custom.NotifDataProviderAPI.NotifDataColumns;
import timber.log.Timber;
/**
* @author Mahendri Dwicahyo
*/
......@@ -45,7 +48,7 @@ public class DownAdapter extends RecyclerView.Adapter<DownAdapter.DownViewHolder
@Override
public void onBindViewHolder(DownAdapter.DownViewHolder holder, int position) {
if (!dataValid) throw new IllegalStateException("Cursor tidak valid");
cursor.moveToPosition(cursor.getPosition());
cursor.moveToPosition(position);
holder.setData(cursor);
}
......
......@@ -25,7 +25,7 @@ public class NotifDataDao {
String selectionArgs[] = {values.get(NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID).toString(),
values.get(NotifDataProviderAPI.NotifDataColumns.LAST_UPDATE_DATE).toString()};
Cursor lebih = getAdditinalCursor(selection, selectionArgs);
Cursor lebih = getNotifDataCursor(selection, selectionArgs);
if(lebih.getCount()==0){
lebih.close();
String selection2 = NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID + " =? and " +
......@@ -51,14 +51,14 @@ public class NotifDataDao {
}
//edit Mahendri
public Cursor getAdditinalCursor() {
public Cursor getNotifDataCursor() {
String selection = NotifDataColumns.LATEST + " =? ";
String[] selectionArgs = new String[]{String.valueOf(NotifDataColumns.IS_LATEST)};
return getNotifDataCursor(null, selection, selectionArgs, null);
}
public Cursor getAdditinalCursor(CharSequence charSequence,String sortOrder, boolean viewMode) {
public Cursor getNotifDataCursor(CharSequence charSequence, String sortOrder, boolean viewMode) {
if(viewMode){
String selection = NotifDataProviderAPI.NotifDataColumns.NAME_INSTANCE + " LIKE ? and "
+ NotifDataProviderAPI.NotifDataColumns.LATEST+ " =? ";
......@@ -77,11 +77,11 @@ public class NotifDataDao {
}
}
public Cursor getAdditinalCursor(String sortOrder) {
public Cursor getNotifDataCursor(String sortOrder) {
return getNotifDataCursor(null, null, null, sortOrder);
}
public Cursor getAdditinalCursor(String selection, String[] selectionArgs) {
public Cursor getNotifDataCursor(String selection, String[] selectionArgs) {
return getNotifDataCursor(null, selection, selectionArgs, null);
}
......@@ -196,7 +196,7 @@ public class NotifDataDao {
return notifDataList;
}
public ContentValues getValuesFromAdditinalObject(NotifData notifData) {
public ContentValues getValuesFromNotifData(NotifData notifData) {
ContentValues values = new ContentValues();
values.put(NotifDataProviderAPI.NotifDataColumns.UUID, notifData.getUuid());
values.put(NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID, notifData.getInstanceuuid());
......
......@@ -252,7 +252,7 @@ public class NotifDataProvider extends ContentProvider {
sUriMatcher.addURI(NotifDataProviderAPI.AUTHORITY, "notifdata", ADDITIONAL);
sUriMatcher.addURI(NotifDataProviderAPI.AUTHORITY, "notifdata/#", ADDITIONAL_ID);
sAdditionalProjectionMap = new HashMap<String, String>();
sAdditionalProjectionMap = new HashMap<>();
sAdditionalProjectionMap.put(NotifDataProviderAPI.NotifDataColumns._ID, NotifDataProviderAPI.NotifDataColumns._ID);
sAdditionalProjectionMap.put(NotifDataProviderAPI.NotifDataColumns.UUID, NotifDataProviderAPI.NotifDataColumns.UUID);
sAdditionalProjectionMap.put(NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID, NotifDataProviderAPI.NotifDataColumns.INSTANCE_UUID);
......
......@@ -16,7 +16,6 @@ import org.odk.collect.android.revalidasi.activities.DataDownloadActivity;
import org.odk.collect.android.revalidasi.custom.NotifData;
import org.odk.collect.android.revalidasi.custom.NotifDataDao;
import java.util.Date;
import java.util.UUID;
import timber.log.Timber;
......@@ -132,7 +131,7 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
.latest("1")
.download("0")
.build();
ContentValues values = (new NotifDataDao()).getValuesFromAdditinalObject(notifData);
ContentValues values = (new NotifDataDao()).getValuesFromNotifData(notifData);
Uri insert = (new NotifDataDao()).saveInstance(values);
Timber.i("Insert on %s", insert.toString());
}
......
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