use of org.odk.collect.android.activities.CollectAbstractActivity in project collect by opendatakit.
the class AppListFragment method setupBottomSheet.
private void setupBottomSheet() {
CollectAbstractActivity activity = (CollectAbstractActivity) getActivity();
if (activity == null) {
Timber.e("Activity is null");
return;
}
bottomSheetDialog = new BottomSheetDialog(activity);
View sheetView = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null);
final RecyclerView recyclerView = sheetView.findViewById(R.id.recyclerView);
final SortDialogAdapter adapter = new SortDialogAdapter(getActivity(), recyclerView, sortingOptions, getSelectedSortingOrder(), new RecyclerViewClickListener() {
@Override
public void onItemClicked(SortDialogAdapter.ViewHolder holder, int position) {
holder.updateItemColor(selectedSortingOrder);
performSelectedSearch(position);
bottomSheetDialog.dismiss();
}
});
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
bottomSheetDialog.setContentView(sheetView);
}
use of org.odk.collect.android.activities.CollectAbstractActivity in project collect by opendatakit.
the class ResetDialogPreferenceFragmentCompat method handleResult.
private void handleResult(final List<Integer> resetActions, List<Integer> failedResetActions) {
final StringBuilder resultMessage = new StringBuilder();
for (int action : resetActions) {
switch(action) {
case RESET_PREFERENCES:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_settings_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_settings_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_INSTANCES:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_saved_forms_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_saved_forms_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_FORMS:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_blank_forms_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_blank_forms_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_CACHE:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_cache_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_cache_result), context.getString(R.string.success)));
}
break;
case ProjectResetter.ResetAction.RESET_LAYERS:
if (failedResetActions.contains(action)) {
resultMessage.append(String.format(context.getString(R.string.reset_layers_result), context.getString(R.string.error_occured)));
} else {
resultMessage.append(String.format(context.getString(R.string.reset_layers_result), context.getString(R.string.success)));
}
break;
}
if (resetActions.indexOf(action) < resetActions.size() - 1) {
resultMessage.append("\n\n");
}
}
if (!((CollectAbstractActivity) context).isInstanceStateSaved()) {
((CollectAbstractActivity) context).runOnUiThread(() -> {
if (resetActions.contains(RESET_PREFERENCES)) {
((CollectAbstractActivity) context).recreate();
}
ResetSettingsResultDialog resetSettingsResultDialog = ResetSettingsResultDialog.newInstance(String.valueOf(resultMessage));
try {
resetSettingsResultDialog.show(((CollectAbstractActivity) context).getSupportFragmentManager(), RESET_SETTINGS_RESULT_DIALOG_TAG);
} catch (ClassCastException e) {
Timber.i(e);
}
});
}
context = null;
}
Aggregations