首页 文章 精选 留言 我的

精选列表

搜索[隐私浏览],共10000篇文章
优秀的个人博客,低调大师

Android使用TBS浏览器加载pdf等文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qingfeng812/article/details/79077350 项目结构 技术方案 TBS的其它优点,可以自行搜索网上其它资料,很多。 加载文件核心类是 TbsReaderView,腾讯文档没有写,所以需要查找网上资料。 TBS目前只支持加载本地文件。所以远程文件需要先下载,后用TBS加载文件显示。 负责加载和显示文件的界面,离开本界面之后务必需要销毁,否则再次加载文件无法加载成功,会一直显示加载文件进度条。 关键代码: mTbsReaderView.onStop();//销毁界面的时候一定要加上,否则后面加载文件会发生异常。 完整项目源码 package com.yifeng.sample.tbs; import android.app.DownloadManager; import android.app.DownloadManager.Request; import android.content.Intent; import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.RelativeLayout; import com.tencent.smtt.sdk.TbsReaderView; import com.tencent.smtt.sdk.TbsReaderView.ReaderCallback; import java.io.File; public class MainActivity extends AppCompatActivity implements ReaderCallback { private TbsReaderView mTbsReaderView; private Button mDownloadBtn; private DownloadManager mDownloadManager; private long mRequestId; private DownloadObserver mDownloadObserver; private String mFileUrl = "http://www.beijing.gov.cn/zhuanti/ggfw/htsfwbxzzt/shxfl/fw/P020150720516332194302.doc"; private String mFileName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTbsReaderView = new TbsReaderView(this, this); mDownloadBtn = (Button) findViewById(R.id.btn_download); RelativeLayout rootRl = (RelativeLayout) findViewById(R.id.rl_root); rootRl.addView(mTbsReaderView, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mFileName = parseName(mFileUrl); if (isLocalExist()) { mDownloadBtn.setText("打开文件"); } if (isLocalExist()) { mDownloadBtn.setVisibility(View.GONE); displayFile(); } else { startDownload(); } } @Override public void onBackPressed() { startActivity(new Intent(MainActivity.this,IndexActivity.class)); finish();//不关掉此界面,之后加载文件会无法加载 } public void onClickDownload(View v) { // if (isLocalExist()) { // mDownloadBtn.setVisibility(View.GONE); // displayFile(); // } else { // startDownload(); // } } private void displayFile() { Bundle bundle = new Bundle(); bundle.putString("filePath", "/storage/emulated/0/uu/HTTP权威指南.pdf"); bundle.putString("tempPath", Environment.getExternalStorageDirectory().getPath()); boolean result = mTbsReaderView.preOpen(parseFormat("HTTP权威指南.pdf"), false); if (result) { mTbsReaderView.openFile(bundle); } } private String parseFormat(String fileName) { return fileName.substring(fileName.lastIndexOf(".") + 1); } private String parseName(String url) { String fileName = null; try { fileName = url.substring(url.lastIndexOf("/") + 1); } finally { if (TextUtils.isEmpty(fileName)) { fileName = String.valueOf(System.currentTimeMillis()); } } return fileName; } private boolean isLocalExist() { return getLocalFile().exists(); } private File getLocalFile() { return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), mFileName); } private void startDownload() { mDownloadObserver = new DownloadObserver(new Handler()); getContentResolver().registerContentObserver(Uri.parse("content://downloads/my_downloads"), true, mDownloadObserver); mDownloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(mFileUrl)); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mFileName); request.allowScanningByMediaScanner(); request.setNotificationVisibility(Request.VISIBILITY_HIDDEN); mRequestId = mDownloadManager.enqueue(request); } private void queryDownloadStatus() { DownloadManager.Query query = new DownloadManager.Query().setFilterById(mRequestId); Cursor cursor = null; try { cursor = mDownloadManager.query(query); if (cursor != null && cursor.moveToFirst()) { //已经下载的字节数 int currentBytes = cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); //总需下载的字节数 int totalBytes = cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_TOTAL_SIZE_BYTES)); //状态所在的列索引 int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); Log.i("downloadUpdate: ", currentBytes + " " + totalBytes + " " + status); mDownloadBtn.setText("正在下载:" + currentBytes + "/" + totalBytes); if (DownloadManager.STATUS_SUCCESSFUL == status && mDownloadBtn.getVisibility() == View.VISIBLE) { mDownloadBtn.setVisibility(View.GONE); mDownloadBtn.performClick(); } } } finally { if (cursor != null) { cursor.close(); } } } @Override public void onCallBackAction(Integer integer, Object o, Object o1) { } @Override protected void onDestroy() { super.onDestroy(); mTbsReaderView.onStop(); if (mDownloadObserver != null) { getContentResolver().unregisterContentObserver(mDownloadObserver); } } private class DownloadObserver extends ContentObserver { private DownloadObserver(Handler handler) { super(handler); } @Override public void onChange(boolean selfChange, Uri uri) { Log.i("downloadUpdate: ", "onChange(boolean selfChange, Uri uri)"); queryDownloadStatus(); } } }

优秀的个人博客,低调大师

Elasticsearch之shield(权限)插件安装之后的浏览详解

