本文整理汇总了Java中android.app.WallpaperManager.getDesiredMinimumWidth方法的典型用法代码示例。如果您正苦于以下问题:Java WallpaperManager.getDesiredMinimumWidth方法的具体用法?Java WallpaperManager.getDesiredMinimumWidth怎么用?Java WallpaperManager.getDesiredMinimumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.WallpaperManager
的用法示例。
在下文中一共展示了WallpaperManager.getDesiredMinimumWidth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suggestWallpaperDimension
import android.app.WallpaperManager; //导入方法依赖的package包/类
public static void suggestWallpaperDimension(Resources res,
final SharedPreferences sharedPrefs,
WindowManager windowManager,
final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
final Point defaultWallpaperSize = WallpaperUtils.getDefaultWallpaperSize(res, windowManager);
// If we have saved a wallpaper width/height, use that instead
int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);
if (savedWidth == -1 || savedHeight == -1) {
if (!fallBackToDefaults) {
return;
} else {
savedWidth = defaultWallpaperSize.x;
savedHeight = defaultWallpaperSize.y;
}
}
if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
}
}
示例2: suggestWallpaperDimension
import android.app.WallpaperManager; //导入方法依赖的package包/类
static public void suggestWallpaperDimension(Resources res,
final SharedPreferences sharedPrefs,
WindowManager windowManager,
final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
// If we have saved a wallpaper width/height, use that instead
int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);
if (savedWidth == -1 || savedHeight == -1) {
if (!fallBackToDefaults) {
return;
} else {
savedWidth = defaultWallpaperSize.x;
savedHeight = defaultWallpaperSize.y;
}
}
if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
}
}
示例3: setCustomLockscreenImage
import android.app.WallpaperManager; //导入方法依赖的package包/类
private void setCustomLockscreenImage() {
Intent intent = new Intent(getActivity(), PickImageActivity.class);
intent.putExtra(PickImageActivity.EXTRA_CROP, true);
intent.putExtra(PickImageActivity.EXTRA_SCALE, true);
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point displaySize = new Point();
display.getRealSize(displaySize);
// Lock screen for tablets visible section are different in landscape/portrait,
// image need to be cropped correctly, like wallpaper setup for scrolling in background in home screen
// other wise it does not scale correctly
if (Utils.isTabletUI(getActivity())) {
WallpaperManager wpManager = WallpaperManager.getInstance(getActivity());
int wpWidth = wpManager.getDesiredMinimumWidth();
int wpHeight = wpManager.getDesiredMinimumHeight();
float spotlightX = (float) displaySize.x / wpWidth;
float spotlightY = (float) displaySize.y / wpHeight;
intent.putExtra(PickImageActivity.EXTRA_ASPECT_X, wpWidth);
intent.putExtra(PickImageActivity.EXTRA_ASPECT_Y, wpHeight);
intent.putExtra(PickImageActivity.EXTRA_OUTPUT_X, wpWidth);
intent.putExtra(PickImageActivity.EXTRA_OUTPUT_Y, wpHeight);
intent.putExtra(PickImageActivity.EXTRA_SPOTLIGHT_X, spotlightX);
intent.putExtra(PickImageActivity.EXTRA_SPOTLIGHT_Y, spotlightY);
} else {
boolean isPortrait = getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT;
intent.putExtra(PickImageActivity.EXTRA_ASPECT_X, isPortrait ? displaySize.x : displaySize.y);
intent.putExtra(PickImageActivity.EXTRA_ASPECT_Y, isPortrait ? displaySize.y : displaySize.x);
}
getActivity().startActivityFromFragment(this, intent, REQ_LOCKSCREEN_BACKGROUND);
}
示例4: loadSourceBitmap
import android.app.WallpaperManager; //导入方法依赖的package包/类
private void loadSourceBitmap(final OnLoadSourceListener l) {
InputStream stream = getPhotoStream();
if (stream == null) {
return;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(stream, new Rect(0, 0, 0, 0), options);
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
WallpaperManager manager = WallpaperManager.getInstance(this);
int width;
int height;
if (1.0 * options.outWidth / options.outHeight
> 1.0 * manager.getDesiredMinimumWidth() / manager.getDesiredMinimumHeight()) {
width = (int) (1.0 * options.outWidth / options.outHeight * manager.getDesiredMinimumHeight());
height = manager.getDesiredMinimumHeight();
} else {
width = manager.getDesiredMinimumWidth();
height = (int) (1.0 * options.outHeight / options.outWidth * manager.getDesiredMinimumWidth());
}
ImageHelper.loadBitmap(
this,
new SimpleTarget<Bitmap>(width, height) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
if (l != null) {
l.onLoadSourceBitmap(resource);
}
}
},
getIntent().getData());
}
示例5: suggestWallpaperDimension
import android.app.WallpaperManager; //导入方法依赖的package包/类
static public void suggestWallpaperDimension(Resources res,
final SharedPreferences sharedPrefs,
WindowManager windowManager,
final WallpaperManager wallpaperManager) {
final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
// If we have saved a wallpaper width/height, use that instead
int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, defaultWallpaperSize.x);
int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, defaultWallpaperSize.y);
if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
}
}
示例6: handleRatioChange
import android.app.WallpaperManager; //导入方法依赖的package包/类
private void handleRatioChange(final int width, final int height)
{
WallpaperManager wm = WallpaperManager.getInstance(context);
// width of the background as is has been created
final float background_width = (float) context.getResources().getInteger(Defines.getResourceIDbyName("integer", "background_width"));
// the amount of pixels which will be 'scrolled', 'width' pixels will always be visible
max_offset = wm.getDesiredMinimumWidth() - width;
// ratio between the width which will be used to display the wallpaper and the width of the width of the
// background resource
current_ratio = (float) (2 * height) / background_width;
max_parallax = context.getResources().getInteger(Defines.getResourceIDbyName("integer", "parallax")) * current_ratio;
min_parallax = -max_parallax;
scroll_factor = (background_width * current_ratio - width) / max_offset;
scroll_speed_factor = calcSpeedFactor(2 * height, max_offset * scroll_factor);
setCurrentPositionSF();
for (int l = 0; l < layer_array.length; l++) {
final float offset = -(virtual_scroll_speed_factor[l][1]) * max_parallax;
for (int i = 0; i < layer_array[l].length; i++) {
layer_array[l][i].setNewPositionParallaxOffset(offset);
}
}
resetParallax();
render_width = width;
setXOffset(x_offset);
setMetrics(pixelToInchesFactor);
}