当前位置: 首页>>代码示例>>Java>>正文


Java StaggeredGridLayoutManager类代码示例

本文整理汇总了Java中android.support.v7.widget.StaggeredGridLayoutManager的典型用法代码示例。如果您正苦于以下问题:Java StaggeredGridLayoutManager类的具体用法?Java StaggeredGridLayoutManager怎么用?Java StaggeredGridLayoutManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StaggeredGridLayoutManager类属于android.support.v7.widget包,在下文中一共展示了StaggeredGridLayoutManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    ActivityCompat.setExitSharedElementCallback(this, exitTransitionCallback);
    super.onCreate(savedInstanceState);

    int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    getWindow().getDecorView().setSystemUiVisibility(mUIFlag);

    setContentView(R.layout.activity_gallery);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    ArrayList<String> imagesList = new ArrayList<>();
    for (int i = 1; i <= 23; i++)
        imagesList.add("http://ssninstincts.org.in/img/gallery/big/" + i + ".jpg");

    galleryAdapter = new GalleryAdapter(this, imagesList);
    StaggeredGridLayoutManager gridLayoutManager =
            new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
    galleryRecyclerView.setHasFixedSize(true);
    galleryRecyclerView.setLayoutManager(gridLayoutManager);
    galleryRecyclerView.setAdapter(galleryAdapter);
}
 
开发者ID:adithya321,项目名称:Instincts-2k17,代码行数:34,代码来源:GalleryActivity.java

示例2: canChildScrollUp

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else if(view instanceof  RecyclerView){
            RecyclerView recyclerView = (RecyclerView)view;
            RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
            if(layoutManager instanceof LinearLayoutManager){
                int position = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
                return position != 0;
            }else{
                if(layoutManager instanceof StaggeredGridLayoutManager ){
                    StaggeredGridLayoutManager stagger = (StaggeredGridLayoutManager) layoutManager;
                    int[] positions = stagger.findFirstCompletelyVisibleItemPositions(null);
                    return positions[0] != 0;
                }else{
                    throw new RuntimeException("can not support this LayoutManager ");
                }
            }
        }else{
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:30,代码来源:PtrDefaultHandler.java

示例3: initRecyclerView

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private void initRecyclerView() {
    mAdapter = new XRecyclerViewAdapter<>();
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setLoadingMore(this);
    recyclerView.setAdapter(
            mAdapter
                    .setLayoutId(R.layout.item_fiction_pt_list)
                    .setOnItemClickListener((view, position, info) -> {
                        String detailUrl = info.detailUrl;
                        if (TextUtils.isEmpty(detailUrl)) {
                            UIUtils.snackBar(mStatusView, R.string.pt_list_content_error);
                            return;
                        }
                        String bookinfo = detailUrl.replaceAll(".html", "/index.html").replaceAll("bookinfo", "html");
                        if (TextUtils.isEmpty(bookinfo)) {
                            UIUtils.snackBar(mStatusView, R.string.pt_list_content_error);
                            return;
                        }
                        FictionContentsActivity.getInstance(ApiConfig.Type.PIAO_TIAN, bookinfo, info.title);
                    })
                    .onXBind((holder, position, fictionModel) -> holder.setTextView(R.id.tv_title, fictionModel.title))
    );
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:25,代码来源:PtFictionMoreActivity.java

示例4: ItemSenderUser

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
public ItemSenderUser(View itemView) {
    super(itemView);

    //Load fields
    this.tvClientName = (TextView) itemView.findViewById( R.id.tv_client_name );

    this.imageView = (ImageView) this.itemView.findViewById(R.id.iv_profile);
    //Set on click
    this.imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            click();
        }
    });
    StaggeredGridLayoutManager.LayoutParams st = (StaggeredGridLayoutManager.LayoutParams) this.itemView.getLayoutParams();
}
 
开发者ID:tec-ustp,项目名称:SIIEScanner,代码行数:17,代码来源:ItemSenderUser.java

示例5: setRecyclerStlty

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private void setRecyclerStlty() {
    switch (mAdapter.getmStyle()) {
        case ListView:
        case HorizontalListView:
            setLView();
            break;
        case GridView:
        case HorizontalGridView:
            setGView();
            break;
        case WaterFall:
            StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(mNunColumns, StaggeredGridLayoutManager.VERTICAL);
            mRecyclerView.setLayoutManager(manager);
            break;
        case HorizontalWaterFall:
            StaggeredGridLayoutManager manager1 = new StaggeredGridLayoutManager(mNunColumns, StaggeredGridLayoutManager.HORIZONTAL);
            mRecyclerView.setLayoutManager(manager1);
            break;
        case MultiLayout:
            //多布局暂未实现
            break;

    }

}
 
开发者ID:liusmallpig,项目名称:LowRecyclerView,代码行数:26,代码来源:RecyclerViewUtils.java

示例6: scrollToItem

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
/**
 * TODO 支持offset
 *
 * @param section
 * @param rowInSection
 * @param offset
 * @param animate
 * @return
 */
