|
|
@@ -115,7 +115,7 @@ public class PDFDownloadActivity extends BaseActivity implements View.OnClickLis
|
|
|
break;
|
|
|
case com.core.app.Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
result = msg.getData().getString("response");
|
|
|
- if (TextUtils.isEmpty(JSON.parseObject(result).getString("exceptionInfo"))) {
|
|
|
+ if (JSON.parseObject(result) != null && TextUtils.isEmpty(JSON.parseObject(result).getString("exceptionInfo"))) {
|
|
|
analysisPdfPath(result);
|
|
|
} else {
|
|
|
ToastMessage(msg.getData().getString("result"));
|
|
|
@@ -151,23 +151,7 @@ public class PDFDownloadActivity extends BaseActivity implements View.OnClickLis
|
|
|
downloadUrl = responseObject.optString("path");
|
|
|
if (!TextUtils.isEmpty(downloadUrl)) {
|
|
|
downloadUrl = replace + "report/" + downloadUrl;
|
|
|
- mPauseTextView.setVisibility(View.VISIBLE);
|
|
|
- breakPoints = 0L;
|
|
|
- File directory = new File(PDF_FILE_PATH);
|
|
|
- if (!directory.exists() && !directory.isDirectory()) {
|
|
|
- boolean mkdirs = directory.mkdirs();
|
|
|
-
|
|
|
- } else {
|
|
|
- CommonUtil.delAllFile(PDF_FILE_PATH);
|
|
|
- }
|
|
|
- file = new File(PDF_FILE_PATH, PDF_FILE_NAME);
|
|
|
- try {
|
|
|
- file.createNewFile();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- mDownloader = new ProgressDownloader(downloadUrl, file, PDFDownloadActivity.this);
|
|
|
- mDownloader.download(0L);
|
|
|
+ downloadPdf();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -178,6 +162,26 @@ public class PDFDownloadActivity extends BaseActivity implements View.OnClickLis
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void downloadPdf() {
|
|
|
+ mPauseTextView.setVisibility(View.VISIBLE);
|
|
|
+ breakPoints = 0L;
|
|
|
+ File directory = new File(PDF_FILE_PATH);
|
|
|
+ if (!directory.exists() && !directory.isDirectory()) {
|
|
|
+ boolean mkdirs = directory.mkdirs();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ CommonUtil.delAllFile(PDF_FILE_PATH);
|
|
|
+ }
|
|
|
+ file = new File(PDF_FILE_PATH, PDF_FILE_NAME);
|
|
|
+ try {
|
|
|
+ file.createNewFile();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ mDownloader = new ProgressDownloader(downloadUrl, file, PDFDownloadActivity.this);
|
|
|
+ mDownloader.download(0L);
|
|
|
+ }
|
|
|
+
|
|
|
private void displayFromFile(File fileName) {
|
|
|
try {
|
|
|
mPDFView.fromFile(fileName)
|
|
|
@@ -248,8 +252,15 @@ public class PDFDownloadActivity extends BaseActivity implements View.OnClickLis
|
|
|
// downloadUrl = "http://print.ubtob.com/report/pdf/data?u=" + CommonUtil.getSharedPreferences(ct, "erp_master")
|
|
|
// + "&pf=phone&r=" + mReportName + "&w=where " + mCondition;
|
|
|
|
|
|
- replace = CommonUtil.getAppBaseUrl(this).replace("ERP/", "");
|
|
|
+ try {
|
|
|
+ String appBaseUrl = CommonUtil.getAppBaseUrl(this);
|
|
|
+ replace = appBaseUrl.substring(0, appBaseUrl.length() - 1);
|
|
|
+ replace = replace.substring(0, replace.lastIndexOf("/") + 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ replace = CommonUtil.getAppBaseUrl(this).replace("ERP/", "");
|
|
|
+ }
|
|
|
|
|
|
+ Log.d("pdfurl", replace);
|
|
|
mPDFView = (PDFView) findViewById(R.id.pdf_download_pdfview);
|
|
|
mPDFView.useBestQuality(true);
|
|
|
|
|
|
@@ -280,7 +291,11 @@ public class PDFDownloadActivity extends BaseActivity implements View.OnClickLis
|
|
|
mStateTextView.setText(R.string.str_loading);
|
|
|
mErrorLinearLayout.setVisibility(View.GONE);
|
|
|
// PDFUtils.downloadPDF(downloadUrl, mHandler);
|
|
|
- obtainPdfPath();
|
|
|
+ if (TextUtils.isEmpty(downloadUrl)) {
|
|
|
+ obtainPdfPath();
|
|
|
+ } else {
|
|
|
+ downloadPdf();
|
|
|
+ }
|
|
|
break;
|
|
|
case R.id.pdf_download_pause_tv:
|
|
|
if (getString(R.string.pause_download).equals(mPauseTextView.getText().toString())) {
|