• 明日计划:团队开发Fooks第十天


    一、明日计划

    解决ShareSDK官方版本更新后无法加载新的SDK的问题,对个人信息的修改进行添加

    二、今日成果

    成功使用x5内核打开下载的文档

    package com.example.fooks;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Environment;
    import android.text.TextUtils;
    import android.util.Log;
    import android.widget.RelativeLayout;
    
    import androidx.annotation.Nullable;
    
    import com.example.fooks.utils.APPAplication;
    import com.tencent.smtt.sdk.TbsReaderView;
    
    import java.io.File;
    
    public class BookActivity extends Activity implements TbsReaderView.ReaderCallback {
        private TbsReaderView mTbsReaderView;
        private  com.tencent.smtt.sdk.WebView mTBWebview;
    //    com.tencent.smtt.sdk.WebView webView = new com.tencent.smtt.sdk.WebView(this);
    //
    //    int width = webView.getView().getWidth();
    
        private String mUsername;
        private String mPath;
        private String mBookName;
        private String TAG="BookActivity";
    
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_book);
    
    
            Intent intent =getIntent();
            mUsername =intent.getStringExtra("username");
            mBookName=intent.getStringExtra("bookName");
            mPath=intent.getStringExtra("path");
            Log.e(TAG,"用户名"+mUsername);
            Log.e(TAG,"书名"+mBookName);
            Log.e(TAG,"路径"+mPath);
            initView();
            OpenBook();
        }
    
        private void OpenBook() {
            File file =new File(mPath);
            if (!file.exists()) {
                Log.d("print","准备创建/TbsReaderTemp!!");
                boolean mkdir = file.mkdir();
                if(!mkdir){
                    Log.d("print","创建/TbsReaderTemp失败!!!!!");
                }
            }
            Bundle bundle = new Bundle();
       /*   1.TbsReader: Set reader view exception:Cannot add a null child view to a ViewGroup
            TbsReaderView: OpenFile failed! [可能是文件的路径错误]*/
       /*   2.插件加载失败
            so文件不支持;*/
       /*
       ndk {
                //设置支持的SO库架构  'arm64-v8a',
                abiFilters 'armeabi', "armeabi-v7a",  'x86'
            } */
       /*
            3.自适应大小
        */
            Log.d("print","filePath"+mPath);//可能是路径错误
            Log.d("print","tempPath"+Environment.getExternalStorageDirectory().getPath());
            bundle.putString("filePath", mPath);
            bundle.putString("tempPath", Environment.getExternalStorageDirectory().getPath());
            boolean result = mTbsReaderView.preOpen(getFileType(mBookName), false);
            if (result) {
                mTbsReaderView.openFile(bundle);
            }
        }
    
    
    
    
        private void initView() {
            mTbsReaderView=new TbsReaderView (this, this);
            mTBWebview= findViewById(R.id.tbsView);
            com.tencent.smtt.sdk.WebView webView = new com.tencent.smtt.sdk.WebView(this);
    
            int width = webView.getView().getWidth();
            mTBWebview.addView(mTbsReaderView,new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
        }
    
        private String getFileType(String paramString) {
            String str = "";
            if (TextUtils.isEmpty(paramString)) {
                return str;
            }
            int i = paramString.lastIndexOf('.');
            if (i <= -1) {
                return str;
            }
            str = paramString.substring(i + 1);
            return str;
        }
        @Override
        protected void onStop() {
            super.onStop ();
        }
    
        @Override
        protected void onDestroy() {
            super.onDestroy ();
            mTbsReaderView.onStop ();
        }
    
    
        @Override
        public void onCallBackAction(Integer integer, Object o, Object o1) {
    
        }
    }
    BookActivity.java
  • 相关阅读:
    901Air724UG模块(4G全网通GPRS开发)Air724UG(4G)使用SPI控制CH395Q(以太网模块)实现TCP/IP通信
    02STM32+MN316(NBIOT)基本控制篇(自建MQTT服务器)硬件使用说明
    Docker 清理none镜像 Prune命令
    Leetcode 252. 会议室 253. 会议室II 贪心算法扫描线技巧
    Leetcode 77. 组合(中等)回溯算法
    Leetcode 787. K 站中转内最便宜的航班(中等) 动态规划
    Leetcode 174. 地下城游戏(困难) 动态规划
    Linux arm环境下pip3安装av失败
    Leetcode 134. 加油站(中等) 贪心算法
    Leetcode 698. 划分为k个相等的子集(中等) 回溯算法=集合划分
  • 原文地址:https://www.cnblogs.com/yeyueweiliang/p/12771079.html
Copyright © 2020-2023  润新知