use of androidx.recyclerview.widget.DividerItemDecoration in project collect by opendatakit.
the class FormHierarchyActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hierarchy_layout);
Collect.getInstance().getComponent().inject(this);
recyclerView = findViewById(R.id.list);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
TextView emptyView = findViewById(android.R.id.empty);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FormController formController = Collect.getInstance().getFormController();
// https://github.com/getodk/collect/issues/998
if (formController == null) {
finish();
Timber.w("FormController is null");
return;
}
formEntryViewModel = new ViewModelProvider(this, formEntryViewModelFactory).get(FormEntryViewModel.class);
formEntryViewModel.formLoaded(Collect.getInstance().getFormController());
startIndex = formController.getFormIndex();
setTitle(formController.getFormTitle());
groupPathTextView = findViewById(R.id.pathtext);
jumpBeginningButton = findViewById(R.id.jumpBeginningButton);
jumpEndButton = findViewById(R.id.jumpEndButton);
configureButtons(formController);
restoreInstanceState(savedInstanceState);
refreshView();
// TODO: avoid another iteration through all displayed elements
if (recyclerView != null && recyclerView.getAdapter() != null && recyclerView.getAdapter().getItemCount() > 0) {
emptyView.setVisibility(View.GONE);
recyclerView.post(() -> {
int position = 0;
// startIndex which can either represent a question or a field list.
for (HierarchyElement hierarchyElement : elementsToDisplay) {
FormIndex indexToCheck = hierarchyElement.getFormIndex();
if (startIndex.equals(indexToCheck) || (formController.indexIsInFieldList(startIndex) && indexToCheck.toString().startsWith(startIndex.toString()))) {
position = elementsToDisplay.indexOf(hierarchyElement);
break;
}
}
((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, 0);
});
}
}
use of androidx.recyclerview.widget.DividerItemDecoration in project sdk_demo_app_android by zendesk.
the class DateFragment method onStart.
@Override
public void onStart() {
super.onStart();
storage = Global.getStorage(getActivity());
dateAdapter = new DateAdapter(new OnDateClickListener() {
@Override
public void onClick(DateModel item) {
EditDateActivity.start(getActivity(), Long.toString(item.getDateInMillis()));
}
@Override
public void onLongClick(DateModel item) {
showRemoveDialog(item);
}
});
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), 0));
recyclerView.setAdapter(dateAdapter);
}
use of androidx.recyclerview.widget.DividerItemDecoration in project android_packages_apps_Settings by omnirom.
the class WifiCallingDisclaimerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.wfc_disclaimer_fragment, container, false);
mAgreeButton = view.findViewById(R.id.agree_button);
mAgreeButton.setOnClickListener(this);
mDisagreeButton = view.findViewById(R.id.disagree_button);
mDisagreeButton.setOnClickListener(this);
final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.disclaimer_item_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(new DisclaimerItemListAdapter(mDisclaimerItemList));
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (!recyclerView.canScrollVertically(1)) {
mScrollToBottom = true;
updateButtonState();
recyclerView.removeOnScrollListener(this);
}
}
});
return view;
}
use of androidx.recyclerview.widget.DividerItemDecoration in project openScale by oliexdev.
the class TableFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
tableView = inflater.inflate(R.layout.fragment_table, container, false);
tableHeaderView = tableView.findViewById(R.id.tableHeaderView);
recyclerView = tableView.findViewById(R.id.tableDataView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()));
adapter = new MeasurementsAdapter();
recyclerView.setAdapter(adapter);
measurementViews = MeasurementView.getMeasurementList(getContext(), MeasurementView.DateTimeOrder.FIRST);
for (MeasurementView measurement : measurementViews) {
measurement.setUpdateViews(false);
}
OpenScale.getInstance().getScaleMeasurementsLiveData().observe(getViewLifecycleOwner(), new Observer<List<ScaleMeasurement>>() {
@Override
public void onChanged(List<ScaleMeasurement> scaleMeasurements) {
updateOnView(scaleMeasurements);
}
});
OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
requireActivity().finish();
}
};
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), onBackPressedCallback);
return tableView;
}
use of androidx.recyclerview.widget.DividerItemDecoration in project MiMangaNu by raulhaag.
the class ServerFilteredNavigationFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedState) {
super.onActivityCreated(savedState);
SharedPreferences pm = PreferenceManager.getDefaultSharedPreferences(getActivity());
colors = ThemeColors.getColors(pm);
ActionBar mActBar = getActivity().getActionBar();
if (mActBar != null) {
mActBar.setTitle(getResources().getString(R.string.listaen) + " " + serverBase.getServerName());
mActBar.setDisplayHomeAsUpEnabled(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getActivity().getWindow();
window.setNavigationBarColor(colors[0]);
window.setStatusBarColor(colors[4]);
}
serverBase = ServerBase.getServer(serverID, getContext());
if (filters == null) {
filters = serverBase.getBasicFilter();
}
recyclerViewGrid = getView().findViewById(R.id.grilla);
if (serverBase.getFilteredType() == ServerBase.FilteredType.TEXT) {
DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
Drawable sd = ContextCompat.getDrawable(getContext(), R.drawable.divider);
sd.setColorFilter(colors[0], PorterDuff.Mode.DARKEN);
divider.setDrawable(sd);
recyclerViewGrid.addItemDecoration(divider);
}
loading = getView().findViewById(R.id.loading);
int columnSize = Integer.parseInt(pm.getString("grid_columns", "-1"));
if (columnSize == -1 || pm.getBoolean("grid_columns_automatic_detection", true))
columnSize = Util.getInstance().getGridColumnSizeFromWidth(getActivity());
if (serverBase.getFilteredType() == ServerBase.FilteredType.TEXT)
columnSize = 1;
recyclerViewGrid.setLayoutManager(new GridLayoutManager(getActivity(), columnSize));
if (mAdapter != null) {
mAdapter.setOnCreateContextMenuListener(this);
recyclerViewGrid.setAdapter(mAdapter);
recyclerViewGrid.getLayoutManager().scrollToPosition(firstVisibleItem);
loading.setVisibility(View.INVISIBLE);
} else {
loadLastTask = (LoadLastTask) new LoadLastTask().execute(req_page);
}
}
Aggregations