List of usage examples for android.app WallpaperManager getDesiredMinimumHeight
public int getDesiredMinimumHeight()
From source file:com.leo.runningman.ui.ImageDetailActivity.java
private void setWapaper(Bitmap bitmap) { try {/*w ww .j a v a 2 s . co m*/ WallpaperManager wpm = WallpaperManager.getInstance(this); float minH = wpm.getDesiredMinimumHeight(); float minW = wpm.getDesiredMinimumWidth(); Bitmap targetBitmap = getResizedBitmap(bitmap, (int) minH, (int) minW); wpm.setBitmap(targetBitmap); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.leo.runningman.ui.ImageDetailFragment.java
private void setWapaper(final Bitmap bitmap) { final Context mContext = this.getActivity(); new Handler().post(new Runnable() { @Override// ww w .ja v a 2s.c o m public void run() { try { WallpaperManager wpm = WallpaperManager.getInstance(mContext); float minH = wpm.getDesiredMinimumHeight(); float minW = wpm.getDesiredMinimumWidth(); Bitmap targetBitmap = getResizedBitmap(bitmap, (int) minH, (int) minW); wpm.setBitmap(targetBitmap); Toast.makeText(mContext, getActivity().getResources().getString(R.string.set_wallpaper_success), 200).show(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(mContext, getActivity().getResources().getString(R.string.set_wallpaper_failure), 200).show(); } } }); }
From source file:nf.frex.android.FrexActivity.java
private void setWallpaper() { final WallpaperManager wallpaperManager = WallpaperManager.getInstance(FrexActivity.this); final int desiredWidth = wallpaperManager.getDesiredMinimumWidth(); final int desiredHeight = wallpaperManager.getDesiredMinimumHeight(); final Image image = view.getImage(); final int imageWidth = image.getWidth(); final int imageHeight = image.getHeight(); final boolean useDesiredSize = desiredWidth > imageWidth || desiredHeight > imageHeight; DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() { @Override//from w w w . j a va2 s . com public void onClick(DialogInterface dialog, int which) { // ok } }; if (useDesiredSize) { showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_compute_msg, desiredWidth, desiredHeight), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Image wallpaperImage; try { wallpaperImage = new Image(desiredWidth, desiredHeight); } catch (OutOfMemoryError e) { alert(getString(R.string.out_of_memory)); return; } final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); Generator.ProgressListener progressListener = new Generator.ProgressListener() { int numLines; @Override public void onStarted(int numTasks) { } @Override public void onSomeLinesComputed(int taskId, int line1, int line2) { numLines += 1 + line2 - line1; progressDialog.setProgress(numLines); } @Override public void onStopped(boolean cancelled) { progressDialog.dismiss(); if (!cancelled) { setWallpaper(wallpaperManager, wallpaperImage); } } }; final Generator wallpaperGenerator = new Generator(view.getGeneratorConfig(), SettingsActivity.NUM_CORES, progressListener); DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } wallpaperGenerator.cancel(); } }; progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setMax(desiredHeight); progressDialog.setOnCancelListener(cancelListener); progressDialog.show(); Arrays.fill(wallpaperImage.getValues(), FractalView.MISSING_VALUE); wallpaperGenerator.start(wallpaperImage, false); } }, noListener, null); } else { showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_replace_msg), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setWallpaper(wallpaperManager, image); } }, noListener, null); } }