Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.

When device orientation is changed no changes will happen #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;

import static org.odk.share.views.ui.instance.fragment.ReviewedInstancesFragment.MODE;

Expand Down Expand Up @@ -73,7 +74,7 @@ public class BlankFormsFragment extends FormListFragment implements LoaderManage

private FormsAdapter formAdapter;
private LinkedHashSet<Long> selectedForms;

private static final String SELECTED_FORMS = "SelectedForms";

public BlankFormsFragment() {
}
Expand All @@ -90,6 +91,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
llm.setOrientation(RecyclerView.VERTICAL);
recyclerView.setLayoutManager(llm);
addListItemDivider();
if (savedInstanceState != null && savedInstanceState.containsKey(SELECTED_FORMS)) {
selectedForms = (LinkedHashSet<Long>) savedInstanceState.getSerializable(SELECTED_FORMS);
}
return view;
}

Expand Down Expand Up @@ -121,6 +125,12 @@ public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor cursor) {
} else {
setEmptyViewVisibility(0);
}
try {
sendButton.setEnabled(selectedForms.size() > 0);
toggleButtonLabel();
} catch (Exception e) {
Timber.e(e);
}
}


Expand All @@ -140,10 +150,16 @@ public void onItemClick(BaseCursorViewHolder holder, int position) {
}

sendButton.setEnabled(selectedForms.size() > 0);

toggleButtonLabel();
}

@Override
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);

outState.putSerializable(SELECTED_FORMS, selectedForms);
}

private void setEmptyViewVisibility(int len) {
if (len > 0) {
recyclerView.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;

import static org.odk.share.views.ui.instance.fragment.ReviewedInstancesFragment.MODE;

Expand All @@ -46,6 +47,7 @@ public class FilledFormsFragment extends InstanceListFragment implements LoaderM
public static final String INSTANCE_IDS = "instance_ids";
private static final String INSTANCE_LIST_ACTIVITY_SORTING_ORDER = "instanceListActivitySortingOrder";
private static final int INSTANCE_LOADER = 1;
private static final String SELECTED_INSTANCES = "selectedInstances";

@BindView(R.id.recyclerview)
RecyclerView recyclerView;
Expand Down Expand Up @@ -80,6 +82,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
llm.setOrientation(RecyclerView.VERTICAL);
recyclerView.setLayoutManager(llm);
addListItemDivider();
if (savedInstanceState != null && savedInstanceState.containsKey(SELECTED_INSTANCES)) {
selectedInstances = (LinkedHashSet<Long>) savedInstanceState.getSerializable(SELECTED_INSTANCES);
}
return view;
}

Expand Down Expand Up @@ -111,6 +116,21 @@ public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor cursor) {
} else {
setEmptyViewVisibility(0);
}

try {
sendButton.setEnabled(selectedInstances.size() > 0);
toggleButtonLabel();
} catch (Exception e) {
Timber.e(e);
}
}


@Override
public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(outState);

outState.putSerializable(SELECTED_INSTANCES, selectedInstances);
}


Expand Down