use of android.support.v7.widget.RecyclerView.Adapter in project SuperSLiM by TonicArtos.
the class LinearLayoutTests method test_overscrollBeforeStartAfterEnd.
@Test
public void test_overscrollBeforeStartAfterEnd() throws Exception {
final int numItems = 1;
final int dy = 100;
RecyclerView.Adapter adapter;
int[] layoutPadding;
adapter = new TestAdapterBuilder().addLinearSection(numItems, Utils.RV_WIDTH, Utils.RV_HEIGHT + dy * 2, null).build(mActivity);
layoutPadding = new int[] { 0, 0, 0, 0 };
Utils.doOverscrollTest(new int[] { 0, -dy }, layoutPadding, false, adapter, mLayoutManager, mRecyclerView);
}
use of android.support.v7.widget.RecyclerView.Adapter in project SuperSLiM by TonicArtos.
the class LinearLayoutTests method test_overscrollAfterStartBeforeEnd.
@Test
public void test_overscrollAfterStartBeforeEnd() throws Exception {
final int numItems = 1;
final int dy = 100;
RecyclerView.Adapter adapter;
int[] layoutPadding;
adapter = new TestAdapterBuilder().addLinearSection(numItems, Utils.RV_WIDTH, Utils.RV_HEIGHT - dy * 2, null).build(mActivity);
layoutPadding = new int[] { 0, 0, 0, 0 };
Utils.doOverscrollTest(new int[] { 0, dy }, layoutPadding, true, adapter, mLayoutManager, mRecyclerView);
}
use of android.support.v7.widget.RecyclerView.Adapter in project SuperSLiM by TonicArtos.
the class Utils method doOverscrollTest.
/**
* Perform an overscroll test.
*
* @param offset Offset to apply to simulate overscroll; dx, dy.
* @param padding Padding values; l, t, r, b.
* @param expected Expected bounds; l, t, r, b.
* @param adapter Adapter to use.
* @param mLayoutManager Layout manager to use.
* @param mRecyclerView RecyclerView to use.
*/
public static void doOverscrollTest(int[] offset, int[] padding, boolean expected, RecyclerView.Adapter adapter, LayoutManagerWrapper mLayoutManager, RecyclerView mRecyclerView) throws Exception {
setupLayoutTest(padding, adapter, mLayoutManager, mRecyclerView);
// Shift so that bounds are after start and end.
adjustPosition(mRecyclerView, offset[0], offset[1]);
Method isOverscrolled = LayoutManager.class.getDeclaredMethod("isOverscrolled", LayoutState.class);
isOverscrolled.setAccessible(true);
LayoutState state = mock(LayoutState.class);
RecyclerView.State mRecyclerViewState = mock(RecyclerView.State.class);
when(state.getRecyclerState()).thenReturn(mRecyclerViewState);
when(mRecyclerViewState.getItemCount()).thenReturn(adapter.getItemCount());
boolean result = (Boolean) isOverscrolled.invoke(mLayoutManager, state);
assertEquals(expected, result);
}
use of android.support.v7.widget.RecyclerView.Adapter in project CoCoin by Nightonke.
the class HelpActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity_help);
mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.getInstance().typefaceLatoLight, Typeface.NORMAL);
mViewPager.getPagerTitleStrip().setAllCaps(false);
mViewPager.getPagerTitleStrip().setUnderlineColor(Color.parseColor("#00000000"));
mViewPager.getPagerTitleStrip().setIndicatorColor(Color.parseColor("#00000000"));
mViewPager.getPagerTitleStrip().setUnderlineHeight(0);
mViewPager.getPagerTitleStrip().setIndicatorHeight(0);
setTitle("");
toolbar = mViewPager.getToolbar();
if (toolbar != null) {
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
}
View logo = findViewById(R.id.logo_white);
if (logo != null) {
logo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.notifyHeaderChanged();
}
});
}
adapter = new HelpFragmentAdapter(getSupportFragmentManager(), 0);
mViewPager.getViewPager().setAdapter(adapter);
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
mViewPager.getPagerTitleStrip().invalidate();
mViewPager.getViewPager().setOffscreenPageLimit(2);
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
return HeaderDesign.fromColorAndDrawable(ContextCompat.getColor(CoCoinApplication.getAppContext(), R.color.my_blue), ContextCompat.getDrawable(CoCoinApplication.getAppContext(), R.drawable.cocoin_blue_bg));
}
});
}
use of android.support.v7.widget.RecyclerView.Adapter in project CoCoin by Nightonke.
the class TodayViewFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
layoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setHasFixedSize(true);
Calendar now = Calendar.getInstance();
Calendar leftRange;
Calendar rightRange;
RecordManager recordManager = RecordManager.getInstance(mContext.getApplicationContext());
int start = -1;
int end = 0;
switch(position) {
case TODAY:
leftRange = CoCoinUtil.GetTodayLeftRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
}
if (start == -1) {
start = i;
}
}
break;
case YESTERDAY:
leftRange = CoCoinUtil.GetYesterdayLeftRange(now);
rightRange = CoCoinUtil.GetYesterdayRightRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
} else if (!recordManager.RECORDS.get(i).getCalendar().after(rightRange)) {
if (start == -1) {
start = i;
}
}
}
break;
case THIS_WEEK:
leftRange = CoCoinUtil.GetThisWeekLeftRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
}
if (start == -1) {
start = i;
}
}
break;
case LAST_WEEK:
leftRange = CoCoinUtil.GetLastWeekLeftRange(now);
rightRange = CoCoinUtil.GetLastWeekRightRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
} else if (recordManager.RECORDS.get(i).getCalendar().before(rightRange)) {
if (start == -1) {
start = i;
}
}
}
break;
case THIS_MONTH:
leftRange = CoCoinUtil.GetThisMonthLeftRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
}
if (start == -1) {
start = i;
}
}
break;
case LAST_MONTH:
leftRange = CoCoinUtil.GetLastMonthLeftRange(now);
rightRange = CoCoinUtil.GetLastMonthRightRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
} else if (recordManager.RECORDS.get(i).getCalendar().before(rightRange)) {
if (start == -1) {
start = i;
}
}
}
break;
case THIS_YEAR:
leftRange = CoCoinUtil.GetThisYearLeftRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
}
if (start == -1) {
start = i;
}
}
break;
case LAST_YEAR:
leftRange = CoCoinUtil.GetLastYearLeftRange(now);
rightRange = CoCoinUtil.GetLastYearRightRange(now);
for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
end = i + 1;
break;
} else if (recordManager.RECORDS.get(i).getCalendar().before(rightRange)) {
if (start == -1) {
start = i;
}
}
}
break;
}
adapter = new TodayViewRecyclerViewAdapter(start, end, mContext, position);
mAdapter = new RecyclerViewMaterialAdapter(adapter);
mRecyclerView.setAdapter(mAdapter);
MaterialViewPagerHelper.registerRecyclerView(getActivity(), mRecyclerView, null);
}
Aggregations