Giter Site home page Giter Site logo

zhongxiaohong / superfileview Goto Github PK

View Code? Open in Web Editor NEW
1.2K 37.0 220.0 38.02 MB

基于腾讯浏览服务Tbs,使用X5Webkit内核,实现文件的展示功能,支持多种文件格式

License: Apache License 2.0

Java 100.00%
pdf android docx excel txt ppt tbs word doc

superfileview's Introduction

交流群 540686217

说明

  • 基于腾讯浏览服务,支持多种文件格式,例如doc、excel、ppt、excel、pdf等格式;
  • 支持展示网络文件
  • 支持测试本demo之前先把test文件夹里的文件复制到手机存储,方便测试,路径如下: 这里写图片描述

TBS服务接入

参考腾讯TBS官网,地址:https://x5.tencent.com/tbs/guide/sdkInit.html

效果图

这里写图片描述

常见问题

  • no suport by

出现这个错误提示的原因,首先可能是手机上没有Tbs内核,如果有tbs内核,则可能是内核正在初始化安装,还处于冷启动阶段,这个时候内核还不能使用,打开文件会出现这个错误,可以使用可以按如下方式确定内核是否成功加载并且可用: 方法1:

  QbSdk.initX5Environment(this, new QbSdk.PreInitCallback() {
            @Override
            public void onCoreInitFinished() {

            }

            @Override
            public void onViewInitFinished(boolean b) {
              //这里被回调,并且b=true说明内核初始化并可以使用
              //如果b=false,内核会尝试安装,你可以通过下面监听接口获知
            }
        });

       QbSdk.setTbsListener(new TbsListener() {
           @Override
           public void onDownloadFinish(int i) {
              //tbs内核下载完成回调
          }

           @Override
           public void onInstallFinish(int i) {
              //内核安装完成回调,
          }

           @Override
           public void onDownloadProgress(int i) {
                //下载进度监听
           }
       });

方法2:

QbSdk.preInit(this, new QbSdk.PreInitCallback() {
            @Override
            public void onCoreInitFinished() {
             
            }

            @Override
            public void onViewInitFinished(boolean b) {
              
            }
        });
        //tbs内核下载跟踪
        QbSdk.setTbsListener(this.tbsListener);
        //判断是否要自行下载内核
        boolean needDownload = TbsDownloader.needDownload(this, TbsDownloader.DOWNLOAD_OVERSEA_TBS);
        if (needDownload && isNetworkWifi(this)) {
        //isNetworkWifi(this)是我
        //自己写的一个方法,这里我也希望wifi下再下载
            TbsDownloader.startDownload(this);
        }

方法1、方法2 主要的区别在于方法1更加“自动”,内部会自动判断需不需要下载内核,因此在使用方法1来初始化的话,需要注意一下,此时tbs内核在非Wifi状态下是默认不会下载的,你可以通过以下方法来改变这个设置: QbSdk.setDownloadWithoutWifi(true);  

  • 插件加载失败

首次打开相关文件的时候需要下载相关文件的插件,因此需要保持网络可用状态,否则下载插件失败会出现这个错误。

  • NoSuchMethodException: onCallBackAction

这个错误我也是懵逼,不管成功打开与否,都会有这玩意,所以暂时先忽略。

博客

http://www.jianshu.com/p/3f57d640b24d

superfileview's People

Contributors

zhongxiaohong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

superfileview's Issues

在同一个界面不能重复打开文档

第一次打开成功,选择其他文档后重新加载不出来,提示

invokeInstance -- exceptions:java.lang.NoSuchMethodException: onCallBackAction [class java.lang.Integer, class java.lang.Object, class java.lang.Object]

这个错误,能看看吗

not supported by:docx、not supported by:pdf

前几天还是可以的,现在一直报这样的错误!

10-17 11:10:38.375 22880-22880/com.silang.superfileview D/FileDisplayActivity: 文件path:/storage/emulated/0/test.docx
10-17 11:10:38.376 22880-22880/com.silang.superfileview D/superFileLog: /storage/emulated/0/test.docx
10-17 11:10:38.376 22880-22880/com.silang.superfileview D/SuperFileView: paramString:/storage/emulated/0/test.docx
10-17 11:10:38.376 22880-22880/com.silang.superfileview D/SuperFileView: paramString.substring(i + 1)------>docx
10-17 11:10:38.383 22880-22880/com.silang.superfileview E/TbsReaderView: not supported by:docx
10-17 11:10:38.483 22880-22880/com.silang.superfileview I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@28738328 time:92399976
10-17 11:10:50.969 22880-22880/com.silang.superfileview I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@15a6c1d9 time:92412462
10-17 11:10:51.255 22880-22880/com.silang.superfileview D/superFileLog: FileDisplayActivity-->onDestroy
10-17 11:10:51.874 22880-22880/com.silang.superfileview W/EasyPermissions: hasPermissions: API version < M, returning true by default
10-17 11:10:51.874 22880-22880/com.silang.superfileview I/Timeline: Timeline: Activity_launch_request id:com.silang.superfileview time:92413368
10-17 11:10:51.981 22880-22880/com.silang.superfileview D/FileDisplayActivity: 文件path:/storage/emulated/0/test.pdf
10-17 11:10:51.982 22880-22880/com.silang.superfileview D/superFileLog: /storage/emulated/0/test.pdf
10-17 11:10:51.982 22880-22880/com.silang.superfileview D/SuperFileView: paramString:/storage/emulated/0/test.pdf
10-17 11:10:51.982 22880-22880/com.silang.superfileview D/SuperFileView: paramString.substring(i + 1)------>pdf
10-17 11:10:51.990 22880-22880/com.silang.superfileview E/TbsReaderView: not supported by:pdf

