CopyProcess.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package epson.print.rpcopy;
  2. import android.content.Context;
  3. import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
  4. import java.util.Iterator;
  5. import epson.print.CommonDefine;
  6. import epson.print.R;
  7. import epson.print.rpcopy.Component.ecopycomponent.ECopyComponent;
  8. import epson.print.rpcopy.Component.ecopycomponent.ECopyOptionItem;
  9. public class CopyProcess implements ECopyComponent.ICopyStatusListener {
  10. ActivityBase activityBase;
  11. ECopyComponent.ICopyCancelRequest cancelRequest;
  12. ECopyComponent copyComponent;
  13. boolean disconnectWifi;
  14. String jobToken;
  15. ActivityBase.errorDialog printererror;
  16. ActivityBase.WheelDialog wheel;
  17. public CopyProcess(ActivityBase activityBase2) {
  18. this(activityBase2, (String) null);
  19. }
  20. public CopyProcess(ActivityBase activityBase2, String str) {
  21. copyComponent = ECopyComponent.sharedComponent();
  22. disconnectWifi = false;
  23. activityBase = activityBase2;
  24. jobToken = str;
  25. ActivityBase activityBase3 = activityBase;
  26. activityBase3.getClass();
  27. wheel = new ActivityBase.WheelDialog(activityBase);
  28. }
  29. public void startCopy(Context context) {
  30. String str = jobToken;
  31. cancelRequest = str == null ? copyComponent.startCopy(this, context) : copyComponent.recoverCopy(str, this);
  32. }
  33. public void onStarted(ECopyComponent.ICopyStatusListener.CopyTaskType copyTaskType) {
  34. wheel.show(activityBase.getString(R.string.CopyTaskProgressCopying), new ActivityBase.CancelRequestCallback() {
  35. public void onCancelRequest() {
  36. cancelRequest.cancel();
  37. }
  38. });
  39. }
  40. public void onProcessed(ECopyComponent.ICopyStatusListener.CopyTaskType copyTaskType, int i, int i2, ECopyComponent.ICopyStatusListener.CopyTaskProgress copyTaskProgress, final ECopyComponent.ICopyResumeRequest iCopyResumeRequest) {
  41. ActivityBase.errorDialog errordialog = printererror;
  42. if (errordialog != null) {
  43. errordialog.Cancel();
  44. }
  45. if (copyTaskProgress.equals(ECopyComponent.ICopyStatusListener.CopyTaskProgress.Copying) || copyTaskProgress.equals(ECopyComponent.ICopyStatusListener.CopyTaskProgress.Processing)) {
  46. ActivityBase.WheelDialog wheelDialog = wheel;
  47. wheelDialog.setText(activityBase.getString(R.string.CopyTaskProgressCopying) + " " + i2 + CommonDefine.SLASH + i);
  48. } else {
  49. wheel.setText("");
  50. }
  51. switch (copyTaskProgress) {
  52. case Stopped:
  53. ActivityBase activityBase2 = activityBase;
  54. activityBase2.getClass();
  55. printererror = new ActivityBase.errorDialog(activityBase);
  56. ECopyComponent.ICopyResumeRequest.StopReason stopReason = iCopyResumeRequest.getStopReason();
  57. if (stopReason.equals(ECopyComponent.ICopyResumeRequest.StopReason.PrinterMediaEmptyError)) {
  58. Iterator<ECopyOptionItem> it = copyComponent.getCopyOptionItems().iterator();
  59. while (it.hasNext()) {
  60. ECopyOptionItem next = it.next();
  61. if (next.getKey().equals(ECopyOptionItem.ECopyOptionItemKey.PrintMediaSource) && next.getSelectedChoice().equals(ECopyOptionItem.ECopyOptionItemChoice.PrintMediaSource_Manual)) {
  62. stopReason = ECopyComponent.ICopyResumeRequest.StopReason.ManualfeedGuide;
  63. }
  64. }
  65. }
  66. String[] reasonText = printererror.getReasonText(stopReason);
  67. printererror.showErrorDialog(reasonText[0], reasonText[1], iCopyResumeRequest.isPossibleClearError() ? ActivityBase.DialogButtons.ClearErrorCancel : ActivityBase.DialogButtons.Cancel, new ActivityBase.IClose() {
  68. public void onClose(ActivityBase.ClickButton clickButton) {
  69. iCopyResumeRequest.resume(clickButton == ActivityBase.ClickButton.ClearError ? ECopyComponent.ICopyResumeRequest.ResumeState.ClearError : ECopyComponent.ICopyResumeRequest.ResumeState.Cancel);
  70. }
  71. });
  72. return;
  73. case Waiting2ndPage:
  74. activityBase.showNextPageDialog(new ActivityBase.INextPageClose() {
  75. public void onClose(ECopyComponent.ICopyResumeRequest.ResumeState resumeState) {
  76. iCopyResumeRequest.resume(resumeState);
  77. }
  78. });
  79. return;
  80. case Canceling:
  81. wheel.hideCancelButton();
  82. return;
  83. default:
  84. return;
  85. }
  86. }
  87. public void onFinished(ECopyComponent.ICopyStatusListener.CopyTaskType copyTaskType, ECopyComponent.ICopyStatusListener.CopyTaskResult copyTaskResult) {
  88. wheel.dismiss();
  89. switch (copyTaskResult) {
  90. case Succeed:
  91. Iterator<ECopyOptionItem> it = copyComponent.getCopyOptionItems().iterator();
  92. while (it.hasNext()) {
  93. ECopyOptionItem next = it.next();
  94. if (next.getKey().equals(ECopyOptionItem.ECopyOptionItemKey.Copies)) {
  95. next.selectValue(next.getDefaultValue());
  96. copyComponent.setCopyOptionItem(next);
  97. }
  98. }
  99. break;
  100. case Busy:
  101. case ErrorCommunication:
  102. case RemoveAdfPaper:
  103. case ErrorOther:
  104. ActivityBase activityBase2 = activityBase;
  105. activityBase2.getClass();
  106. printererror = new ActivityBase.errorDialog(activityBase);
  107. String[] reasonText = printererror.getReasonText(copyTaskResult);
  108. printererror.showErrorDialog(reasonText[0], reasonText[1], ActivityBase.DialogButtons.Ok, new ActivityBase.IClose() {
  109. public void onClose(ActivityBase.ClickButton clickButton) {
  110. }
  111. });
  112. break;
  113. }
  114. if (disconnectWifi) {
  115. WiFiDirectManager.disconnect(activityBase, WiFiDirectManager.DEVICE_TYPE_PRINTER, ActivityBase.printerIp);
  116. }
  117. }
  118. public boolean isProccessing() {
  119. return wheel.isShowing();
  120. }
  121. public void setDisconnectWifi(boolean z) {
  122. disconnectWifi = z;
  123. }
  124. }