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);
}
}
}
}
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);
}
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);
}
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;
}
};
}
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);
}
}
Aggregations