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


Java RecyclerView类代码示例

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


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

示例1: onBindViewHolder

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TLRPC.Document sticker = cache.get(position);
            ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
            break;
        case 1:
            if (position == totalItems) {
                int row = (position - 1) / stickersPerRow;
                TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row);
                if (pack == null) {
                    ((EmptyCell) holder.itemView).setHeight(1);
                } else {
                    int height = stickersGridView.getMeasuredHeight() - (int) Math.ceil(pack.documents.size() / (float) stickersPerRow) * AndroidUtilities.dp(82);
                    ((EmptyCell) holder.itemView).setHeight(height > 0 ? height : 1);
                }
            } else {
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            }
            break;
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:24,代码来源:StickerMasksView.java

示例2: postDispatchSwipe

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
private void postDispatchSwipe(final RecoverAnimation anim, final int swipeDir) {
    // wait until animations are complete.
    mRecyclerView.post(new Runnable() {
        @Override
        public void run() {
            if (mRecyclerView != null && mRecyclerView.isAttachedToWindow() &&
                    !anim.mOverridden &&
                    anim.mViewHolder.getAdapterPosition() != RecyclerView.NO_POSITION) {
                final RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
                // if animator is running or we have other active recover animations, we try
                // not to call onSwiped because DefaultItemAnimator is not good at merging
                // animations. Instead, we wait and batch.
                if ((animator == null || !animator.isRunning(null))
                        && !hasRunningRecoverAnim()) {
                    mCallback.onSwiped(anim.mViewHolder, swipeDir);
                } else {
                    mRecyclerView.post(this);
                }
            }
        }
    });
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:23,代码来源:ItemTouchHelper.java

示例3: findSwipedView

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
private ViewHolder findSwipedView(MotionEvent motionEvent) {
    final RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager();
    if (mActivePointerId == ACTIVE_POINTER_ID_NONE) {
        return null;
    }
    final int pointerIndex = MotionEventCompat.findPointerIndex(motionEvent, mActivePointerId);
    final float dx = MotionEventCompat.getX(motionEvent, pointerIndex) - mInitialTouchX;
    final float dy = MotionEventCompat.getY(motionEvent, pointerIndex) - mInitialTouchY;
    final float absDx = Math.abs(dx);
    final float absDy = Math.abs(dy);

    if (absDx < mSlop && absDy < mSlop) {
        return null;
    }
    if (absDx > absDy && lm.canScrollHorizontally()) {
        return null;
    } else if (absDy > absDx && lm.canScrollVertically()) {
        return null;
    }
    View child = findChildView(motionEvent);
    if (child == null) {
        return null;
    }
    return mRecyclerView.getChildViewHolder(child);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:26,代码来源:ItemTouchHelper.java

示例4: onBindViewHolder

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (!deviceHasGoodCamera || position != 0) {
        if (deviceHasGoodCamera) {
            position--;
        }
        PhotoAttachPhotoCell cell = (PhotoAttachPhotoCell) holder.itemView;
        MediaController.PhotoEntry photoEntry = MediaController.allPhotosAlbumEntry.photos.get(position);
        cell.setPhotoEntry(photoEntry, position == MediaController.allPhotosAlbumEntry.photos.size() - 1);
        cell.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false);
        cell.getImageView().setTag(position);
        cell.setTag(position);
    } else if (deviceHasGoodCamera && position == 0) {
        if (cameraView != null && cameraView.isInitied()) {
            holder.itemView.setVisibility(View.INVISIBLE);
        } else {
            holder.itemView.setVisibility(View.VISIBLE);
        }
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:21,代码来源:ChatAttachAlert.java

示例5: interpolateOutOfBoundsScroll

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
/**
 * Called by the ItemTouchHelper when user is dragging a view out of bounds.
 * <p>
 * You can override this method to decide how much RecyclerView should scroll in response
 * to this action. Default implementation calculates a value based on the amount of View
 * out of bounds and the time it spent there. The longer user keeps the View out of bounds,
 * the faster the list will scroll. Similarly, the larger portion of the View is out of
 * bounds, the faster the RecyclerView will scroll.
 *
 * @param recyclerView        The RecyclerView instance to which ItemTouchHelper is
 *                            attached to.
 * @param viewSize            The total size of the View in scroll direction, excluding
 *                            item decorations.
 * @param viewSizeOutOfBounds The total size of the View that is out of bounds. This value
 *                            is negative if the View is dragged towards left or top edge.
 * @param totalSize           The total size of RecyclerView in the scroll direction.
 * @param msSinceStartScroll  The time passed since View is kept out of bounds.
 * @return The amount that RecyclerView should scroll. Keep in mind that this value will
 * be passed to {@link RecyclerView#scrollBy(int, int)} method.
 */
public int interpolateOutOfBoundsScroll(RecyclerView recyclerView,
        int viewSize, int viewSizeOutOfBounds,
        int totalSize, long msSinceStartScroll) {
    final int maxScroll = getMaxDragScroll(recyclerView);
    final int absOutOfBounds = Math.abs(viewSizeOutOfBounds);
    final int direction = (int) Math.signum(viewSizeOutOfBounds);
    // might be negative if other direction
    float outOfBoundsRatio = Math.min(1f, 1f * absOutOfBounds / viewSize);
    final int cappedScroll = (int) (direction * maxScroll *
            sDragViewScrollCapInterpolator.getInterpolation(outOfBoundsRatio));
    final float timeRatio;
    if (msSinceStartScroll > DRAG_SCROLL_ACCELERATION_LIMIT_TIME_MS) {
        timeRatio = 1f;
    } else {
        timeRatio = (float) msSinceStartScroll / DRAG_SCROLL_ACCELERATION_LIMIT_TIME_MS;
    }
    final int value = (int) (cappedScroll * sDragScrollInterpolator
            .getInterpolation(timeRatio));
    if (value == 0) {
        return viewSizeOutOfBounds > 0 ? 1 : -1;
    }
    return value;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:44,代码来源:ItemTouchHelper.java

示例6: onViewAttachedToWindow

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
    if (holder.itemView instanceof ChatMessageCell) {
        final ChatMessageCell messageCell = (ChatMessageCell) holder.itemView;
        messageCell.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                messageCell.getViewTreeObserver().removeOnPreDrawListener(this);

                int height = chatListView.getMeasuredHeight();
                int top = messageCell.getTop();
                int bottom = messageCell.getBottom();
                int viewTop = top >= 0 ? 0 : -top;
                int viewBottom = messageCell.getMeasuredHeight();
                if (viewBottom > height) {
                    viewBottom = viewTop + height;
                }
                messageCell.setVisiblePart(viewTop, viewBottom - viewTop);

                return true;
            }
        });
        messageCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && messageCell.getMessageObject().getId() == highlightMessageId);
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:26,代码来源:ChatActivity.java

