の進展ダイアログを表示、私の非同期タスクは次のとおりです。は、私は私の非同期タスクの進捗ダイアログを表示する必要がありますこんにちはAsyncTask
private class UserProfileDialog extends AsyncTask<String, String, String> {
private String imagePath;
private String name;
private String status;
private String number;
private Activity activity;
private ProgressDialog progressDialog;
public UserProfileDialog(Activity activity) {
this.activity = activity;
}
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(activity);
progressDialog.setMessage("Please Wait...");
progressDialog.setCancelable(false);
progressDialog.show();
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
imagePath = params[0];
name = params[1];
status = params[2];
number = params[3];
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
//show the dialog for dob date picker
final Dialog profileDialog = new Dialog(context);
profileDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
profileDialog.setContentView(R.layout.profile_dialog_me);
TextView title = (TextView) profileDialog.findViewById(R.id.title);
title.setTypeface(EasyFonts.robotoBold(context));
ImageView imageCloser = (ImageView) profileDialog.findViewById(R.id.imageCloser);
final ImageView profilePicture_x = (ImageView) profileDialog.findViewById(R.id.profilePicture);
//set the profile picture
Bitmap originalBitmap = BitmapFactory.decodeFile(new File(imagePath).getAbsolutePath());
originalBitmap = ModifyOrientationUtility.modifyOrientation(originalBitmap, new File(imagePath).getAbsolutePath());
Bitmap bitmap = resizeBitmapFitXY(400, 400, originalBitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
Glide.with(context)
.load(stream.toByteArray())
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.dontAnimate()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
// TODO Auto-generated method stub
profilePicture_x.setImageBitmap(arg0);
}
});
TextView profileName = (TextView) profileDialog.findViewById(R.id.profileName);
profileName.setTypeface(EasyFonts.robotoLight(context));
profileName.setText(name);
TextView profileNumber = (TextView) profileDialog.findViewById(R.id.profileNumber);
profileNumber.setTypeface(EasyFonts.robotoLight(context));
profileNumber.setText(number);
TextView profileStatus = (TextView) profileDialog.findViewById(R.id.profileStatus);
profileStatus.setTypeface(EasyFonts.robotoLight(context));
profileStatus.setText(status);
//UI Events
imageCloser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
profileDialog.dismiss();
}
});
//show the dialog
profileDialog.show();
} catch (Exception exp) {
MyMLogger.showMLog("xm", "show profile dialog " + exp.toString(), logFromClass, "showProfileDialog");
exp.printStackTrace();
}
}
});
return null;
}
@Override
protected void onPostExecute(String s) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
super.onPostExecute(s);
}
}
AsyncTaskを見つけるのを働いているが、それは私の進行状況が表示されていませんボタンをクリックしてタスクを開始すると、ダイアログが表示されます。
しかし、プロファイルダイアログを閉じると、進行状況ダイアログが表示されます(onPostExecuteは無視されます)。
誰かが問題を理解してください、私はちょっと混乱して、なぜ起こっているのですか?
は、なぜあなたはそこ 'AsyncTask'を使用している、このリンクをチェックする?、これを試してみてくださいとにかくUIスレッドですべてを実行しています。また、グライドがイメージのサイズ変更を処理させるのはなぜですか? –
問題は私がRecyclerViewアダプタでこれを表示していることです。グライドで設定する前に画像の向きを変更しています! –
私はGlideも回転を扱うことができると信じています。 –