Guest User

Untitled

a guest
Jan 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. public class InformationActivity extends AppCompatActivity {
  2.  
  3. public static Activity activity;
  4. public static MaterialDialog dialog;
  5.  
  6. @Override
  7. public void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.information);
  10. activity = this;
  11. dialog = new MaterialDialog.Builder(this).build();
  12.  
  13. }
  14.  
  15.  
  16. @Override
  17. protected void onResume() {
  18. super.onResume();
  19.  
  20. dialog = new MaterialDialog.Builder(this)
  21. .title("Подождите")
  22. .content("Загрузка")
  23. .progress(true, 0)
  24. .cancelable(false)
  25. .show();
  26. new GetUser(this, phone, new Country(this).getCountry()).execute();
  27. }
  28. }
  29.  
  30. @Override
  31. protected void onPause() {
  32. super.onPause();
  33. if (dialog.isShowing()) {
  34. dialog.dismiss();
  35. }
  36. finish();
  37. }
  38.  
  39. }
  40.  
  41. public class GetUser extends AsyncTask<String, Void, String> {
  42.  
  43. OkHttpClient client;
  44.  
  45. Context context;
  46. String url;
  47. String RESPONSE;
  48. String country;
  49. ArrayList<HashMap<String, String>> DATA;
  50. JSONArray jsonArray;
  51. String phone;
  52. public GetUser(Context context, String phone, String country)
  53. {
  54. this.context = context;
  55. client = new OkHttpClient();
  56. this.phone = phone;
  57. DATA = new ArrayList<>();
  58. this.country = country;
  59. }
  60. @Override
  61. protected String doInBackground(String... params) {
  62.  
  63. try {
  64. RESPONSE = run(url);
  65. } catch (IOException e) {
  66. e.printStackTrace();
  67. }
  68.  
  69. return "";
  70. }
  71.  
  72. @Override
  73. protected void onPostExecute(String result) {
  74.  
  75. if (InformationActivity.dialog.isShowing()) {
  76. InformationActivity.dialog.dismiss();
  77. }
  78.  
  79. }
  80.  
  81. @Override
  82. protected void onPreExecute() {
  83.  
  84. }
  85.  
  86. @Override
  87. protected void onProgressUpdate(Void... values) {
  88.  
  89. }
  90.  
  91.  
  92.  
  93. String run(String url) throws IOException {
  94.  
  95. RequestBody requestBody = new MultipartBody.Builder()
  96. .setType(MultipartBody.FORM)
  97. .addFormDataPart(dataOneInf(),phone)
  98. .addFormDataPart(dataTwoInf(),country)
  99. .addFormDataPart(dataThreeInf(),eInf())
  100. .build();
  101.  
  102. Request request = new Request.Builder()
  103. .url(dataURLInf())
  104. .post(requestBody)
  105. .build();
  106.  
  107. Response response = client.newCall(request).execute();
  108. return response.body().string();
  109. }
  110. }
  111.  
  112. java.lang.IllegalArgumentException
  113. View=com.android.internal.policy.PhoneWindow$DecorView{21d0893 V.E...... R......D 0,0-608,281} not attached to window manager
  114. com.afollestad.materialdialogs.MaterialDialog.dismiss
Add Comment
Please, Sign In to add comment