Skip to content

Commit

Permalink
WD|Fix load registers #4.
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Nov 8, 2017
1 parent a87ad9d commit 627e452
Show file tree
Hide file tree
Showing 20 changed files with 536 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

mBaseFragment = new KIbuSmartRegisterFragment();
Fragment[] otherFragments = {new AdvancedSearchFragment()};
// Fragment[] otherFragments = {new AdvancedSearchFragment()};
Fragment[] otherFragments = {};

// Instantiate a ViewPager and a PagerAdapter.
mPagerAdapter = new BidanRegisterActivityPagerAdapter(getSupportFragmentManager(), mBaseFragment, otherFragments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.bidan.activity.ChildImmunizationActivity;
import org.smartregister.bidan.application.BidanApplication;
import org.smartregister.bidan.application.VaccinatorApplication;
import org.smartregister.clientandeventmodel.DateUtil;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.cursoradapter.SmartRegisterQueryBuilder;
Expand Down Expand Up @@ -530,8 +528,11 @@ private void initListMode() {
setTablename(tableName);
String parentTableName = BidanConstants.MOTHER_TABLE_NAME;

// AdvancedSearchClientsProvider hhscp = new AdvancedSearchClientsProvider(getActivity(),
// clientActionHandler, context().alertService(), BidanApplication.getInstance().vaccineRepository(),
// BidanApplication.getInstance().weightRepository(), commonRepository());
AdvancedSearchClientsProvider hhscp = new AdvancedSearchClientsProvider(getActivity(),
clientActionHandler, context().alertService(), VaccinatorApplication.getInstance().vaccineRepository(), VaccinatorApplication.getInstance().weightRepository(), commonRepository());
clientActionHandler, context().alertService(), commonRepository());
clientAdapter = new AdvancedSearchPaginatedCursorAdapter(getActivity(), null, hhscp, context().commonrepository(tableName));
clientsView.setAdapter(clientAdapter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ protected void onCreation() {
@Override
protected void onResumption() {
super.onResumption();
getDefaultOptionsProvider();
if (isPausedOrRefreshList()) {
initializeQueries();
}
updateSearchView();
// getDefaultOptionsProvider();
// if (isPausedOrRefreshList()) {
// initializeQueries();
// }
// updateSearchView();
try {
LoginActivity.setLanguage();
} catch (Exception e) {
Expand Down Expand Up @@ -219,9 +219,9 @@ public void onClick(View view) {
clientsView.setVisibility(View.VISIBLE);
clientsProgressView.setVisibility(View.INVISIBLE);
setServiceModeViewDrawableRight(null);
initializeQueries();
updateSearchView();
populateClientListHeaderView(view);
// initializeQueries();
// updateSearchView();
// populateClientListHeaderView(view);

View qrCode = view.findViewById(R.id.scan_qr_code);
qrCode.setOnClickListener(clientActionHandler);
Expand Down Expand Up @@ -369,8 +369,8 @@ private void populateClientListHeaderView(View view) {
LinearLayout clientsHeaderLayout = (LinearLayout) view.findViewById(org.smartregister.R.id.clients_header_layout);
clientsHeaderLayout.setVisibility(View.GONE);

LinearLayout headerLayout = (LinearLayout) getLayoutInflater(null).inflate(R.layout.smart_register_child_header, null);
clientsView.addHeaderView(headerLayout);
// LinearLayout headerLayout = (LinearLayout) getLayoutInflater(null).inflate(R.layout.smart_register_child_header, null);
// clientsView.addHeaderView(headerLayout);
clientsView.setEmptyView(getActivity().findViewById(R.id.empty_view));

}
Expand Down Expand Up @@ -508,7 +508,6 @@ private boolean filterMode() {
return filterSection != null && filterSection.getTag() != null;
}


////////////////////////////////////////////////////////////////
// Inner classes
////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.smartregister.bidan.option.StatusSort;
import org.smartregister.bidan.provider.AnakSmartClientsProvider;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.bidan.servicemode.BidanServiceModeOption;
import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.view.LocationPickerView;
import org.smartregister.commonregistry.CommonPersonObjectClient;
Expand Down Expand Up @@ -70,15 +71,14 @@ public class KANCSmartRegisterFragment extends BaseSmartRegisterFragment impleme
@Override
protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() {
return new SecuredNativeSmartRegisterActivity.DefaultOptionsProvider() {
// FIXME path_conflict
//@Override
public FilterOption searchFilterOption() {
return new BasicSearchOption("");
}

@Override
public ServiceModeOption serviceMode() {
return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
return new BidanServiceModeOption(null, "Bidan Ayu", new int[]{
R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
R.string.child_next_vaccine
}, new int[]{5, 2, 2, 3, 3});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.smartregister.bidan.option.StatusSort;
import org.smartregister.bidan.provider.AnakSmartClientsProvider;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.bidan.servicemode.BidanServiceModeOption;
import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.view.LocationPickerView;
import org.smartregister.commonregistry.CommonPersonObjectClient;
Expand Down Expand Up @@ -71,15 +72,14 @@ public class KAnakSmartRegisterFragment extends BaseSmartRegisterFragment implem
@Override
protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() {
return new SecuredNativeSmartRegisterActivity.DefaultOptionsProvider() {
// FIXME path_conflict
//@Override
public FilterOption searchFilterOption() {
return new BasicSearchOption("");
}

@Override
public ServiceModeOption serviceMode() {
return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
return new BidanServiceModeOption(null, "Bidan Ayu", new int[]{
R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
R.string.child_next_vaccine
}, new int[]{5, 2, 2, 3, 3});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.smartregister.bidan.option.StatusSort;
import org.smartregister.bidan.provider.AnakSmartClientsProvider;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.servicemode.BidanServiceModeOption;
import org.smartregister.bidan.view.LocationPickerView;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.commonregistry.CommonRepository;
Expand All @@ -54,6 +54,7 @@
//import org.smartregister.immunization.util.VaccinateActionUtils;

public class KIbuSmartRegisterFragment extends BaseSmartRegisterFragment implements SyncStatusBroadcastReceiver.SyncStatusListener {
private static final String TAG = KIbuSmartRegisterFragment.class.getName();
private final ClientActionHandler clientActionHandler = new ClientActionHandler();
private LocationPickerView clinicSelection;
private static final long NO_RESULT_SHOW_DIALOG_DELAY = 1000l;
Expand All @@ -70,18 +71,18 @@ public class KIbuSmartRegisterFragment extends BaseSmartRegisterFragment impleme
@Override
protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() {
return new SecuredNativeSmartRegisterActivity.DefaultOptionsProvider() {
// FIXME path_conflict
//@Override
public FilterOption searchFilterOption() {
return new BasicSearchOption("");
}

@Override
public ServiceModeOption serviceMode() {
return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
R.string.child_next_vaccine
}, new int[]{5, 2, 2, 3, 3});
return new BidanServiceModeOption(null, "Bidan Ayu", new int[]{
R.string.header_nama, R.string.header_id, R.string.header_obsetri,
R.string.header_edd, R.string.header_anak, R.string.header_status_b,
R.string.header_edit
}, new int[]{244, 75, 110, 125, 160, 205, 75});
}

@Override
Expand Down Expand Up @@ -220,6 +221,7 @@ public void onClick(View view) {
setServiceModeViewDrawableRight(null);
initializeQueries();
updateSearchView();
// Override ServiceMode
populateClientListHeaderView(view);

View qrCode = view.findViewById(R.id.scan_qr_code);
Expand Down Expand Up @@ -308,6 +310,7 @@ private void initializeQueries() {
queryBUilder.SelectInitiateMainTable(tableName, new String[]{
tableName + ".relationalid",
tableName + ".details",
// TODO change "zeir_id"
tableName + ".zeir_id",
tableName + ".relational_id",
tableName + ".first_name",
Expand Down Expand Up @@ -380,10 +383,12 @@ private void populateClientListHeaderView(View view) {
LinearLayout clientsHeaderLayout = (LinearLayout) view.findViewById(org.smartregister.R.id.clients_header_layout);
clientsHeaderLayout.setVisibility(View.GONE);

LinearLayout headerLayout = (LinearLayout) getLayoutInflater(null).inflate(R.layout.smart_register_child_header, null);
LinearLayout headerLayout = (LinearLayout) getLayoutInflater(null).inflate(R.layout.smart_register_header, null);
clientsView.addHeaderView(headerLayout);
clientsView.setEmptyView(getActivity().findViewById(R.id.empty_view));

// clientsView.setVisibility(View.GONE);

}

private String filterSelectionCondition(boolean urgentOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.smartregister.bidan.option.StatusSort;
import org.smartregister.bidan.provider.AnakSmartClientsProvider;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.bidan.servicemode.BidanServiceModeOption;
import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.view.LocationPickerView;
import org.smartregister.commonregistry.CommonPersonObjectClient;
Expand Down Expand Up @@ -70,15 +71,14 @@ public class KKBSmartRegisterFragment extends BaseSmartRegisterFragment implemen
@Override
protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() {
return new SecuredNativeSmartRegisterActivity.DefaultOptionsProvider() {
// FIXME path_conflict
//@Override
public FilterOption searchFilterOption() {
return new BasicSearchOption("");
}

@Override
public ServiceModeOption serviceMode() {
return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
return new BidanServiceModeOption(null, "Bidan Ayu", new int[]{
R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
R.string.child_next_vaccine
}, new int[]{5, 2, 2, 3, 3});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.smartregister.bidan.option.StatusSort;
import org.smartregister.bidan.provider.AnakSmartClientsProvider;
import org.smartregister.bidan.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.bidan.servicemode.BidanServiceModeOption;
import org.smartregister.bidan.servicemode.VaccinationServiceModeOption;
import org.smartregister.bidan.view.LocationPickerView;
import org.smartregister.commonregistry.CommonPersonObjectClient;
Expand Down Expand Up @@ -70,15 +71,14 @@ public class KPNCSmartRegisterFragment extends BaseSmartRegisterFragment impleme
@Override
protected SecuredNativeSmartRegisterActivity.DefaultOptionsProvider getDefaultOptionsProvider() {
return new SecuredNativeSmartRegisterActivity.DefaultOptionsProvider() {
// FIXME path_conflict
//@Override
public FilterOption searchFilterOption() {
return new BasicSearchOption("");
}

@Override
public ServiceModeOption serviceMode() {
return new VaccinationServiceModeOption(null, "Linda Clinic", new int[]{
return new BidanServiceModeOption(null, "Bidan Ayu", new int[]{
R.string.child_profile, R.string.birthdate_age, R.string.epi_number, R.string.child_contact_number,
R.string.child_next_vaccine
}, new int[]{5, 2, 2, 3, 3});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@

import android.content.Context;
import android.database.Cursor;
import android.support.v4.app.FragmentActivity;
import android.view.View;

import org.smartregister.bidan.fragment.AdvancedSearchFragment;
import org.smartregister.commonregistry.CommonRepository;
import org.smartregister.growthmonitoring.repository.WeightRepository;
import org.smartregister.immunization.repository.VaccineRepository;
import org.smartregister.bidan.R;
import org.smartregister.service.AlertService;
import org.smartregister.view.contract.SmartRegisterClient;

/**
* Created by Keyman on 06-Apr-17.
*/
public class AdvancedSearchClientsProvider extends ChildSmartClientsProvider {
//public class AdvancedSearchClientsProvider extends ChildSmartClientsProvider {
public class AdvancedSearchClientsProvider extends ClientsProvider {

// public AdvancedSearchClientsProvider(Context context, View.OnClickListener onClickListener,
// AlertService alertService, VaccineRepository vaccineRepository, WeightRepository weightRepository, CommonRepository commonRepository) {
// super(context, onClickListener, alertService, vaccineRepository, weightRepository, commonRepository);
//
// }

public AdvancedSearchClientsProvider(Context context, View.OnClickListener onClickListener,
AlertService alertService, VaccineRepository vaccineRepository, WeightRepository weightRepository, CommonRepository commonRepository) {
super(context, onClickListener, alertService, vaccineRepository, weightRepository, commonRepository);
AlertService alertService,
CommonRepository commonRepository) {
super(context, onClickListener, alertService, commonRepository);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.smartregister.bidan.provider;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AbsListView;

import org.smartregister.commonregistry.CommonRepository;
import org.smartregister.cursoradapter.SmartRegisterCLientsProviderForCursorAdapter;
import org.smartregister.growthmonitoring.repository.WeightRepository;
import org.smartregister.immunization.repository.VaccineRepository;
import org.smartregister.provider.SmartRegisterClientsProvider;
import org.smartregister.service.AlertService;
import org.smartregister.view.contract.SmartRegisterClient;
import org.smartregister.view.contract.SmartRegisterClients;
import org.smartregister.view.dialog.FilterOption;
import org.smartregister.view.dialog.ServiceModeOption;
import org.smartregister.view.dialog.SortOption;
import org.smartregister.view.viewholder.OnClickFormLauncher;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

/**
* Created by sid-tech on 11/8/17.
*/
public class ClientsProvider implements SmartRegisterCLientsProviderForCursorAdapter {

private final LayoutInflater inflater;
private final Context context;
private final View.OnClickListener onClickListener;
private final AlertService alertService;
private final AbsListView.LayoutParams clientViewLayoutParams;
private final CommonRepository commonRepository;


public ClientsProvider(Context context, View.OnClickListener onClickListener,
AlertService alertService, CommonRepository commonRepository) {
this.onClickListener = onClickListener;
this.context = context;
this.alertService = alertService;
this.commonRepository = commonRepository;
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

clientViewLayoutParams = new AbsListView.LayoutParams(MATCH_PARENT, (int) context.getResources().getDimension(org.smartregister.R.dimen.list_item_height));
}

@Override
public void getView(Cursor cursor, SmartRegisterClient smartRegisterClient, View view) {

}

@Override
public SmartRegisterClients updateClients(FilterOption filterOption, ServiceModeOption serviceModeOption, FilterOption filterOption1, SortOption sortOption) {
return null;
}

@Override
public void onServiceModeSelected(ServiceModeOption serviceModeOption) {

}

@Override
public OnClickFormLauncher newFormLauncher(String s, String s1, String s2) {
return null;
}

@Override
public LayoutInflater inflater() {
return null;
}

@Override
public View inflatelayoutForCursorAdapter() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import util.NetworkUtils;

public class SyncIntentService extends IntentService {
private static final String TAG = SyncIntentService.class.getName();
private static final String EVENTS_SYNC_PATH = "/rest/event/add";
private static final String REPORTS_SYNC_PATH = "/rest/report/add";
private static final String STOCK_Add_PATH = "/rest/stockresource/add/";
Expand Down Expand Up @@ -125,6 +126,7 @@ private FetchStatus sync() {
try {
// Fetch locations
String locations = Utils.getPreference(context, LocationPickerView.PREF_TEAM_LOCATIONS, "");
Log.e(TAG, "sync: "+ locations );

if (StringUtils.isBlank(locations)) {
return FetchStatus.fetchedFailed;
Expand All @@ -133,7 +135,7 @@ private FetchStatus sync() {
pushToServer();
FetchStatus formActionsFetctStatus = pullFormAndActionsFromServer(locations);

pullStockFromServer();
// pullStockFromServer();

return formActionsFetctStatus;
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 627e452

Please sign in to comment.