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. ...@@ -367,7 +367,7 @@ the specific language governing permissions and limitations under the License.
android:parentActivityName=".capi.activity.CapiMainActivity" /> android:parentActivityName=".capi.activity.CapiMainActivity" />
<activity <activity
android:name=".pemutakhiran.BlokSensusActivity" android:name=".pemutakhiran.BSActivity"
android:theme="@style/VsenAppTheme" /> android:theme="@style/VsenAppTheme" />
<activity <activity
android:name=".pemutakhiran.RutaActivity" android:name=".pemutakhiran.RutaActivity"
......
...@@ -29,14 +29,12 @@ import android.support.v7.app.AppCompatActivity; ...@@ -29,14 +29,12 @@ import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.Window; import android.view.Window;
import com.rahadi.vsen.samples.BlokSensusSampleActivity;
import org.odk.collect.android.BuildConfig; import org.odk.collect.android.BuildConfig;
import org.odk.collect.android.R; import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect; import org.odk.collect.android.application.Collect;
import org.odk.collect.android.capi.activity.CapiLoginActivity; import org.odk.collect.android.capi.activity.CapiLoginActivity;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences; 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.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys; import org.odk.collect.android.preferences.PreferenceKeys;
...@@ -83,7 +81,7 @@ public class SplashScreenActivity extends AppCompatActivity { ...@@ -83,7 +81,7 @@ public class SplashScreenActivity extends AppCompatActivity {
if (preferences.getBoolean(PreferenceKeys.KEY_LOGIN_STATUS, false)) { if (preferences.getBoolean(PreferenceKeys.KEY_LOGIN_STATUS, false)) {
// startActivity(new Intent(this, CapiMainActivity.class)); // startActivity(new Intent(this, CapiMainActivity.class));
startActivity(new Intent(this, BlokSensusActivity.class)); startActivity(new Intent(this, BSActivity.class));
} else { } else {
startActivity(new Intent(this, CapiLoginActivity.class)); startActivity(new Intent(this, CapiLoginActivity.class));
} }
......
...@@ -7,21 +7,31 @@ import android.os.AsyncTask; ...@@ -7,21 +7,31 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; 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.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.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys; import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.preferences.PreferencesActivity; import org.odk.collect.android.preferences.PreferencesActivity;
import org.odk.collect.android.revalidasi.notifikasi.ConfigKey;
import org.odk.collect.android.revalidasi.notifikasi.GetUuidTask; import org.odk.collect.android.revalidasi.notifikasi.GetUuidTask;
import timber.log.Timber;
/** /**
* @author Mahendri Dwicahyo * @author Mahendri Dwicahyo
*/ */
...@@ -63,17 +73,17 @@ public class CapiLoginActivity extends AppCompatActivity ...@@ -63,17 +73,17 @@ public class CapiLoginActivity extends AppCompatActivity
switch (v.getId()) { switch (v.getId()) {
case R.id.btn_login: case R.id.btn_login:
// if (TextUtils.isEmpty(username.getText().toString())) { if (TextUtils.isEmpty(username.getText().toString())) {
// Toast.makeText(this, "Username can't be empty", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Username can't be empty", Toast.LENGTH_SHORT).show();
// return; return;
// } }
// if (TextUtils.isEmpty(password.getText().toString())) { if (TextUtils.isEmpty(password.getText().toString())) {
// Toast.makeText(this, "Password can't be empty", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Password can't be empty", Toast.LENGTH_SHORT).show();
// return; return;
// } }
//
// login(username.getText().toString(), password.getText().toString()); login(username.getText().toString(), password.getText().toString());
startActivity(new Intent(this, BlokSensusActivity.class)); // startActivity(new Intent(this, BSActivity.class));
break; break;
case R.id.server_config_text: case R.id.server_config_text:
...@@ -96,27 +106,75 @@ public class CapiLoginActivity extends AppCompatActivity ...@@ -96,27 +106,75 @@ public class CapiLoginActivity extends AppCompatActivity
@Override @Override
public void loginDone(String result) { 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(); dialog.dismiss();
loginBtn.setText("LOGIN"); loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
if (ConfigKey.LOGIN_SUCCESS.equals(result)) {
GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true); GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true);
Intent toMain = new Intent(this, CapiMainActivity.class); Intent toMain = new Intent(this, BSActivity.class);
startActivity(toMain); startActivity(toMain);
finish(); finish();
} else {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder
.setTitle("Login Gagal")
.setMessage(result)
.setPositiveButton("OK", null)
.create()
.show();
}
} }
@Override private void onLoginFailed(String result) {
public void loginProgressUpdate(String status) { dialog.dismiss();
dialog.setMessage(status); loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder
.setTitle("Login Gagal")
.setMessage(result)
.setPositiveButton("OK", null)
.create()
.show();
} }
} }
\ No newline at end of file
...@@ -2,13 +2,13 @@ package org.odk.collect.android.pemutakhiran; ...@@ -2,13 +2,13 @@ package org.odk.collect.android.pemutakhiran;
import android.os.Bundle; import android.os.Bundle;
import com.rahadi.vsen.activities.BlokSensusImpActivity; import com.rahadi.vsen.activities.BSImpActivity;
/** /**
* Created by Rahadi on 27/01/2018. * Created by Rahadi on 27/01/2018.
*/ */
public class BlokSensusActivity extends BlokSensusImpActivity { public class BSActivity extends BSImpActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
......
package org.odk.collect.android.revalidasi.notifikasi; package org.odk.collect.android.revalidasi.notifikasi;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import com.google.firebase.messaging.FirebaseMessaging; 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.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.odk.collect.android.application.Collect; import org.odk.collect.android.application.Collect;
import org.odk.collect.android.preferences.GeneralSharedPreferences; import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys; 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.HttpEntity;
import org.opendatakit.httpclientandroidlib.HttpResponse; import org.opendatakit.httpclientandroidlib.HttpResponse;
import org.opendatakit.httpclientandroidlib.HttpStatus; import org.opendatakit.httpclientandroidlib.HttpStatus;
import org.opendatakit.httpclientandroidlib.client.HttpClient; import org.opendatakit.httpclientandroidlib.client.HttpClient;
import org.opendatakit.httpclientandroidlib.client.methods.HttpGet; 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 org.opendatakit.httpclientandroidlib.util.EntityUtils;
import java.net.MalformedURLException; import java.net.MalformedURLException;
...@@ -63,7 +55,7 @@ public class GetUuidTask extends AsyncTask<String, String, String> { ...@@ -63,7 +55,7 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
listener.loginDone(result); listener.loginDone(result);
} }
private String reload(final String username, String password) { private String reload(String username, String password) {
URI loginUri; URI loginUri;
try { try {
String serverUrl = (String) prefs.get(PreferenceKeys.KEY_SERVER_URL); String serverUrl = (String) prefs.get(PreferenceKeys.KEY_SERVER_URL);
...@@ -79,16 +71,18 @@ public class GetUuidTask extends AsyncTask<String, String, String> { ...@@ -79,16 +71,18 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
} }
// get shared HttpContext so that authentication and cookies are retained. // get shared HttpContext so that authentication and cookies are retained.
HttpClientContext localContext = WebUtils.createHttpContext(); HttpContext localContext = Collect.getInstance().getHttpContext();
HttpClient httpclient = WebUtils.createHttpClient(); HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT);
// set up request... // set up request...
HttpGet req = WebUtils.createOpenRosaHttpGet(loginUri); HttpGet req = WebUtils.createOpenRosaHttpGet(loginUri);
WebUtils.clearAllCredentials(localContext);
String host = loginUri == null ? null : loginUri.getHost(); String host = loginUri == null ? null : loginUri.getHost();
System.out.println(host); 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); Timber.d("username: %s, password: %s", username, password);
HttpResponse response; HttpResponse response;
...@@ -135,39 +129,8 @@ public class GetUuidTask extends AsyncTask<String, String, String> { ...@@ -135,39 +129,8 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
if (StringUtils.isNotEmpty(uuid)) if (StringUtils.isNotEmpty(uuid))
FirebaseMessaging.getInstance().subscribeToTopic(getPureUri(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); Timber.d("AggregatePreference UUID2: %s", uuid);
return status[0]; return "Sukses login server";
} catch (Exception e) { } catch (Exception e) {
Timber.d(e); Timber.d(e);
...@@ -175,23 +138,7 @@ public class GetUuidTask extends AsyncTask<String, String, String> { ...@@ -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 { public interface LoginListener {
void loginDone(String result); void loginDone(String result);
void loginProgressUpdate(String status);
} }
} }
...@@ -11,14 +11,13 @@ import android.view.Menu; ...@@ -11,14 +11,13 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Toast;
import com.rahadi.vsen.R; import com.rahadi.vsen.R;
import com.rahadi.vsen.adapters.BlokSensusAdapter; import com.rahadi.vsen.adapters.BlokSensusAdapter;
import com.rahadi.vsen.contexts.Vsen; import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI; import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.BlokSensusDao; 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.OnRecyclerItemClickListener;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener; import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.BlokSensusModel; import com.rahadi.vsen.models.BlokSensusModel;
...@@ -39,7 +38,7 @@ import timber.log.Timber; ...@@ -39,7 +38,7 @@ import timber.log.Timber;
* Created by Rahadi on 27/01/2018. * 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_SEND = 1;
public static final int REQUEST_SAMPLING = 2; public static final int REQUEST_SAMPLING = 2;
...@@ -77,9 +76,9 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements ...@@ -77,9 +76,9 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
public void onItemClick(View v, int position) { public void onItemClick(View v, int position) {
BlokSensusModel bsm = blokSensusModels.get(position); BlokSensusModel bsm = blokSensusModels.get(position);
if (bsm.getStatus().equalsIgnoreCase(BSProviderAPI.STATUS_SAMPLE_UPLOADED)) { 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_UUID, bsm.getUuid());
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() + i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus()); bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus());
...@@ -128,6 +127,11 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements ...@@ -128,6 +127,11 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
snackbar.show(); snackbar.show();
} }
@Override
public void onSynchronizationFailed(Exception e) {
}
}); });
} }
...@@ -179,7 +183,7 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements ...@@ -179,7 +183,7 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
snackbar.setAction("LIHAT SAMPEL", new View.OnClickListener() { snackbar.setAction("LIHAT SAMPEL", new View.OnClickListener() {
@Override @Override
public void onClick(View view) { 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)); i.putExtra(DsrtImpActivity.KEY_BS_UUID, data.getStringExtra(KEY_RESULT_BS_UUID));
...@@ -213,7 +217,7 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements ...@@ -213,7 +217,7 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements
public void onLihatRutaClicked(String bsUuid, String bsNks, String bsStatus) { public void onLihatRutaClicked(String bsUuid, String bsNks, String bsStatus) {
Class targetClass = getRutaActivityClass(); 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_UUID, bsUuid);
i.putExtra(RutaSampleActivity.BS_NKS, bsNks); i.putExtra(RutaSampleActivity.BS_NKS, bsNks);
i.putExtra(RutaSampleActivity.BS_STATUS, bsStatus); i.putExtra(RutaSampleActivity.BS_STATUS, bsStatus);
...@@ -229,6 +233,14 @@ public abstract class BlokSensusImpActivity extends AppCompatActivity implements ...@@ -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 getDsrtActivityClass();
public abstract Class getRutaActivityClass(); public abstract Class getRutaActivityClass();
......
...@@ -139,6 +139,11 @@ public abstract class RutaImpActivity extends AppCompatActivity implements OnEdi ...@@ -139,6 +139,11 @@ public abstract class RutaImpActivity extends AppCompatActivity implements OnEdi
kirimFragment.notifyRutaChanged(); kirimFragment.notifyRutaChanged();
} }
} }
@Override
public void onSynchronizationFailed(Exception e) {
}
}); });
} }
......
...@@ -17,7 +17,7 @@ import com.rahadi.vsen.R; ...@@ -17,7 +17,7 @@ import com.rahadi.vsen.R;
import com.rahadi.vsen.activities.DsrtImpActivity; import com.rahadi.vsen.activities.DsrtImpActivity;
import com.rahadi.vsen.contexts.Vsen; import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI; 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.listeners.OnRecyclerItemClickListener;
import com.rahadi.vsen.models.BlokSensusModel; import com.rahadi.vsen.models.BlokSensusModel;
import com.rahadi.vsen.providers.BSProviderAPI; import com.rahadi.vsen.providers.BSProviderAPI;
...@@ -33,12 +33,12 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl ...@@ -33,12 +33,12 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl
private Context context; private Context context;
private List<BlokSensusModel> blokSensuses; private List<BlokSensusModel> blokSensuses;
private OnRecyclerItemClickListener onRecyclerItemClickListener; 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.context = context;
this.blokSensuses = blokSensuses; this.blokSensuses = blokSensuses;
this.onLihatRutaClickedListener = onLihatRutaClickedListener; this.onBSAdapterButtonClickedListener = onBSAdapterButtonClickedListener;
} }
public void setBlokSensuses(List<BlokSensusModel> blokSensuses) { public void setBlokSensuses(List<BlokSensusModel> blokSensuses) {
...@@ -214,7 +214,7 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl ...@@ -214,7 +214,7 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl
lihatRutaButton.setOnClickListener(new View.OnClickListener() { lihatRutaButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { 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()); bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus(), bsm.getStatus());
} }
}); });
...@@ -222,11 +222,8 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl ...@@ -222,11 +222,8 @@ public class BlokSensusAdapter extends RecyclerView.Adapter<BlokSensusAdapter.Bl
lihatSampelButton.setOnClickListener(new View.OnClickListener() { lihatSampelButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent i = new Intent(context, DsrtImpActivity.class); onBSAdapterButtonClickedListener.onLihatSampelClicked(bsm.getUuid(), bsm.getKodeProvinsi() +
i.putExtra(DsrtImpActivity.KEY_BS_UUID, bsm.getUuid());
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus()); bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus());
context.startActivity(i);
} }
}); });
......
...@@ -6,7 +6,7 @@ package com.rahadi.vsen.contexts; ...@@ -6,7 +6,7 @@ package com.rahadi.vsen.contexts;
public final class VsenAPI { 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_PCL = 0;
public static final int PRIVILEGE_PML = 1; public static final int PRIVILEGE_PML = 1;
public static final int LOGIN_STATE_LOGGED_IN = 2; public static final int LOGIN_STATE_LOGGED_IN = 2;
...@@ -29,6 +29,6 @@ public final class VsenAPI { ...@@ -29,6 +29,6 @@ public final class VsenAPI {
} }
public static class Preferences { 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; ...@@ -14,7 +14,7 @@ import android.widget.CompoundButton;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.rahadi.vsen.R; 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.Vsen;
import com.rahadi.vsen.contexts.VsenAPI; import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.RutaDao; import com.rahadi.vsen.daos.RutaDao;
...@@ -136,12 +136,17 @@ public class KirimFragment extends Fragment { ...@@ -136,12 +136,17 @@ public class KirimFragment extends Fragment {
@Override @Override
public void onSynchronizationCompleted(JSONArray result) {