示例7: onBindViewHolder

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TLRPC.Document sticker = cache.get(position);
            ((StickerEmojiCell) holder.itemView).setSticker(sticker, false);
            break;
        case 1:
            if (position == totalItems) {
                int row = (position - 1) / stickersPerRow;
                TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row);
                if (pack == null) {
                    ((EmptyCell) holder.itemView).setHeight(1);
                } else {
                    int height = pager.getHeight() - (int) Math.ceil(pack.documents.size() / (float) stickersPerRow) * AndroidUtilities.dp(82);
                    ((EmptyCell) holder.itemView).setHeight(height > 0 ? height : 1);
                }
            } else {
                ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(82));
            }
            break;
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:24,代码来源:EmojiView.java

示例8: onBindViewHolder

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (searchResultBotContext != null) {
        boolean hasTop = searchResultBotContextSwitch != null;
        if (holder.getItemViewType() == 2) {
            if (hasTop) {
                ((BotSwitchCell) holder.itemView).setText(searchResultBotContextSwitch.text);
            }
        } else {
            if (hasTop) {
                position--;
            }
            ((ContextLinkCell) holder.itemView).setLink(searchResultBotContext.get(position), contextMedia, position != searchResultBotContext.size() - 1, hasTop && position == 0);
        }
    } else {
        if (searchResultUsernames != null) {
            ((MentionCell) holder.itemView).setUser(searchResultUsernames.get(position));
        } else if (searchResultHashtags != null) {
            ((MentionCell) holder.itemView).setText(searchResultHashtags.get(position));
        } else if (searchResultCommands != null) {
            ((MentionCell) holder.itemView).setBotCommand(searchResultCommands.get(position), searchResultCommandsHelp.get(position), searchResultCommandsUsers != null ? searchResultCommandsUsers.get(position) : null);
        }
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:25,代码来源:MentionsAdapter.java

示例9: onCreateViewHolder

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Holder holder;
    switch (viewType) {
        case 1:
            holder = new Holder(new PhotoAttachCameraCell(mContext));
            break;
        default:
            if (!viewsCache.isEmpty()) {
                holder = viewsCache.get(0);
                viewsCache.remove(0);
            } else {
                holder = createHolder();
            }
            break;
    }

    return holder;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:20,代码来源:ChatAttachAlert.java

示例10: attachToRecyclerView

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
/**
 * Attaches the ItemTouchHelper to the provided RecyclerView. If TouchHelper is already
 * attached to a RecyclerView, it will first detach from the previous one. You can call this
 * method with {@code null} to detach it from the current RecyclerView.
 *
 * @param recyclerView The RecyclerView instance to which you want to add this helper or
 *                     {@code null} if you want to remove ItemTouchHelper from the current
 *                     RecyclerView.
 */
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
    if (mRecyclerView == recyclerView) {
        return; // nothing to do
    }
    if (mRecyclerView != null) {
        destroyCallbacks();
    }
    mRecyclerView = recyclerView;
    if (mRecyclerView != null) {
        final Resources resources = recyclerView.getResources();
        mSwipeEscapeVelocity = AndroidUtilities.dp(120);
        mMaxSwipeVelocity = AndroidUtilities.dp(800);
        setupCallbacks();
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:25,代码来源:ItemTouchHelper.java

示例11: addChildDrawingOrderCallback

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
private void addChildDrawingOrderCallback() {
    if (Build.VERSION.SDK_INT >= 21) {
        return;// we use elevation on Lollipop
    }
    if (mChildDrawingOrderCallback == null) {
        mChildDrawingOrderCallback = new RecyclerView.ChildDrawingOrderCallback() {
            @Override
            public int onGetChildDrawingOrder(int childCount, int i) {
                if (mOverdrawChild == null) {
                    return i;
                }
                int childPosition = mOverdrawChildPosition;
                if (childPosition == -1) {
                    childPosition = mRecyclerView.indexOfChild(mOverdrawChild);
                    mOverdrawChildPosition = childPosition;
                }
                if (i == childCount - 1) {
                    return childPosition;
                }
                return i < childPosition ? i : i + 1;
            }
        };
    }
    mRecyclerView.setChildDrawingOrderCallback(mChildDrawingOrderCallback);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:26,代码来源:ItemTouchHelper.java

示例12: getSwipeDirs

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public int getSwipeDirs(RecyclerView recyclerView,RecyclerView.ViewHolder viewHolder) {
    if (viewHolder.itemView instanceof ChatMessageCell) {
        int type = getMessageType(message);
        boolean allowChatActions = true;
        message = ((ChatMessageCell) viewHolder.itemView).getMessageObject();
        boolean isVoiceMsg = MessageObject.isVoiceDocument(this.message.getDocument());
        if ((currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(ChatActivity.this.currentEncryptedChat.layer) < 46) || ((type == ChatActivity.attach_gallery && this.message.getDialogId() == ChatActivity.this.mergeDialogId) || ((ChatActivity.this.currentEncryptedChat == null && this.message.getId() < 0) || ChatActivity.this.isBroadcast || ((ChatActivity.this.currentChat != null && (ChatObject.isNotInChat(ChatActivity.this.currentChat) || !(!ChatObject.isChannel(ChatActivity.this.currentChat) || ChatActivity.this.currentChat.creator || ChatActivity.this.currentChat.editor || ChatActivity.this.currentChat.megagroup))) || isVoiceMsg)))) {
            allowChatActions = false;
        }
        if (allowChatActions) {
            ChatActivity.this.chatListView.cancelClickRunnables(true);
            return super.getSwipeDirs(recyclerView, viewHolder);
        }
    }
    return ChatActivity.attach_photo;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:18,代码来源:ChatActivity.java

示例13: onDraw

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onDraw(Canvas c, RecyclerView recyclerView, View view,
        float dX, float dY, int actionState, boolean isCurrentlyActive) {
    if (actionState != ItemTouchHelper.ACTION_STATE_DRAG) {
        draw(c, recyclerView, view, dX, dY);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:8,代码来源:ItemTouchUIUtilImpl.java

示例14: onDraw

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    // we don't know if RV changed something so we should invalidate this index.
    mOverdrawChildPosition = -1;
    float dx = 0, dy = 0;
    if (mSelected != null) {
        getSelectedDxDy(mTmpPosition);
        dx = mTmpPosition[0];
        dy = mTmpPosition[1];
    }
    mCallback.onDraw(c, parent, mSelected,
            mRecoverAnimations, mActionState, dx, dy);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:14,代码来源:ItemTouchHelper.java

示例15: onBindViewHolder

import org.telegram.messenger.support.widget.RecyclerView; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (getItemViewType(position) == 0) {
        ArchivedStickerSetCell cell = (ArchivedStickerSetCell) holder.itemView;
        cell.setTag(position);
        TLRPC.StickerSetCovered stickerSet = sets.get(position);
        cell.setStickersSet(stickerSet, position != sets.size() - 1, false);
        cell.setChecked(StickersQuery.isStickerPackInstalled(stickerSet.set.id));
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:11,代码来源:ArchivedStickersActivity.java


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