Search in sources :

Example 6 with OnScrollListener

use of android.support.v7.widget.RecyclerView.OnScrollListener in project smooth-app-bar-layout by henrytao-me.

the class BaseBehavior method initScrollTarget.

private void initScrollTarget(final CoordinatorLayout coordinatorLayout, final AppBarLayout child) {
    Utils.log("initScrollTarget | %b", vScrollTarget != null);
    if (vScrollTarget != null) {
        long tag = getViewTag(vScrollTarget, true);
        if (!mScrollTargets.contains(tag)) {
            mScrollTargets.add(tag);
            OnScrollListener listener = new OnScrollListener() {

                @Override
                public void onScrollChanged(View view, int x, int y, int dx, int dy, boolean accuracy) {
                    if (view == vScrollTarget) {
                        BaseBehavior.this.onScrollChanged(coordinatorLayout, child, view, y, dy, accuracy);
                    }
                }
            };
            if (vScrollTarget instanceof NestedScrollView) {
                ObservableNestedScrollView.newInstance((NestedScrollView) vScrollTarget, mOverrideOnScrollListener, listener);
            } else if (vScrollTarget instanceof RecyclerView) {
                ObservableRecyclerView.newInstance((RecyclerView) vScrollTarget, listener);
            }
        }
    }
}
Also used : OnScrollListener(me.henrytao.smoothappbarlayout.base.OnScrollListener) ObservableRecyclerView(me.henrytao.smoothappbarlayout.base.ObservableRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ObservableNestedScrollView(me.henrytao.smoothappbarlayout.base.ObservableNestedScrollView) NestedScrollView(android.support.v4.widget.NestedScrollView) ObservableRecyclerView(me.henrytao.smoothappbarlayout.base.ObservableRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ObservableNestedScrollView(me.henrytao.smoothappbarlayout.base.ObservableNestedScrollView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView)

Example 7 with OnScrollListener

use of android.support.v7.widget.RecyclerView.OnScrollListener in project material by rey5137.

the class TabIndicatorView method init.

protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    setHorizontalScrollBarEnabled(false);
    mTabPadding = -1;
    mTabSingleLine = true;
    mCenterCurrentTab = false;
    mIndicatorHeight = -1;
    mIndicatorAtTop = false;
    mScrolling = false;
    mIsRtl = false;
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(ThemeUtil.colorAccent(context, 0xFFFFFFFF));
    mAdapter = new Adapter();
    setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, mIsRtl);
    setLayoutManager(mLayoutManager);
    setItemAnimator(new DefaultItemAnimator());
    addOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                updateIndicator(mLayoutManager.findViewByPosition(mSelectedPosition));
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            updateIndicator(mLayoutManager.findViewByPosition(mSelectedPosition));
        }
    });
    applyStyle(context, attrs, defStyleAttr, defStyleRes);
    if (!isInEditMode())
        mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) Paint(android.graphics.Paint) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Paint(android.graphics.Paint)

Example 8 with OnScrollListener

use of android.support.v7.widget.RecyclerView.OnScrollListener in project Signal-Android by WhisperSystems.

the class ConversationFragment method initializeResources.

private void initializeResources() {
    this.recipients = RecipientFactory.getRecipientsForIds(getActivity(), getActivity().getIntent().getLongArrayExtra("recipients"), true);
    this.threadId = this.getActivity().getIntent().getLongExtra("thread_id", -1);
    this.lastSeen = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
    this.firstLoad = true;
    OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
    list.addOnScrollListener(scrollListener);
}
Also used : OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener)

Example 9 with OnScrollListener

use of android.support.v7.widget.RecyclerView.OnScrollListener in project CalendarListview by traex.

the class DayPickerView method init.

public void init(Context paramContext) {
    setLayoutManager(new LinearLayoutManager(paramContext));
    mContext = paramContext;
    setUpListView();
    onScrollListener = new OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            final SimpleMonthView child = (SimpleMonthView) recyclerView.getChildAt(0);
            if (child == null) {
                return;
            }
            mPreviousScrollPosition = dy;
            mPreviousScrollState = mCurrentScrollState;
        }
    };
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 10 with OnScrollListener

use of android.support.v7.widget.RecyclerView.OnScrollListener in project android_frameworks_base by AOSPA.

the class RecentsTvView method launchTaskFomRecents.

/**
     * Launch the given task from recents with animation. If the task is not focused, this will
     * attempt to scroll to focus the task before launching.
     * @param task
     */
private void launchTaskFomRecents(final Task task, boolean animate) {
    if (!animate) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
        return;
    }
    mTaskStackHorizontalView.requestFocus();
    Task focusedTask = mTaskStackHorizontalView.getFocusedTask();
    if (focusedTask != null && task != focusedTask) {
        if (mScrollListener != null) {
            mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
        }
        mScrollListener = new OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    TaskCardView cardView = mTaskStackHorizontalView.getChildViewForTask(task);
                    if (cardView != null) {
                        mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, cardView, null, INVALID_STACK_ID);
                    } else {
                        // This should not happen normally. If this happens then the data in
                        // the grid view was altered during the scroll. Log error and launch
                        // task with no animation.
                        Log.e(TAG, "Card view for task : " + task + ", returned null.");
                        SystemServicesProxy ssp = Recents.getSystemServices();
                        ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
                    }
                    mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
                }
            }
        };
        mTaskStackHorizontalView.addOnScrollListener(mScrollListener);
        mTaskStackHorizontalView.setSelectedPositionSmooth(((TaskStackHorizontalViewAdapter) mTaskStackHorizontalView.getAdapter()).getPositionOfTask(task));
    } else {
        mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, mTaskStackHorizontalView.getChildViewForTask(task), null, INVALID_STACK_ID);
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)9 OnScrollListener (android.support.v7.widget.RecyclerView.OnScrollListener)6 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 Task (com.android.systemui.recents.model.Task)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 ActionBar (android.app.ActionBar)1 Paint (android.graphics.Paint)1 Handler (android.os.Handler)1 NestedScrollView (android.support.v4.widget.NestedScrollView)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 View (android.view.View)1 RecyclerViewAdapter (com.daimajia.swipedemo.adapter.RecyclerViewAdapter)1 DividerItemDecoration (com.daimajia.swipedemo.adapter.util.DividerItemDecoration)1 FadeInLeftAnimator (jp.wasabeef.recyclerview.animators.FadeInLeftAnimator)1 ObservableNestedScrollView (me.henrytao.smoothappbarlayout.base.ObservableNestedScrollView)1 ObservableRecyclerView (me.henrytao.smoothappbarlayout.base.ObservableRecyclerView)1 OnScrollListener (me.henrytao.smoothappbarlayout.base.OnScrollListener)1