@Override
public UDBaseListOrRecyclerView scrollToItem(int section, int rowInSection, int offset, boolean animate) {
    final LVRecyclerView recyclerView = getLVRecyclerView();
    if (recyclerView != null) {
        if (animate) {
            recyclerView.smoothScrollToPosition(getPositionBySectionAndRow(section, rowInSection));
        } else {
            if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
                ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(getPositionBySectionAndRow(section, rowInSection), offset);
            } else if (recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
                ((StaggeredGridLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(getPositionBySectionAndRow(section, rowInSection), offset);
            } else {
                recyclerView.scrollToPosition(getPositionBySectionAndRow(section, rowInSection));
            }
        }
    }
    return this;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:28,代码来源:UDBaseRecyclerView.java

示例7: isLastRow

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private boolean isLastRow(RecyclerView parent, int pos, int rowCount, int childCount) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        childCount = childCount - childCount % rowCount;
        if (pos >= childCount) { // 如果是最后一行,则不需要绘制底部分割线
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            childCount = childCount - childCount % rowCount;
            if (pos >= childCount) { // 如果是最后一行,则不需要绘制底部分割线
                return true;
            }
        } else {
            if ((pos + 1) % rowCount == 0) { // 如果是最后一行,则不需要绘制底部分割线
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:23,代码来源:DividerGridItemDecoration.java

示例8: isLastColumn

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private boolean isLastColumn(RecyclerView parent, int pos, int rowCount, int childCount) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % rowCount == 0) { // 如果是最后一列,则不需要绘制右侧分割线
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % rowCount == 0) { // 如果是最后一列,则不需要绘制右侧分割线
                return true;
            }
        } else {
            childCount = childCount - childCount % rowCount;
            if (pos >= childCount) { // 如果是最后一列,则不需要绘制右侧分割线
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:23,代码来源:DividerGridItemDecoration.java

示例9: isLastRaw

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private boolean isLastRaw(RecyclerView parent, int pos, int spanCount, int childCount) {
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if (pos >= childCount - (childCount % spanCount)) {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        if (((StaggeredGridLayoutManager) layoutManager).getOrientation() == 1) {
            if (pos >= childCount - (childCount % spanCount)) {
                return true;
            }
        } else if ((pos + 1) % spanCount == 0) {
            return true;
        }
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:DividerGridItemDecoration.java

示例10: initActivityCreated

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
@Override
protected void initActivityCreated() {
    if (!isPrepared || !isVisible || isLoad) {
        return;
    }
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.post(this::onRefresh);
    swipeRefreshLayout.setEnabled(false);
    mAdapter = new MultiAdapter<>(new ArrayList<>());
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setAdapter(
            mAdapter.setXMultiAdapterListener(this)
    );

    setLoad();
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:18,代码来源:PtFictionHomeFragment.java

示例11: isLastColum

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private boolean isLastColum(RecyclerView parent, int pos, int spanCount, int childCount) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
        {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager)
                .getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
            {
                return true;
            }
        } else {
            childCount = childCount - childCount % spanCount;
            if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
                return true;
        }
    }
    return false;
}
 
开发者ID:OCNYang,项目名称:RecyclerViewEvent,代码行数:24,代码来源:DividerGridItemDecoration.java

示例12: onCreateView

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
    listView = (RecyclerView) view.findViewById(R.id.list);
    listView.setHasFixedSize(true);
    listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
    List<ItemList> lists = new ArrayList<ItemList>();
    videoadapter = new VideoAdapter(lists);
    listView.setAdapter(videoadapter);

    mPresent = new VideoPresenter((VideoData.View) this);

    srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
    srfLayout.setOnRefreshListener(this);
    srfLayout.post(() -> onRefresh());
    return view;
}
 
开发者ID:popo1379,项目名称:popomusic,代码行数:19,代码来源:KepuFragment.java

示例13: findFirstVisibleItemPosition

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
public int findFirstVisibleItemPosition() {
    switch (type) {
        case LinearLayout:
            return ((LinearLayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPosition();
        case Grid:
            return ((GridLayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPosition();
        case LinearLayoutWithHeaders:
            return ((LayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPosition();
        case StaggeredGridLayout:
            return ((StaggeredGridLayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPositions(null)[0];
        default:
            throw new IllegalStateException("Type of layoutManager unknown." +
                    "In this case this method needs to be overridden");
    }
}
 
开发者ID:jonashao,项目名称:Samantha,代码行数:20,代码来源:RealmRecyclerView.java

示例14: setLayoutManger

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
public SmartRecycleView setLayoutManger(LayoutManagerType layoutManagerType, int orientation, int spanCout) {
    RecyclerView.LayoutManager layoutManager = null;
    if (layoutManagerType == LayoutManagerType.LINEAR_LAYOUT) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(orientation);
        layoutManager = linearLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.GRID_LAYOUT) {
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, spanCout);
        gridLayoutManager.setOrientation(orientation);
        layoutManager = gridLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.STAGGER_LAYOUT) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(spanCout, orientation);
        layoutManager = staggeredGridLayoutManager;
    }
    mRecyclerView.setLayoutManager(layoutManager);
    return this;
}
 
开发者ID:GaoGersy,项目名称:MultiSelecter,代码行数:18,代码来源:SmartRecycleView.java

示例15: isLastColum

import android.support.v7.widget.StaggeredGridLayoutManager; //导入依赖的package包/类
private boolean isLastColum(RecyclerView parent, int pos, int spanCount,
                            int childCount) {
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
        {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager)
                .getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边
            {
                return true;
            }
        } else {
            childCount = childCount - childCount % spanCount;
            if (pos >= childCount)// 如果是最后一列,则不需要绘制右边
                return true;
        }
    }
    return false;
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:25,代码来源:DividerGridItemDecoration.java


注:本文中的android.support.v7.widget.StaggeredGridLayoutManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。