Commit f5cc77af authored by rahadi's avatar rahadi

Added Pemutakhiran Module

parent f1ca714d
package org.odk.collect.android.capi;
import android.os.AsyncTask;
import android.util.Log;
import org.odk.collect.android.utilities.FileUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
......@@ -15,10 +18,10 @@ import java.util.HashSet;
import javax.xml.parsers.DocumentBuilderFactory;
public class ParseXml{
public class ParseXml {
//dapetin instance berdasarkan idINstance dan variabel form
public static HashMap<String, String> getLoadedXmlValues(String dir, HashSet<String> arvar){
public static HashMap<String, String> getLoadedXmlValues(String dir, HashSet<String> arvar) {
int eventType;
String name;
XmlPullParserFactory xmlPullParserFactory;
......@@ -32,51 +35,54 @@ public class ParseXml{
FileInputStream is = new FileInputStream(new File(dir));
parser.setInput(is, null);
eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT){
if(eventType == XmlPullParser.START_TAG){
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
name = parser.getName();
if(arvar.contains(name)){
if (arvar.contains(name)) {
informasi.put(name, parser.nextText());
}
}
eventType = parser.next();
}
} catch (Exception e) {
Log.d("DEBUGC","error happen when parser value ");
Log.d("DEBUGC", "error happen when parser value ");
}
return informasi;
}
//cari variabel apa aja yg ada di form
public static ArrayList<String> getVariabelForm (String dir, String ids){
public static ArrayList<String> getVariabelForm(String dir, String ids) {
ArrayList<String> arrayVariabel = new ArrayList<>();
File xml = new File(dir);
try {
FileInputStream is = new FileInputStream(new File(dir));
FileInputStream is = new FileInputStream(xml);
Document doc = DocumentBuilderFactory
.newInstance()
.newDocumentBuilder()
.parse(is);
.newInstance()
.newDocumentBuilder()
.parse(is);
NodeList nl = doc.getElementsByTagName(ids);
NodeList nld;
if(nl.item(0)!=null) {
if (nl.item(0) != null) {
nld = nl.item(0).getChildNodes();
} else {
nl = doc.getElementsByTagName("data");
// nl = doc.getElementsByTagName("data");
// RAHADI: modified
nl = doc.getElementsByTagName(FileUtils.parseXML(xml).get(FileUtils.TOP_ELEMENT));
nld = nl.item(0).getChildNodes();
}
addChildNode(arrayVariabel, nld);
} catch (Exception e) {
Log.d("DEBUGCOLL", "error because "+e.toString());
Log.d("DEBUGCOLL", "error because " + e.toString());
}
return arrayVariabel;
}
private static void addChildNode(ArrayList<String> arrayLists, NodeList nodeList){
for (int j=0; j<nodeList.getLength(); j++){
private static void addChildNode(ArrayList<String> arrayLists, NodeList nodeList) {
for (int j = 0; j < nodeList.getLength(); j++) {
Node ndcc = nodeList.item(j);
// if(ndcc.getAttributes()!=null && ndcc.getAttributes().getNamedItem("jr:template")!=null) {
......
......@@ -91,7 +91,7 @@ public class CapiLoginActivity extends AppCompatActivity
}
}
public void login(final String username, final String password){
public void login(final String username, final String password) {
//disable login button
loginBtn.setClickable(false);
loginBtn.setText("Proses login");
......@@ -111,53 +111,57 @@ 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) {
UserModel r = new GsonBuilder().create().fromJson(result.toString(), UserModel.class);
Timber.d(r.toString());
Vsen.getInstance().setUserSession(r);
dialog.setMessage("Sinkronisasi Data..");
new BSSynchronizationTask(null, null).execute(username, uuid,
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
// TODO: 20/02/2018 RAHADI: dynamize
String formId = "VSEN18K.v2";
new GetGenerateTask(formId).execute(new OnSynchronizationCompletedListener<String>() {
@Override
public void onSynchronizationCompleted(String result) {
onLoginSucceed();
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
if (result.equals(GetUuidTask.SUCCESS)) {
// RAHADI: Register ke Pemutakhiran, etc.
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) {
UserModel r = new GsonBuilder().create().fromJson(result.toString(), UserModel.class);
Timber.d(r.toString());
Vsen.getInstance().setUserSession(r);
dialog.setMessage("Sinkronisasi Data..");
new BSSynchronizationTask(null, null).execute(username, uuid,
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
String formId = Vsen.getInstance().getGenerateFormId();
new GetGenerateTask(formId).execute(new OnSynchronizationCompletedListener<String>() {
@Override
public void onSynchronizationCompleted(String result) {
onLoginSucceed();
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
} else {
onLoginFailed(result);
}
}
private void onLoginSucceed() {
......@@ -175,6 +179,7 @@ public class CapiLoginActivity extends AppCompatActivity
private void onLoginFailed(String result) {
dialog.dismiss();
loginBtn.setClickable(true);
loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
......
package org.odk.collect.android.capi.activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -12,7 +13,6 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
......@@ -24,15 +24,27 @@ import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
import com.mikepenz.materialdrawer.model.SectionDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.daos.BlokSensusDao;
import com.rahadi.vsen.daos.CatatanDao;
import com.rahadi.vsen.daos.DsrtDao;
import com.rahadi.vsen.daos.DsrtLogDao;
import com.rahadi.vsen.daos.GenerateDao;
import com.rahadi.vsen.daos.RutaDao;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.squareup.picasso.Picasso;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.odk.collect.android.R;
import org.odk.collect.android.activities.SplashScreenActivity;
import org.odk.collect.android.capi.fragment.CapiFormFragment;
......@@ -161,27 +173,57 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
}
private void logout() {
prefs.reset(PreferenceKeys.KEY_LOGIN_STATUS);
prefs.reset(PreferenceKeys.KEY_USERNAME);
prefs.reset(PreferenceKeys.KEY_PASSWORD);
prefs.reset(PreferenceKeys.KEY_USERGROUP);
prefs.reset(PreferenceKeys.KEY_METADATA_USERGROUP);
String uuid = (String) prefs.get(PreferenceKeys.KEY_UNIQUES);
if (StringUtils.isNotEmpty(uuid))
FirebaseMessaging.getInstance().unsubscribeFromTopic(GetUuidTask.getPureUri(uuid));
startActivity(new Intent(CapiMainActivity.this, SplashScreenActivity.class));
finish();
final ProgressDialog pd = new ProgressDialog(this);
pd.setCancelable(false);
pd.setMessage("Logging Out..");
pd.show();
UserModel um = Vsen.getInstance().getUserSession();
new BSSynchronizationTask(null, null).execute(um.getIdUser(), um.getAuthToken(),
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
pd.dismiss();
Vsen.getInstance().clearUserSession();
new BlokSensusDao().deleteBlokSensus();
new CatatanDao().deleteCatatan();
new DsrtDao().deleteDsrt();
new DsrtLogDao().deleteDsrtLog();
new GenerateDao().deleteGenerate();
new RutaDao().deleteRuta();
prefs.reset(PreferenceKeys.KEY_LOGIN_STATUS);
prefs.reset(PreferenceKeys.KEY_USERNAME);
prefs.reset(PreferenceKeys.KEY_PASSWORD);
prefs.reset(PreferenceKeys.KEY_USERGROUP);
prefs.reset(PreferenceKeys.KEY_METADATA_USERGROUP);
String uuid = (String) prefs.get(PreferenceKeys.KEY_UNIQUES);
if (StringUtils.isNotEmpty(uuid))
FirebaseMessaging.getInstance().unsubscribeFromTopic(GetUuidTask.getPureUri(uuid));
startActivity(new Intent(CapiMainActivity.this, SplashScreenActivity.class));
finish();
}
@Override
public void onSynchronizationFailed(Exception e) {
pd.dismiss();
Toast.makeText(CapiMainActivity.this, "Gagal Logout", Toast.LENGTH_LONG).show();
}
});
}
private void initializeDrawer(final Context context, Bundle savedInstanceState) {
//get user data
String username = (String) prefs.get(PreferenceKeys.KEY_USERNAME);
String userGroup = (String) prefs.get(PreferenceKeys.KEY_USERGROUP);
// String username = (String) prefs.get(PreferenceKeys.KEY_USERNAME);
// String userGroup = (String) prefs.get(PreferenceKeys.KEY_USERGROUP);
String username = (String) Vsen.getInstance().getUserSession().getNamaUser();
String userGroup = (String) Vsen.getInstance().getUserSession().getIdUser();
//build drawer header
AccountHeader accountHeader = new AccountHeaderBuilder()
.withActivity(this)
.withSelectionListEnabledForSingleProfile(false)
.withHeaderBackground(R.drawable.capi_header_drawer)
.addProfiles(new ProfileDrawerItem()
.withName(username)
......@@ -196,11 +238,17 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
.withToolbar(toolbar)
.withSavedInstance(savedInstanceState)
.withHasStableIds(true)
.withItemAnimator(new DefaultItemAnimator())
// .withItemAnimator(new DefaultItemAnimator())
.withAccountHeader(accountHeader)
.addDrawerItems(
new PrimaryDrawerItem().withName("Pemutakhiran").withIcon(R.drawable.wb_ic_edit_bs).withIdentifier(MENU_PEMUTAKHIRAN),
new DividerDrawerItem(),
new SectionDrawerItem()
.withName("Menu")
.withEnabled(true)
.withDivider(false),
new PrimaryDrawerItem()
.withName("Pemutakhiran")
.withIcon(R.drawable.wb_ic_edit_bs)
.withIdentifier(MENU_PEMUTAKHIRAN),
new PrimaryDrawerItem()
.withName("Daftar Kuesioner")
.withIcon(R.drawable.ic_survey)
......@@ -212,11 +260,16 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
new PrimaryDrawerItem()
.withName("Peta WB Digital")
.withIcon(R.drawable.wb_ic_map)
.withIdentifier(MENU_PETA_WB),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("Pengaturan").withIcon(R.drawable.ic_setting).withIdentifier(MENUSETTING),
new PrimaryDrawerItem().withName("Logout").withIcon(R.drawable.ic_logout).withIdentifier(MENULOGOUT)
)
.withIdentifier(MENU_PETA_WB)
).withStickyFooterDivider(true)
.withStickyFooterShadow(false)
.addStickyDrawerItems(
new SecondaryDrawerItem().withName("Pengaturan")
.withIcon(R.drawable.ic_setting)
.withIdentifier(MENUSETTING),
new SecondaryDrawerItem().withName("Logout")
.withIcon(R.drawable.ic_logout)
.withIdentifier(MENULOGOUT))
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
......
......@@ -436,7 +436,7 @@ public class CapiInstanceAdapter extends RecyclerView.Adapter<CapiInstanceAdapte
void selectItem(int layoutPosition){
boolean isSelected = selectedItem.contains(layoutPosition);
if (isSelected) selectedItem.remove(layoutPosition);
if (isSelected) selectedItem.remove(selectedItem.indexOf(layoutPosition));
else selectedItem.add(layoutPosition);
//check instance finalized or fail to upload
......
package org.odk.collect.android.pemutakhiran.activities;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.Toast;
import com.rahadi.vsen.activities.DsrtMinImpActivity;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.daos.BlokSensusDao;
import com.rahadi.vsen.daos.RutaDao;
import com.rahadi.vsen.listeners.OnGenerateCompletedListener;
import com.rahadi.vsen.models.KeyValueModel;
......@@ -32,8 +35,7 @@ public class DsrtActivity extends DsrtMinImpActivity implements OnGenerateComple
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: 21/02/2018 RAHADI: Dynamize
formId = "VSEN18K.v2";
formId = Vsen.getInstance().getGenerateFormId();
RutaDao rutaDao = new RutaDao();
Cursor b = rutaDao.getRutaCursor(null, RutaProviderAPI.Columns.BS_UUID + "=?",
......@@ -64,6 +66,12 @@ public class DsrtActivity extends DsrtMinImpActivity implements OnGenerateComple
@Override
public void onGenerateSucceed(int currentIdx, String rutaName) {
if (currentIdx == rutaModels.size() - 1) {
ContentValues cv = new ContentValues();
cv.put(BSProviderAPI.Columns.STATUS_GENERATE, 1);
new BlokSensusDao().updateBlokSensus(cv, BSProviderAPI.Columns.UUID + "=?",
new String[]{getBsUuid()});
progressDialog.dismiss();
Toast.makeText(this, "Generate Selesai", Toast.LENGTH_LONG).show();
} else {
......@@ -73,7 +81,7 @@ public class DsrtActivity extends DsrtMinImpActivity implements OnGenerateComple
HashMap<String, KeyValueModel> keyValues = new HashMap<>();
keyValues.put(BSProviderAPI.Columns.CONTENT_TYPE, new KeyValueModel(BSProviderAPI.Columns.UUID, getBsUuid()));
keyValues.put(RutaProviderAPI.Columns.CONTENT_TYPE, new KeyValueModel(RutaProviderAPI.Columns.UUID, rutaModels.get(0).getUuid()));
keyValues.put(RutaProviderAPI.Columns.CONTENT_TYPE, new KeyValueModel(RutaProviderAPI.Columns.UUID, rutaModels.get(currentIdx).getUuid()));
GenerateTask task = new GenerateTask(formId, getBsNks(), rutaModels, keyValues,
DsrtActivity.this);
......
......@@ -25,7 +25,9 @@ public class ItemPanduanActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wb_activity_item_panduan);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
recyclerView = (RecyclerView) findViewById(R.id.rv_item_panduan);
Log.d(VAR.DEBUG, "get intent : " +getIntent().getIntExtra("panduan",-1) +"-" +getIntent().getStringExtra("item"));
prepareData(getIntent().getIntExtra("panduan",-1));
......
......@@ -15,7 +15,7 @@ import org.odk.collect.android.petawbdigital.assets.VAR;
public class PanduanActivity extends AppCompatActivity {
String[] listArray= {
String[] listArray = {
"Unduh data BS",
"Unggah data BS",
"Pemutakhiran batas BS",
......@@ -31,17 +31,19 @@ public class PanduanActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wb_activity_panduan);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ArrayAdapter adapter = new ArrayAdapter(this, R.layout.wb_layout_panduan,listArray);
ListView listview =(ListView) findViewById(R.id.lv_panduan);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
ArrayAdapter adapter = new ArrayAdapter(this, R.layout.wb_layout_panduan, listArray);
ListView listview = (ListView) findViewById(R.id.lv_panduan);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(PanduanActivity.this,ItemPanduanActivity.class);
intent.putExtra("item",listArray[position]);
intent.putExtra("panduan",position);
Log.d(VAR.DEBUG,"item panduan : " +position+" - " +listArray[position]);
Intent intent = new Intent(PanduanActivity.this, ItemPanduanActivity.class);
intent.putExtra("item", listArray[position]);
intent.putExtra("panduan", position);
Log.d(VAR.DEBUG, "item panduan : " + position + " - " + listArray[position]);
startActivity(intent);
}
});
......
......@@ -33,7 +33,9 @@ public class SettingTampilan extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wb_activity_setting_tampilan);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
cb_posisi = (CheckBox) findViewById(R.id.cb_posisi);
rlTampilanLm = (RelativeLayout) findViewById(R.id.rl_tampilkan_landmark);
......
......@@ -31,6 +31,12 @@ import timber.log.Timber;
*/
public class GetUuidTask extends AsyncTask<String, String, String> {
public static final String ERROR_GENERAL = "Terjadi permasalahan server";
public static final String ERROR_URL = "Terjadi kesalahan pada alamat server";
public static final String ERROR_EMPTY = "Respon server kosong";
public static final String ERROR_ID = "Fail to get id on server";
public static final String SUCCESS = "Sukses login server";
private LoginListener listener;
private GeneralSharedPreferences prefs;
......@@ -64,10 +70,10 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
loginUri = urlLogin.toURI();
} catch (MalformedURLException e) {
e.printStackTrace();
return "Terjadi kesalahan pada alamat server";
return ERROR_URL;
} catch (URISyntaxException e) {
e.printStackTrace();
return "Terjadi kesalahan pada alamat server";
return ERROR_URL;
}
// get shared HttpContext so that authentication and cookies are retained.
......@@ -82,6 +88,7 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
//add credentials
WebUtils.clearAllCredentials();
WebUtils.clearHostCredentials(host);
WebUtils.addCredentials(username, password, host);
Timber.d("username: %s, password: %s", username, password);
......@@ -93,15 +100,15 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
//respon error
if (statusCode != HttpStatus.SC_OK) {
if (loginUri != null)
Timber.d("Fail Catch as %s ( %d ) %s",
Timber.e("Fail Catch as %s ( %d ) %s",
response.getStatusLine().getReasonPhrase(), statusCode, loginUri.toString());
return "Terjadi permasalahan server";
return ERROR_GENERAL;
}
//respon kosong
HttpEntity entity = response.getEntity();
if (entity == null) {
return "Respon server kosong";
return ERROR_EMPTY;
}
//cek apakah pernah subscribe sebelumnya
......@@ -130,11 +137,11 @@ public class GetUuidTask extends AsyncTask<String, String, String> {
FirebaseMessaging.getInstance().subscribeToTopic(getPureUri(uuid));
Timber.d("AggregatePreference UUID2: %s", uuid);
return "Sukses login server";
return SUCCESS;
} catch (Exception e) {
Timber.d(e);
return "Fail to get id on server";
return ERROR_ID;
}
}
......
......@@ -50,7 +50,6 @@ import org.odk.collect.android.listeners.FormLoaderListener;
import org.odk.collect.android.logic.FileReferenceFactory;
import org.odk.collect.android.logic.FormController;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.revalidasi.notifikasi.ConfigKey;
import org.odk.collect.android.utilities.FileUtils;
import org.odk.collect.android.utilities.ZipUtils;
......@@ -74,46 +73,22 @@ import timber.log.Timber;
*
* @author Carl Hartung (carlhartung@gmail.com)
* @author Yaw Anokwa (yanokwa@gmail.com)
* edit Mahendri Dwicahyo
* edit Mahendri Dwicahyo
*/
public class FormLoaderTask extends AsyncTask<String, String, FormLoaderTask.FECWrapper> {
private static final String ITEMSETS_CSV = "itemsets.csv";
private final String xPath;
private final String waitingXPath;
FECWrapper data;
private FormLoaderListener stateListener;
private String errorMsg;
private String instancePath;
private final String xPath;
private final String waitingXPath;
private boolean pendingActivityResult = false;
private int requestCode = 0;
private int resultCode = 0;
private Intent intent = null;
private ExternalDataManager externalDataManager;
protected class FECWrapper {
FormController controller;
boolean usedSavepoint;
protected FECWrapper(FormController controller, boolean usedSavepoint) {
this.controller = controller;
this.usedSavepoint = usedSavepoint;
}
protected FormController getController() {
return controller;
}
protected boolean hasUsedSavepoint() {
return usedSavepoint;
}
protected void free() {
controller = null;
}
}
FECWrapper data;
public FormLoaderTask(String instancePath, String xpath, String waitingXPath) {
this.instancePath = instancePath;
xPath = xpath;
......@@ -172,6 +147,7 @@ public class FormLoaderTask extends AsyncTask<String, String, FormLoaderTask.FEC
if (fd == null) {
errorMsg = "Error reading XForm file";
} else {
Timber.i("Serializing Form..");
serializeFormDef(fd, formPath);
}
} catch (Exception e) {
......@@ -241,8 +217,8 @@ public class FormLoaderTask extends AsyncTask<String, String, FormLoaderTask.FEC
//TODO : refactor akses SharedPref mengikuti ODK ori
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(Collect.getInstance());
String userGroup = prefs.getString(PreferenceKeys.KEY_USERGROUP,null);
if (StringUtils.isBlank(userGroup)){
String userGroup = prefs.getString(PreferenceKeys.KEY_USERGROUP, null);
if (StringUtils.isBlank(userGroup)) {
errorMsg = "Pastikan anda sudah login";
return null;
}
......@@ -275,7 +251,7 @@ public class FormLoaderTask extends AsyncTask<String, String, FormLoaderTask.FEC
// but we should give the option to the user to edit the form
// otherwise the survey will be TOTALLY inaccessible.
Timber.w("We have a syntactically correct instance, but the data threw an "
+ "exception inside JR. We should allow editing.");
+ "exception inside JR. We should allow editing.");
} else {
errorMsg = e.getMessage();
return null;
......@@ -640,4 +616,26 @@ public class FormLoaderTask extends AsyncTask<String, String, FormLoaderTask.FEC