码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-04-25 00:55:05      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:book   filetype   intent   int   tencent   top   layout   加载失败   you   

一、明日计划

解决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

 

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

标签:book   filetype   intent   int   tencent   top   layout   加载失败   you   

原文地址:https://www.cnblogs.com/yeyueweiliang/p/12771079.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!