com.github.barteksc.pdfviewer.PDFView Java Examples

The following examples show how to use com.github.barteksc.pdfviewer.PDFView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StoryView.java    From zom-android-matrix with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #2
Source File: StoryView.java    From zom-android-matrix with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: PagePDFViewer.java    From BBSSDK-for-Android with Apache License 2.0 4 votes vote down vote up
protected View initViewerContentView(Context context) {
	pdfView = new PDFView(context, null);
	return pdfView;
}
 
Example #4
Source File: DefaultScrollHandle.java    From AndroidPdfViewerV2 with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example #5
Source File: DefaultLinkHandler.java    From AndroidPdfViewer with Apache License 2.0 4 votes vote down vote up
public DefaultLinkHandler(PDFView pdfView) {
    this.pdfView = pdfView;
}
 
Example #6
Source File: DefaultScrollHandle.java    From AndroidPdfViewer with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example #7
Source File: ScrollHandle.java    From AndroidPdfViewerV2 with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
 
Example #8
Source File: ScrollHandle.java    From AndroidPdfViewer with Apache License 2.0 2 votes vote down vote up
/**
 * 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);