Java源码示例:com.github.barteksc.pdfviewer.PDFView

示例1
private void setCurrentPage() {

        if (currentPageViewHolder != null) {
            if (currentPageViewHolder.itemView instanceof SimpleExoPlayerView) {
                Player player = ((SimpleExoPlayerView)currentPageViewHolder.itemView).getPlayer();
                if (player != null) {
                    player.setPlayWhenReady(false);
                }
            }
        }

        currentPage = getCurrentPagePosition();
        currentPageViewHolder = (currentPage >= 0) ? getHistoryView().findViewHolderForAdapterPosition(currentPage) : null;
        if (currentPageViewHolder != null) {
            if (currentPageViewHolder.itemView instanceof SimpleExoPlayerView) {
                SimpleExoPlayerView playerView = (SimpleExoPlayerView) currentPageViewHolder.itemView;
                playerView.getPlayer().setPlayWhenReady(true);
            } else if (currentPageViewHolder.itemView instanceof PZSImageView) {
                getHistoryView().removeCallbacks(advanceToNextRunnable);
                getHistoryView().postDelayed(advanceToNextRunnable, AUTO_ADVANCE_TIMEOUT_IMAGE);
            } else if (currentPageViewHolder.itemView instanceof PDFView) {
                getHistoryView().removeCallbacks(advanceToNextRunnable);
                getHistoryView().postDelayed(advanceToNextRunnable, AUTO_ADVANCE_TIMEOUT_PDF);
            }
        }
    }
 
示例2
@Override
public void onViewRecycled(@NonNull MessageViewHolder holder) {
    if (holder.itemView instanceof PDFView) {
        final PDFView pdfView = (PDFView)holder.itemView;
        pdfView.post(new Runnable() {
            @Override
            public void run() {
                pdfView.recycle();
            }
        });
    } else if (holder.itemView instanceof SimpleExoPlayerView) {
        ((SimpleExoPlayerView)holder.itemView).getPlayer().stop(true);
        ((SimpleExoPlayerView)holder.itemView).getPlayer().release();
        ((SimpleExoPlayerView)holder.itemView).setPlayer(null);
    }
    super.onViewRecycled(holder);
}
 
示例3
protected View initViewerContentView(Context context) {
	pdfView = new PDFView(context, null);
	return pdfView;
}
 
示例4
@Override
public void setupLayout(PDFView pdfView) {
    int align, width, height;
    Drawable background;
    // determine handler position, default is right (when scrolling vertically) or bottom (when scrolling horizontally)
    if (pdfView.isSwipeVertical()) {
        width = HANDLE_LONG;
        height = HANDLE_SHORT;
        if (inverted) { // left
            align = ALIGN_PARENT_LEFT;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_left);
        } else { // right
            align = ALIGN_PARENT_RIGHT;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_right);
        }
    } else {
        width = HANDLE_SHORT;
        height = HANDLE_LONG;
        if (inverted) { // top
            align = ALIGN_PARENT_TOP;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_top);
        } else { // bottom
            align = ALIGN_PARENT_BOTTOM;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_bottom);
        }
    }

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        setBackgroundDrawable(background);
    } else {
        setBackground(background);
    }

    LayoutParams lp = new LayoutParams(Util.getDP(context, width), Util.getDP(context, height));
    lp.setMargins(0, 0, 0, 0);

    LayoutParams tvlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    tvlp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

    addView(textView, tvlp);

    lp.addRule(align);
    pdfView.addView(this, lp);

    this.pdfView = pdfView;
}
 
示例5
public DefaultLinkHandler(PDFView pdfView) {
    this.pdfView = pdfView;
}
 
示例6
@Override
public void setupLayout(PDFView pdfView) {
    int align, width, height;
    Drawable background;
    // determine handler position, default is right (when scrolling vertically) or bottom (when scrolling horizontally)
    if (pdfView.isSwipeVertical()) {
        width = HANDLE_LONG;
        height = HANDLE_SHORT;
        if (inverted) { // left
            align = ALIGN_PARENT_LEFT;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_left);
        } else { // right
            align = ALIGN_PARENT_RIGHT;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_right);
        }
    } else {
        width = HANDLE_SHORT;
        height = HANDLE_LONG;
        if (inverted) { // top
            align = ALIGN_PARENT_TOP;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_top);
        } else { // bottom
            align = ALIGN_PARENT_BOTTOM;
            background = ContextCompat.getDrawable(context, R.drawable.default_scroll_handle_bottom);
        }
    }

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        setBackgroundDrawable(background);
    } else {
        setBackground(background);
    }

    LayoutParams lp = new LayoutParams(Util.getDP(context, width), Util.getDP(context, height));
    lp.setMargins(0, 0, 0, 0);

    LayoutParams tvlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    tvlp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

    addView(textView, tvlp);

    lp.addRule(align);
    pdfView.addView(this, lp);

    this.pdfView = pdfView;
}
 
示例7
/**
 * Method called by PDFView after setting scroll handle.
 * Do not call this method manually.
 * For usage sample see {@link DefaultScrollHandle}
 *
 * @param pdfView PDFView instance
 */
void setupLayout(PDFView pdfView);
 
示例8
/**
 * Method called by PDFView after setting scroll handle.
 * Do not call this method manually.
 * For usage sample see {@link DefaultScrollHandle}
 *
 * @param pdfView PDFView instance
 */
void setupLayout(PDFView pdfView);