访问es:-u es_admin 表示使用用户es_admin进行访问 [hadoop@HadoopMaster elasticsearch-2.4.3]$ pwd /home/hadoop/app/elasticsearch-2.4.3 [hadoop@HadoopMaster elasticsearch-2.4.3]$ curl -u es_admin -XGET 'http://192.168.80.10:9200/' Enter host password for user 'es_admin': { "name" : "node-0", "cluster_name" : "escluster", "cluster_uuid" : "gBwdRD7iRRyC6TRji7ohFw", "version" : { "number" : "2.4.3", "build_hash" : "d38a34e7b75af4e17ead16f156feffa432b22be3", "build_timestamp" : "2016-12-07T16:28:56Z", "build_snapshot" : false, "lucene_version" : "5.5.2" }, "tagline" : "You Know, for Search" } [hadoop@HadoopMaster elasticsearch-2.4.3]$ curl -u es_admin -XGET 'http://localhost:9200/' 或 curl -u es_admin -XGET 'http://192.168.80.10:9200/' [hadoop@HadoopSlave1 elasticsearch-2.4.3]$ pwd /home/hadoop/app/elasticsearch-2.4.3 [hadoop@HadoopSlave1 elasticsearch-2.4.3]$ bin/shield/esusers useradd es_admin -r admin Enter new password: Retype new password: [hadoop@HadoopSlave1 elasticsearch-2.4.3]$ curl -u es_admin -XGET 'http://192.168.80.11:9200/' Enter host password for user 'es_admin': { "name" : "node-1", "cluster_name" : "escluster", "cluster_uuid" : "gBwdRD7iRRyC6TRji7ohFw", "version" : { "number" : "2.4.3", "build_hash" : "d38a34e7b75af4e17ead16f156feffa432b22be3", "build_timestamp" : "2016-12-07T16:28:56Z", "build_snapshot" : false, "lucene_version" : "5.5.2" }, "tagline" : "You Know, for Search" } [hadoop@HadoopSlave1 elasticsearch-2.4.3]$ [hadoop@HadoopSlave2 elasticsearch-2.4.3]$ pwd /home/hadoop/app/elasticsearch-2.4.3 [hadoop@HadoopSlave2 elasticsearch-2.4.3]$ bin/shield/esusers useradd es_admin -r admin Enter new password: Retype new password: [hadoop@HadoopSlave2 elasticsearch-2.4.3]$ curl -u es_admin -XGET 'http://192.168.80.12:9200/' Enter host password for user 'es_admin': { "name" : "node-2", "cluster_name" : "escluster", "cluster_uuid" : "gBwdRD7iRRyC6TRji7ohFw", "version" : { "number" : "2.4.3", "build_hash" : "d38a34e7b75af4e17ead16f156feffa432b22be3", "build_timestamp" : "2016-12-07T16:28:56Z", "build_snapshot" : false, "lucene_version" : "5.5.2" }, "tagline" : "You Know, for Search" } [hadoop@HadoopSlave2 elasticsearch-2.4.3]$ 访问的会提示输入刚才设置的密码。(我刚才输入的密码是123456,用户名是es_admin)。 这样以后再访问es的时候就需要输入用户名和密码了。 本文转自大数据躺过的坑博客园博客,原文链接:http://www.cnblogs.com/zlslch/p/6618757.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

haproxy根据客户端浏览器进行跳转

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 根据手机端 acliphonehdr_sub(user-agent)-iiphone redirectprefix if iphone aclandroidhdr_sub(user-agent)-iandroid redirectprefix if android 根据访问后缀 acltest_picpath_end.gif.png.jpg.css.js use_backendnginxpools if test_pic 根据访问开始路径来匹配 acltest_staticpath_beg /html/ aclhd_domhdr(Host)-i test .com -i忽略大小写 hdr是函数 methodhttp方法 req_ver请求版本 resp_ver响应版本 statushttp状态 url精确匹配url url_reg正则匹配 url_dir斜线之间 url_dom斜线之间或点之间 在haproxy匹配的时候根据use_backend先后顺序进行匹配 Haproxy健康检查方式 1.基于端口的健康检查方式 checkport80 2.基于http的 head 的ipurl健康检查方式 optionhttpchkHEEAD /health .txtHTTP /1 .0 serverweb1192.168.1.2:80maxconn20480weight8checkinter3000fall2rise2 3.基于http的get的健康检查方式 optionhttpchkGET /health .txt 4.基于具体业务域名的URL健康检查 optionhttpchkHEAD /index .jspHTTP /1 .1\r\nHost: optionhttpchkGET /index .jspHTTP /1 .1\r\nHost:www. test .com haproxy中backup参数的使用 本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1689112

优秀的个人博客,低调大师

浏览器都能做人脸检测了?

Shape Detection API 的发布已经有一些时日,其主要的提供的能力是给予前端直接可用的特征检测的接口(包括条形码、人脸、文本检测)。本文将简单的对其进行介绍,对前端进行人脸检测进行普适性的讲解。(本文不讲算法~望轻拍) 1 背景与场景 人脸检测(Face Detection)算是老生常谈的课题了,在诸多行业应用广泛,例如金融、安防、电子商务、智能手机、娱乐图片等行业。其中涉及的技术也在不断的演变,下面简要介绍几种思路: 基于特征的人脸检测 例如opencv中内置了基于Viola-Jones目标检测框架的Harr分类器,只需要载入一个配置文件(haarcascade_frontalface_alt.xml)就能直接调用detectObject去完成检测过程,同时也支持其他特征的检测(如鼻子、嘴巴等)。 基于学习的人脸检测,其实也

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册