Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class InformationActivity extends AppCompatActivity {
- public static Activity activity;
- public static MaterialDialog dialog;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.information);
- activity = this;
- dialog = new MaterialDialog.Builder(this).build();
- }
- @Override
- protected void onResume() {
- super.onResume();
- dialog = new MaterialDialog.Builder(this)
- .title("Подождите")
- .content("Загрузка")
- .progress(true, 0)
- .cancelable(false)
- .show();
- new GetUser(this, phone, new Country(this).getCountry()).execute();
- }
- }
- @Override
- protected void onPause() {
- super.onPause();
- if (dialog.isShowing()) {
- dialog.dismiss();
- }
- finish();
- }
- }
- public class GetUser extends AsyncTask<String, Void, String> {
- OkHttpClient client;
- Context context;
- String url;
- String RESPONSE;
- String country;
- ArrayList<HashMap<String, String>> DATA;
- JSONArray jsonArray;
- String phone;
- public GetUser(Context context, String phone, String country)
- {
- this.context = context;
- client = new OkHttpClient();
- this.phone = phone;
- DATA = new ArrayList<>();
- this.country = country;
- }
- @Override
- protected String doInBackground(String... params) {
- try {
- RESPONSE = run(url);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return "";
- }
- @Override
- protected void onPostExecute(String result) {
- if (InformationActivity.dialog.isShowing()) {
- InformationActivity.dialog.dismiss();
- }
- }
- @Override
- protected void onPreExecute() {
- }
- @Override
- protected void onProgressUpdate(Void... values) {
- }
- String run(String url) throws IOException {
- RequestBody requestBody = new MultipartBody.Builder()
- .setType(MultipartBody.FORM)
- .addFormDataPart(dataOneInf(),phone)
- .addFormDataPart(dataTwoInf(),country)
- .addFormDataPart(dataThreeInf(),eInf())
- .build();
- Request request = new Request.Builder()
- .url(dataURLInf())
- .post(requestBody)
- .build();
- Response response = client.newCall(request).execute();
- return response.body().string();
- }
- }
- java.lang.IllegalArgumentException
- View=com.android.internal.policy.PhoneWindow$DecorView{21d0893 V.E...... R......D 0,0-608,281} not attached to window manager
- com.afollestad.materialdialogs.MaterialDialog.dismiss
Add Comment
Please, Sign In to add comment