Search in sources :

Example 6 with DividerItemDecoration

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);
        });
    }
}
Also used : FormController(org.odk.collect.android.javarosawrapper.FormController) HierarchyElement(org.odk.collect.android.logic.HierarchyElement) FormIndex(org.javarosa.core.model.FormIndex) TextView(android.widget.TextView) FormEntryViewModel(org.odk.collect.android.formentry.FormEntryViewModel) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 7 with DividerItemDecoration

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);
}
Also used : DateModel(com.zendesk.rememberthedate.model.DateModel) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration)

Example 8 with DividerItemDecoration

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;
}
Also used : OnScrollListener(androidx.recyclerview.widget.RecyclerView.OnScrollListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 9 with DividerItemDecoration

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;
}
Also used : UserMeasurementView(com.health.openscale.gui.measurement.UserMeasurementView) MeasurementView(com.health.openscale.gui.measurement.MeasurementView) OnBackPressedCallback(androidx.activity.OnBackPressedCallback) ScaleMeasurement(com.health.openscale.core.datatypes.ScaleMeasurement) ArrayList(java.util.ArrayList) List(java.util.List) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration)

Example 10 with DividerItemDecoration

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);
    }
}
Also used : Window(android.view.Window) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SharedPreferences(android.content.SharedPreferences) Drawable(android.graphics.drawable.Drawable) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) ActionBar(android.app.ActionBar)

Aggregations

DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)26 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)20 RecyclerView (androidx.recyclerview.widget.RecyclerView)15 View (android.view.View)12 TextView (android.widget.TextView)7 Button (android.widget.Button)6 Context (android.content.Context)5 ArrayList (java.util.ArrayList)5 Activity (android.app.Activity)4 Bundle (android.os.Bundle)4 ProgressBar (android.widget.ProgressBar)4 Nullable (androidx.annotation.Nullable)4 List (java.util.List)4 SuppressLint (android.annotation.SuppressLint)3 Log (android.util.Log)3 LayoutInflater (android.view.LayoutInflater)3 MenuItem (android.view.MenuItem)3 ViewGroup (android.view.ViewGroup)3 RelativeLayout (android.widget.RelativeLayout)3 NonNull (androidx.annotation.NonNull)3