LocalProgressDialog.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package com.epson.iprint.storage;
  2. import android.app.Dialog;
  3. import android.os.Bundle;
  4. import android.support.annotation.NonNull;
  5. import android.support.annotation.Nullable;
  6. import android.support.p000v4.app.FragmentManager;
  7. import android.view.KeyEvent;
  8. import android.view.LayoutInflater;
  9. import android.view.View;
  10. import android.view.ViewGroup;
  11. import android.widget.Button;
  12. import android.widget.LinearLayout;
  13. import android.widget.TextView;
  14. import epson.print.R;
  15. public class LocalProgressDialog extends DialogFragment {
  16. private static final String LOG_TAG = "MyProgress";
  17. private static final String PARAM_CANCELABLE = "cancelable";
  18. private static final String PARAM_CANCEL_CONFIRM_DIALOG_TAG = "tag_confirm-cancel";
  19. private static final String PARAM_MESSAGE_ID = "message-id";
  20. private String mCancelConfirmDialogTag;
  21. public static LocalProgressDialog newInstance(boolean z, int i, @NonNull String str) {
  22. if (!z || str != null) {
  23. LocalProgressDialog localProgressDialog = new LocalProgressDialog();
  24. Bundle bundle = new Bundle();
  25. bundle.putBoolean(PARAM_CANCELABLE, z);
  26. bundle.putInt(PARAM_MESSAGE_ID, i);
  27. bundle.putString(PARAM_CANCEL_CONFIRM_DIALOG_TAG, str);
  28. localProgressDialog.setArguments(bundle);
  29. return localProgressDialog;
  30. }
  31. throw new IllegalArgumentException();
  32. }
  33. @Nullable
  34. public View onCreateView(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
  35. Bundle arguments = getArguments();
  36. boolean z = arguments.getBoolean(PARAM_CANCELABLE, false);
  37. int i = arguments.getInt(PARAM_MESSAGE_ID, 0);
  38. this.mCancelConfirmDialogTag = arguments.getString(PARAM_CANCEL_CONFIRM_DIALOG_TAG);
  39. View inflate = layoutInflater.inflate(R.layout.my_progress, viewGroup, false);
  40. Button button = (Button) inflate.findViewById(R.id.cancelButton);
  41. button.setOnClickListener(new View.OnClickListener() {
  42. public void onClick(View view) {
  43. LocalProgressDialog.this.showCancelConfirmDialog();
  44. }
  45. });
  46. button.setText(R.string.str_cancel);
  47. int i2 = 8;
  48. button.setVisibility(z ? 0 : 8);
  49. TextView textView = (TextView) inflate.findViewById(R.id.messageText);
  50. if (i != 0) {
  51. textView.setText(i);
  52. }
  53. if (i != 0) {
  54. i2 = 0;
  55. }
  56. textView.setVisibility(i2);
  57. ((LinearLayout) inflate.findViewById(R.id.dialog_back)).setOnClickListener(new View.OnClickListener() {
  58. public void onClick(View view) {
  59. }
  60. });
  61. inflate.setFocusableInTouchMode(true);
  62. inflate.requestFocus();
  63. inflate.setOnKeyListener(new View.OnKeyListener() {
  64. public boolean onKey(View view, int i, KeyEvent keyEvent) {
  65. return i == 4;
  66. }
  67. });
  68. setCancelable(false);
  69. return inflate;
  70. }
  71. @NonNull
  72. public Dialog onCreateDialog(Bundle bundle) {
  73. Dialog onCreateDialog = super.onCreateDialog(bundle);
  74. onCreateDialog.requestWindowFeature(1);
  75. return onCreateDialog;
  76. }
  77. /* access modifiers changed from: private */
  78. public void showCancelConfirmDialog() {
  79. if (this.mCancelConfirmDialogTag != null) {
  80. FragmentManager fragmentManager = getFragmentManager();
  81. if (fragmentManager != null) {
  82. ConfirmCancelDialog.newInstance(R.string.str_msg_scan_cancel).show(fragmentManager, this.mCancelConfirmDialogTag);
  83. return;
  84. }
  85. return;
  86. }
  87. throw new IllegalStateException();
  88. }
  89. }