Search in sources :

Example 1 with DividerItemDecoration

use of com.gh4a.widget.DividerItemDecoration in project gh4a by slapperwan.

the class LoadingListFragmentBase method onCreateContentView.

@Override
protected View onCreateContentView(LayoutInflater inflater, ViewGroup parent) {
    View view = inflater.inflate(R.layout.list_fragment_content, parent, false);
    mEmptyViewContainer = view.findViewById(R.id.empty_view_container);
    TextView emptyView = view.findViewById(android.R.id.empty);
    int emptyTextResId = getEmptyTextResId();
    if (emptyTextResId != 0) {
        emptyView.setText(emptyTextResId);
    }
    mLayoutManager = new LinearLayoutManager(view.getContext());
    mRecyclerView = view.findViewById(R.id.list);
    mRecyclerView.setLayoutManager(mLayoutManager);
    onRecyclerViewInflated(mRecyclerView, inflater);
    if (hasDividers()) {
        mRecyclerView.addItemDecoration(new DividerItemDecoration(view.getContext()));
    }
    if (!hasCards()) {
        mRecyclerView.setBackgroundResource(UiUtils.resolveDrawable(getActivity(), R.attr.listBackground));
    }
    mFastScroller = view.findViewById(R.id.fast_scroller);
    mFastScroller.attachRecyclerView(mRecyclerView);
    mFastScroller.setVisibility(View.VISIBLE);
    mFastScroller.setOnHandleTouchListener((v, event) -> {
        switch(event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
                getBaseActivity().setRightDrawerLockedClosed(true);
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                getBaseActivity().setRightDrawerLockedClosed(false);
                break;
        }
        return false;
    });
    return view;
}
Also used : TextView(android.widget.TextView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.gh4a.widget.DividerItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 2 with DividerItemDecoration

use of com.gh4a.widget.DividerItemDecoration in project gh4a by slapperwan.

the class IssueLabelListActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.generic_list);
    setContentShown(false);
    mAdapter = new IssueLabelAdapter(this);
    mAdapter.setOnItemClickListener(this);
    RecyclerView recyclerView = findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DividerItemDecoration(this));
    recyclerView.setTag(R.id.FloatingActionButtonScrollEnabled, new Object());
    recyclerView.setAdapter(mAdapter);
    CoordinatorLayout rootLayout = getRootLayout();
    mFab = (FloatingActionButton) getLayoutInflater().inflate(R.layout.add_fab, rootLayout, false);
    mFab.setOnClickListener(this);
    rootLayout.addView(mFab);
    updateFabVisibility();
    loadLabels(false);
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(STATE_KEY_ADDED_LABEL)) {
            mAddedLabel = savedInstanceState.getParcelable(STATE_KEY_EDITING_LABEL);
            mAdapter.add(mAddedLabel);
            startEditing(mAddedLabel);
        } else if (savedInstanceState.containsKey(STATE_KEY_EDITING_LABEL)) {
            IssueLabelAdapter.EditableLabel label = savedInstanceState.getParcelable(STATE_KEY_EDITING_LABEL);
            int count = mAdapter.getCount();
            for (int i = 0; i < count; i++) {
                IssueLabelAdapter.EditableLabel item = mAdapter.getItem(i);
                if (item.name().equals(label.name())) {
                    item.editedName = label.editedName;
                    item.editedColor = label.editedColor;
                    startEditing(item);
                    break;
                }
            }
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) IssueLabelAdapter(com.gh4a.adapter.IssueLabelAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.gh4a.widget.DividerItemDecoration)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 DividerItemDecoration (com.gh4a.widget.DividerItemDecoration)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 NestedScrollView (android.support.v4.widget.NestedScrollView)1 View (android.view.View)1 TextView (android.widget.TextView)1 IssueLabelAdapter (com.gh4a.adapter.IssueLabelAdapter)1