Search in sources :

Example 1 with IssueLabelAdapter

use of com.gh4a.adapter.IssueLabelAdapter 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

CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 IssueLabelAdapter (com.gh4a.adapter.IssueLabelAdapter)1 DividerItemDecoration (com.gh4a.widget.DividerItemDecoration)1