use of android.support.v7.widget.StaggeredGridLayoutManager in project RxJavaSamples by rengwuxian.
the class MapFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_map, container, false);
ButterKnife.bind(this, view);
gridRv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
gridRv.setAdapter(adapter);
swipeRefreshLayout.setColorSchemeColors(Color.BLUE, Color.GREEN, Color.RED, Color.YELLOW);
swipeRefreshLayout.setEnabled(false);
return view;
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project vlayout by alibaba.
the class TestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText position = (EditText) findViewById(R.id.position);
if (!TextUtils.isEmpty(position.getText())) {
try {
int pos = Integer.parseInt(position.getText().toString());
recyclerView.scrollToPosition(pos);
} catch (Exception e) {
Log.e("VlayoutActivity", e.getMessage(), e);
}
}
}
});
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(4, 4, 4, 4);
}
});
recyclerView.setAdapter(new RecyclerView.Adapter() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// TextView view = (TextView) LayoutInflater.from(TestActivity.this).inflate(R.layout.item, parent, false);
// FrameLayout frameLayout = new FrameLayout(TestActivity.this);
FrameLayout frameLayout = (FrameLayout) LayoutInflater.from(TestActivity.this).inflate(R.layout.item, parent, false);
;
// frameLayout.addView(view);
return new MainViewHolder(frameLayout);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
layoutParams.height = (int) (200 + (position % 15) * 10);
holder.itemView.findViewById(R.id.title).setLayoutParams(layoutParams);
if (position == 30) {
StaggeredGridLayoutManager.LayoutParams lp = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
lp.setFullSpan(true);
holder.itemView.setLayoutParams(lp);
} else {
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
if (lp instanceof StaggeredGridLayoutManager.LayoutParams) {
((StaggeredGridLayoutManager.LayoutParams) lp).setFullSpan(false);
}
}
((TextView) holder.itemView.findViewById(R.id.title)).setText(Integer.toString(position));
}
@Override
public int getItemCount() {
return 60;
}
});
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project TwinklingRefreshLayout by lcodecorex.
the class ScrollingUtil method isRecyclerViewToTop.
public static boolean isRecyclerViewToTop(RecyclerView recyclerView) {
if (recyclerView != null) {
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager == null) {
return true;
}
if (manager.getItemCount() == 0) {
return true;
}
if (manager instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
int firstChildTop = 0;
if (recyclerView.getChildCount() > 0) {
// 处理item高度超过一屏幕时的情况
View firstVisibleChild = recyclerView.getChildAt(0);
if (firstVisibleChild != null && firstVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) {
if (android.os.Build.VERSION.SDK_INT < 14) {
return !(ViewCompat.canScrollVertically(recyclerView, -1) || recyclerView.getScrollY() > 0);
} else {
return !ViewCompat.canScrollVertically(recyclerView, -1);
}
}
// 如果RecyclerView的子控件数量不为0,获取第一个子控件的top
// 解决item的topMargin不为0时不能触发下拉刷新
View firstChild = recyclerView.getChildAt(0);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) firstChild.getLayoutParams();
firstChildTop = firstChild.getTop() - layoutParams.topMargin - getRecyclerViewItemTopInset(layoutParams) - recyclerView.getPaddingTop();
}
if (layoutManager.findFirstCompletelyVisibleItemPosition() < 1 && firstChildTop == 0) {
return true;
}
} else if (manager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager;
int[] out = layoutManager.findFirstCompletelyVisibleItemPositions(null);
if (out[0] < 1) {
return true;
}
}
}
return false;
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project VirtualApp by asLody.
the class HomeActivity method initLaunchpad.
private void initLaunchpad() {
mLauncherView.setHasFixedSize(true);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL);
mLauncherView.setLayoutManager(layoutManager);
mLaunchpadAdapter = new LaunchpadAdapter(this);
SmartRecyclerAdapter wrap = new SmartRecyclerAdapter(mLaunchpadAdapter);
View footer = new View(this);
footer.setLayoutParams(new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, VUiKit.dpToPx(this, 60)));
wrap.setFooterView(footer);
mLauncherView.setAdapter(wrap);
mLauncherView.addItemDecoration(new ItemOffsetDecoration(this, R.dimen.desktop_divider));
ItemTouchHelper touchHelper = new ItemTouchHelper(new LauncherTouchCallback());
touchHelper.attachToRecyclerView(mLauncherView);
mLaunchpadAdapter.setAppClickListener((pos, data) -> {
if (!data.isLoading()) {
mLaunchpadAdapter.notifyItemChanged(pos);
mPresenter.launchApp(data);
}
});
}
use of android.support.v7.widget.StaggeredGridLayoutManager in project BGARefreshLayout-Android by bingoogolapple.
the class RefreshStaggeredRecyclerViewFragment method processLogic.
@Override
protected void processLogic(Bundle savedInstanceState) {
mRefreshLayout.setCustomHeaderView(DataEngine.getCustomHeaderView(mApp), true);
mRefreshLayout.setRefreshViewHolder(new BGANormalRefreshViewHolder(mApp, true));
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
mDataRv.setLayoutManager(layoutManager);
mDataRv.setAdapter(mAdapter);
}
Aggregations