use of android.support.v7.widget.RecyclerView in project SuperSLiM by TonicArtos.
the class Utils method checkSimpleGridLayout.
public static void checkSimpleGridLayout(RecyclerView recyclerView, int itemHeight, int numColumns) {
final int width = recyclerView.getWidth();
final int gridWidth = width - recyclerView.getPaddingLeft() - recyclerView.getPaddingRight();
final int columnWidth = gridWidth / numColumns;
for (int i = 0; i < 20; i += numColumns) {
final int top = i / numColumns * itemHeight;
for (int j = 0; j < numColumns && i + j < 20; j++) {
View child = recyclerView.getChildAt(i + j);
assertThat(child).hasHeight(itemHeight);
assertThat(child).hasLeft(j * columnWidth + recyclerView.getPaddingLeft());
if (j == numColumns - 1) {
assertThat(child).hasRight(width - recyclerView.getPaddingRight());
} else {
assertThat(child).hasRight(j * columnWidth + columnWidth + recyclerView.getPaddingLeft());
}
assertThat(child).hasTop(top + recyclerView.getPaddingTop());
assertThat(child).hasBottom(top + itemHeight + recyclerView.getPaddingTop());
}
}
}
use of android.support.v7.widget.RecyclerView 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 in project BoomMenu by Nightonke.
the class RecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
assert recyclerView != null;
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new RecyclerViewAdapter());
}
use of android.support.v7.widget.RecyclerView in project CoCoin by Nightonke.
the class AccountBookMonthViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity_account_book_month_view);
userName = (TextView) findViewById(R.id.user_name);
userEmail = (TextView) findViewById(R.id.user_email);
userName.setTypeface(CoCoinUtil.typefaceLatoRegular);
userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
if (user != null) {
userName.setText(user.getUsername());
userEmail.setText(user.getEmail());
}
mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
View view = mViewPager.getRootView();
TextView title = (TextView) view.findViewById(R.id.logo_white);
title.setTypeface(CoCoinUtil.typefaceLatoLight);
title.setText(SettingManager.getInstance().getAccountBookName());
mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
setTitle("");
toolbar = mViewPager.getToolbar();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
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);
}
}
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
mDrawer.setDrawerListener(mDrawerToggle);
View logo = findViewById(R.id.logo_white);
if (logo != null) {
logo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.notifyHeaderChanged();
}
});
}
monthModeAdapter = new MonthViewFragmentAdapter(getSupportFragmentManager());
mViewPager.getViewPager().setOffscreenPageLimit(monthModeAdapter.getCount());
mViewPager.getViewPager().setAdapter(monthModeAdapter);
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
if (monthModeAdapter.getCount() == 1) {
mViewPager.getPagerTitleStrip().setVisibility(View.INVISIBLE);
}
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(RecordManager.TAGS.get(page).getId()), CoCoinUtil.GetTagDrawable(-3));
}
});
recyclerView = (RecyclerView) mDrawer.findViewById(R.id.recycler_view);
drawerMonthViewRecyclerViewAdapter = new DrawerMonthViewRecyclerViewAdapter(mContext);
recyclerView.setAdapter(drawerMonthViewRecyclerViewAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setItemAnimator(new DefaultItemAnimator());
drawerMonthViewRecyclerViewAdapter.SetOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
mViewPager.getViewPager().setCurrentItem(position);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mDrawer.closeDrawers();
}
}, 700);
}
});
profileImage = (CircleImageView) mDrawer.findViewById(R.id.profile_image);
profileImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SettingManager.getInstance().getLoggenOn()) {
CoCoinUtil.showToast(mContext, R.string.change_logo_tip);
} else {
CoCoinUtil.showToast(mContext, R.string.login_tip);
}
}
});
mDemoSlider = (SliderLayout) findViewById(R.id.slider);
HashMap<String, Integer> urls = CoCoinUtil.GetDrawerTopUrl();
for (String name : urls.keySet()) {
CustomSliderView customSliderView = new CustomSliderView(this);
// initialize a SliderLayout
customSliderView.image(urls.get(name)).setScaleType(BaseSliderView.ScaleType.Fit);
mDemoSlider.addSlider(customSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
mDemoSlider.setCustomAnimation(new DescriptionAnimation());
mDemoSlider.setDuration(4000);
mDemoSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
loadLogo();
}
use of android.support.v7.widget.RecyclerView 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