ActivityViewImageSelect.java 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678
  1. package epson.print;
  2. import android.app.Activity;
  3. import android.app.AlertDialog;
  4. import android.arch.lifecycle.Observer;
  5. import android.arch.lifecycle.ViewModelProviders;
  6. import android.content.ComponentName;
  7. import android.content.Context;
  8. import android.content.DialogInterface;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.ServiceConnection;
  12. import android.content.SharedPreferences;
  13. import android.content.res.Configuration;
  14. import android.database.Cursor;
  15. import android.net.Uri;
  16. import android.os.AsyncTask;
  17. import android.os.Bundle;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Message;
  21. import android.os.RemoteException;
  22. import android.support.annotation.MainThread;
  23. import android.view.KeyEvent;
  24. import android.view.Menu;
  25. import android.view.MenuItem;
  26. import android.view.View;
  27. import android.widget.AdapterView;
  28. import android.widget.Button;
  29. import android.widget.Gallery;
  30. import android.widget.ImageButton;
  31. import android.widget.ImageView;
  32. import android.widget.LinearLayout;
  33. import android.widget.TextView;
  34. import android.widget.Toast;
  35. import android.widget.ZoomControls;
  36. import com.epson.iprint.apf.ApfAdapter;
  37. import com.epson.iprint.apf.ApfPreviewView;
  38. import com.epson.iprint.prtlogger.NewLoggerController;
  39. import com.epson.iprint.prtlogger.PrintLog;
  40. import com.epson.iprint.shared.EpsoniPrintSharedActivity;
  41. import com.epson.iprint.shared.SharedParamPhoto;
  42. import com.epson.mobilephone.common.escpr.MediaInfo;
  43. import com.epson.mobilephone.common.license.LicenseTopActivity;
  44. import com.epson.mobilephone.common.wifidirect.NfcTagUtils;
  45. import java.io.File;
  46. import java.io.FileNotFoundException;
  47. import java.io.FileOutputStream;
  48. import java.io.IOException;
  49. import java.io.InputStream;
  50. import java.util.ArrayList;
  51. import java.util.Deque;
  52. import java.util.Iterator;
  53. import epson.common.Constants;
  54. import epson.common.DialogProgressViewModel;
  55. import epson.common.ExternalFileUtils;
  56. import epson.common.IprintLicenseInfo;
  57. import epson.common.IprintUserSurveyInfo;
  58. import epson.common.OsAssistant;
  59. import epson.common.Utils;
  60. import epson.print.Util.AsyncTaskExecutor;
  61. import epson.print.Util.EPLog;
  62. import epson.print.imgsel.PhotoImageSelectActivity;
  63. import epson.print.phlayout.PhotoPreview;
  64. import epson.print.phlayout.PhotoPreviewImageList;
  65. import epson.print.screen.PaperSourceInfo;
  66. import epson.print.screen.PaperSourceSetting;
  67. import epson.print.screen.PaperSourceSettingScr;
  68. import epson.print.screen.PrintProgress;
  69. import epson.print.screen.PrintSetting;
  70. import epson.print.screen.SettingScr;
  71. import epson.print.service.EpsonService;
  72. import epson.print.service.IEpsonService;
  73. import epson.print.service.IEpsonServiceCallback;
  74. public class ActivityViewImageSelect extends ActivityIACommon implements View.OnClickListener, PhotoPreview.ViewSizeChangeListener, ReviewInvitationDialog.OnClickListener {
  75. private static final int ALL_REFRESH_DRAW_END = 4;
  76. private static final String DIALOG_ALL_UPDATE = "dialog_all_update";
  77. private static final String DIALOG_KEY_STORE_DIALOG = "store-dialog";
  78. private static final String DIALOG_LOAD = "dialog_load";
  79. private static final String DIALOG_PROGRESS = "dialog_progress";
  80. private static final int FROM_EPSON_PHOTO = 0;
  81. private static final int FROM_NOT_PHOTO = 1;
  82. public static final String LIST_ALBUM = "listAlbum";
  83. private static final int LOAD_ALL_IMAGE = 3;
  84. static final int MAX_IMAGE_NUMBER = 30;
  85. private static final int MESSAGE_OUT_OF_MEMORY_ERROR_NOTIFY = 8;
  86. private static final int OUT_OF_MEMORY_ERROR = 7;
  87. public static final String PARAMS_KEY_EPSON_COLOR_MODE = "epson_color_mode";
  88. public static final String PARAMS_KEY_FROM_EPSON = "FROM_EPSON";
  89. public static final String PARAMS_KEY_IMAGE_LIST = "imageList";
  90. public static final String PARAMS_KEY_PRINT_LOG = "print_log";
  91. private static final int PREVIEW_LOAD_DIALOG_DISMISS = 1;
  92. private static final int PREVIEW_LOAD_DIALOG_SHOW = 0;
  93. private static final int REQUEST_CODE_LICENSE_CHECK = 10;
  94. private static final int RESULT_RUNTIMEPERMMISSION = 9;
  95. private static final int START_PRINT = 5;
  96. private static final String TAG = "ActivityViewImageSelect";
  97. private static final int UPDATE_PAPERSIZE_TEXT = 6;
  98. private static final int ZOOM_CONTROL = 2;
  99. private ArrayList<PaperSourceSetting> aPaperSourceSetting;
  100. private ImageButton addButton = null;
  101. boolean bAutoStartPrint = false;
  102. boolean bRequestPermission = false;
  103. private Context context = null;
  104. private int currentColor = 0;
  105. private int currentLayout = 2;
  106. private int currentLayoutMulti = 0;
  107. private int currentPaperSize = 0;
  108. private String currentPrinterName = "";
  109. private Button deleteButton = null;
  110. private boolean enableShowWarning = true;
  111. private Gallery gallery = null;
  112. private GalleryAdapter galleryAdapter = null;
  113. private final PhotoPreviewImageList imageList = new PhotoPreviewImageList();
  114. private int imageNo = 0;
  115. private boolean isCustomAction = false;
  116. private boolean isPaperLandscape = false;
  117. private boolean isPrintedOK = false;
  118. private boolean isRemotePrinter = false;
  119. private boolean mAllReloadTaskDone;
  120. protected final Object mAllReloadTaskLock = new Object();
  121. private volatile boolean mAllReloadTaskRetryRequested;
  122. private IEpsonServiceCallback mCallback = new IEpsonServiceCallback.Stub() {
  123. public void onFindPrinterResult(String str, String str2, String str3, String str4, String str5) throws RemoteException {
  124. }
  125. public void onGetInkState() throws RemoteException {
  126. }
  127. public void onGetStatusState() throws RemoteException {
  128. }
  129. public void onNotifyContinueable(int i) throws RemoteException {
  130. }
  131. public void onNotifyEndJob(int i) throws RemoteException {
  132. }
  133. public void onNotifyError(int i, int i2, boolean z) throws RemoteException {
  134. }
  135. public void onNotifyProgress(int i, int i2) throws RemoteException {
  136. }
  137. };
  138. private boolean mEnableEpsonColorDisplay;
  139. private ImageView mEpsonColorImageView;
  140. private ServiceConnection mEpsonConnection = new ServiceConnection() {
  141. public void onServiceDisconnected(ComponentName componentName) {
  142. try {
  143. ActivityViewImageSelect.mEpsonService.unregisterCallback(ActivityViewImageSelect.mCallback);
  144. } catch (RemoteException e) {
  145. e.printStackTrace();
  146. }
  147. IEpsonService unused = ActivityViewImageSelect.mEpsonService = null;
  148. }
  149. public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
  150. IEpsonService unused = ActivityViewImageSelect.mEpsonService = IEpsonService.Stub.asInterface(iBinder);
  151. if (ActivityViewImageSelect.mEpsonService != null) {
  152. try {
  153. ActivityViewImageSelect.mEpsonService.registerCallback(ActivityViewImageSelect.mCallback);
  154. } catch (RemoteException e) {
  155. e.printStackTrace();
  156. }
  157. }
  158. }
  159. };
  160. private IEpsonService mEpsonService = null;
  161. private boolean mFileCheckEnd;
  162. Handler mHandler = new Handler(new Handler.Callback() {
  163. public boolean handleMessage(Message message) {
  164. if (ActivityViewImageSelect.this.isFinishing()) {
  165. return true;
  166. }
  167. int i = message.what;
  168. if (i != 100) {
  169. switch (i) {
  170. case 0:
  171. ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_LOAD);
  172. break;
  173. case 1:
  174. ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_LOAD);
  175. break;
  176. case 2:
  177. break;
  178. case 3:
  179. ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
  180. AllReloadTask unused = activityViewImageSelect.reloadTask = new AllReloadTask(activityViewImageSelect.context);
  181. if (ActivityViewImageSelect.this.reloadTask != null) {
  182. ActivityViewImageSelect.this.reloadTask.executeOnExecutor(new Void[0]);
  183. }
  184. ActivityViewImageSelect.mHandler.sendEmptyMessageDelayed(1, 300);
  185. break;
  186. default:
  187. switch (i) {
  188. case 5:
  189. ActivityViewImageSelect.this.startPrint();
  190. break;
  191. case 6:
  192. ActivityViewImageSelect.this.papersizeTextView.setText(ActivityViewImageSelect.this.getString(new MediaInfo.PaperSize().getStringId(ActivityViewImageSelect.this.currentPaperSize)));
  193. break;
  194. case 7:
  195. if (ActivityViewImageSelect.this.imageList.size() <= 0) {
  196. ActivityViewImageSelect.this.deleteButton.setEnabled(false);
  197. ActivityViewImageSelect.this.printButton.setEnabled(false);
  198. int unused2 = ActivityViewImageSelect.this.imageNo = 0;
  199. }
  200. TextView access$1900 = ActivityViewImageSelect.this.pageTextView;
  201. access$1900.setText(ActivityViewImageSelect.this.imageNo + CommonDefine.SLASH + ActivityViewImageSelect.this.imageList.size());
  202. ActivityViewImageSelect.this.updateGallery();
  203. ActivityViewImageSelect.this.previewImageView.invalidate();
  204. Toast.makeText(ActivityViewImageSelect.this.context, ActivityViewImageSelect.this.context.getString(R.string.file_size_notsupport), 1).show();
  205. break;
  206. case 8:
  207. ActivityViewImageSelect.this.showSimpleDialog(R.string.str_err_msg_out_of_memory_title);
  208. return true;
  209. }
  210. }
  211. } else {
  212. ArrayList unused3 = ActivityViewImageSelect.this.aPaperSourceSetting = message.getData().getParcelableArrayList(PaperSourceInfo.KEY_PAPERSOURCEINFO);
  213. if (ActivityViewImageSelect.this.aPaperSourceSetting != null) {
  214. ActivityViewImageSelect.this.papersizeTextView.setBackgroundColor(ActivityViewImageSelect.this.getResources().getColor(R.color.epson_blue));
  215. ActivityViewImageSelect.this.papersizeTextView.setTextColor(ActivityViewImageSelect.this.getResources().getColor(R.color.all_white));
  216. PrintSetting printSetting = new PrintSetting(ActivityViewImageSelect.this, PrintSetting.Kind.photo);
  217. printSetting.loadSettings();
  218. if (ActivityViewImageSelect.this.paperSourceInfo.checkPaperMissmatch(printSetting, ActivityViewImageSelect.this.aPaperSourceSetting)) {
  219. ActivityViewImageSelect.this.paperMissmath.setVisibility(View.VISIBLE);
  220. } else {
  221. ActivityViewImageSelect.this.paperMissmath.setVisibility(View.GONE);
  222. }
  223. } else {
  224. ActivityViewImageSelect.this.papersizeTextView.setBackgroundColor(ActivityViewImageSelect.this.getResources().getColor(R.color.all_white));
  225. ActivityViewImageSelect.this.papersizeTextView.setTextColor(ActivityViewImageSelect.this.getResources().getColor(R.color.epson_blue));
  226. ActivityViewImageSelect.this.paperMissmath.setVisibility(View.GONE);
  227. }
  228. }
  229. return true;
  230. }
  231. });
  232. private final ArrayList<String> mImageFilenameListFromIntent = new ArrayList<>();
  233. private int mIntentFileType = 0;
  234. protected volatile boolean mIsAllReloadTaskRetryAcceptable;
  235. private boolean mLicenseCheckDone;
  236. private DialogProgressViewModel mModelDialog;
  237. private boolean mOnSizeChangeReceived;
  238. private PrintLog mPrintLog;
  239. private ReviewInvitationViewModel mReviewInvitationViewModel;
  240. private int mStartActivityFromPhoto = 0;
  241. private TextView pageTextView = null;
  242. private ImageView paperMissmath = null;
  243. PaperSourceInfo paperSourceInfo = null;
  244. private TextView papersizeTextView = null;
  245. protected ApfPreviewView previewImageView;
  246. private Button printButton = null;
  247. private String printerId = "";
  248. private AllReloadTask reloadTask = null;
  249. private Button rotateButton = null;
  250. private ZoomControls zoomControls = null;
  251. public void onCreate(Bundle bundle) {
  252. super.onCreate(bundle);
  253. setContentView(R.layout.photo_preview);
  254. context = this;
  255. mReviewInvitationViewModel = (ReviewInvitationViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(ReviewInvitationViewModel.class);
  256. mReviewInvitationViewModel.getShowInvitationLiveData().observe(this, new Observer<Boolean>() {
  257. public void onChanged(@Nullable Boolean bool) {
  258. if (bool.booleanValue()) {
  259. ActivityViewImageSelect.this.showStoreDialog();
  260. }
  261. }
  262. });
  263. mOnSizeChangeReceived = false;
  264. mLicenseCheckDone = false;
  265. mFileCheckEnd = false;
  266. mModelDialog = (DialogProgressViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(DialogProgressViewModel.class);
  267. mModelDialog.getDialogJob().observe(this, new Observer() {
  268. public final void onChanged(Object obj) {
  269. ActivityViewImageSelect.lambda$onCreate$0(ActivityViewImageSelect.this, (Deque) obj);
  270. }
  271. });
  272. NewLoggerController.stopLoggerIfNotAgreed(this);
  273. setActionBar(R.string.photo_btn_label, true);
  274. ExternalFileUtils.getInstance(this).initTempViewDir();
  275. ExternalFileUtils.getInstance(this).initTempCRDir();
  276. ExternalFileUtils.getInstance(this).initPrintDir();
  277. Intent intent = getIntent();
  278. if (intent == null) {
  279. Toast.makeText(this, getString(R.string.no_image), 0).show();
  280. finish();
  281. }
  282. setFieldFromStartIntent(intent);
  283. if (mImageFilenameListFromIntent.size() == 0) {
  284. clearListToastAndFinish();
  285. return;
  286. }
  287. mEnableEpsonColorDisplay = getEpsonColorModeFromIntent(intent);
  288. PhotoPreview photoPreview = (PhotoPreview) findViewById(R.id.previewImageView);
  289. photoPreview.setViewSizeChangeListener(this);
  290. previewImageView = new ApfPreviewView();
  291. previewImageView.init(this, photoPreview);
  292. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  293. if (sharedPreferences != null) {
  294. currentPrinterName = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  295. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  296. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  297. printSetting.loadSettings();
  298. currentPaperSize = printSetting.paperSizeValue;
  299. currentLayout = printSetting.layoutValue;
  300. currentLayoutMulti = printSetting.layoutMultiPageValue;
  301. currentColor = printSetting.colorValue;
  302. previewImageView.setLayout(this.currentLayout, currentLayoutMulti);
  303. previewImageView.setPaper(this.currentPaperSize);
  304. previewImageView.setColor(this.currentColor);
  305. }
  306. previewImageView.setApfLibParams(0, 0, 0);
  307. papersizeTextView = (TextView) findViewById(R.id.btn_paper_size);
  308. papersizeTextView.setText(getPaperSizeName());
  309. papersizeTextView.setOnClickListener(this);
  310. pageTextView = (TextView) findViewById(R.id.btn_photo_count);
  311. Handler handler = mHandler;
  312. if (handler != null) {
  313. handler.sendEmptyMessage(2);
  314. }
  315. rotateButton = (Button) findViewById(R.id.bt_rotate);
  316. rotateButton.setOnClickListener(this);
  317. gallery = (Gallery) findViewById(R.id.gallery);
  318. if (mImageFilenameListFromIntent.size() != 0) {
  319. gallery.setCallbackDuringFling(false);
  320. gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  321. public void onNothingSelected(AdapterView<?> adapterView) {
  322. }
  323. public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
  324. if (ActivityViewImageSelect.this.imageNo != i) {
  325. int unused = ActivityViewImageSelect.this.imageNo = i;
  326. ActivityViewImageSelect.this.gallery.setSelection(ActivityViewImageSelect.this.imageNo);
  327. new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
  328. }
  329. }
  330. });
  331. }
  332. addButton = (ImageButton) findViewById(R.id.btn_add_photo);
  333. addButton.setOnClickListener(this);
  334. deleteButton = (Button) findViewById(R.id.btn_deselect);
  335. deleteButton.setOnClickListener(this);
  336. if (mImageFilenameListFromIntent.size() == 0) {
  337. deleteButton.setEnabled(false);
  338. }
  339. if (mStartActivityFromPhoto != 0) {
  340. addButton.setVisibility(View.GONE);
  341. deleteButton.setVisibility(View.GONE);
  342. }
  343. printButton = (Button) findViewById(R.id.btn_print);
  344. printButton.setOnClickListener(this);
  345. previewImageView.setZoomControlHandler(mHandler);
  346. paperMissmath = (ImageView) findViewById(R.id.icon_papermissmatch);
  347. mModelDialog.doShow(DIALOG_LOAD);
  348. enableShowWarning = getSharedPreferences(Constants.PREFS_EPSON_CONNECT, 0).getBoolean(Constants.ENABLE_SHOW_WARNING, true);
  349. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  350. switch (intent.getIntExtra("from", 0)) {
  351. case 3:
  352. setTitle(getString(R.string.document_btn_label));
  353. ((LinearLayout) findViewById(R.id.linearLayout3)).setVisibility(View.GONE);
  354. break;
  355. case 4:
  356. setTitle(getString(R.string.network_storage_title));
  357. ((LinearLayout) findViewById(R.id.linearLayout3)).setVisibility(View.GONE);
  358. break;
  359. default:
  360. setTitle(getString(R.string.photo_btn_label));
  361. break;
  362. }
  363. mEpsonColorImageView = (ImageView) findViewById(R.id.epsonColorImageView);
  364. updateEpsonColorStatus();
  365. paperSourceInfo = PaperSourceInfo.getInstance(this);
  366. if (mEpsonService == null) {
  367. bindService(new Intent(this, EpsonService.class), mEpsonConnection, 1);
  368. }
  369. if (bundle == null) {
  370. startLicenseCheckActivity();
  371. } else if (!permissionCheck()) {
  372. finish();
  373. }
  374. }
  375. public static /* synthetic */ void lambda$onCreate$0(ActivityViewImageSelect activityViewImageSelect, Deque deque) {
  376. String[] checkQueue = activityViewImageSelect.mModelDialog.checkQueue();
  377. if (checkQueue != null) {
  378. String str = checkQueue[0];
  379. String str2 = checkQueue[1];
  380. if (str2.equals("do_show")) {
  381. activityViewImageSelect.showDialog(str);
  382. }
  383. if (str2.equals("do_dismiss")) {
  384. activityViewImageSelect.dismissDialog(str);
  385. }
  386. }
  387. }
  388. private void showStoreDialog() {
  389. ReviewInvitationDialog.newInstance().show(getSupportFragmentManager(), DIALOG_KEY_STORE_DIALOG);
  390. }
  391. private void observeImageList(PhotoPreviewImageList photoPreviewImageList) {
  392. PhotoImageConvertViewModel photoImageConvertViewModel = (PhotoImageConvertViewModel) ViewModelProviders.m2of((FragmentActivity) this).get(PhotoImageConvertViewModel.class);
  393. photoImageConvertViewModel.getData().observe(this, new Observer<PhotoImageConvertViewModel.Result>() {
  394. public void onChanged(@Nullable PhotoImageConvertViewModel.Result result) {
  395. if (result.epImageWrappers == null) {
  396. ActivityViewImageSelect.this.clearListToastAndFinish();
  397. } else if (!ActivityViewImageSelect.this.setPhotoImageList(result.epImageWrappers)) {
  398. ActivityViewImageSelect.this.clearListToastAndFinish();
  399. } else {
  400. ActivityViewImageSelect.this.updateImageListDisplay();
  401. boolean unused = ActivityViewImageSelect.mFileCheckEnd = true;
  402. ActivityViewImageSelect.this.loadImage();
  403. }
  404. }
  405. });
  406. photoImageConvertViewModel.setOriginalImageList(mImageFilenameListFromIntent);
  407. }
  408. private void updateGallery() {
  409. galleryAdapter.setImageList(this.imageList.getGalleryFileList());
  410. }
  411. private boolean checkExternalStorageReadPermission() {
  412. return ActivityRequestPermissions.checkPermission(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"});
  413. }
  414. private void requestReadExternalStoragePermission() {
  415. ActivityRequestPermissions.requestPermission((Activity) this, new ActivityRequestPermissions.Permission(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}[0], new String[]{getString(R.string.permission_dialog_title), getString(R.string.permission_dialog_title)}, new String[]{ActivityRequestPermissions.DialogParameter.setMessage2((Context) this, getString(R.string.permission_dialog_message_storage)), ActivityRequestPermissions.DialogParameter.setMessage3A((Context) this, getString(R.string.permission_dialog_message_storage), getString(R.string.permission_function_storage))}), 9);
  416. bRequestPermission = true;
  417. }
  418. private boolean setPhotoImageList(@Nullable ArrayList<PhotoPreviewImageList.EpImageWrapper> arrayList) {
  419. imageList.clear();
  420. if (arrayList == null) {
  421. return false;
  422. }
  423. Iterator<PhotoPreviewImageList.EpImageWrapper> it = arrayList.iterator();
  424. while (it.hasNext()) {
  425. imageList.add(it.next());
  426. }
  427. if (this.imageList.size() <= 0) {
  428. return false;
  429. }
  430. return true;
  431. }
  432. private void updateImageListDisplay() {
  433. previewImageView.setImageList(this.imageList);
  434. TextView textView = pageTextView;
  435. textView.setText("1/" + imageList.size());
  436. if (this.imageList.size() == 0) {
  437. deleteButton.setEnabled(false);
  438. }
  439. }
  440. private void startLicenseCheckActivity() {
  441. IprintLicenseInfo.beforeLicenseCheck(getApplicationContext());
  442. startActivityForResult(LicenseTopActivity.getStartIntent(getApplicationContext(), new IprintLicenseInfo(), new IprintUserSurveyInfo()), 10);
  443. }
  444. private void setFieldFromStartIntent(@NonNull Intent intent) {
  445. ArrayList<String> arrayFileFullPath;
  446. int i = 0;
  447. isCustomAction = false;
  448. mImageFilenameListFromIntent.clear();
  449. mIntentFileType = 0;
  450. mStartActivityFromPhoto = 1;
  451. try {
  452. mPrintLog = (PrintLog) intent.getSerializableExtra("print_log");
  453. } catch (ClassCastException unused) {
  454. }
  455. if (EpsoniPrintSharedActivity.ACTION_PHOTO_PRINT.equals(intent.getAction())) {
  456. isCustomAction = true;
  457. SharedParamPhoto sharedParamPhoto = (SharedParamPhoto) intent.getSerializableExtra("extParam");
  458. if (sharedParamPhoto != null && (arrayFileFullPath = sharedParamPhoto.getArrayFileFullPath()) != null) {
  459. int i2 = 0;
  460. while (i < arrayFileFullPath.size()) {
  461. if (i2 < 30) {
  462. mImageFilenameListFromIntent.add(arrayFileFullPath.get(i));
  463. i2++;
  464. }
  465. i++;
  466. }
  467. if (sharedParamPhoto.isFileTypeValid()) {
  468. mIntentFileType = sharedParamPhoto.getFile_type();
  469. }
  470. mStartActivityFromPhoto = 1;
  471. } else {
  472. return;
  473. }
  474. } else {
  475. if (intent.getStringArrayListExtra(LIST_ALBUM) == null && intent.getStringArrayListExtra("imageList") == null && -1 == intent.getIntExtra("from", -1)) {
  476. new PrintSetting(this, (PrintSetting.Kind) null).resetPrintSettings();
  477. }
  478. if (intent.getStringArrayListExtra(LIST_ALBUM) != null) {
  479. if (intent.getBooleanExtra(CommonDefine.STYPE, false)) {
  480. mStartActivityFromPhoto = 1;
  481. intent.removeExtra(CommonDefine.STYPE);
  482. }
  483. ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra(LIST_ALBUM);
  484. if (stringArrayListExtra != null) {
  485. while (i < stringArrayListExtra.size()) {
  486. mImageFilenameListFromIntent.add(stringArrayListExtra.get(i));
  487. i++;
  488. }
  489. intent.removeExtra(LIST_ALBUM);
  490. } else {
  491. return;
  492. }
  493. } else if (intent.getBooleanExtra(PARAMS_KEY_FROM_EPSON, false)) {
  494. mStartActivityFromPhoto = 1;
  495. Uri uri = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
  496. if (uri != null) {
  497. String decode = Uri.decode(uri.getPath());
  498. if (decode != null) {
  499. mImageFilenameListFromIntent.add(decode);
  500. } else {
  501. return;
  502. }
  503. } else {
  504. ArrayList<String> stringArrayListExtra2 = intent.getStringArrayListExtra("android.intent.extra.STREAM");
  505. if (stringArrayListExtra2 != null) {
  506. while (i < stringArrayListExtra2.size()) {
  507. mImageFilenameListFromIntent.add(stringArrayListExtra2.get(i));
  508. i++;
  509. }
  510. } else {
  511. return;
  512. }
  513. }
  514. } else if ("android.intent.action.SEND".equals(intent.getAction())) {
  515. mStartActivityFromPhoto = 1;
  516. setPrintLogForExternalApp();
  517. try {
  518. Uri uri2 = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM");
  519. if (uri2 != null) {
  520. addImageByIntent(intent, uri2);
  521. } else {
  522. return;
  523. }
  524. } catch (Exception unused2) {
  525. return;
  526. }
  527. } else if ("android.intent.action.VIEW".equals(intent.getAction())) {
  528. mStartActivityFromPhoto = 1;
  529. setPrintLogForExternalApp();
  530. try {
  531. addImageByIntent(intent, intent.getData());
  532. } catch (Exception unused3) {
  533. }
  534. } else if ("android.intent.action.SEND_MULTIPLE".equals(intent.getAction())) {
  535. mStartActivityFromPhoto = 1;
  536. setPrintLogForExternalApp();
  537. Bundle extras = intent.getExtras();
  538. if (extras != null) {
  539. if (extras.get("android.intent.extra.STREAM") instanceof ArrayList) {
  540. try {
  541. ArrayList parcelableArrayListExtra = intent.getParcelableArrayListExtra("android.intent.extra.STREAM");
  542. if (parcelableArrayListExtra != null) {
  543. while (i < parcelableArrayListExtra.size() && i < 30) {
  544. try {
  545. addImageByIntent(intent, (Uri) parcelableArrayListExtra.get(i));
  546. i++;
  547. } catch (Exception unused4) {
  548. return;
  549. }
  550. }
  551. }
  552. } catch (Exception unused5) {
  553. return;
  554. }
  555. } else {
  556. try {
  557. addImageByIntent(intent, (Uri) intent.getExtras().getParcelable("android.intent.extra.STREAM"));
  558. } catch (Exception unused6) {
  559. return;
  560. }
  561. }
  562. } else {
  563. return;
  564. }
  565. } else {
  566. mStartActivityFromPhoto = 0;
  567. ArrayList<String> stringArrayListExtra3 = intent.getStringArrayListExtra("imageList");
  568. if (stringArrayListExtra3 != null) {
  569. while (i < stringArrayListExtra3.size()) {
  570. mImageFilenameListFromIntent.add(stringArrayListExtra3.get(i));
  571. i++;
  572. }
  573. } else {
  574. return;
  575. }
  576. }
  577. }
  578. if (mPrintLog == null) {
  579. mPrintLog = new PrintLog();
  580. }
  581. }
  582. private void setPrintLogForExternalApp() {
  583. if (mPrintLog == null) {
  584. mPrintLog = new PrintLog();
  585. }
  586. if (mPrintLog.callerPackage == null) {
  587. mPrintLog.callerPackage = getCallingPackage();
  588. }
  589. if (mPrintLog.uiRoute <= 0) {
  590. mPrintLog.uiRoute = 4097;
  591. }
  592. }
  593. private void requestPermissionOrObserveImageList() {
  594. if (!requestExternalStoragePermissionIfNeeded()) {
  595. observeImageList(this.imageList);
  596. }
  597. }
  598. private boolean requestExternalStoragePermissionIfNeeded() {
  599. if (!isPermissionRequestRequired(mImageFilenameListFromIntent)) {
  600. return false;
  601. }
  602. requestReadExternalStoragePermission();
  603. return true;
  604. }
  605. private boolean isPermissionRequestRequired(@NonNull ArrayList<String> arrayList) {
  606. if (!ActivityRequestPermissions.isRuntimePermissionSupported() || checkExternalStorageReadPermission()) {
  607. return false;
  608. }
  609. String lowerCase = ExternalFileUtils.getInstance(this).getWorkingDir().toLowerCase();
  610. Iterator<String> it = arrayList.iterator();
  611. while (it.hasNext()) {
  612. if (!it.next().toLowerCase().startsWith(lowerCase)) {
  613. return true;
  614. }
  615. }
  616. return false;
  617. }
  618. private void loadImage() {
  619. if (mFileCheckEnd && mOnSizeChangeReceived && mLicenseCheckDone) {
  620. galleryAdapter = new GalleryAdapter(getApplicationContext(), imageList.getGalleryFileList());
  621. gallery.setAdapter(this.galleryAdapter);
  622. gallery.setSelection(this.imageNo);
  623. galleryAdapter.setAlignLeft(this.gallery);
  624. mHandler.sendEmptyMessage(3);
  625. }
  626. }
  627. private void clearListToastAndFinish() {
  628. Toast.makeText(this, getString(R.string.file_size_notsupport), 1).show();
  629. imageList.clear();
  630. onBackPressed();
  631. }
  632. public static boolean checkBmpNot24Bit(@NonNull EPImage ePImage) {
  633. return Utils.checkMimeType(ePImage.loadImageFileName, CommonDefine.IMAGE_TYPE_BMP) && new EPImageUtil().getBitCount(ePImage.loadImageFileName) != 24;
  634. }
  635. private void addImageByIntent(Intent intent, Uri uri) {
  636. String contentFromCR;
  637. String type = intent.getType();
  638. String uri2 = uri.toString();
  639. if (uri2.startsWith("content://")) {
  640. Cursor cursor = null;
  641. try {
  642. cursor = getContentResolver().query(uri, new String[]{"_data"}, (String) null, (String[]) null, (String) null);
  643. } catch (IllegalArgumentException unused) {
  644. }
  645. if (cursor != null) {
  646. cursor.close();
  647. } else if (uri.toString().startsWith("content://com.android.gallery3d.provider")) {
  648. EPLog.m305d(TAG, "Actual URI: " + uri.toString());
  649. uri = Uri.parse(uri.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
  650. EPLog.m305d(TAG, "Effective URI: " + uri.toString());
  651. }
  652. String contentFromCR2 = getContentFromCR(uri, type);
  653. if (contentFromCR2 != null) {
  654. mImageFilenameListFromIntent.add(contentFromCR2);
  655. return;
  656. }
  657. String realPathFromURI = getRealPathFromURI(uri);
  658. if (realPathFromURI != null) {
  659. mImageFilenameListFromIntent.add(realPathFromURI);
  660. EPLog.m305d(TAG, "addImageByIntent by getRealPathFromURI");
  661. return;
  662. }
  663. } else if (uri2.startsWith("file://")) {
  664. if (type == null || type.length() <= 0 || (contentFromCR = getContentFromCR(uri, type)) == null) {
  665. String path = uri.getPath();
  666. if (path.startsWith("/file:")) {
  667. path = path.substring(6);
  668. }
  669. if (Utils.isPhotoFile(path)) {
  670. mImageFilenameListFromIntent.add(path);
  671. EPLog.m305d(TAG, "addImageByIntent by isPhotoFile()");
  672. return;
  673. }
  674. } else {
  675. mImageFilenameListFromIntent.add(contentFromCR);
  676. return;
  677. }
  678. }
  679. clearListToastAndFinish();
  680. }
  681. private String getContentFromCR(Uri uri, String str) {
  682. String str2;
  683. File file;
  684. EPLog.m305d(TAG, "getContentFromCR uri = " + uri + " fType = " + str);
  685. try {
  686. str2 = Utils.makeTempFileName(str);
  687. } catch (FileNotFoundException unused) {
  688. EPLog.m318w(TAG, "getContentFromCR Unknown fType = " + str);
  689. str2 = String.valueOf(System.currentTimeMillis());
  690. }
  691. try {
  692. InputStream openInputStream = getContentResolver().openInputStream(uri);
  693. File file2 = new File(ExternalFileUtils.getInstance(this).getTempCRDir(), str2);
  694. FileOutputStream fileOutputStream = new FileOutputStream(file2);
  695. byte[] bArr = new byte[1024];
  696. while (true) {
  697. int read = openInputStream.read(bArr);
  698. if (read <= 0) {
  699. break;
  700. }
  701. fileOutputStream.write(bArr, 0, read);
  702. }
  703. fileOutputStream.close();
  704. if (Utils.getExtention(file2.getName()) == null) {
  705. String realMimeType = Utils.getRealMimeType(file2.getAbsolutePath());
  706. String mimeExt = realMimeType != null ? Utils.getMimeExt(realMimeType) : null;
  707. if (mimeExt != null) {
  708. file = new File(file2.getAbsolutePath() + mimeExt);
  709. file2.renameTo(file);
  710. EPLog.m305d(TAG, "getContentFromCR success");
  711. return file.getAbsolutePath();
  712. }
  713. }
  714. file = file2;
  715. EPLog.m305d(TAG, "getContentFromCR success");
  716. return file.getAbsolutePath();
  717. } catch (IOException e) {
  718. e.printStackTrace();
  719. return null;
  720. }
  721. }
  722. public String getRealPathFromURI(Uri uri) {
  723. Cursor query = getContentResolver().query(uri, new String[]{"_data"}, (String) null, (String[]) null, (String) null);
  724. String str = null;
  725. if (query == null) {
  726. return null;
  727. }
  728. try {
  729. int columnIndexOrThrow = query.getColumnIndexOrThrow("_data");
  730. query.moveToFirst();
  731. str = query.getString(columnIndexOrThrow);
  732. } catch (Exception e) {
  733. e.printStackTrace();
  734. } catch (Throwable th) {
  735. query.close();
  736. throw th;
  737. }
  738. query.close();
  739. return str;
  740. }
  741. public static boolean checkEPImage(EPImage ePImage) {
  742. return ePImage != null && ePImage.srcWidth > 0 && ePImage.srcHeight > 0;
  743. }
  744. protected boolean getEpsonColorModeFromIntent(Intent intent) {
  745. return intent.getBooleanExtra(PARAMS_KEY_EPSON_COLOR_MODE, false);
  746. }
  747. private String getPaperSizeName() {
  748. MediaInfo.PaperSize paperSize = new MediaInfo.PaperSize();
  749. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  750. printSetting.loadSettings();
  751. return getString(paperSize.getStringId(printSetting.paperSizeValue));
  752. }
  753. private boolean permissionCheck() {
  754. if (!IprintLicenseInfo.isAgreedCurrentVersion(getApplicationContext())) {
  755. return false;
  756. }
  757. mLicenseCheckDone = true;
  758. requestPermissionOrObserveImageList();
  759. return true;
  760. }
  761. protected void onActivityResult(int i, int i2, Intent intent) {
  762. super.onActivityResult(i, i2, intent);
  763. switch (i) {
  764. case 5:
  765. if (i2 == -1) {
  766. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  767. String string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  768. if (!string.equals(this.currentPrinterName)) {
  769. currentPrinterName = string;
  770. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  771. updateEpsonColorStatus();
  772. bAutoStartPrint = true;
  773. mHandler.sendEmptyMessage(3);
  774. return;
  775. }
  776. onClick(this.printButton);
  777. EPLog.m305d(TAG, "onClick(printButton)");
  778. return;
  779. }
  780. return;
  781. case 9:
  782. if (i2 != -1) {
  783. clearListToastAndFinish();
  784. return;
  785. } else {
  786. requestPermissionOrObserveImageList();
  787. return;
  788. }
  789. case 10:
  790. if (!permissionCheck()) {
  791. mModelDialog.doDismiss(DIALOG_LOAD);
  792. finish();
  793. return;
  794. }
  795. return;
  796. case CommonDefine.REQUEST_SETTING /*254*/:
  797. onPrintSettingEnd(i2);
  798. return;
  799. case 255:
  800. unlockScreenRotation();
  801. if (i2 == 0) {
  802. setResult(i2);
  803. if (this.isCustomAction) {
  804. setResult(0);
  805. finish();
  806. return;
  807. }
  808. } else if (i2 != 4) {
  809. if (i2 == 1000) {
  810. printButton.setEnabled(true);
  811. ExternalFileUtils.getInstance(this).initPrintDir();
  812. return;
  813. }
  814. return;
  815. }
  816. mReviewInvitationViewModel.onPrintEnd(PrintProgress.isPrintSuccess(i2));
  817. if (this.isCustomAction) {
  818. setResult(-1);
  819. finish();
  820. return;
  821. }
  822. printButton.setEnabled(true);
  823. ExternalFileUtils.getInstance(this).initPrintDir();
  824. return;
  825. default:
  826. return;
  827. }
  828. }
  829. private void onPrintSettingEnd(int i) {
  830. int i2;
  831. boolean z;
  832. int i3;
  833. int i4;
  834. int i5;
  835. int i6;
  836. int i7;
  837. boolean z2;
  838. if (i == 3) {
  839. printButton.setEnabled(true);
  840. SharedPreferences sharedPreferences = getSharedPreferences("PrintSetting", 0);
  841. String string = getString(R.string.str_lbl_title_scan);
  842. printerId = sharedPreferences.getString(Constants.PRINTER_ID, (String) null);
  843. int i8 = 2;
  844. if (sharedPreferences != null) {
  845. string = sharedPreferences.getString(Constants.PRINTER_NAME, getString(R.string.str_lbl_title_scan));
  846. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  847. printSetting.loadSettings();
  848. i7 = printSetting.paperSizeValue;
  849. i8 = printSetting.layoutValue;
  850. i6 = printSetting.layoutMultiPageValue;
  851. i5 = printSetting.colorValue;
  852. i4 = printSetting.photoApfValueForLocalPrinter;
  853. i3 = printSetting.sharpnessForPhoto;
  854. int i9 = printSetting.paperTypeValue;
  855. int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
  856. EpLog.m77i("KIND = " + printSetting.getKind() + " NEW setteing = " + i9 + " plain = " + code);
  857. i2 = (i9 == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
  858. z = MyPrinter.isRemotePrinter(this);
  859. } else {
  860. i2 = 0;
  861. i7 = 0;
  862. i6 = 0;
  863. i5 = 0;
  864. i4 = 0;
  865. i3 = 0;
  866. z = false;
  867. }
  868. if (!this.currentPrinterName.equalsIgnoreCase(string)) {
  869. currentPrinterName = string;
  870. z2 = true;
  871. } else {
  872. z2 = false;
  873. }
  874. if (this.currentLayout != i8) {
  875. currentLayout = i8;
  876. previewImageView.setLayout(this.currentLayout, currentLayoutMulti);
  877. z2 = true;
  878. }
  879. if (this.currentLayoutMulti != i6) {
  880. currentLayoutMulti = i6;
  881. previewImageView.setLayout(this.currentLayout, currentLayoutMulti);
  882. z2 = true;
  883. }
  884. if (this.currentPaperSize != i7) {
  885. currentPaperSize = i7;
  886. previewImageView.setPaper(i7);
  887. papersizeTextView.setText(getString(new MediaInfo.PaperSize().getStringId(i7)));
  888. z2 = true;
  889. }
  890. if (this.currentColor != i5) {
  891. currentColor = i5;
  892. previewImageView.setColor(this.currentColor);
  893. z2 = true;
  894. }
  895. if (this.imageList.size() == 0) {
  896. printButton.setEnabled(false);
  897. }
  898. if (this.isRemotePrinter != z) {
  899. isRemotePrinter = z;
  900. z2 = true;
  901. }
  902. if (!z) {
  903. if (this.previewImageView.getApfMode() != i4) {
  904. z2 = true;
  905. }
  906. if (this.previewImageView.getSharpnessValue() != i3) {
  907. z2 = true;
  908. }
  909. if (this.previewImageView.getClearlyVividMode() != i2) {
  910. z2 = true;
  911. }
  912. }
  913. updateEpsonColorStatus();
  914. if (z2) {
  915. mHandler.sendEmptyMessage(3);
  916. }
  917. }
  918. }
  919. private boolean isEpsonColorMode() {
  920. boolean z = false;
  921. if (!mEnableEpsonColorDisplay) {
  922. return false;
  923. }
  924. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  925. printSetting.loadSettings();
  926. int apfValue = getApfValue(printSetting);
  927. int i = printSetting.paperTypeValue;
  928. int i2 = printSetting.colorValue;
  929. if (apfValue == 1) {
  930. z = true;
  931. }
  932. return ApfAdapter.isEpsonColor(this, i, i2, z);
  933. }
  934. private void updateEpsonColorStatus() {
  935. mEpsonColorImageView.setVisibility(isEpsonColorMode() ? 0 : 8);
  936. }
  937. protected void onResume() {
  938. EPLog.m305d("ActivityImageViewSelect", "onResume");
  939. super.onResume();
  940. NfcTagUtils.enableForegroundDispatch(this, (IntentFilter[]) null, (String[][]) null);
  941. paperMissmath.setVisibility(View.GONE);
  942. paperSourceInfo.start(this, mHandler);
  943. }
  944. protected void onNewIntent(Intent intent) {
  945. NfcTagUtils.EpsonNfcConnectInfo parseNECTag;
  946. super.onNewIntent(intent);
  947. String action = intent.getAction();
  948. if (this.reloadTask != null) {
  949. switch (C211111.$SwitchMap$android$os$AsyncTask$Status[this.reloadTask.getStatus().ordinal()]) {
  950. case 1:
  951. case 2:
  952. if ("android.nfc.action.NDEF_DISCOVERED".equals(action) && (parseNECTag = NfcTagUtils.parseNECTag(this, intent)) != null) {
  953. Intent intent2 = new Intent();
  954. intent2.setClass(this, ActivityNfcPrinter.class);
  955. intent2.putExtra(ActivityNfcPrinter.CONNECTINFO, parseNECTag);
  956. intent2.putExtra(ActivityNfcPrinter.CHANGEMODE, 1);
  957. startActivityForResult(intent2, 5);
  958. return;
  959. }
  960. return;
  961. default:
  962. return;
  963. }
  964. }
  965. }
  966. /* renamed from: epson.print.ActivityViewImageSelect$11 */
  967. static /* synthetic */ class C211111 {
  968. static final /* synthetic */ int[] $SwitchMap$android$os$AsyncTask$Status = new int[AsyncTask.Status.values().length];
  969. /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|6) */
  970. /* JADX WARNING: Code restructure failed: missing block: B:7:?, code lost:
  971. return;
  972. */
  973. /* JADX WARNING: Failed to process nested try/catch */
  974. /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0014 */
  975. static {
  976. /*
  977. android.os.AsyncTask$Status[] r0 = android.os.AsyncTask.Status.values()
  978. int r0 = r0.length
  979. int[] r0 = new int[r0]
  980. $SwitchMap$android$os$AsyncTask$Status = r0
  981. int[] r0 = $SwitchMap$android$os$AsyncTask$Status // Catch:{ NoSuchFieldError -> 0x0014 }
  982. android.os.AsyncTask$Status r1 = android.os.AsyncTask.Status.PENDING // Catch:{ NoSuchFieldError -> 0x0014 }
  983. int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x0014 }
  984. r2 = 1
  985. r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x0014 }
  986. L_0x0014:
  987. int[] r0 = $SwitchMap$android$os$AsyncTask$Status // Catch:{ NoSuchFieldError -> 0x001f }
  988. android.os.AsyncTask$Status r1 = android.os.AsyncTask.Status.FINISHED // Catch:{ NoSuchFieldError -> 0x001f }
  989. int r1 = r1.ordinal() // Catch:{ NoSuchFieldError -> 0x001f }
  990. r2 = 2
  991. r0[r1] = r2 // Catch:{ NoSuchFieldError -> 0x001f }
  992. L_0x001f:
  993. return
  994. */
  995. throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityViewImageSelect.C211111.<clinit>():void");
  996. }
  997. }
  998. protected void onDestroy() {
  999. EPLog.m305d("ActivityImageViewSelect", "onDestroy");
  1000. super.onDestroy();
  1001. }
  1002. @MainThread
  1003. private void localUnbindService() {
  1004. IEpsonService iEpsonService = mEpsonService;
  1005. if (iEpsonService != null) {
  1006. try {
  1007. iEpsonService.cancelSearchPrinter();
  1008. mEpsonService.unregisterCallback(mCallback);
  1009. unbindService(mEpsonConnection);
  1010. } catch (RemoteException unused) {
  1011. }
  1012. }
  1013. }
  1014. protected void onPause() {
  1015. EPLog.m305d("ActivityImageViewSelect", "onPause");
  1016. super.onPause();
  1017. NfcTagUtils.disableForegroundDispatch(this);
  1018. paperSourceInfo.stop();
  1019. if (isFinishing()) {
  1020. localUnbindService();
  1021. ApfPreviewView.deleteWorkingDirectory(this);
  1022. PhotoImageConvertViewModel.clearTempDirectory(this);
  1023. }
  1024. }
  1025. protected void onRestart() {
  1026. EPLog.m305d("ActivityImageViewSelect", "onRestart");
  1027. super.onRestart();
  1028. }
  1029. public void onBackPressed() {
  1030. if (mStartActivityFromPhoto == 0) {
  1031. Intent intent = new Intent();
  1032. intent.putStringArrayListExtra("imageList", imageList.getArgumentFileList());
  1033. setResult(18, intent);
  1034. } else if (this.isPrintedOK) {
  1035. setResult(-1);
  1036. } else {
  1037. setResult(0);
  1038. }
  1039. finish();
  1040. }
  1041. private void check3GAndStartPrint() {
  1042. mHandler.sendEmptyMessage(5);
  1043. }
  1044. private void showSimpleDialog(int i) {
  1045. SimpleMessageDialogFragment.newInstance(i).show(getSupportFragmentManager(), "simple-dialog");
  1046. }
  1047. private void unlockScreenRotation() {
  1048. setRequestedOrientation(-1);
  1049. }
  1050. private void startPrint() {
  1051. printButton.setEnabled(false);
  1052. OsAssistant.lockScreenRotation(this);
  1053. ExternalFileUtils.getInstance(this).initPrintDir();
  1054. if (this.isRemotePrinter) {
  1055. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  1056. edit.putInt(epson.common.Constants.SOURCE_TYPE, 2);
  1057. edit.commit();
  1058. }
  1059. PrintSetting printSetting = new PrintSetting(this, PrintSetting.Kind.photo);
  1060. printSetting.loadSettings();
  1061. EPImageList imageList2 = previewImageView.getImageList();
  1062. imageList2.apfModeInPrinting = getApfValue(printSetting);
  1063. imageList2.setSharpness(getSharpnessValue(printSetting));
  1064. imageList2.setClearlyVivid(getClearlyVividValue(printSetting));
  1065. imageList2.setMultifileMode(true);
  1066. if (mPrintLog == null) {
  1067. mPrintLog = new PrintLog();
  1068. }
  1069. mPrintLog.previewType = 1;
  1070. startActivityForResult(PrintProgress.getPrintIntent(this, imageList2, false, isEpsonColorMode(), mPrintLog), 255);
  1071. }
  1072. private void addPhotos() {
  1073. PhotoImageSelectActivity.startAddImageSelect(this, imageList.getArgumentFileList());
  1074. }
  1075. public void onClick(View view) {
  1076. switch (view.getId()) {
  1077. case R.id.bt_rotate /*2131230858*/:
  1078. if (this.isPaperLandscape) {
  1079. isPaperLandscape = false;
  1080. } else {
  1081. isPaperLandscape = true;
  1082. }
  1083. if (this.currentLayout != 4) {
  1084. new PaperDirectionRotateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
  1085. return;
  1086. }
  1087. return;
  1088. case R.id.btn_add_photo /*2131230867*/:
  1089. if (this.imageList.size() == 30) {
  1090. new AlertDialog.Builder(this).setMessage(getString(R.string.max_image)).setNegativeButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  1091. public void onClick(DialogInterface dialogInterface, int i) {
  1092. }
  1093. }).create().show();
  1094. return;
  1095. }
  1096. addPhotos();
  1097. finish();
  1098. return;
  1099. case R.id.btn_deselect /*2131230869*/:
  1100. removeCurrentImage();
  1101. return;
  1102. case R.id.btn_paper_size /*2131230874*/:
  1103. if (this.aPaperSourceSetting != null) {
  1104. Intent intent = new Intent();
  1105. intent.setClass(this, PaperSourceSettingScr.class);
  1106. intent.putParcelableArrayListExtra(PaperSourceInfo.KEY_PAPERSOURCEINFO, aPaperSourceSetting);
  1107. intent.putExtra(PaperSourceSettingScr.PRINT_SETTING_TYPE, PrintSetting.Kind.photo.name());
  1108. startActivityForResult(intent, CommonDefine.REQUEST_SETTING);
  1109. return;
  1110. }
  1111. callPrintSetting();
  1112. return;
  1113. case R.id.btn_print /*2131230877*/:
  1114. isRemotePrinter = MyPrinter.isRemotePrinter(this);
  1115. if (this.isRemotePrinter && enableShowWarning) {
  1116. AlertDialog.Builder cancelable = new AlertDialog.Builder(this.context).setCancelable(false);
  1117. cancelable.setMessage(getString(R.string.epsonconnect_str_remote_print_warning) + "\n\n" + getString(R.string.epsonconnect_str_remote_print_warning2)).setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() {
  1118. public void onClick(DialogInterface dialogInterface, int i) {
  1119. ActivityViewImageSelect.this.check3GAndStartPrint();
  1120. }
  1121. }).setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
  1122. public void onClick(DialogInterface dialogInterface, int i) {
  1123. }
  1124. }).show();
  1125. return;
  1126. } else if (this.currentPrinterName.equalsIgnoreCase(getString(R.string.str_lbl_title_scan))) {
  1127. new AlertDialog.Builder(this.context).setCancelable(false).setTitle(R.string.printer_not_select).setMessage(getString(R.string.printer_notselect_warning)).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
  1128. public void onClick(DialogInterface dialogInterface, int i) {
  1129. }
  1130. }).show();
  1131. return;
  1132. } else {
  1133. check3GAndStartPrint();
  1134. return;
  1135. }
  1136. default:
  1137. return;
  1138. }
  1139. }
  1140. protected void adjustImageNo() {
  1141. if (this.imageNo >= imageList.size()) {
  1142. imageNo = imageList.size() - 1;
  1143. }
  1144. if (this.imageNo < 0) {
  1145. imageNo = 0;
  1146. }
  1147. }
  1148. protected void removeCurrentImage() {
  1149. previewImageView.invalidateImageNo();
  1150. int i = imageNo;
  1151. if (i >= 0 && i < imageList.size()) {
  1152. imageList.remove(this.imageNo);
  1153. imageNo--;
  1154. }
  1155. updateGallery();
  1156. adjustImageNo();
  1157. new PreviewImageSelectTask().executeOnExecutor(new Void[0]);
  1158. }
  1159. protected void updateScreen() {
  1160. if (this.imageList.size() < 30) {
  1161. addButton.setEnabled(true);
  1162. addButton.setImageResource(R.drawable.plus);
  1163. }
  1164. if (this.imageList.size() > 0) {
  1165. TextView textView = pageTextView;
  1166. textView.setText((this.imageNo + 1) + CommonDefine.SLASH + imageList.size());
  1167. gallery.setSelection(this.imageNo);
  1168. } else {
  1169. deleteButton.setEnabled(false);
  1170. printButton.setEnabled(false);
  1171. pageTextView.setText("0/0");
  1172. }
  1173. if (this.previewImageView.getIsPaperLandscape()) {
  1174. isPaperLandscape = true;
  1175. } else {
  1176. isPaperLandscape = false;
  1177. }
  1178. Handler handler = mHandler;
  1179. if (handler != null) {
  1180. handler.sendEmptyMessage(2);
  1181. }
  1182. }
  1183. public boolean onOptionsItemSelected(MenuItem menuItem) {
  1184. if (menuItem.getItemId() == R.id.Menu_Show_PrintSettings) {
  1185. callPrintSetting();
  1186. }
  1187. return super.onOptionsItemSelected(menuItem);
  1188. }
  1189. public boolean onCreateOptionsMenu(Menu menu) {
  1190. super.onCreateOptionsMenu(menu);
  1191. getMenuInflater().inflate(R.menu.print_menu, menu);
  1192. return true;
  1193. }
  1194. public void callPrintSetting() {
  1195. System.gc();
  1196. SharedPreferences.Editor edit = getSharedPreferences("PrintSetting", 0).edit();
  1197. edit.putInt(epson.common.Constants.SOURCE_TYPE, 2);
  1198. edit.commit();
  1199. startActivityForResult(new Intent(this, SettingScr.class), CommonDefine.REQUEST_SETTING);
  1200. }
  1201. public boolean onKeyDown(int i, KeyEvent keyEvent) {
  1202. if (keyEvent.getAction() == 0 && i == 84) {
  1203. EPLog.m307e("key search", "diable");
  1204. return true;
  1205. } else if (keyEvent.getAction() != 0 || i != 4) {
  1206. return false;
  1207. } else {
  1208. onBackPressed();
  1209. return true;
  1210. }
  1211. }
  1212. public void onConfigurationChanged(Configuration configuration) {
  1213. super.onConfigurationChanged(configuration);
  1214. }
  1215. protected int getApfValue(PrintSetting printSetting) {
  1216. if (!this.isRemotePrinter) {
  1217. return printSetting.photoApfValueForLocalPrinter;
  1218. }
  1219. return 0;
  1220. }
  1221. protected int getSharpnessValue(PrintSetting printSetting) {
  1222. if (!this.isRemotePrinter) {
  1223. return printSetting.sharpnessForPhoto;
  1224. }
  1225. return 0;
  1226. }
  1227. protected int getClearlyVividValue(PrintSetting printSetting) {
  1228. if (!this.isRemotePrinter) {
  1229. int i = printSetting.paperTypeValue;
  1230. int code = Constants.MediaName.EPS_MTID_PLAIN.getCode();
  1231. EpLog.m77i("setteing = " + i + "plain = " + code);
  1232. return (i == code && printSetting.getKind() == PrintSetting.Kind.photo) ? 1 : 0;
  1233. }
  1234. }
  1235. public void onViewSizeChanged() {
  1236. EPLog.m305d(TAG, "onViewSizeChanged()");
  1237. if (isFinishing()) {
  1238. EPLog.m305d(TAG, "onViewSizeChanged() isFinishing == true");
  1239. return;
  1240. }
  1241. mOnSizeChangeReceived = true;
  1242. loadImage();
  1243. }
  1244. public void invitationDialogClicked(boolean z) {
  1245. mReviewInvitationViewModel.setStartStoreEnd();
  1246. }
  1247. protected boolean executeAllReloadTaskAgain() {
  1248. synchronized (mAllReloadTaskLock) {
  1249. if (!mIsAllReloadTaskRetryAcceptable) {
  1250. return false;
  1251. }
  1252. mAllReloadTaskRetryRequested = true;
  1253. return true;
  1254. }
  1255. }
  1256. protected boolean lastCheckAllReloadTaskRetryRequest() {
  1257. synchronized (mAllReloadTaskLock) {
  1258. if (mAllReloadTaskRetryRequested) {
  1259. return true;
  1260. }
  1261. mIsAllReloadTaskRetryAcceptable = false;
  1262. return false;
  1263. }
  1264. }
  1265. /* JADX WARNING: Removed duplicated region for block: B:18:0x003a */
  1266. /* JADX WARNING: Removed duplicated region for block: B:19:0x003c */
  1267. /* JADX WARNING: Removed duplicated region for block: B:20:0x0045 */
  1268. /* JADX WARNING: Removed duplicated region for block: B:21:0x004e */
  1269. /* JADX WARNING: Removed duplicated region for block: B:23:0x0058 */
  1270. /* JADX WARNING: Removed duplicated region for block: B:25:? A[RETURN, SYNTHETIC] */
  1271. /* Code decompiled incorrectly, please refer to instructions dump. */
  1272. private void showDialog(String r4) {
  1273. /*
  1274. r3 = this;
  1275. int r0 = r4.hashCode()
  1276. r1 = -2144563074(0xffffffff802c907e, float:-4.092596E-39)
  1277. r2 = 0
  1278. if (r0 == r1) goto L_0x0029
  1279. r1 = -21731516(0xfffffffffeb46744, float:-1.1989861E38)
  1280. if (r0 == r1) goto L_0x001f
  1281. r1 = 23498109(0x1668d7d, float:4.234584E-38)
  1282. if (r0 == r1) goto L_0x0015
  1283. goto L_0x0033
  1284. L_0x0015:
  1285. java.lang.String r0 = "dialog_load"
  1286. boolean r0 = r4.equals(r0)
  1287. if (r0 == 0) goto L_0x0033
  1288. r0 = 1
  1289. goto L_0x0034
  1290. L_0x001f:
  1291. java.lang.String r0 = "dialog_progress"
  1292. boolean r0 = r4.equals(r0)
  1293. if (r0 == 0) goto L_0x0033
  1294. r0 = 0
  1295. goto L_0x0034
  1296. L_0x0029:
  1297. java.lang.String r0 = "dialog_all_update"
  1298. boolean r0 = r4.equals(r0)
  1299. if (r0 == 0) goto L_0x0033
  1300. r0 = 2
  1301. goto L_0x0034
  1302. L_0x0033:
  1303. r0 = -1
  1304. L_0x0034:
  1305. r1 = 2131625177(0x7f0e04d9, float:1.8877555E38)
  1306. switch(r0) {
  1307. case 0: goto L_0x004e;
  1308. case 1: goto L_0x0045;
  1309. case 2: goto L_0x003c;
  1310. default: goto L_0x003a;
  1311. }
  1312. L_0x003a:
  1313. r0 = 0
  1314. goto L_0x0056
  1315. L_0x003c:
  1316. java.lang.String r0 = r3.getString(r1)
  1317. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r2, r0)
  1318. goto L_0x0056
  1319. L_0x0045:
  1320. java.lang.String r0 = r3.getString(r1)
  1321. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r2, r0)
  1322. goto L_0x0056
  1323. L_0x004e:
  1324. java.lang.String r0 = r3.getString(r1)
  1325. epson.common.DialogProgress r0 = epson.common.DialogProgress.newInstance(r4, r2, r0)
  1326. L_0x0056:
  1327. if (r0 == 0) goto L_0x0062
  1328. r0.setCancelable(r2)
  1329. android.support.v4.app.FragmentManager r1 = r3.getSupportFragmentManager()
  1330. r0.show(r1, r4)
  1331. L_0x0062:
  1332. return
  1333. */
  1334. throw new UnsupportedOperationException("Method not decompiled: epson.print.ActivityViewImageSelect.showDialog(java.lang.String):void");
  1335. }
  1336. private void dismissDialog(String str) {
  1337. DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag(str);
  1338. if (dialogFragment != null) {
  1339. dialogFragment.dismiss();
  1340. }
  1341. }
  1342. private class AllReloadTask extends AsyncTaskExecutor<Void, Integer, Boolean> {
  1343. private Context context = null;
  1344. private volatile boolean endRedraw = false;
  1345. private boolean firstDraw = true;
  1346. Handler handler = new Handler(new Handler.Callback() {
  1347. public boolean handleMessage(Message message) {
  1348. if (message.what == 4) {
  1349. EPLog.m313i(ActivityViewImageSelect.TAG, "handleMessage(): msg.arg1 = " + message.arg1 + ", index = " + AllReloadTask.this.index);
  1350. if (AllReloadTask.this.firstDraw) {
  1351. boolean unused = AllReloadTask.this.firstDraw = false;
  1352. }
  1353. boolean unused2 = AllReloadTask.this.endRedraw = true;
  1354. }
  1355. return true;
  1356. }
  1357. });
  1358. private int index = 0;
  1359. private boolean mDeletePreview;
  1360. public AllReloadTask(Context context2) {
  1361. context = context2;
  1362. }
  1363. public AsyncTask<Void, Integer, Boolean> executeOnExecutor(Void... voidArr) {
  1364. if (ActivityViewImageSelect.this.executeAllReloadTaskAgain()) {
  1365. return null;
  1366. }
  1367. ActivityViewImageSelect.mIsAllReloadTaskRetryAcceptable = true;
  1368. return super.executeOnExecutor(voidArr);
  1369. }
  1370. protected void onPreExecute() {
  1371. ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_ALL_UPDATE);
  1372. ActivityViewImageSelect.this.imageList.clearExceptSrcFileName();
  1373. ActivityViewImageSelect.this.previewImageView.setDrawEndHandler(this.handler);
  1374. }
  1375. protected Boolean doInBackground(Void... voidArr) {
  1376. System.gc();
  1377. int i = 0;
  1378. do {
  1379. try {
  1380. if (ActivityViewImageSelect.mEpsonService != null) {
  1381. break;
  1382. }
  1383. Thread.sleep(100);
  1384. i++;
  1385. } catch (RemoteException e) {
  1386. e.printStackTrace();
  1387. } catch (InterruptedException e2) {
  1388. e2.printStackTrace();
  1389. }
  1390. } while (i < 100);
  1391. if (ActivityViewImageSelect.mEpsonService != null) {
  1392. if (ActivityViewImageSelect.this.isRemotePrinter) {
  1393. ActivityViewImageSelect.mEpsonService.EpsonConnectUpdatePrinterSettings(PrintSetting.Kind.photo.name());
  1394. } else {
  1395. ActivityViewImageSelect.mEpsonService.updatePrinterSettings(PrintSetting.Kind.photo.name());
  1396. }
  1397. }
  1398. PrintSetting printSetting = new PrintSetting(ActivityViewImageSelect.this, PrintSetting.Kind.photo);
  1399. printSetting.loadSettings();
  1400. int unused = ActivityViewImageSelect.this.currentPaperSize = printSetting.paperSizeValue;
  1401. int unused2 = ActivityViewImageSelect.this.currentLayout = printSetting.layoutValue;
  1402. int unused3 = ActivityViewImageSelect.this.currentLayoutMulti = printSetting.layoutMultiPageValue;
  1403. int unused4 = ActivityViewImageSelect.this.currentColor = printSetting.colorValue;
  1404. ActivityViewImageSelect.this.previewImageView.setLayout(ActivityViewImageSelect.this.currentLayout, ActivityViewImageSelect.this.currentLayoutMulti);
  1405. ActivityViewImageSelect.this.previewImageView.setPaper(ActivityViewImageSelect.this.currentPaperSize);
  1406. ActivityViewImageSelect.this.previewImageView.setColor(ActivityViewImageSelect.this.currentColor);
  1407. ActivityViewImageSelect.this.previewImageView.setApfLibParams(ActivityViewImageSelect.this.getApfValue(printSetting), ActivityViewImageSelect.this.getSharpnessValue(printSetting), ActivityViewImageSelect.this.getClearlyVividValue(printSetting));
  1408. ActivityViewImageSelect.mHandler.sendEmptyMessage(6);
  1409. do {
  1410. boolean unused5 = ActivityViewImageSelect.mAllReloadTaskRetryRequested = false;
  1411. ActivityViewImageSelect.this.previewImageView.setPaper(ActivityViewImageSelect.this.currentPaperSize);
  1412. updatePreviewImage();
  1413. } while (ActivityViewImageSelect.this.lastCheckAllReloadTaskRetryRequest());
  1414. boolean unused6 = ActivityViewImageSelect.mAllReloadTaskDone = true;
  1415. return true;
  1416. }
  1417. private void updatePreviewImage() {
  1418. ActivityViewImageSelect.this.previewImageView.invalidateImageNo();
  1419. ActivityViewImageSelect.this.previewImageView.invalidatePreview();
  1420. index = 0;
  1421. while (this.index < ActivityViewImageSelect.this.imageList.size()) {
  1422. EPLog.m313i(ActivityViewImageSelect.TAG, "doInBack Start -> " + index);
  1423. while (!ActivityViewImageSelect.mAllReloadTaskRetryRequested) {
  1424. try {
  1425. if (ActivityViewImageSelect.this.previewImageView.setImage(this.index, 2, ActivityViewImageSelect.this)) {
  1426. endRedraw = false;
  1427. publishProgress(new Integer[]{Integer.valueOf(this.index + 1)});
  1428. int i = 0;
  1429. while (true) {
  1430. if (this.endRedraw) {
  1431. break;
  1432. }
  1433. Thread.sleep(100, 0);
  1434. i++;
  1435. if (i >= 50) {
  1436. break;
  1437. }
  1438. }
  1439. EPLog.m313i(ActivityViewImageSelect.TAG, "doInBack End -> " + index);
  1440. index++;
  1441. } else {
  1442. Thread.sleep(300);
  1443. }
  1444. } catch (InterruptedException e) {
  1445. e.printStackTrace();
  1446. } catch (OutOfMemoryError unused) {
  1447. ActivityViewImageSelect.this.imageList.remove(this.index);
  1448. index--;
  1449. mDeletePreview = true;
  1450. if (ActivityViewImageSelect.mAllReloadTaskDone) {
  1451. ActivityViewImageSelect.mHandler.sendEmptyMessage(8);
  1452. int unused2 = ActivityViewImageSelect.this.imageNo = 0;
  1453. } else {
  1454. ActivityViewImageSelect.mHandler.sendEmptyMessage(7);
  1455. }
  1456. }
  1457. }
  1458. return;
  1459. }
  1460. if (ActivityViewImageSelect.this.imageList.size() > 0) {
  1461. showCurrentImage();
  1462. return;
  1463. }
  1464. try {
  1465. ActivityViewImageSelect.this.previewImageView.setImage(0, 2, ActivityViewImageSelect.this);
  1466. } catch (OutOfMemoryError unused3) {
  1467. }
  1468. }
  1469. private void showCurrentImage() {
  1470. boolean z = false;
  1471. while (true) {
  1472. try {
  1473. ActivityViewImageSelect.this.previewImageView.setImage(ActivityViewImageSelect.this.imageNo, 0, ActivityViewImageSelect.this);
  1474. return;
  1475. } catch (OutOfMemoryError unused) {
  1476. if (!z) {
  1477. ActivityViewImageSelect.mHandler.sendEmptyMessage(8);
  1478. }
  1479. z = true;
  1480. if (ActivityViewImageSelect.this.imageList.size() > 0) {
  1481. if (ActivityViewImageSelect.this.imageNo >= 0 && ActivityViewImageSelect.this.imageNo < ActivityViewImageSelect.this.imageList.size()) {
  1482. ActivityViewImageSelect.this.imageList.remove(ActivityViewImageSelect.this.imageNo);
  1483. }
  1484. int unused2 = ActivityViewImageSelect.this.imageNo = 0;
  1485. } else {
  1486. return;
  1487. }
  1488. }
  1489. }
  1490. }
  1491. private boolean testCheckStatus() {
  1492. try {
  1493. Thread.sleep(1000);
  1494. } catch (InterruptedException e) {
  1495. e.printStackTrace();
  1496. }
  1497. return ActivityViewImageSelect.mAllReloadTaskRetryRequested;
  1498. }
  1499. protected void onProgressUpdate(Integer... numArr) {
  1500. ActivityViewImageSelect.this.previewImageView.invalidate();
  1501. TextView access$1900 = ActivityViewImageSelect.this.pageTextView;
  1502. access$1900.setText(numArr[0] + CommonDefine.SLASH + ActivityViewImageSelect.this.imageList.size());
  1503. if (ActivityViewImageSelect.this.previewImageView.getIsPaperLandscape()) {
  1504. boolean unused = ActivityViewImageSelect.this.isPaperLandscape = true;
  1505. } else {
  1506. boolean unused2 = ActivityViewImageSelect.this.isPaperLandscape = false;
  1507. }
  1508. }
  1509. protected void onPostExecute(Boolean bool) {
  1510. if (!ActivityViewImageSelect.this.isFinishing()) {
  1511. if (mDeletePreview) {
  1512. ActivityViewImageSelect.this.updateGallery();
  1513. }
  1514. ActivityViewImageSelect.this.previewImageView.invalidate();
  1515. ActivityViewImageSelect.this.updateScreen();
  1516. ActivityViewImageSelect.this.previewImageView.setDrawEndHandler((Handler) null);
  1517. ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_ALL_UPDATE);
  1518. if (ActivityViewImageSelect.this.bAutoStartPrint) {
  1519. ActivityViewImageSelect activityViewImageSelect = ActivityViewImageSelect.this;
  1520. activityViewImageSelect.onClick(activityViewImageSelect.printButton);
  1521. EPLog.m305d(ActivityViewImageSelect.TAG, "onClick(printButton)");
  1522. ActivityViewImageSelect.this.bAutoStartPrint = false;
  1523. }
  1524. }
  1525. }
  1526. }
  1527. private class PreviewImageSelectTask extends AsyncTaskExecutor<Void, Void, Void> {
  1528. private boolean mError;
  1529. private PreviewImageSelectTask() {
  1530. }
  1531. protected Void doInBackground(Void... voidArr) {
  1532. boolean z = false;
  1533. while (true) {
  1534. try {
  1535. ActivityViewImageSelect.this.previewImageView.setImage(ActivityViewImageSelect.this.imageNo, 0, ActivityViewImageSelect.this);
  1536. return null;
  1537. } catch (OutOfMemoryError unused) {
  1538. mError = true;
  1539. if (!z) {
  1540. ActivityViewImageSelect.mHandler.sendEmptyMessage(8);
  1541. }
  1542. if (ActivityViewImageSelect.this.imageList.size() <= 0) {
  1543. return null;
  1544. }
  1545. if (ActivityViewImageSelect.this.imageNo >= 0 && ActivityViewImageSelect.this.imageNo < ActivityViewImageSelect.this.imageList.size()) {
  1546. ActivityViewImageSelect.this.imageList.remove(ActivityViewImageSelect.this.imageNo);
  1547. }
  1548. int unused2 = ActivityViewImageSelect.this.imageNo = 0;
  1549. z = true;
  1550. }
  1551. }
  1552. }
  1553. protected void onPreExecute() {
  1554. ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_PROGRESS);
  1555. }
  1556. protected void onPostExecute(Void voidR) {
  1557. if (!ActivityViewImageSelect.this.isFinishing()) {
  1558. if (mError) {
  1559. ActivityViewImageSelect.this.updateGallery();
  1560. }
  1561. ActivityViewImageSelect.this.previewImageView.invalidate();
  1562. ActivityViewImageSelect.this.updateScreen();
  1563. ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_PROGRESS);
  1564. }
  1565. }
  1566. }
  1567. private class PaperDirectionRotateTask extends AsyncTask<Void, Void, Void> {
  1568. private PaperDirectionRotateTask() {
  1569. }
  1570. protected void onPreExecute() {
  1571. ActivityViewImageSelect.mModelDialog.doShow(ActivityViewImageSelect.DIALOG_PROGRESS);
  1572. }
  1573. protected void onPostExecute(Void voidR) {
  1574. if (!ActivityViewImageSelect.this.isFinishing()) {
  1575. ActivityViewImageSelect.mModelDialog.doDismiss(ActivityViewImageSelect.DIALOG_PROGRESS);
  1576. }
  1577. }
  1578. protected Void doInBackground(Void... voidArr) {
  1579. ActivityViewImageSelect.this.previewImageView.setIsPaperLandscape(ActivityViewImageSelect.this.isPaperLandscape, ActivityViewImageSelect.this);
  1580. return null;
  1581. }
  1582. }
  1583. }