tbs文件阅读器问题

之前我也使用过tbs作为文件阅读器,但是为什么我用的时候,文件浏览页面都会有下载qq浏览器的链接,而你这里却没有呢?

无语的not supported by:txt

懂事是好东西,但是我真心无力了,直接运行,一点问题没有,打包在运行,MMP,文件提示不支持

打开文本文档和PPT文档有一些bug。

有的文本文档打开会重复显示里面的内容;还有在打开PPT的时候,有时候能正常显示,但是有时候就显示不出来,屏幕就一片灰啥都没有,返回到上一界面再重新打开有概率会正常显示。
楼主设置什么原因?求解。

不知道你们有没有碰过这个需求,就是在网页上浏览pdf

不知道你们有没有碰过这个需求,就是在网页上浏览pdf,这样链接就可以点击多次,你可以优化一下,把添加view的操作和删除view的操作抽出来,写成方法,这样就不怕多次点击链接了,删除view的时候顺便把tbsreader.onstop一下

Demo 网络下载查看有点问题

首先,非常感谢楼主的Demo!
原Demo中的网络下载发现下载失败,查看了一下log,发现楼主创建了一个007的文件夹,下载的文件却扔进了10086的文件夹中,故扔出异常!
FileDisplayActivity类 185行 007 ->10086

右下角按钮能不能隐藏啊

有个问题 每次打开 右下角都会有 最近文件 按钮,点击这个按钮没有反应,可不可以将这个按钮隐藏啊

打开本地报错

invokeInstance -- exceptions:java.lang.NoSuchMethodException: onCallBackAction [class java.lang.Integer, class java.lang.Object, class java.lang.Object]
at java.lang.Class.getMethod(Class.java:1981)
at java.lang.Class.getMethod(Class.java:1637)
at com.tencent.tbs.reader.TbsReaderEventProxy.invokeInstance(Unknown Source)
at com.tencent.tbs.reader.TbsReaderEventProxy.doCallBackEvent(Unknown Source)
at com.tencent.tbs.reader.TbsReader.initReader(Unknown Source)
at com.tencent.tbs.reader.TbsReader.openFile(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.tencent.smtt.export.external.DexLoader.invokeMethod(Unknown Source)
at com.tencent.smtt.sdk.p.a(Unknown Source)
at com.tencent.smtt.sdk.TbsReaderView.openFile(Unknown Source)
at com.silang.superfileview.SuperFileView2.displayFile(SuperFileView2.java:80)
at com.silang.superfileview.FileDisplayActivity.getFilePathAndShowFile(FileDisplayActivity.java:72)

有问题

demo 只打开了PPT
其他格式都是失败呢 兄弟

奇怪问题,之前用了好几天了都可以查看文件,今天突然就用不了了

java.lang.NumberFormatException: null
at com.manage.port.portmanage.views.office.SuperFileView2.displayFile(SuperFileView2.java:74)
12-07 16:45:27.856 24673-24673/com.manage.port.portmanage W/System.err: at com.manage.port.portmanage.views.office.FileDisplayActivity$3.onResponse(FileDisplayActivity.java:170)

12-07 16:45:27.861 24673-24673/com.manage.port.portmanage E/TbsReaderView: not supported by:pdf

我把你的代码粘贴到我的项目中,出现了问题.

第一次读取pdf或者ppt是可以的,等我第二次进入的时候,就一直显示正在加载中,之后就是一直都是正在加载中了,也不显示内容....不知道为什么..你的demo没问题,到我的项目中就有这个问题了.

Draw own view or change text on failure.

I have tried your view, the one problem I got is on load failure or on some error. How can I show my custom view? Or at least tell me how to change the text from Chinese to any other language. I even noticed view prompt on the lower right corner of the screen when I open the view second time and while opening also. How can I change this ?

java.lang.ClassNotFoundException: Didn't find class "retrofit2.Callback"

                                                                        Caused by: java.lang.ClassNotFoundException: Didn't find class "retrofit2.Callback" on path: DexPathList[[zip file "/data/app/com.sse.android.xxx-2/base.apk"],nativeLibraryDirectories=[/data/app/com.sse.android.xxx-2/lib/arm, /system/fake-libs, /data/app/com.sse.android.xxx-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]

集成遇到这个问题,请问怎么解决?按照网上的方法都试了,还是不行...

缓存目录和缓存文件路径写错了

作者代码里缓存目录写了007,但是缓存文件路径却写了10086
这导致了 open failed: ENOENT (No such file or directory)

    /***
     * 获取缓存目录
     *
     * @param url
     * @return
     */
    private File getCacheDir(String url) {

        return new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/007/");

    }
    /***
     * 绝对路径获取缓存文件
     *
     * @param url
     * @return
     */
    private File getCacheFile(String url) {
        File cacheFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/10086/"
                + getFileName(url));
        TLog.d(TAG, "缓存文件 = " + cacheFile.toString());
        return cacheFile;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.