EccPrintLog.java 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. package epson.maintain.activity;
  2. import android.os.AsyncTask;
  3. import android.os.Bundle;
  4. import android.webkit.WebView;
  5. import android.webkit.WebViewClient;
  6. import androidx.fragment.app.DialogFragment;
  7. import androidx.fragment.app.FragmentActivity;
  8. import androidx.lifecycle.Observer;
  9. import androidx.lifecycle.ViewModelProviders;
  10. import epson.common.DialogProgress;
  11. import epson.common.DialogProgressViewModel;
  12. import epson.print.ActivityIACommon;
  13. import epson.print.R;
  14. import epson.print.Util.EPLog;
  15. import epson.print.ecclient.EccErrorInfo;
  16. import java.lang.ref.WeakReference;
  17. import java.util.Deque;
  18. import java.util.Locale;
  19. import org.opencv.core.Core;
  20. public class EccPrintLog extends ActivityIACommon implements DialogProgress.DialogButtonClick {
  21. private static final String DIALOG_ERROR = "dialog_error";
  22. private static final String DIALOG_PROGRESS = "dialog_progress";
  23. static final String LOG_TAG = "EccPrintLog";
  24. static RemotePrintHistoryTask mRemotePrintHistoryTask;
  25. private EccPrintLogViewModel mEccPrintLogViewModel;
  26. private DialogProgressViewModel mModelDialog;
  27. private WebView mWebView;
  28. public void onCancelDialog(String str) {
  29. }
  30. public void onNegativeClick(String str) {
  31. }
  32. public void onNeutralClick(String str) {
  33. }
  34. protected void onCreate(Bundle bundle) {
  35. EPLog.i(LOG_TAG, "onCreate() start");
  36. super.onCreate(bundle);
  37. setContentView(R.layout.epsonconnect_print_log);
  38. mModelDialog = (DialogProgressViewModel) ViewModelProviders.of((FragmentActivity) this).get(DialogProgressViewModel.class);
  39. mModelDialog.getDialogJob().observe(this, new Observer() {
  40. public final void onChanged(Object obj) {
  41. EccPrintLog.lambda$onCreate$0(EccPrintLog.this, (Deque) obj);
  42. }
  43. });
  44. mEccPrintLogViewModel = (EccPrintLogViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(EccPrintLogViewModel.class);
  45. setActionBar(R.string.epsonconnect_str_print_history, true);
  46. mWebView = (WebView) findViewById(R.id.prtlog_webview);
  47. mWebView.setVerticalScrollbarOverlay(true);
  48. mWebView.getSettings().setJavaScriptEnabled(true);
  49. mWebView.setWebViewClient(new WebViewClient() {
  50. public void onReceivedError(WebView webView, int i, String str, String str2) {
  51. int i2;
  52. if (i != -15) {
  53. switch (i) {
  54. case Core.StsAutoTrace /*-8*/:
  55. case -7:
  56. case -6:
  57. break;
  58. default:
  59. i2 = -1200;
  60. break;
  61. }
  62. }
  63. i2 = -1100;
  64. EccPrintLog.this.show_message_and_finish(i2);
  65. }
  66. });
  67. startRemotePrintHistoryTask();
  68. }
  69. public static /* synthetic */ void lambda$onCreate$0(EccPrintLog eccPrintLog, Deque deque) {
  70. String[] checkQueue = eccPrintLog.mModelDialog.checkQueue();
  71. if (checkQueue != null) {
  72. String str = checkQueue[0];
  73. String str2 = checkQueue[1];
  74. if (str2.equals("do_show")) {
  75. eccPrintLog.showDialog(str);
  76. }
  77. if (str2.equals("do_dismiss")) {
  78. eccPrintLog.dismissDialog(str);
  79. }
  80. }
  81. }
  82. private synchronized void startRemotePrintHistoryTask() {
  83. if (mRemotePrintHistoryTask == null) {
  84. EPLog.i(LOG_TAG, "RemotePrintHistoryTask creating.");
  85. LogUrl logUrl = new LogUrl();
  86. logUrl.setContextDependValue(this);
  87. mRemotePrintHistoryTask = new RemotePrintHistoryTask(this);
  88. mRemotePrintHistoryTask.execute(new LogUrl[]{logUrl});
  89. } else {
  90. EPLog.i(LOG_TAG, "RemotePrintHistoryTask exists. not create");
  91. mRemotePrintHistoryTask.setActivity(this);
  92. }
  93. showProgressDialog();
  94. }
  95. private String[] getErrorTitleAndMessage(int i) {
  96. String str;
  97. String str2;
  98. String[] strArr = new String[2];
  99. getString(R.string.ECC_ERR_SVR_GENERAL_TITLE);
  100. if (i != -1100) {
  101. if (i != 10) {
  102. switch (i) {
  103. case EccErrorInfo.ECC_ERR_SVR_HTTP_NOT_FOUND /*-1209*/:
  104. case EccErrorInfo.ECC_ERR_SVR_BUSY /*-1208*/:
  105. str = getString(R.string.ECC_ERR_SVR_BUSY_TITLE);
  106. str2 = getString(R.string.ECC_ERR_SVR_BUSY);
  107. break;
  108. default:
  109. switch (i) {
  110. case -1203:
  111. str = getString(R.string.ECC_ERR_SVR_INVALID_ACCESSKEY_TITLE);
  112. str2 = getString(R.string.ECC_ERR_SVR_INVALID_ACCESSKEY);
  113. break;
  114. case -1202:
  115. str = getString(R.string.ECC_ERR_SVR_REMOTE_INVALID_TITLE);
  116. str2 = getString(R.string.ECC_ERR_SVR_REMOTE_INVALID);
  117. break;
  118. case -1201:
  119. str = getString(R.string.ECC_ERR_SVR_NOT_REGISTERED_TITLE);
  120. str2 = getString(R.string.ECC_ERR_SVR_NOT_REGISTERED);
  121. break;
  122. }
  123. }
  124. } else {
  125. getString(R.string.ECC_ERR_SVR_GENERAL_TITLE);
  126. }
  127. String string = getString(R.string.ECC_ERR_SVR_GENERAL_TITLE);
  128. str2 = getString(R.string.ECC_ERR_SVR_GENERAL2) + "0X" + Integer.toHexString(i).toUpperCase(Locale.US) + getString(R.string.ECC_ERR_SVR_GENERAL3);
  129. str = string;
  130. } else {
  131. str = getString(R.string.EC_ERR_COMM_ERROR_TITLE);
  132. str2 = getString(R.string.EC_ERR_COMM_ERROR);
  133. }
  134. strArr[0] = str;
  135. strArr[1] = str2;
  136. return strArr;
  137. }
  138. private void show_message_and_finish(int i) {
  139. mEccPrintLogViewModel.setTitleAndMessage(getErrorTitleAndMessage(i));
  140. mModelDialog.doShow(DIALOG_ERROR);
  141. }
  142. protected void onDestroy() {
  143. dissmissProgressDialog();
  144. super.onDestroy();
  145. }
  146. private void dissmissProgressDialog() {
  147. mModelDialog.doDismiss(DIALOG_PROGRESS);
  148. }
  149. private void showProgressDialog() {
  150. mModelDialog.doShow(DIALOG_PROGRESS);
  151. }
  152. private void showDialog(java.lang.String r12) {
  153. throw new UnsupportedOperationException("Method not decompiled: epson.maintain.activity.EccPrintLog.showDialog(java.lang.String):void");
  154. }
  155. private void dismissDialog(String str) {
  156. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
  157. if (dialogFragment != null) {
  158. dialogFragment.dismiss();
  159. }
  160. }
  161. public synchronized void setUrl(String str, int i) {
  162. mRemotePrintHistoryTask = null;
  163. EPLog.i(LOG_TAG, "setUrl");
  164. dissmissProgressDialog();
  165. if (str == null || i != 0) {
  166. show_message_and_finish(i);
  167. }
  168. if (mWebView != null) {
  169. mWebView.loadUrl(str);
  170. }
  171. }
  172. public void onPositiveClick(String str) {
  173. if (((str.hashCode() == 722082897 && str.equals(DIALOG_ERROR)) ? (char) 0 : 65535) == 0) {
  174. finish();
  175. }
  176. }
  177. static class RemotePrintHistoryTask extends AsyncTask<LogUrl, Void, Void> {
  178. WeakReference<EccPrintLog> mEccPrintLog;
  179. int mErrorCode;
  180. private String mLogUrl;
  181. public RemotePrintHistoryTask(EccPrintLog eccPrintLog) {
  182. mEccPrintLog = new WeakReference<>(eccPrintLog);
  183. }
  184. public void setActivity(EccPrintLog eccPrintLog) {
  185. mEccPrintLog = new WeakReference<>(eccPrintLog);
  186. }
  187. protected Void doInBackground(LogUrl... logUrlArr) {
  188. try {
  189. mLogUrl = logUrlArr[0].getUrl();
  190. mErrorCode = 0;
  191. return null;
  192. } catch (EccPrintLogException e) {
  193. mErrorCode = e.getErrorCode();
  194. return null;
  195. }
  196. }
  197. protected void onPostExecute(Void voidR) {
  198. EccPrintLog eccPrintLog;
  199. EPLog.i(EccPrintLog.LOG_TAG, "onPostExecute() begin");
  200. WeakReference<EccPrintLog> weakReference = mEccPrintLog;
  201. if (weakReference != null && (eccPrintLog = (EccPrintLog) weakReference.get()) != null) {
  202. eccPrintLog.setUrl(mLogUrl, mErrorCode);
  203. EPLog.i(EccPrintLog.LOG_TAG, "onPostExecute() end");
  204. }
  205. }
  206. }
  207. }