Commit 67b4f6f8 authored by rahadi's avatar rahadi

Added Pemutakhiran Module

parent 0ac2fd7f
......@@ -29,9 +29,6 @@ public class Vsen extends ContextWrapper {
public static void plant(Context context) {
singleton = new Vsen(context);
// TODO: 10/01/2018 DELETE THIS
getInstance().setUserSessionDummy();
requestQueue = Volley.newRequestQueue(context);
if (BuildConfig.DEBUG) {
......@@ -89,18 +86,6 @@ public class Vsen extends ContextWrapper {
return editor.commit();
}
// TODO: 10/01/2018 DELETE THIS DUMMY
public void setUserSessionDummy() {
Timber.d("Dummy Set");
setUserSession(new UserModel.Builder().setIdUser("rpcl")
.setNamaUser("Petugas Cacah Lapangan")
.setPrivilege(VsenAPI.PRIVILEGE_PCL)
.setIdSupervisor("rpml")
.setNamaSupervisor("Pengawas Monitoring Lapangan")
.setAuthToken("tokendummy")
.build());
}
public boolean clearUserSession() {
SharedPreferences pref = getInstance().getSharedPreferences(VsenAPI.Session.KEY_SESSION, MODE_PRIVATE);
return pref.edit().clear().commit();
......
......@@ -24,6 +24,11 @@ public final class VsenAPI {
}
public static class SerializedName {
public static final String ID_PCL = "id_pcl";
public static final String NAMA_PCL = "nama_pcl";
public static final String ID_PML = "id_pml";
public static final String NAMA_PML = "nama_pml";
public static final String PRIVILEGE = "privilege";
public static final String USERNAME = "username";
public static final String TOKEN = "token";
}
......
......@@ -54,7 +54,7 @@ public class DsrtDao {
.setStatus(cursor.getString(cursor.getColumnIndex(DsrtProviderAPI.Columns.STATUS)));
Cursor c = new DsrtLogDao().getDsrtLogCursor(null, DsrtLogProviderAPI.Columns.RUTA_UUID + "=?",
new String[]{cursor.getString(cursor.getColumnIndex(DsrtProviderAPI.Columns.BS_UUID))},
new String[]{cursor.getString(cursor.getColumnIndex(DsrtProviderAPI.Columns.RUTA_UUID))},
DsrtLogProviderAPI.Columns.TIMEMILLIS);
List<DsrtLogModel> logModels = new DsrtLogDao().getDsrtLogListFromCursor(c);
......
......@@ -104,8 +104,12 @@ public class CatatanFragment extends Fragment {
if (null != c1) {
if (c1.moveToFirst()) {
tambahCatatan.setText(c1.getString(c1.getColumnIndex(CatatanProviderAPI.Columns.CATATAN)));
} else {
tambahCatatan.getText().clear();
}
c1.close();
} else {
tambahCatatan.getText().clear();
}
tambahCatatan.addTextChangedListener(new TextWatcher() {
private final long DELAY = 500;
......@@ -158,6 +162,8 @@ public class CatatanFragment extends Fragment {
}
public void notifyRutaChanged() {
catatanAdapter.notifyDataSetChanged();
if (Vsen.getInstance().getUserSession().getPrivilege() == VsenAPI.PRIVILEGE_PCL) {
if (bsStatus.equalsIgnoreCase(BSProviderAPI.STATUS_UPDATING)) {
setTambahCatatanEnabled(true);
......
......@@ -11,15 +11,19 @@ import com.rahadi.vsen.contexts.VsenAPI;
public class UserModel {
@Expose()
@SerializedName(VsenAPI.SerializedName.USERNAME)
@SerializedName(VsenAPI.SerializedName.ID_PCL)
private String idUser;
@SerializedName(VsenAPI.SerializedName.NAMA_PCL)
private String namaUser;
@SerializedName(VsenAPI.SerializedName.PRIVILEGE)
private int privilege;
@SerializedName(VsenAPI.SerializedName.ID_PML)
private String idSupervisor;
@SerializedName(VsenAPI.SerializedName.NAMA_PML)
private String namaSupervisor;
@Expose()
......
......@@ -321,10 +321,10 @@ public class BSSynchronizationTask extends BaseLoadableTask
cl.put(DsrtLogProviderAPI.Columns.NAMA_PENGIRIM, dl.getNamaPengirim());
cl.put(DsrtLogProviderAPI.Columns.RUTA_UUID, dl.getRutaUuid());
int ul = new DsrtLogDao().updateDsrtLog(cd, DsrtLogProviderAPI.Columns.RUTA_UUID + "=?",
int ul = new DsrtLogDao().updateDsrtLog(cl, DsrtLogProviderAPI.Columns.RUTA_UUID + "=?",
new String[]{dl.getRutaUuid()});
if (ul == 0) {
new DsrtLogDao().insertDsrtLog(cd);
new DsrtLogDao().insertDsrtLog(cl);
}
}
}
......
......@@ -44,8 +44,9 @@ public class UserRegisterTask implements Response.Listener<JSONObject>, Response
Gson gson = builder.setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().serializeNulls().create();
try {
UserModel userModel = Vsen.getInstance().getUserSession();
JSONObject json = new JSONObject(gson.toJson(userModel));
JSONObject json = new JSONObject();
json.put(VsenAPI.SerializedName.ID_PCL, username);
json.put(VsenAPI.SerializedName.TOKEN, token);
RequestObjectService rs = new RequestObjectService(Request.Method.POST, URL, json, this, this);
......
......@@ -13,6 +13,8 @@ import com.rahadi.vsen.R;
import com.rahadi.vsen.listeners.OnDsrtActionButtonClickListener;
import com.rahadi.vsen.providers.DsrtLogProviderAPI;
import timber.log.Timber;
/**
* Created by Rahadi on 21/01/2018.
*/
......@@ -60,6 +62,8 @@ public class DsrtActionButtonView extends LinearLayout {
}
private void setupButtons() {
Timber.d("Setting up Buttons with %s Status", status);
switch (status) {
case DsrtLogProviderAPI.STATUS_UNTOUCHED:
if (isPml) {
......@@ -71,6 +75,7 @@ public class DsrtActionButtonView extends LinearLayout {
setupButtonView(singleButton, R.drawable.ic_open, R.string.mulai_mencacah);
}
break;
case DsrtLogProviderAPI.STATUS_SAVED:
if (isPml) {
......@@ -82,6 +87,7 @@ public class DsrtActionButtonView extends LinearLayout {
setupButtonView(singleButton, R.drawable.ic_edit_primary, R.string.edit_isian);
}
break;
case DsrtLogProviderAPI.STATUS_READY:
if (isPml) {
......@@ -97,6 +103,7 @@ public class DsrtActionButtonView extends LinearLayout {
setupButtonView(doubleLeftButton, R.drawable.ic_edit_primary, R.string.edit_isian);
setupButtonView(doubleRightButton, R.drawable.ic_file_upload, R.string.kirim_isian);
}
break;
case DsrtLogProviderAPI.STATUS_SENT:
if (isPml) {
......@@ -110,12 +117,14 @@ public class DsrtActionButtonView extends LinearLayout {
setupButtonView(singleButton, R.drawable.ic_catatan, R.string.lihat_isian);
}
break;
case DsrtLogProviderAPI.STATUS_CHECK:
doubleButtonGroup.setVisibility(GONE);
singleButton.setVisibility(VISIBLE);
setupButtonView(singleButton, R.drawable.ic_catatan, R.string.lihat_isian);
break;
case DsrtLogProviderAPI.STATUS_RECALL:
if (isPml) {
......@@ -129,12 +138,14 @@ public class DsrtActionButtonView extends LinearLayout {
setupButtonView(singleButton, R.drawable.ic_file_download, R.string.unduh_isian);
}
break;
case DsrtLogProviderAPI.STATUS_FINAL:
doubleButtonGroup.setVisibility(GONE);
singleButton.setVisibility(VISIBLE);
setupButtonView(singleButton, R.drawable.ic_catatan, R.string.lihat_isian);
break;
}
}
......
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