Commit 0ac2fd7f authored by rahadi's avatar rahadi

Added Pemutakhiran Module

parent bebbdb15
......@@ -367,7 +367,7 @@ the specific language governing permissions and limitations under the License.
android:parentActivityName=".capi.activity.CapiMainActivity" />
<activity
android:name=".pemutakhiran.BlokSensusActivity"
android:name=".pemutakhiran.BSActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.RutaActivity"
......
......@@ -29,14 +29,12 @@ import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Window;
import com.rahadi.vsen.samples.BlokSensusSampleActivity;
import org.odk.collect.android.BuildConfig;
import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.capi.activity.CapiLoginActivity;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.pemutakhiran.BlokSensusActivity;
import org.odk.collect.android.pemutakhiran.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
......@@ -83,7 +81,7 @@ public class SplashScreenActivity extends AppCompatActivity {
if (preferences.getBoolean(PreferenceKeys.KEY_LOGIN_STATUS, false)) {
// startActivity(new Intent(this, CapiMainActivity.class));
startActivity(new Intent(this, BlokSensusActivity.class));
startActivity(new Intent(this, BSActivity.class));
} else {
startActivity(new Intent(this, CapiLoginActivity.class));
}
......
......@@ -7,21 +7,31 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.rahadi.vsen.samples.BlokSensusSampleActivity;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.listeners.OnSynchronizationErrorListener;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.rahadi.vsen.tasks.UserRegisterTask;
import org.json.JSONArray;
import org.json.JSONObject;
import org.odk.collect.android.R;
import org.odk.collect.android.pemutakhiran.BlokSensusActivity;
import org.odk.collect.android.pemutakhiran.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.preferences.PreferencesActivity;
import org.odk.collect.android.revalidasi.notifikasi.ConfigKey;
import org.odk.collect.android.revalidasi.notifikasi.GetUuidTask;
import timber.log.Timber;
/**
* @author Mahendri Dwicahyo
*/
......@@ -63,17 +73,17 @@ public class CapiLoginActivity extends AppCompatActivity
switch (v.getId()) {
case R.id.btn_login:
// if (TextUtils.isEmpty(username.getText().toString())) {
// Toast.makeText(this, "Username can't be empty", Toast.LENGTH_SHORT).show();
// return;
// }
// if (TextUtils.isEmpty(password.getText().toString())) {
// Toast.makeText(this, "Password can't be empty", Toast.LENGTH_SHORT).show();
// return;
// }
//
// login(username.getText().toString(), password.getText().toString());
startActivity(new Intent(this, BlokSensusActivity.class));
if (TextUtils.isEmpty(username.getText().toString())) {
Toast.makeText(this, "Username can't be empty", Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(password.getText().toString())) {
Toast.makeText(this, "Password can't be empty", Toast.LENGTH_SHORT).show();
return;
}
login(username.getText().toString(), password.getText().toString());
// startActivity(new Intent(this, BSActivity.class));
break;
case R.id.server_config_text:
......@@ -96,15 +106,69 @@ public class CapiLoginActivity extends AppCompatActivity
@Override
public void loginDone(String result) {
final String username = (String) GeneralSharedPreferences.getInstance().get(PreferenceKeys.KEY_USERNAME);
final String uuid = (String) GeneralSharedPreferences.getInstance().get(PreferenceKeys.KEY_UNIQUES);
new UserRegisterTask(username, uuid).execute(new OnSynchronizationCompletedListener<JSONObject>() {
@Override
public void onSynchronizationCompleted(JSONObject result) {
// TODO: 22/01/2018 RAHADI: FILL IN THE BLANK
Timber.d("UserRegister: " + result.toString());
Vsen.getInstance().setUserSession(new UserModel.Builder()
.setIdUser(username)
.setNamaUser("")
.setIdSupervisor("")
.setNamaSupervisor("")
.setPrivilege(0)
.setAuthToken(uuid)
.build());
dialog.setMessage("Sinkronisasi Data..");
new BSSynchronizationTask(null, null).execute(username, uuid,
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
Timber.d("BSSync: " + result.toString());
onLoginSucceed();
}
@Override
public void onSynchronizationFailed(Exception e) {
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
}
}, new OnSynchronizationErrorListener() {
@Override
public void onSynchronizationError(Exception exception) {
Timber.e(exception);
onLoginFailed("Fail to get id on server : " + exception.getMessage());
}
});
}
private void onLoginSucceed() {
dialog.dismiss();
loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
if (ConfigKey.LOGIN_SUCCESS.equals(result)) {
GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true);
Intent toMain = new Intent(this, CapiMainActivity.class);
Intent toMain = new Intent(this, BSActivity.class);
startActivity(toMain);
finish();
} else {
}
private void onLoginFailed(String result) {
dialog.dismiss();
loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder
.setTitle("Login Gagal")
......@@ -113,10 +177,4 @@ public class CapiLoginActivity extends AppCompatActivity
.create()
.show();
}
}
@Override
public void loginProgressUpdate(String status) {
dialog.setMessage(status);
}
}
......@@ -2,13 +2,13 @@ package org.odk.collect.android.pemutakhiran;
import android.os.Bundle;
import com.rahadi.vsen.activities.BlokSensusImpActivity;
import com.rahadi.vsen.activities.BSImpActivity;
/**
* Created by Rahadi on 27/01/2018.
*/
public class BlokSensusActivity extends BlokSensusImpActivity {
public class BSActivity extends BSImpActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
......
package org.odk.collect.android.revalidasi.notifikasi;
import android.net.Uri;
import android.os.AsyncTask;
import com.google.firebase.messaging.FirebaseMessaging;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.listeners.OnSynchronizationErrorListener;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.rahadi.vsen.tasks.UserRegisterTask;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.revalidasi.briefcase.util.WebUtils;
import org.odk.collect.android.utilities.WebUtils;
import org.opendatakit.httpclientandroidlib.HttpEntity;
import org.opendatakit.httpclientandroidlib.HttpResponse;
import org.opendatakit.httpclientandroidlib.HttpStatus;
import org.opendatakit.httpclientandroidlib.client.HttpClient;
import org.opendatakit.httpclientandroidlib.client.methods.HttpGet;
import org.opendatakit.httpclientandroidlib.client.protocol.HttpClientContext;
import org.opendatakit.httpclientandroidlib.protocol.HttpContext;
import org.opendatakit.httpclientandroidlib.util.EntityUtils;
import java.net.MalformedURLException;
......@@ -63,7 +55,7 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
listener.loginDone(result);
}
private String reload(final String username, String password) {
private String reload(String username, String password) {
URI loginUri;
try {
String serverUrl = (String) prefs.get(PreferenceKeys.KEY_SERVER_URL);
......@@ -79,16 +71,18 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
}
// get shared HttpContext so that authentication and cookies are retained.
HttpClientContext localContext = WebUtils.createHttpContext();
HttpClient httpclient = WebUtils.createHttpClient();
HttpContext localContext = Collect.getInstance().getHttpContext();
HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT);
// set up request...
HttpGet req = WebUtils.createOpenRosaHttpGet(loginUri);
WebUtils.clearAllCredentials(localContext);
String host = loginUri == null ? null : loginUri.getHost();
System.out.println(host);
WebUtils.addCredentials(localContext, username, password.toCharArray(), host);
//add credentials
WebUtils.clearAllCredentials();
WebUtils.addCredentials(username, password, host);
Timber.d("username: %s, password: %s", username, password);
HttpResponse response;
......@@ -135,39 +129,8 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
if (StringUtils.isNotEmpty(uuid))
FirebaseMessaging.getInstance().subscribeToTopic(getPureUri(uuid));
clearCachedCrendentials();
publishProgress("Meregistrasikan ke server pemutakhiran..");
final String finalUuid = uuid;
final String[] status = {"Fail to get id on server"};
new UserRegisterTask(username, uuid).execute(new OnSynchronizationCompletedListener<JSONObject>() {
@Override
public void onSynchronizationCompleted(JSONObject result) {
// TODO: 22/01/2018 RAHADI: FILL IN THE BLANK
Vsen.getInstance().setUserSession(new UserModel.Builder()
.setIdUser(username)
.setAuthToken(finalUuid)
.build());
publishProgress("Sinkronisasi Data..");
new BSSynchronizationTask(null, null).execute(username, finalUuid, new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
status[0] = "Sukses login server";
}
});
}
}, new OnSynchronizationErrorListener() {
@Override
public void onSynchronizationError(Exception exception) {
status[0] = "Fail to get id on server";
}
});
Timber.d("AggregatePreference UUID2: %s", uuid);
return status[0];
return "Sukses login server";
} catch (Exception e) {
Timber.d(e);
......@@ -175,23 +138,7 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
}
}
@Override
protected void onProgressUpdate(String... values) {
super.onProgressUpdate(values);
listener.loginProgressUpdate(values[0]);
}
private void clearCachedCrendentials() {
String server = (String) GeneralSharedPreferences
.getInstance().get(PreferenceKeys.KEY_SERVER_URL);
Uri u = Uri.parse(server);
org.odk.collect.android.utilities.WebUtils.clearHostCredentials(u.getHost());
Collect.getInstance().getCookieStore().clear();
}
public interface LoginListener {
void loginDone(String result);
void loginProgressUpdate(String status);
}
}
......@@ -11,14 +11,13 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.rahadi.vsen.R;
import com.rahadi.vsen.adapters.BlokSensusAdapter;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.BlokSensusDao;
import com.rahadi.vsen.listeners.OnLihatRutaClickedListener;
import com.rahadi.vsen.listeners.OnBSAdapterButtonClickedListener;
import com.rahadi.vsen.listeners.OnRecyclerItemClickListener;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.BlokSensusModel;
......@@ -39,7 +38,7 @@ import timber.log.Timber;
* Created by Rahadi on 27/01/2018.
*/
public abstract class BlokSensusImpActivity extends AppCompatActivity implements OnLihatRutaClickedListener {
public abstract class BSImpActivity extends AppCompatActivity implements OnBSAdapterButtonClickedListener {
public static final int REQUEST_SEND = 1;
public static final int REQUEST_SAMPLING = 2;
......@@ -77,9 +76,9 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
public void onItemClick(View v, int position) {
BlokSensusModel bsm = blokSensusModels.get(position);
if (bsm.getStatus().equalsIgnoreCase(BSProviderAPI.STATUS_SAMPLE_UPLOADED)) {
Class targetClass = BlokSensusImpActivity.this.getDsrtActivityClass();
Class targetClass = BSImpActivity.this.getDsrtActivityClass();
Intent i = new Intent(BlokSensusImpActivity.this, targetClass);
Intent i = new Intent(BSImpActivity.this, targetClass);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, bsm.getUuid());
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus());
......@@ -128,6 +127,11 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
snackbar.show();
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
......@@ -179,7 +183,7 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
snackbar.setAction("LIHAT SAMPEL", new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(BlokSensusImpActivity.this, DsrtImpActivity.class);
Intent i = new Intent(BSImpActivity.this, DsrtImpActivity.class);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, data.getStringExtra(KEY_RESULT_BS_UUID));
......@@ -213,7 +217,7 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
public void onLihatRutaClicked(String bsUuid, String bsNks, String bsStatus) {
Class targetClass = getRutaActivityClass();
Intent i = new Intent(BlokSensusImpActivity.this, targetClass);
Intent i = new Intent(BSImpActivity.this, targetClass);
i.putExtra(RutaSampleActivity.BS_UUID, bsUuid);
i.putExtra(RutaSampleActivity.BS_NKS, bsNks);
i.putExtra(RutaSampleActivity.BS_STATUS, bsStatus);
......@@ -229,6 +233,14 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
}
}
public void onLihatSampelClicked(String bsUuid, String bsNks) {
Class targetClass = getDsrtActivityClass();
Intent i = new Intent(BSImpActivity.this, targetClass);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, bsUuid);
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsNks);
startActivity(i);
}
public abstract Class getDsrtActivityClass();
public abstract Class getRutaActivityClass();
......
......@@ -139,6 +139,11 @@ public abstract class RutaImpActivity extends AppCompatActivity implements OnEdi
kirimFragment.notifyRutaChanged();
}
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
......
......@@ -17,7 +17,7 @@ import com.rahadi.vsen.R;
import com.rahadi.vsen.activities.DsrtImpActivity;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.listeners.OnLihatRutaClickedListener;
import com.rahadi.vsen.listeners.OnBSAdapterButtonClickedListener;
import com.rahadi.vsen.listeners.OnRecyclerItemClickListener;
import com.rahadi.vsen.models.BlokSensusModel;
import com.rahadi.vsen.providers.BSProviderAPI;
......@@ -33,12 +33,12 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl
private Context context;
private List<BlokSensusModel> blokSensuses;
private OnRecyclerItemClickListener onRecyclerItemClickListener;
private OnLihatRutaClickedListener onLihatRutaClickedListener;
private OnBSAdapterButtonClickedListener onBSAdapterButtonClickedListener;
public BlokSensusAdapter(Context context, List<BlokSensusModel> blokSensuses, OnLihatRutaClickedListener onLihatRutaClickedListener) {
public BlokSensusAdapter(Context context, List<BlokSensusModel> blokSensuses, OnBSAdapterButtonClickedListener onBSAdapterButtonClickedListener) {
this.context = context;
this.blokSensuses = blokSensuses;
this.onLihatRutaClickedListener = onLihatRutaClickedListener;
this.onBSAdapterButtonClickedListener = onBSAdapterButtonClickedListener;
}
public void setBlokSensuses(List<BlokSensusModel> blokSensuses) {
......@@ -214,7 +214,7 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl
lihatRutaButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onLihatRutaClickedListener.onLihatRutaClicked(bsm.getUuid(), bsm.getKodeProvinsi() +
onBSAdapterButtonClickedListener.onLihatRutaClicked(bsm.getUuid(), bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus(), bsm.getStatus());
}
});
......@@ -222,11 +222,8 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl
lihatSampelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, DsrtImpActivity.class);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, bsm.getUuid());
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() +
onBSAdapterButtonClickedListener.onLihatSampelClicked(bsm.getUuid(), bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus());
context.startActivity(i);
}
});
......
......@@ -6,7 +6,7 @@ package com.rahadi.vsen.contexts;
public final class VsenAPI {
public static final String DEFAULT_URL = "http://192.168.100.3:8080/vsen.p/api/";
public static final String DEFAULT_URL = "http://10.100.12.112:8080/pemutakhiran/api/";
public static final int PRIVILEGE_PCL = 0;
public static final int PRIVILEGE_PML = 1;
public static final int LOGIN_STATE_LOGGED_IN = 2;
......@@ -29,6 +29,6 @@ public final class VsenAPI {
}
public static class Preferences {
public static final String KEY_SERVER_URL = "server_url";
public static final String KEY_SERVER_URL = "updating_server_url";
}
}
......@@ -14,7 +14,7 @@ import android.widget.CompoundButton;
import android.widget.FrameLayout;
import com.rahadi.vsen.R;
import com.rahadi.vsen.samples.BlokSensusSampleActivity;
import com.rahadi.vsen.samples.BSSampleActivity;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.RutaDao;
......@@ -136,12 +136,17 @@ public class KirimFragment extends Fragment {
@Override
public void onSynchronizationCompleted(JSONArray result) {
Intent i = new Intent();
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
i.putExtra(BSSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BSSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
getActivity().setResult(BlokSensusSampleActivity.RESULT_SENT, i);
getActivity().setResult(BSSampleActivity.RESULT_SENT, i);
getActivity().finish();
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
});
......@@ -183,13 +188,13 @@ public class KirimFragment extends Fragment {
@Override
public void onAmbilSampelCompleted(List<String> dsrtUuids) {
Intent i = new Intent();
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
i.putExtra(BSSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BSSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
if (dsrtUuids != null) {
getActivity().setResult(BlokSensusSampleActivity.RESULT_SAMPLED, i);
getActivity().setResult(BSSampleActivity.RESULT_SAMPLED, i);
} else {
getActivity().setResult(BlokSensusSampleActivity.RESULT_SAMPLING_FAILED, i);
getActivity().setResult(BSSampleActivity.RESULT_SAMPLING_FAILED, i);
}
getActivity().finish();
}
......@@ -228,12 +233,17 @@ public class KirimFragment extends Fragment {
@Override
public void onSynchronizationCompleted(JSONArray result) {
Intent i = new Intent();
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
i.putExtra(BSSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BSSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
getActivity().setResult(BlokSensusSampleActivity.RESULT_SENT, i);
getActivity().setResult(BSSampleActivity.RESULT_SENT, i);
getActivity().finish();
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
});
......@@ -278,12 +288,17 @@ public class KirimFragment extends Fragment {
@Override
public void onSynchronizationCompleted(JSONArray result) {
Intent i = new Intent();
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BlokSensusSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
i.putExtra(BSSampleActivity.KEY_RESULT_BS, bsFullName);
i.putExtra(BSSampleActivity.KEY_RESULT_BS_UUID, bsUuid);
getActivity().setResult(BlokSensusSampleActivity.RESULT_SENT, i);
getActivity().setResult(BSSampleActivity.RESULT_SENT, i);
getActivity().finish();
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
});
......
......@@ -4,6 +4,8 @@ package com.rahadi.vsen.listeners;
* Created by Rahadi on 10/01/2018.
*/
public interface OnLihatRutaClickedListener {
public interface OnBSAdapterButtonClickedListener {
void onLihatRutaClicked(String bsUuid, String bsNks, String bsStatus);
void onLihatSampelClicked(String bsUuid, String bsNks);
}
package com.rahadi.vsen.listeners;
import org.json.JSONArray;
/**
* Created by Rahadi on 01/01/2018.
*/
public interface OnSynchronizationCompletedListener<T> {
void onSynchronizationCompleted(T result);
void onSynchronizationFailed(Exception e);
}
......@@ -19,7 +19,7 @@ import com.rahadi.vsen.adapters.BlokSensusAdapter;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.BlokSensusDao;
import com.rahadi.vsen.listeners.OnLihatRutaClickedListener;
import com.rahadi.vsen.listeners.OnBSAdapterButtonClickedListener;
import com.rahadi.vsen.listeners.OnRecyclerItemClickListener;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.BlokSensusModel;
......@@ -35,7 +35,7 @@ import java.util.List;
import timber.log.Timber;
public abstract class BlokSensusSampleActivity extends AppCompatActivity implements OnLihatRutaClickedListener {
public abstract class BSSampleActivity extends AppCompatActivity implements OnBSAdapterButtonClickedListener {
public static final int REQUEST_SEND = 1;
public static final int REQUEST_SAMPLING = 2;
......@@ -82,7 +82,7 @@ public abstract class BlokSensusSampleActivity extends AppCompatActivity impleme
public void onItemClick(View v, int position) {
BlokSensusModel bsm = blokSensusModels.get(position);
if (bsm.getStatus().equalsIgnoreCase(BSProviderAPI.STATUS_SAMPLE_UPLOADED)) {
Intent i = new Intent(BlokSensusSampleActivity.this, DsrtImpActivity.class);
Intent i = new Intent(BSSampleActivity.this, DsrtImpActivity.class);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, bsm.getUuid());
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus());
......@@ -131,6 +131,11 @@ public abstract class BlokSensusSampleActivity extends AppCompatActivity impleme
snackbar.show();
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
......@@ -179,7 +184,7 @@ public abstract class BlokSensusSampleActivity extends AppCompatActivity impleme
snackbar.setAction("LIHAT SAMPEL", new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(BlokSensusSampleActivity.this, DsrtImpActivity.class);
Intent i = new Intent(BSSampleActivity.this, DsrtImpActivity.class);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, data.getStringExtra(KEY_RESULT_BS_UUID));
......@@ -213,7 +218,7 @@ public abstract class BlokSensusSampleActivity extends AppCompatActivity impleme
@Override
public void onLihatRutaClicked(String bsUuid, String bsNks, String bsStatus) {
Intent i = new Intent(BlokSensusSampleActivity.this, RutaSampleActivity.class);
Intent i = new Intent(BSSampleActivity.this, RutaSampleActivity.class);
i.putExtra(RutaSampleActivity.BS_UUID, bsUuid);
i.putExtra(RutaSampleActivity.BS_NKS, bsNks);
i.putExtra(RutaSampleActivity.BS_STATUS, bsStatus);
......
......@@ -152,6 +152,11 @@ public class RutaSampleActivity extends AppCompatActivity implements OnEditRutaS
kirimFragment.notifyRutaChanged();
}
}
@Override
public void onSynchronizationFailed(Exception e) {
}
});
}
......
......@@ -17,7 +17,7 @@ public class SplashSampleActivity extends AppCompatActivity {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent mainIntent = new Intent(SplashSampleActivity.this, BlokSensusSampleActivity.class);
Intent mainIntent = new Intent(SplashSampleActivity.this, BSSampleActivity.class);
startActivity(mainIntent);