CopyProcess.java 6.4 KB

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