This article i will introduce how to render PDF from url. This is more convenient and easy method to render PDF in android from url without downloading file in local storage.
To render pdf from url you need library, please add below dependency in your app level gradle file build.gradle(Module:app)
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
Now add below code in your xml file
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"/>
Place below code in your activity inside onCreate and replace myPdfUrl with your actual pdf url
new RetrievePDFStream().execute(myPdfUrl);
add below Async function in your activity outside onCreate
public class RetrievePDFStream extends AsyncTask<String, Void, InputStream> {
ProgressDialog progressDialog;
protected void onPreExecute()
{
progressDialog = new ProgressDialog(LoadPdfActivity.this);
progressDialog.setTitle("Fetching attachment...");
progressDialog.setMessage("Please wait...");
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.show();
}
@Override
protected InputStream doInBackground(String... strings) {
InputStream inputStream = null;
try {
URL urlx = new URL(strings[0]);
HttpURLConnection urlConnection = (HttpURLConnection) urlx.openConnection();
if (urlConnection.getResponseCode() == 200) {
inputStream = new BufferedInputStream(urlConnection.getInputStream());
}
} catch (IOException e) {
return null;
}
return inputStream;
}
@Override
protected void onPostExecute(InputStream inputStream) {
pdfView.fromStream(inputStream)
.enableSwipe(true) // allows to block changing pages using swipe
.swipeHorizontal(false)
.enableDoubletap(true)
.defaultPage(0)
.onError(new OnErrorListener() {
@Override
public void onError(Throwable t) {
Toast.makeText(LoadPdfActivity.this,"Something went wrong, please contact administrator.",Toast.LENGTH_LONG).show();
}
})
.onPageError(new OnPageErrorListener() {
@Override
public void onPageError(int page, Throwable t) {
Toast.makeText(LoadPdfActivity.this,"Something went wrong, please contact administrator.",Toast.LENGTH_LONG).show();
}
})
.enableAnnotationRendering(false) // render annotations (such as comments, colors or forms)
.password(null)
.scrollHandle(null)
.enableAntialiasing(true) // improve rendering a little bit on low-res screens
// spacing between pages in dp. To define spacing color, set view background
.spacing(0).load();
progressDialog.dismiss();
}
}
Now run your app and see your PDF will load in your app
This article will introduce how to generate SHA1 for release Keystore. This is more convenient and easy method to generate SHA1.
To find out the Android SHA1 fingerprint for release keystore, follow these steps:
cd C:\Program Files\Java\jdk1.7.0_05\bin
keytool -list -v -keystore {keystore_name} -alias {alias_name}
keytool -list -v -keystore C:\Users\MG\Desktop\test.jks -alias test
It will prompt for a password. Enter the password, you will get the SHA1 and MD5 fingerprint.
Android SHA1 Fingerprint Extracting the SHA1 fingerprint from an Android keystore cannot be simpler than this. Above steps can be used on Windows, Mac and on Linux machines.
For Debug mode:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
不知道大家是怎样安排自己的日常计划的,我习惯是建立一个仓库,按照年/周记录在 markdown 里,平时这个仓库也写点简单的 demo,目录类似如下:
week
├── 2016
├── 2017
├── 2018
│ ├── 20180102.md
│ ├── 20180108.md
│ ├── 20180115.md
│ ├── 20180122.md
│ ├── 20180126.md
│ ├── ...
│ ├── ...
│ ├── ...
│ ├── 20181007.md
│ ├── pixi.md
│ ├── schedule.md
│ ├── temp.css
│ ├── temp.html
│ ├── temp.js
│ ├── temp.json
│ └── temp.md
├── package.json
└── yarn.lock
lottie 是一个可以轻易的给各种 native app 添加高质量动画的类库。可以在 iOS、Android 和 React Native 实时渲染 After Effects 动画,就像使用静态图片一样容易。上图即为 lottie 的 logo。
简单的说,lottie 动画制作的流程是,通过 Bodymovin 扩展将 AE 动画导出为 json 数据,然后再将这个 json 渲染在客户端或者 web 端。如下图:
与其他开发人员不同的是,前端开发都是在端上游走舞者,直接与用户交流沟通,这就需要前端开发具有更敏锐的交互体验思考,或者能更精准地理解设计师们意图,将最佳的用户体验带给用户。优质的交互体验对于用户来说学习成本应该是极低的,都是非常自然的操作,却可以让用户感到畅快愉悦,甚至惊喜。本文将通过一个看似简单的 poplayer 来分析我在这其中通过思考做的体验优化,获得类似 native 的体验感。
关于写倒计时大家可能都都比较熟悉,使用 setTimeout 或 setInterval 就可以搞定。几秒钟或者几分钟的倒计时这样写没有问题,但是如果是长时间的倒计时,这样写就会不准确。如果用户修改了他的设备时间,这样的倒计时就没有意义了。今天就说说写一个精确的倒计时的方法。