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


Java OrientationHelper类代码示例

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


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

示例1: initLaunchpad

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:21,代码来源:HomeActivity.java

示例2: getItemOffsets

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    int spanCount = ((GridLayoutManager) parent.getLayoutManager()).getSpanCount();
    int orientation = ((GridLayoutManager)parent.getLayoutManager()).getOrientation();
    int position = parent.getChildLayoutPosition(view);
    if(orientation == OrientationHelper.VERTICAL && (position + 1) % spanCount == 0) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
        return;
    }

    if(orientation == OrientationHelper.HORIZONTAL && (position + 1) % spanCount == 0) {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
        return;
    }

    outRect.set(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:MDGridRvDividerDecoration.java

示例3: recycleFromStart

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
private void recycleFromStart(RecyclerView.Recycler recycler, int line, LayoutManagerHelper helper) {
    final OrientationHelper orientationHelper = helper.getMainOrientationHelper();
    boolean changed = true;
    while (helper.getChildCount() > 0 && changed) {
        View child = helper.getChildAt(0);
        if (child != null && orientationHelper.getDecoratedEnd(child) < line) {
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            int position = lp.getViewPosition();
            Span span = findSpan(position, child, true);
            if (span != null) {
                span.popStart(orientationHelper);
                helper.removeChildView(child);
                recycler.recycleView(child);
            } else {
                changed = false;
            }
        } else {
            return;// done
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:StaggeredGridLayoutHelper.java

示例4: recycleFromEnd

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
private void recycleFromEnd(RecyclerView.Recycler recycler, int line, LayoutManagerHelper helper) {
    final OrientationHelper orientationHelper = helper.getMainOrientationHelper();
    final int childCount = helper.getChildCount();
    int i;
    for (i = childCount - 1; i >= 0; i--) {
        View child = helper.getChildAt(i);
        if (child != null && orientationHelper.getDecoratedStart(child) > line) {
            LayoutParams lp = (LayoutParams) child.getLayoutParams();
            int position = lp.getViewPosition();
            Span span = findSpan(position, child, false);
            if (span != null) {
                span.popEnd(orientationHelper);
                helper.removeChildView(child);
                recycler.recycleView(child);
            }
        } else {
            return;// done
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:StaggeredGridLayoutHelper.java

示例5: calculateDistanceToFinalSnap

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) {
    int[] out = new int[2];
    if (layoutManager.canScrollHorizontally()) {
        out[0] = getDistance(layoutManager, targetView, OrientationHelper.createHorizontalHelper(layoutManager));
    } else {
        out[0] = 0;
    }

    if (layoutManager.canScrollVertically()) {
        out[1] = getDistance(layoutManager, targetView, OrientationHelper.createVerticalHelper(layoutManager));
    } else {
        out[1] = 0;
    }
    return out;
}
 
开发者ID:TakuSemba,项目名称:MultiSnapRecyclerView,代码行数:17,代码来源:SnapHelperDelegator.java

示例6: onCreateView

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
@CallSuper
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view;
    if (orientation() == OrientationHelper.VERTICAL) {
        view = inflater.inflate(R.layout.vertical_fragment_brick, container, false);
    } else {
        view = inflater.inflate(R.layout.horizontal_fragment_brick, container, false);
    }

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    recyclerView.setBackgroundColor(recyclerViewBackground);
    ((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    dataManager.setRecyclerView(getContext(), recyclerView, orientation(), reverse(), view);
    return view;
}
 
开发者ID:wayfair,项目名称:brickkit-android,代码行数:17,代码来源:BrickFragment.java

示例7: onCreate

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_list);
    ButterKnife.bind(this);
    activityComponent().inject(this);


    mRecyclerView.setAdapter(adapter);
    int showListCountSpan = getResources().getInteger(R.integer.show_list_count_span);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(showListCountSpan, OrientationHelper.VERTICAL));
    mPresenter.attachView(this);
    mPresenter.load(savedInstanceState == null);

    adapter.setItemClickListener((view, item) ->
            startActivity(ShowDetailsActivity.getOpenIntent(this, item.getId())));
}
 
开发者ID:OHoussein,项目名称:Android-Show-Reader,代码行数:18,代码来源:ShowListActivity.java

示例8: draw

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
private void draw(Canvas c, RecyclerView parent) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if ((layoutManager instanceof LinearLayoutManager)) {
        LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
        if (manager.getOrientation() == OrientationHelper.VERTICAL)
            drawVerticalOrientationDividers(c, parent, manager);
        else
            drawHorizontalOrientationDividers(c, parent, manager);
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        Log.e(getClass().getSimpleName(), "Will soon support this feature !!");
    } else {
        throw new UnsupportedOperationException(getClass().getSimpleName() +
                " can only be used in the RecyclerView which use GridLayoutManager" +
                " or LinearLayoutManager or StaggeredGridLayoutManager");
    }
}
 
开发者ID:dkzwm,项目名称:ItemDecorations,代码行数:17,代码来源:BaseItemDecoration.java

示例9: scrollToRightPositionWhenItemChanged

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
/**
     * 当item位置变换,滚动recycler到正确的位置
     * TODO: 2017/2/21 0021 整理更优雅的写法  还有scrollToPosition(0)是否必要?
     */
    private void scrollToRightPositionWhenItemChanged(RecyclerView recyclerView, View itemView, int itemPos) {
        final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        if (layoutManager instanceof ItemTouchHelper.ViewDropHandler) {
            OrientationHelper helper = OrientationHelper.createVerticalHelper(layoutManager);
            int start = helper.getDecoratedStart(itemView);
            int end = helper.getDecoratedEnd(itemView);
            ((LinearLayoutManager) layoutManager).scrollToPositionWithOffset(
                    itemPos, lastItemPos > itemPos ? start : end - itemViewHeight);
//                System.out.println(lastItemPos + "-" + childPos + "OrientationHelperOrientationHelper:"
//                        + height + "==" + itemViewHeight + "=||=" + start + "===" + end + "||||||" + myStart + "===" + itemTargetView.getHeight() );
        }
        if (lastItemPos == 0 || itemPos == 0) {
            recyclerView.scrollToPosition(0);
        }
    }
 
开发者ID:free46000,项目名称:MultiItem,代码行数:20,代码来源:ItemDragHelper.java

示例10: onScrollStateChanged

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
    //Fix for bug with bottom selection bar and different month item height in horizontal mode (different count of weeks)
    View view = rvMonths.getLayoutManager().findViewByPosition(getFirstVisiblePosition(rvMonths.getLayoutManager()));
    if (view != null) {
        view.requestLayout();
    }

    if (getCalendarOrientation() == OrientationHelper.HORIZONTAL) {
        multipleSelectionBarAdapter.notifyDataSetChanged();

        //Hide navigation buttons
        boolean show = newState != RecyclerView.SCROLL_STATE_DRAGGING;
        ivPrevious.setVisibility(show ? View.VISIBLE : View.GONE);
        ivNext.setVisibility(show ? View.VISIBLE : View.GONE);
    }

    super.onScrollStateChanged(recyclerView, newState);
}
 
开发者ID:ApplikeySolutions,项目名称:CosmoCalendar,代码行数:20,代码来源:CalendarView.java

示例11: onViewCreated

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    int orientation = OrientationHelper.VERTICAL;
    boolean reverseLayout = false;
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), orientation, reverseLayout);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new SongsAdapter();
    mRecyclerView.setAdapter(mAdapter);

    // hide whole interface until the fragment is connected with the service
    hideContent();
}
 
