|
|
@@ -2,24 +2,15 @@ package com.usai.apex;
|
|
|
|
|
|
import android.animation.Animator;
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
-import android.app.Activity;
|
|
|
-import android.app.AlertDialog;
|
|
|
-import android.app.AlertDialog.Builder;
|
|
|
-import android.app.Dialog;
|
|
|
-import android.app.DownloadManager;
|
|
|
-import android.app.DownloadManager.Request;
|
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.ClipboardManager;
|
|
|
import android.content.Context;
|
|
|
-import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.Color;
|
|
|
-import android.net.Uri;
|
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.support.constraint.ConstraintLayout;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.text.Html;
|
|
|
@@ -32,7 +23,6 @@ import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.View.OnClickListener;
|
|
|
import android.view.ViewGroup;
|
|
|
-import android.webkit.DownloadListener;
|
|
|
import android.webkit.WebResourceRequest;
|
|
|
import android.webkit.WebResourceResponse;
|
|
|
import android.webkit.WebView;
|
|
|
@@ -45,6 +35,7 @@ import android.widget.ScrollView;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
+import com.usai.apex.pdf.PDFPreviewActivity;
|
|
|
import com.usai.util.Network;
|
|
|
import com.usai.util.RAUtil;
|
|
|
import com.usai.util.commonUtil;
|
|
|
@@ -808,6 +799,53 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
showProgress(false);
|
|
|
}
|
|
|
}
|
|
|
+ private void showQuickLook(final String url) {
|
|
|
+
|
|
|
+ showProgressDialog("Please wait","Downloading...");
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+ String cacheDir = ApexTrackingApplication.getInstance().getExternalCacheDir().getAbsolutePath();//ApexTrackingApplication.getInstance().getDocumentDir();
|
|
|
+
|
|
|
+ final Bundle param = new Bundle();
|
|
|
+ // 下载文件
|
|
|
+ final File downloadFile = Network.downloadFile(param,url,cacheDir);
|
|
|
+
|
|
|
+ getActivity().runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ if (downloadFile != null && downloadFile.exists()) {
|
|
|
+ String email = null,email_subject = null,email_content = null;
|
|
|
+ //此处需要新增保存文档的本地表
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ email = mContent.getString("email");
|
|
|
+ email_subject = mContent.getString("email_subject");
|
|
|
+ email_content = mContent.getString("email_content");
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+// email=param.getString("email");
|
|
|
+// email_subject=param.getString("email_subject");
|
|
|
+// email_content=param.getString("email_content");
|
|
|
+
|
|
|
+ previewPDF(downloadFile.getAbsolutePath(),email,email_subject,email_content);
|
|
|
+ } else {
|
|
|
+ showAlert("Sorry,there is a wrong.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// public class DataFragment extends Fragment {
|
|
|
//
|
|
|
@@ -829,10 +867,60 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
+ public void showAlert(String msg) {
|
|
|
+ if (msg == null || msg.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ new android.support.v7.app.AlertDialog.Builder(mContext)
|
|
|
+ .setMessage(msg)
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ protected void previewPDF(String file,String email,String subject,String content) {
|
|
|
+ Intent myIntent = new Intent();
|
|
|
+ myIntent = new Intent(getActivity(), PDFPreviewActivity.class);
|
|
|
+
|
|
|
+ myIntent.putExtra("file",file);
|
|
|
+ myIntent.putExtra("iscache",true);
|
|
|
+
|
|
|
+ try {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+// email = "66666@qq.com";
|
|
|
+// subject = "test subject";
|
|
|
+// content = "test body";
|
|
|
+ if (email != null) {
|
|
|
+ json.put("email",email);
|
|
|
+ }
|
|
|
+ if (subject != null) {
|
|
|
+ json.put("subject",subject);
|
|
|
+ }
|
|
|
+ if (content != null) {
|
|
|
+ json.put("content",content);
|
|
|
+ }
|
|
|
+ myIntent.putExtra("email",json.toString());
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ startActivity(myIntent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void download(String url) {
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- public void download(String url) {
|
|
|
|
|
|
final String download_url = url;
|
|
|
+
|
|
|
+ showQuickLook(url);
|
|
|
+ if(true)
|
|
|
+ return;
|
|
|
+
|
|
|
showProgressDialog("Please wait","Downloading...");
|
|
|
new Thread(new Runnable() {
|
|
|
@Override
|
|
|
@@ -894,6 +982,8 @@ public class DetailFragment extends Fragment implements OnClickListener /*
|
|
|
Log.d("Web Client", "onReceivedError: ");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
|
|
|