Commit 94555bd3 authored by rahadi's avatar rahadi

Added Pemutakhiran Module

parent 67b4f6f8
......@@ -367,14 +367,14 @@ the specific language governing permissions and limitations under the License.
android:parentActivityName=".capi.activity.CapiMainActivity" />
<activity
android:name=".pemutakhiran.BSActivity"
android:name=".pemutakhiran.activities.BSActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.RutaActivity"
android:name=".pemutakhiran.activities.RutaActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.DsrtActivity"
android:name=".pemutakhiran.activities.DsrtActivity"
android:theme="@style/VsenAppTheme" />
</application>
......
......@@ -33,8 +33,8 @@ 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.activity.CapiMainActivity;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.pemutakhiran.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
......@@ -80,8 +80,8 @@ public class SplashScreenActivity extends AppCompatActivity {
}
if (preferences.getBoolean(PreferenceKeys.KEY_LOGIN_STATUS, false)) {
// startActivity(new Intent(this, CapiMainActivity.class));
startActivity(new Intent(this, BSActivity.class));
startActivity(new Intent(this, CapiMainActivity.class));
// startActivity(new Intent(this, BSActivity.class));
} else {
startActivity(new Intent(this, CapiLoginActivity.class));
}
......
......@@ -80,6 +80,9 @@ public class Collect extends Application {
public static final String DEFAULT_FONTSIZE = "16";
public static final String OFFLINE_LAYERS = ODK_ROOT + File.separator + "layers";
public static final String SETTINGS = ODK_ROOT + File.separator + "settings";
public static final String EMPTY_INSTANCES_PATH = ODK_ROOT + File.separator + "instances" + File.separator + "empty";
private static Collect singleton = null;
static {
......@@ -122,7 +125,8 @@ public class Collect extends Application {
}
String[] dirs = {
ODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH, OFFLINE_LAYERS
ODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH, OFFLINE_LAYERS,
EMPTY_INSTANCES_PATH
};
for (String dirName : dirs) {
......
......@@ -14,17 +14,17 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.GsonBuilder;
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.GetGenerateTask;
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.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.preferences.PreferencesActivity;
......@@ -112,16 +112,10 @@ public class CapiLoginActivity extends AppCompatActivity
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());
UserModel r = new GsonBuilder().create().fromJson(result.toString(), UserModel.class);
Timber.d(r.toString());
Vsen.getInstance().setUserSession(r);
dialog.setMessage("Sinkronisasi Data..");
......@@ -129,12 +123,25 @@ public class CapiLoginActivity extends AppCompatActivity
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
Timber.d("BSSync: " + result.toString());
onLoginSucceed();
// 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());
}
});
......@@ -142,13 +149,8 @@ public class CapiLoginActivity extends AppCompatActivity
@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());
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
......@@ -159,7 +161,8 @@ public class CapiLoginActivity extends AppCompatActivity
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true);
Intent toMain = new Intent(this, BSActivity.class);
// Intent toMain = new Intent(this, BSActivity.class);
Intent toMain = new Intent(this, CapiMainActivity.class);
startActivity(toMain);
finish();
}
......
......@@ -3,21 +3,19 @@ package org.odk.collect.android.capi.activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
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.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.google.firebase.messaging.FirebaseMessaging;
......@@ -28,45 +26,35 @@ 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.ProfileSettingDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader;
import com.mikepenz.materialdrawer.util.DrawerImageLoader;
import com.squareup.picasso.Picasso;
import org.apache.commons.lang3.StringUtils;
import org.odk.collect.android.R;
import org.odk.collect.android.activities.FileManagerTabs;
import org.odk.collect.android.capi.preferences.Constants;
import org.odk.collect.android.capi.fragment.CapiFormFragment;
import org.odk.collect.android.activities.InstanceChooserList;
import org.odk.collect.android.activities.InstanceUploaderList;
import org.odk.collect.android.activities.SplashScreenActivity;
import org.odk.collect.android.capi.fragment.CapiFormFragment;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.capi.Helper;
import org.odk.collect.android.capi.ModelResponse;
import org.odk.collect.android.capi.ModelSurvey;
import org.odk.collect.android.listeners.DiskSyncListener;
import org.odk.collect.android.pemutakhiran.activities.BSActivity;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.revalidasi.activities.DataDownloadActivity;
import org.odk.collect.android.revalidasi.notifikasi.GetUuidTask;
import org.odk.collect.android.tasks.DiskSyncTask;
import org.odk.collect.android.utilities.ApplicationConstants;
import java.util.ArrayList;
import timber.log.Timber;
/**
* @author Muhammad Tohir
* edit Mahendri Dwicahyo
* edit Mahendri Dwicahyo
*/
public class CapiMainActivity extends AppCompatActivity implements DiskSyncListener {
//Identifier
private static final int MENU_PEMUTAKHIRAN = 3;
private static final int MENUSURVEY = 4;
private static final int MENU_UPDATE = 5;
private static final int MENUSETTING = 8;
......@@ -91,7 +79,7 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
getSupportActionBar().setTitle("Daftar Kuesioner");
diskSyncTask = (DiskSyncTask) getLastCustomNonConfigurationInstance();
if (diskSyncTask == null){
if (diskSyncTask == null) {
Timber.i("Starting new disk sync task");
diskSyncTask = new DiskSyncTask();
diskSyncTask.setDiskSyncListener(this);
......@@ -103,18 +91,18 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
initializeDrawer(this, savedInstanceState);
}
private void openFragment(Fragment fragment){
private void openFragment(Fragment fragment) {
try {
if(fragment != null){
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_main_menu, fragment).commit();
}
}catch (Exception e){
} catch (Exception e) {
Log.d("DEBUG", e.getMessage());
}
}
private void initLoader(){
private void initLoader() {
//init when url has been found
DrawerImageLoader.init(new AbstractDrawerImageLoader() {
@Override
......@@ -140,7 +128,7 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
diskSyncTask.setDiskSyncListener(this);
super.onResume();
if (diskSyncTask.getStatus() == AsyncTask.Status.FINISHED){
if (diskSyncTask.getStatus() == AsyncTask.Status.FINISHED) {
syncComplete(diskSyncTask.getStatusMessage());
}
}
......@@ -169,13 +157,13 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
prefs.reset(PreferenceKeys.KEY_USERGROUP);
prefs.reset(PreferenceKeys.KEY_METADATA_USERGROUP);
String uuid = (String) prefs.get(PreferenceKeys.KEY_UNIQUES);
if(StringUtils.isNotEmpty(uuid))
if (StringUtils.isNotEmpty(uuid))
FirebaseMessaging.getInstance().unsubscribeFromTopic(GetUuidTask.getPureUri(uuid));
startActivity(new Intent(CapiMainActivity.this, SplashScreenActivity.class));
finish();
}
private void initializeDrawer(final Context context, Bundle savedInstanceState){
private void initializeDrawer(final Context context, Bundle savedInstanceState) {
//get user data
String username = (String) prefs.get(PreferenceKeys.KEY_USERNAME);
......@@ -201,6 +189,8 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
.withItemAnimator(new DefaultItemAnimator())
.withAccountHeader(accountHeader)
.addDrawerItems(
new PrimaryDrawerItem().withName("Pemutakhiran").withIcon(R.drawable.wb_ic_edit_bs).withIdentifier(MENU_PEMUTAKHIRAN),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("Daftar Kuesioner").withIcon(R.drawable.ic_survey).withIdentifier(MENUSURVEY),
new PrimaryDrawerItem().withName("Update Isian").withIcon(R.drawable.ic_assignment_done).withIdentifier(MENU_UPDATE),
new DividerDrawerItem(),
......@@ -210,7 +200,11 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch ((int) drawerItem.getIdentifier()){
switch ((int) drawerItem.getIdentifier()) {
case MENU_PEMUTAKHIRAN:
startActivity(new Intent(context, BSActivity.class));
break;
case MENUSURVEY:
getSupportActionBar().setTitle("Daftar Kuesioner");
openFragment(capiListForms);
......
package org.odk.collect.android.capi.fragment;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -29,6 +30,13 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.rahadi.vsen.tasks.GetGenerateTask;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;
import org.kxml2.kdom.Document;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;
import org.odk.collect.android.R;
import org.odk.collect.android.adapters.CapiFormAdapter;
import org.odk.collect.android.application.Collect;
......@@ -51,6 +59,11 @@ import org.odk.collect.android.tasks.DownloadFormListTask;
import org.odk.collect.android.tasks.DownloadFormsTask;
import org.odk.collect.android.utilities.AuthDialogUtility;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
......@@ -66,14 +79,14 @@ import static org.odk.collect.android.utilities.ApplicationConstants.SortingOrde
/**
* @author Muhammad Tohir
* edit Mahendri Dwicahyo
* edit Mahendri Dwicahyo
*/
public class CapiFormFragment extends Fragment
implements FormListDownloaderListener,
FormDownloaderListener,
AuthDialogUtility.AuthDialogUtilityResultListener,
SearchView.OnQueryTextListener {
FormDownloaderListener,
AuthDialogUtility.AuthDialogUtilityResultListener,
SearchView.OnQueryTextListener {
private static final String FORM_DOWNLOAD_LIST_SORTING_ORDER = "formDownloadListSortingOrder";
......@@ -86,42 +99,84 @@ public class CapiFormFragment extends Fragment
private static final String FORM_ID_KEY = "formid";
private static final String FORM_VERSION_KEY = "formversion";
private static final boolean EXIT = true;
private static final boolean DO_NOT_EXIT = false;
private static final String HAS_BEEN_DOWNLOADED = "hasbeendownloaded";
protected String[] sortingOptions;
private String alertMsg;
private boolean alertShowing = false;
private String alertTitle;
private AlertDialog alertDialog;
private ProgressDialog progressDialog;
private DownloadFormListTask downloadFormListTask;
private DownloadFormsTask downloadFormsTask;
private HashMap<String, FormDetails> formNamesAndURLs = new HashMap<String, FormDetails>();
private ArrayList<HashMap<String, String>> mFormList = new ArrayList<>();
private ArrayList<HashMap<String, String>> mFilteredFormList = new ArrayList<>();
private static final boolean EXIT = true;
private static final boolean DO_NOT_EXIT = false;
private boolean shouldExit;
protected String[] sortingOptions;
private Integer selectedSortingOrder;
//modification
private RecyclerView recycleView;
private ProgressBar progressBar;
private LinearLayout messageHolder;
private TextView messageError;
private CapiFormAdapter adapter;
private static final String HAS_BEEN_DOWNLOADED ="hasbeendownloaded";
private SharedPreferences sharedPreferences;
private SessionManager sm;
private String idPcl;
/**
* Determines if a local form on the device is superseded by a given version (of the same form
* presumably available
* on the server).
*
* @param formId the form to be checked. A form with this ID may or may not reside on the
* local device.
* @param latestVersion the version against which the local form (if any) is tested.
* @return true if a form with id <code>formId</code> exists on the local device and its version
* is less than
* <code>latestVersion</code>.
*/
public static boolean isLocalFormSuperseded(String formId, String latestVersion) {
if (formId == null) {
Timber.e("isLocalFormSuperseded: server is not OpenRosa-compliant. <formID> is null!");
return true;
}
Cursor formCursor = null;
try {
formCursor = new FormsDao().getFormsCursorForFormId(formId);
if (formCursor.getCount() == 0) {
// form does not already exist locally
return true;
}
formCursor.moveToFirst();
int idxJrVersion = formCursor.getColumnIndex(FormsProviderAPI.FormsColumns.JR_VERSION);
if (formCursor.isNull(idxJrVersion)) {
// any non-null version on server is newer
return (latestVersion != null);
}
String jrVersion = formCursor.getString(idxJrVersion);
// apparently, the isNull() predicate above is not respected on all Android OSes???
if (jrVersion == null && latestVersion == null) {
return false;
}
if (jrVersion == null) {
return true;
}
if (latestVersion == null) {
return false;
}
// if what we have is less, then the server is newer
return (jrVersion.compareTo(latestVersion) < 0);
} finally {
if (formCursor != null) {
formCursor.close();
}
}
}
@Nullable
@Override
......@@ -135,7 +190,7 @@ public class CapiFormFragment extends Fragment
messageError = (TextView) v.findViewById(R.id.message);
sharedPreferences = getActivity()
.getSharedPreferences(CapiInstancePreferences.COLLECTIVA_PREFERENCES_KEY,Context.MODE_PRIVATE);
.getSharedPreferences(CapiInstancePreferences.COLLECTIVA_PREFERENCES_KEY, Context.MODE_PRIVATE);
setHasOptionsMenu(true);
alertMsg = getString(R.string.please_wait);
recycleView.setLayoutManager(new LinearLayoutManager(getContext()));
......@@ -159,14 +214,14 @@ public class CapiFormFragment extends Fragment
return v;
}
public void refreshAfterSync(){
public void refreshAfterSync() {
setUpDownloadedFormsOffline();
}
private void initData() {
//edit-wb untuk inisiasi server awal
sm = new SessionManager(getContext());
if(!sm.getInisiasiAwal()){
if (!sm.getInisiasiAwal()) {
sm.setInisiasiAwal();
sm.setIdPcl("1701008");
sm.setUrlServer("http://capi-stis.hol.es/capimaps/index.php/Mine_api/");
......@@ -197,25 +252,25 @@ public class CapiFormFragment extends Fragment
updateAdapter();
}
private void onRefresPage(){
private void onRefresPage() {
Collect.getInstance().getActivityLogger().logAction(this, "refreshForms", "");
mFilteredFormList.clear();
downloadFormList();
}
private void onStartLoading(){
private void onStartLoading() {
progressBar.setVisibility(View.VISIBLE);
messageHolder.setVisibility(View.GONE);
}
private void onErrorLoading(String message){
private void onErrorLoading(String message) {
progressBar.setVisibility(View.GONE);
messageError.setText(message);
messageHolder.setVisibility(View.VISIBLE);
}
private void onDoneLoading(){
private void onDoneLoading() {
progressBar.setVisibility(View.GONE);
messageHolder.setVisibility(View.GONE);
}
......@@ -224,7 +279,7 @@ public class CapiFormFragment extends Fragment
* Starts the download task and shows the progress dialog.
*/
private void downloadFormList() {
Log.d("DEBUGCOLL","start downloading form");
Log.d("DEBUGCOLL", "start downloading form");
onStartLoading();
ConnectivityManager connectivityManager =
......@@ -293,13 +348,13 @@ public class CapiFormFragment extends Fragment
private void showModal() {
final ArrayList<BlokSensus> listBs = ItemsetDbAdapter.getInstance(getContext()).getListBlokSensus();
if (listBs!=null&&listBs.size()>0){
if (listBs != null && listBs.size() > 0) {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final String[] idSelectedBs = {""};
idSelectedBs[0] = listBs.get(0).getIdBs();
final String[] namaListBs = new String[listBs.size()];
Log.d(VAR.DEBUG,"size bs : "+listBs.size());
for(int n=0;n<listBs.size();n++){
Log.d(VAR.DEBUG, "size bs : " + listBs.size());
for (int n = 0; n < listBs.size(); n++) {
namaListBs[n] = listBs.get(n).getNamaBs();
}
builder.setTitle("Pilih Blok Sensus");
......@@ -318,7 +373,7 @@ public class CapiFormFragment extends Fragment
AksesDataOdk aksesDataOdk = new AksesDataOdk();
final ArrayList<Form> arform = aksesDataOdk.getKeteranganForm();
String[] items = new String[arform.size()];
for (int i=0; i<arform.size(); i++){
for (int i = 0; i < arform.size(); i++) {
items[i] = arform.get(i).getDisplayName();
}
final int[] kuesselected = {0};
......@@ -337,7 +392,7 @@ public class CapiFormFragment extends Fragment
public void onClick(DialogInterface dialog2, int id2) {
idKuesioner[0] = arform.get(kuesselected[0]).getIdForm();
Log.d(VAR.DEBUG, "kuesioner : " + idKuesioner[0]);
Intent intent = new Intent(getActivity(),GeoPointMapboxRevoActivity.class);
Intent intent = new Intent(getActivity(), GeoPointMapboxRevoActivity.class);
intent.putExtra("idBs", idSelectedBs[0]);
intent.putExtra("idKuesioner", idKuesioner[0]);
intent.putExtra("question", false);
......@@ -382,7 +437,7 @@ public class CapiFormFragment extends Fragment
builder.show();
}
private void createDialog(int id){
private void createDialog(int id) {
switch (id) {
case PROGRESS_DIALOG:
Collect.getInstance().getActivityLogger().logAction(this,
......@@ -433,9 +488,9 @@ public class CapiFormFragment extends Fragment
dividedFormByStatusDownload();
}
public void triggerActiveSurvey(){
Log.d("DEBUGCOLL","update adapter called size "+mFilteredFormList.size());
if(mFilteredFormList.size()==0) downloadFormList();
public void triggerActiveSurvey() {
Log.d("DEBUGCOLL", "update adapter called size " + mFilteredFormList.size());
if (mFilteredFormList.size() == 0) downloadFormList();
else {
updateAdapter();
}
......@@ -454,59 +509,6 @@ public class CapiFormFragment extends Fragment
});
}
/**
* Determines if a local form on the device is superseded by a given version (of the same form
* presumably available
* on the server).
*
* @param formId the form to be checked. A form with this ID may or may not reside on the
* local device.
* @param latestVersion the version against which the local form (if any) is tested.
* @return true if a form with id <code>formId</code> exists on the local device and its version
* is less than
* <code>latestVersion</code>.
*/
public static boolean isLocalFormSuperseded(String formId, String latestVersion) {
if (formId == null) {
Timber.e("isLocalFormSuperseded: server is not OpenRosa-compliant. <formID> is null!");
return true;
}
Cursor formCursor = null;
try {
formCursor = new FormsDao().getFormsCursorForFormId(formId);
if (formCursor.getCount() == 0) {
// form does not already exist locally
return true;
}
formCursor.moveToFirst();
int idxJrVersion = formCursor.getColumnIndex(FormsProviderAPI.FormsColumns.JR_VERSION);
if (formCursor.isNull(idxJrVersion)) {
// any non-null version on server is newer
return (latestVersion != null);
}
String jrVersion = formCursor.getString(idxJrVersion);
// apparently, the isNull() predicate above is not respected on all Android OSes???
if (jrVersion == null && latestVersion == null) {
return false;
}
if (jrVersion == null) {
return true;
}
if (latestVersion == null) {
return false;
}
// if what we have is less, then the server is newer
return (jrVersion.compareTo(latestVersion) < 0);
} finally {
if (formCursor != null) {
formCursor.close();
}
}
}
/**
* Causes any local forms that have been updated on the server to become checked in the list.
* This is a prompt and a
......@@ -518,17 +520,17 @@ public class CapiFormFragment extends Fragment
for (int idx = 0; idx < mFilteredFormList.size(); idx++) {
HashMap<String, String> item = mFilteredFormList.get(idx);
if(item.get(HAS_BEEN_DOWNLOADED)!=null && item.get(HAS_BEEN_DOWNLOADED).equals("true")) {
if(isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
}else {
if (item.get(HAS_BEEN_DOWNLOADED) != null && item.get(HAS_BEEN_DOWNLOADED).equals("true")) {
if (isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
} else {
if (isLocalFormSuperseded(item.get(FORM_ID_KEY), item.get(FORM_VERSION_KEY))) {
//need to downloaded
item.put(HAS_BEEN_DOWNLOADED, "false");
if(isFormInActiveSurvey(item)) unDownloadedFilteredFormList.add(item);
if (isFormInActiveSurvey(item)) unDownloadedFilteredFormList.add(item);
} else {
//has been downloaded
item.put(HAS_BEEN_DOWNLOADED, "true");
if(isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
if (isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
}
}
}
......@@ -536,13 +538,14 @@ public class CapiFormFragment extends Fragment
downloadedFilteredFormList.addAll(unDownloadedFilteredFormList);
adapter.setDataSet(downloadedFilteredFormList);
if(downloadedFilteredFormList.size()==0){
if (downloadedFilteredFormList.size() == 0) {
//show that there is no form
onErrorLoading("There is no form for you");
}else {
} else {