开发者ID:nfdz,项目名称:foco,代码行数:17,代码来源:MusicDialog.java

示例12: distanceToEnd

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) {
    if (mIsRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
开发者ID:mangoblogger,项目名称:MangoBloggerAndroidApp,代码行数:8,代码来源:GravitySnapHelper.java

示例13: getItemOffsets

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    int position = parent.getChildAdapterPosition(view);
    int orientation = 0;
    int headerCount = 0,footerCount = 0;
    if (parent.getAdapter() instanceof RecyclerArrayAdapter){
        headerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getHeaderCount();
        footerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getFooterCount();
    }

    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof StaggeredGridLayoutManager){
        orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
    }else if (layoutManager instanceof GridLayoutManager){
        orientation = ((GridLayoutManager) layoutManager).getOrientation();
    }else if (layoutManager instanceof LinearLayoutManager){
        orientation = ((LinearLayoutManager) layoutManager).getOrientation();
    }

    if (position>=headerCount&&position<parent.getAdapter().getItemCount()-footerCount||mDrawHeaderFooter){
        if (orientation == OrientationHelper.VERTICAL){
            outRect.bottom = mHeight;
        }else {
            outRect.right = mHeight;
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:DividerDecoration.java

示例14: doBusiness

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
protected void doBusiness() {
    toolbarTitle.setText("新生攻略");
    recyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
    adapter = new FreshmanGuideAdapter(context, dataList);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(context, OrientationHelper.VERTICAL));
    freshmanGuidePresenter = new FreshmanGuidePresenter(this, this);
    freshmanGuidePresenter.showGuideList();
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:11,代码来源:FreshmanGuideActivity.java

示例15: onCreate

import android.support.v7.widget.OrientationHelper; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_recyclerview);
    // Workaround for dash path effect
    // https://code.google.com/p/android/issues/detail?id=29944
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        recyclerView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    SimpleAdapter adapter = new SimpleAdapter(this);
    LinearLayoutManager manager = new LinearLayoutManager(this);
    manager.setOrientation(OrientationHelper.VERTICAL);
    recyclerView.setLayoutManager(manager);
    recyclerView.setAdapter(adapter);

    Paint paint = new Paint();
    paint.setStrokeWidth(5);
    paint.setColor(Color.BLUE);
    paint.setAntiAlias(true);
    paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)
            .paint(paint)
            .showLastDivider()
            .build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:PaintActivity.java


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