DialogProgressWiFiDirect.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package com.epson.mobilephone.common.wifidirect;
  2. import android.app.Dialog;
  3. import android.content.DialogInterface;
  4. import android.os.Bundle;
  5. import android.support.annotation.Nullable;
  6. import android.support.p000v4.app.DialogFragment;
  7. import android.support.p000v4.app.FragmentManager;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.ProgressBar;
  11. import android.widget.RelativeLayout;
  12. import android.widget.TextView;
  13. public class DialogProgressWiFiDirect extends DialogFragment {
  14. public static final int MESSAGE_BOTTOM = 1;
  15. public static final int MESSAGE_ONLY = 2;
  16. public static final int MESSAGE_RIGHT = 0;
  17. private static final String TAG_DIALOG = "tag";
  18. private static final String TAG_MESSAGE = "message";
  19. private static final String TAG_NEGATIVE_MESSAGE = "negative_dialog_message";
  20. private static final String TAG_NEUTRAL_MESSAGE = "neutral_dialog_message";
  21. private static final String TAG_POSITION = "position";
  22. private static final String TAG_POSITIVE_MESSAGE = "positive_dialog_message";
  23. private static final String TAG_TITLE_MESSAGE = "title_message";
  24. /* access modifiers changed from: private */
  25. public DialogButtonClick mActivity;
  26. /* access modifiers changed from: private */
  27. public String mTag;
  28. public interface DialogButtonClick {
  29. void onCancelDialog(String str);
  30. void onNegativeClick(String str);
  31. void onNeutralClick(String str);
  32. void onPositiveClick(String str);
  33. }
  34. public static DialogProgressWiFiDirect newInstance(String str, int i, @Nullable String str2) {
  35. return newInstance(str, i, str2, (String) null, (String) null, (String) null, (String) null);
  36. }
  37. public static DialogProgressWiFiDirect newInstance(String str, int i, @Nullable String str2, @Nullable String str3, @Nullable String str4, @Nullable String str5, @Nullable String str6) {
  38. DialogProgressWiFiDirect dialogProgressWiFiDirect = new DialogProgressWiFiDirect();
  39. Bundle bundle = new Bundle();
  40. bundle.putString(TAG_DIALOG, str);
  41. bundle.putInt("position", i);
  42. bundle.putString("message", str2);
  43. bundle.putString(TAG_TITLE_MESSAGE, str3);
  44. bundle.putString(TAG_POSITIVE_MESSAGE, str4);
  45. bundle.putString(TAG_NEUTRAL_MESSAGE, str5);
  46. bundle.putString(TAG_NEGATIVE_MESSAGE, str6);
  47. dialogProgressWiFiDirect.setArguments(bundle);
  48. return dialogProgressWiFiDirect;
  49. }
  50. private void deleteFragment(FragmentManager fragmentManager, String str) {
  51. Dialog dialog;
  52. DialogProgressWiFiDirect dialogProgressWiFiDirect = (DialogProgressWiFiDirect) fragmentManager.findFragmentByTag(str);
  53. if (dialogProgressWiFiDirect != null && (dialog = dialogProgressWiFiDirect.getDialog()) != null && dialog.isShowing()) {
  54. dialogProgressWiFiDirect.dismiss();
  55. }
  56. }
  57. @NonNull
  58. public Dialog onCreateDialog(@Nullable Bundle bundle) {
  59. this.mTag = getArguments().getString(TAG_DIALOG);
  60. int i = getArguments().getInt("position");
  61. String string = getArguments().getString("message");
  62. String string2 = getArguments().getString(TAG_TITLE_MESSAGE);
  63. String string3 = getArguments().getString(TAG_POSITIVE_MESSAGE);
  64. String string4 = getArguments().getString(TAG_NEUTRAL_MESSAGE);
  65. String string5 = getArguments().getString(TAG_NEGATIVE_MESSAGE);
  66. AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  67. View inflate = getActivity().getLayoutInflater().inflate(C1113R.layout.dialog_progress_wifi_direct, (ViewGroup) null);
  68. try {
  69. this.mActivity = (DialogButtonClick) getActivity();
  70. } catch (ClassCastException unused) {
  71. this.mActivity = null;
  72. }
  73. if (string2 != null) {
  74. builder.setTitle((CharSequence) string2);
  75. }
  76. if (string3 != null) {
  77. builder.setPositiveButton((CharSequence) string3, (DialogInterface.OnClickListener) new DialogInterface.OnClickListener() {
  78. public void onClick(DialogInterface dialogInterface, int i) {
  79. DialogProgressWiFiDirect.this.dismiss();
  80. if (DialogProgressWiFiDirect.this.mActivity != null) {
  81. DialogProgressWiFiDirect.this.mActivity.onPositiveClick(DialogProgressWiFiDirect.this.mTag);
  82. }
  83. }
  84. });
  85. }
  86. if (string4 != null) {
  87. builder.setNeutralButton((CharSequence) string4, (DialogInterface.OnClickListener) new DialogInterface.OnClickListener() {
  88. public void onClick(DialogInterface dialogInterface, int i) {
  89. DialogProgressWiFiDirect.this.dismiss();
  90. if (DialogProgressWiFiDirect.this.mActivity != null) {
  91. DialogProgressWiFiDirect.this.mActivity.onNeutralClick(DialogProgressWiFiDirect.this.mTag);
  92. }
  93. }
  94. });
  95. }
  96. if (string5 != null) {
  97. builder.setNegativeButton((CharSequence) string5, (DialogInterface.OnClickListener) new DialogInterface.OnClickListener() {
  98. public void onClick(DialogInterface dialogInterface, int i) {
  99. DialogProgressWiFiDirect.this.dismiss();
  100. if (DialogProgressWiFiDirect.this.mActivity != null) {
  101. DialogProgressWiFiDirect.this.mActivity.onNegativeClick(DialogProgressWiFiDirect.this.mTag);
  102. }
  103. }
  104. });
  105. }
  106. ProgressBar progressBar = (ProgressBar) inflate.findViewById(C1113R.C1115id.dialog_progress_id);
  107. if (i == 1) {
  108. RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) progressBar.getLayoutParams();
  109. layoutParams.addRule(14);
  110. progressBar.setLayoutParams(layoutParams);
  111. TextView textView = (TextView) inflate.findViewById(C1113R.C1115id.dialog_progress_text_bottom);
  112. textView.setText(string);
  113. progressBar.setVisibility(0);
  114. textView.setVisibility(0);
  115. } else if (i == 0) {
  116. TextView textView2 = (TextView) inflate.findViewById(C1113R.C1115id.dialog_progress_text_right);
  117. textView2.setText(string);
  118. progressBar.setVisibility(0);
  119. textView2.setVisibility(0);
  120. } else {
  121. TextView textView3 = (TextView) inflate.findViewById(C1113R.C1115id.dialog_progress_text_right);
  122. textView3.setText(string);
  123. textView3.setVisibility(0);
  124. }
  125. builder.setView(inflate);
  126. return builder.create();
  127. }
  128. public void onCancel(DialogInterface dialogInterface) {
  129. DialogButtonClick dialogButtonClick = this.mActivity;
  130. if (dialogButtonClick != null) {
  131. dialogButtonClick.onCancelDialog(this.mTag);
  132. }
  133. super.onCancel(dialogInterface);
  134. }
  135. public void show(FragmentManager fragmentManager, String str) {
  136. deleteFragment(fragmentManager, str);
  137. super.showNow(fragmentManager, str);
  138. }
  139. }