I am trying to set as wallpaper through image link.
My Question: How to show dialog box "loading Image from server" and now "Set wallpaper". After this Pop up appear to ask user where they want to set
Current Situation: when user click the button "Set wallpaper". It only shows the dialog message and keep loading. then user need to dismiss the pop up and click again. Which means they need to click 2 times to set wallpaper. I want to make them easy to become more transparent.
Basically i want my user know which process is running in android
Here is below code
progressDialog = ProgressDialog.show(getActivity(),"Please wait...","Set as your wallpaper...",false,true);
Picasso.get()
.load(setImgLink)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getActivity());
try {
if (bitmap != null) {
wallpaperManager.setBitmap(bitmap);
Snackbar.make(relative_image_slider, "Wallpaper was set", Snackbar.LENGTH_SHORT).show();
progressDialog.dismiss();
ct_popup.setText("Wallpaper was set");
final AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity());
builder1.setView(subView);
builder1.setPositiveButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
((ViewGroup)subView.getParent()).removeView(subView);
}
});
builder1.setIcon(R.mipmap.ic_launcher);
builder1.setCancelable(false);
builder1.create();
builder1.show();
}else {
Toast.makeText(getActivity(), "Unable to set your wallpaper !!", Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
Toast.makeText(getActivity(), "Something went wrong !!", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});