Search in sources :

Example 1 with TypeListActivityPresenter

use of io.jawg.osmcontributor.ui.presenters.TypeListActivityPresenter in project osm-contributor by jawg.

the class TypeListActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_type_list);
    ButterKnife.bind(this);
    ((OsmTemplateApplication) getApplication()).getOsmTemplateComponent().inject(this);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    presenter = new TypeListActivityPresenter(this, savedInstanceState);
    typesAdapter = new PoiTypeAdapter(new ArrayList<PoiType>(), bitmapHandler);
    typesAdapter.setPoiTypeAdapterListener(presenter.getPoiTypeAdapterListener());
    recyclerTypes.setAdapter(typesAdapter);
    recyclerTypes.setLayoutManager(new LinearLayoutManager(this));
    ItemTouchHelper.Callback callback = new SwipeItemTouchHelperCallback(typesAdapter);
    ItemTouchHelper swipeItemTouchHelper = new ItemTouchHelper(callback);
    swipeItemTouchHelper.attachToRecyclerView(recyclerTypes);
    tagsAdapter = new PoiTypeTagAdapter(new ArrayList<PoiTypeTag>());
    tagsAdapter.setPoiTypeTagAdapterListener(presenter.getPoiTypeTagAdapterListener());
    tagsAdapter.setOnStartDragListener(this);
    recyclerTags.setAdapter(tagsAdapter);
    recyclerTags.setLayoutManager(new LinearLayoutManager(this));
    ItemTouchHelper.Callback dragSwipeCallback = new DragSwipeItemTouchHelperCallback(tagsAdapter);
    dragSwipeItemTouchHelper = new ItemTouchHelper(dragSwipeCallback);
    dragSwipeItemTouchHelper.attachToRecyclerView(recyclerTags);
    listSwitcher.prepareViews(showingTypes);
    if (savedInstanceState != null) {
        filterConstraint = savedInstanceState.getString(FILTER_CONSTRAINT);
    }
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) PoiTypeAdapter(io.jawg.osmcontributor.ui.adapters.PoiTypeAdapter) PoiTypeTagAdapter(io.jawg.osmcontributor.ui.adapters.PoiTypeTagAdapter) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DragSwipeItemTouchHelperCallback(io.jawg.osmcontributor.utils.helper.DragSwipeItemTouchHelperCallback) SwipeItemTouchHelperCallback(io.jawg.osmcontributor.utils.helper.SwipeItemTouchHelperCallback) DragSwipeItemTouchHelperCallback(io.jawg.osmcontributor.utils.helper.DragSwipeItemTouchHelperCallback) ActionBar(android.support.v7.app.ActionBar) TypeListActivityPresenter(io.jawg.osmcontributor.ui.presenters.TypeListActivityPresenter)

Aggregations

ActionBar (android.support.v7.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 PoiTypeAdapter (io.jawg.osmcontributor.ui.adapters.PoiTypeAdapter)1 PoiTypeTagAdapter (io.jawg.osmcontributor.ui.adapters.PoiTypeTagAdapter)1 TypeListActivityPresenter (io.jawg.osmcontributor.ui.presenters.TypeListActivityPresenter)1 DragSwipeItemTouchHelperCallback (io.jawg.osmcontributor.utils.helper.DragSwipeItemTouchHelperCallback)1 SwipeItemTouchHelperCallback (io.jawg.osmcontributor.utils.helper.SwipeItemTouchHelperCallback)1 ArrayList (java.util.ArrayList)1