Skip to content

Commit

Permalink
Modified demoApp not showing LayoutInfo at each use case
Browse files Browse the repository at this point in the history
  • Loading branch information
davideas committed Apr 25, 2017
1 parent 2d5051c commit 43800cc
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void addUserLearnedSelection(boolean scrollToPosition) {
final ScrollableULSItem item = new ScrollableULSItem("ULS");
item.setTitle(mRecyclerView.getContext().getString(R.string.uls_title));
item.setSubtitle(mRecyclerView.getContext().getString(R.string.uls_subtitle));
addScrollableHeaderWithDelay(item, 1000L, false);
addScrollableHeaderWithDelay(item, 1000L, scrollToPosition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void showNewLayoutInfo(final MenuItem item) {
public void run() {
item.setEnabled(true);
}
}, 1500L);
}, 1000L);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,24 @@
import android.databinding.ObservableArrayList;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import eu.davidea.fastscroller.FastScroller;
import eu.davidea.flexibleadapter.SelectableAdapter;
import eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager;
import eu.davidea.flexibleadapter.databinding.BindingFlexibleAdapter;
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
import eu.davidea.flipview.FlipView;
import eu.davidea.samples.flexibleadapter.MainActivity;
import eu.davidea.samples.flexibleadapter.R;
import eu.davidea.samples.flexibleadapter.animators.GarageDoorItemAnimator;
import eu.davidea.samples.flexibleadapter.items.HeaderItem;
import eu.davidea.samples.flexibleadapter.services.DatabaseConfiguration;
import eu.davidea.samples.flexibleadapter.services.DatabaseService;
import eu.davidea.utils.Utils;

/**
* A fragment representing a list of Items.
Expand Down Expand Up @@ -89,7 +84,6 @@ public void onActivityCreated(Bundle savedInstanceState) {
@SuppressWarnings({"ConstantConditions", "NullableProblems"})
private void initializeRecyclerView(Bundle savedInstanceState) {
//Initialize Adapter and RecyclerView
//ExampleAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
mAdapter = new BindingFlexibleAdapter<>(getActivity(), true);
//Experimenting NEW features (v5.0.0)
mAdapter.setNotifyChangeOfUnfilteredItems(true)//We have highlighted text while filtering, so let's enable this feature to be consistent with the active filter
Expand All @@ -103,8 +97,8 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
mRecyclerView.setItemAnimator(new GarageDoorItemAnimator());

//Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
mAdapter.setFastScroller((FastScroller) getView().findViewById(R.id.fast_scroller),
Utils.getColorAccent(getActivity()), (MainActivity) getActivity());
FastScroller fastScroller = (FastScroller) getView().findViewById(R.id.fast_scroller);
mAdapter.setFastScroller(fastScroller);
mAdapter.setLongPressDragEnabled(true)
.setHandleDragEnabled(true)
.setSwipeEnabled(true)
Expand All @@ -129,33 +123,6 @@ public void performFabAction() {
++fabClickedTimes;
}

@Override
public void showNewLayoutInfo(MenuItem item) {
super.showNewLayoutInfo(item);
}

@Override
protected GridLayoutManager createNewGridLayoutManager() {
GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
//NOTE: If you use simple integer to identify the ViewType,
//here, you should use them and not Layout integers
switch (mAdapter.getItemViewType(position)) {
case R.layout.recycler_scrollable_layout_item:
case R.layout.recycler_scrollable_uls_item:
case R.layout.recycler_header_item:
case R.layout.recycler_expandable_header_item:
return mColumnCount;
default:
return 1;
}
}
});
return gridLayoutManager;
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
Expand All @@ -167,7 +134,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);

menu.findItem(R.id.action_list_type).setVisible(false);
menu.findItem(R.id.action_auto_collapse).setVisible(false);
menu.findItem(R.id.action_expand_collapse_all).setVisible(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
.setEndlessScrollListener(this, mProgressItem)
.setTopEndless(true);

// Add 1 Scrollable Header and 1 Footer items
mAdapter.showLayoutInfo(savedInstanceState == null);
// Add 1 Footer items
mAdapter.addScrollableFooter();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);

// Add 2 Scrollable Headers
// Add 1 Scrollable Header
mAdapter.addUserLearnedSelection(savedInstanceState == null);
mAdapter.showLayoutInfo(savedInstanceState == null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);

// Add 1 Scrollable Header
mAdapter.showLayoutInfo(savedInstanceState == null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);

// Add 3 Scrollable Headers and 1 Footer
// Add 2 Scrollable Headers and 1 Footer
mAdapter.addUserLearnedSelection(savedInstanceState == null);
mAdapter.addScrollableHeaderWithDelay(new ScrollableUseCaseItem(
getString(R.string.headers_sections_use_case_title),
getString(R.string.headers_sections_use_case_description)), 900L, false);
mAdapter.showLayoutInfo(savedInstanceState == null);
mAdapter.addScrollableFooter();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public void run() {
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);

// Add 2 Scrollable Headers
mAdapter.showLayoutInfo(savedInstanceState == null);
// Add 1 Scrollable Header
mAdapter.addScrollableHeader(new ScrollableUseCaseItem(
getString(R.string.overall_use_case_title),
getString(R.string.overall_use_case_description)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ public void run() {
);
}

@Override
public void showNewLayoutInfo(MenuItem item) {
super.showNewLayoutInfo(item);
mAdapter.showLayoutInfo(false);
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_selection_modes, menu);
Expand Down

0 comments on commit 43800cc

Please sign in to comment.