本文整理汇总了Java中com.android.photos.BitmapRegionTileSource类的典型用法代码示例。如果您正苦于以下问题:Java BitmapRegionTileSource类的具体用法?Java BitmapRegionTileSource怎么用?Java BitmapRegionTileSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapRegionTileSource类属于com.android.photos包,在下文中一共展示了BitmapRegionTileSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onClick
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Override
public void onClick(final WallpaperPickerActivity a) {
a.setWallpaperButtonEnabled(false);
final BitmapRegionTileSource.UriBitmapSource bitmapSource =
new BitmapRegionTileSource.UriBitmapSource(a.getContext(), mUri);
a.setCropViewTileSource(bitmapSource, true, false, null, new Runnable() {
@Override
public void run() {
if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
a.selectTile(mView);
a.setWallpaperButtonEnabled(true);
} else {
ViewGroup parent = (ViewGroup) mView.getParent();
if (parent != null) {
parent.removeView(mView);
Toast.makeText(a.getContext(), R.string.image_load_fail,
Toast.LENGTH_SHORT).show();
}
}
}
});
}
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:24,代码来源:WallpaperPickerActivity.java
示例2: onClick
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Override
public void onClick(WallpaperPickerActivity a) {
BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
new BitmapRegionTileSource.ResourceBitmapSource(
mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
bitmapSource.loadInBackground();
BitmapRegionTileSource source = new BitmapRegionTileSource(a, bitmapSource);
CropView v = a.getCropView();
v.setTileSource(source, null);
Point wallpaperSize = WallpaperCropActivity.getDefaultWallpaperSize(
a.getResources(), a.getWindowManager());
RectF crop = WallpaperCropActivity.getMaxCropRect(
source.getImageWidth(), source.getImageHeight(),
wallpaperSize.x, wallpaperSize.y, false);
v.setScale(wallpaperSize.x / crop.width());
v.setTouchEnabled(false);
a.setSystemWallpaperVisiblity(false);
}
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:19,代码来源:WallpaperPickerActivity.java
示例3: addReusableBitmap
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Thunk void addReusableBitmap(TileSource src) {
synchronized (mReusableBitmaps) {
if (Utilities.ATLEAST_KITKAT && src instanceof BitmapRegionTileSource) {
Bitmap preview = ((BitmapRegionTileSource) src).getBitmap();
if (preview != null && preview.isMutable()) {
mReusableBitmaps.add(preview);
}
}
}
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:11,代码来源:WallpaperCropActivity.java
示例4: onClick
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Override
public void onClick(WallpaperPickerActivity a) {
String imageFilename = a.getSavedImages().getImageFilename(mDbId);
File file = new File(a.getFilesDir(), imageFilename);
BitmapRegionTileSource.FilePathBitmapSource bitmapSource =
new BitmapRegionTileSource.FilePathBitmapSource(file.getAbsolutePath(), 1024);
a.setCropViewTileSource(bitmapSource, false, true, null);
}
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:9,代码来源:SavedWallpaperImages.java
示例5: init
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
protected void init() {
setContentView(R.layout.wallpaper_cropper);
mCropView = (CropView) findViewById(R.id.cropView);
mProgressView = findViewById(R.id.loading);
Intent cropIntent = getIntent();
final Uri imageUri = cropIntent.getData();
if (imageUri == null) {
Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
finish();
return;
}
// Action bar
// Show the custom action bar view
final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
actionBar.getCustomView().setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean finishActivityWhenDone = true;
cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
}
});
mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);
// Load image in background
final BitmapRegionTileSource.UriBitmapSource bitmapSource =
new BitmapRegionTileSource.UriBitmapSource(getContext(), imageUri);
mSetWallpaperButton.setEnabled(false);
Runnable onLoad = new Runnable() {
public void run() {
if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
Toast.makeText(getContext(), R.string.wallpaper_load_fail,
Toast.LENGTH_LONG).show();
finish();
} else {
mSetWallpaperButton.setEnabled(true);
}
}
};
setCropViewTileSource(bitmapSource, true, false, null, onLoad);
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:47,代码来源:WallpaperCropActivity.java
示例6: handleMessage
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
/**
* This is called on {@link #mLoaderThread}
*/
@Override
public boolean handleMessage(Message msg) {
if (msg.what == MSG_LOAD_IMAGE) {
final LoadRequest req = (LoadRequest) msg.obj;
try {
req.src.loadInBackground(new InBitmapProvider() {
@Override
public Bitmap forPixelCount(int count) {
Bitmap bitmapToReuse = null;
// Find the smallest bitmap that satisfies the pixel count limit
synchronized (mReusableBitmaps) {
int currentBitmapSize = Integer.MAX_VALUE;
for (Bitmap b : mReusableBitmaps) {
int bitmapSize = b.getWidth() * b.getHeight();
if ((bitmapSize >= count) && (bitmapSize < currentBitmapSize)) {
bitmapToReuse = b;
currentBitmapSize = bitmapSize;
}
}
if (bitmapToReuse != null) {
mReusableBitmaps.remove(bitmapToReuse);
}
}
return bitmapToReuse;
}
});
} catch (SecurityException securityException) {
if (isActivityDestroyed()) {
// Temporarily granted permissions are revoked when the activity
// finishes, potentially resulting in a SecurityException here.
// Even though {@link #isDestroyed} might also return true in different
// situations where the configuration changes, we are fine with
// catching these cases here as well.
return true;
} else {
// otherwise it had a different cause and we throw it further
throw securityException;
}
}
req.result = new BitmapRegionTileSource(getContext(), req.src, mTempStorageForDecoding);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (req == mCurrentLoadRequest) {
onLoadRequestComplete(req,
req.src.getLoadingState() == BitmapSource.State.LOADED);
} else {
addReusableBitmap(req.result);
}
}
});
return true;
}
return false;
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:63,代码来源:WallpaperCropActivity.java
示例7: init
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
protected void init() {
setContentView(R.layout.wallpaper_cropper);
mCropView = (CropView) findViewById(R.id.cropView);
Intent cropIntent = getIntent();
final Uri imageUri = cropIntent.getData();
if (imageUri == null) {
Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
finish();
return;
}
// Action bar
// Show the custom action bar view
final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
actionBar.getCustomView().setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean finishActivityWhenDone = true;
cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
}
});
mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);
// Load image in background
final BitmapRegionTileSource.UriBitmapSource bitmapSource =
new BitmapRegionTileSource.UriBitmapSource(this, imageUri, 1024);
mSetWallpaperButton.setEnabled(false);
Runnable onLoad = new Runnable() {
public void run() {
if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
Toast.makeText(WallpaperCropActivity.this,
getString(R.string.wallpaper_load_fail),
Toast.LENGTH_LONG).show();
finish();
} else {
mSetWallpaperButton.setEnabled(true);
}
}
};
setCropViewTileSource(bitmapSource, true, false, onLoad);
}
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:47,代码来源:WallpaperCropActivity.java
示例8: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
public void setCropViewTileSource(
final BitmapRegionTileSource.BitmapSource bitmapSource, final boolean touchEnabled,
final boolean moveToLeft, final Runnable postExecute) {
final Context context = WallpaperCropActivity.this;
final View progressView = findViewById(R.id.loading);
final AsyncTask<Void, Void, Void> loadBitmapTask = new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void...args) {
if (!isCancelled()) {
bitmapSource.loadInBackground();
}
return null;
}
protected void onPostExecute(Void arg) {
if (!isCancelled()) {
progressView.setVisibility(View.INVISIBLE);
if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
mCropView.setTileSource(
new BitmapRegionTileSource(context, bitmapSource), null);
mCropView.setTouchEnabled(touchEnabled);
if (moveToLeft) {
mCropView.moveToLeft();
}
}
}
if (postExecute != null) {
postExecute.run();
}
}
};
// We don't want to show the spinner every time we load an image, because that would be
// annoying; instead, only start showing the spinner if loading the image has taken
// longer than 1 sec (ie 1000 ms)
progressView.postDelayed(new Runnable() {
public void run() {
if (loadBitmapTask.getStatus() != AsyncTask.Status.FINISHED) {
progressView.setVisibility(View.VISIBLE);
}
}
}, 1000);
loadBitmapTask.execute();
}
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:42,代码来源:WallpaperCropActivity.java
示例9: init
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
protected void init() {
setContentView(R.layout.wallpaper_cropper);
mCropView = (CropView) findViewById(R.id.cropView);
mProgressView = findViewById(R.id.loading);
Intent cropIntent = getIntent();
final Uri imageUri = cropIntent.getData();
if (imageUri == null) {
Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
finish();
return;
}
// Action bar
// Show the custom action bar view
final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
actionBar.getCustomView().setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
actionBar.hide();
boolean finishActivityWhenDone = true;
// Never fade on finish because we return to the app that started us (e.g.
// Photos), not the home screen.
boolean shouldFadeOutOnFinish = false;
cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone,
shouldFadeOutOnFinish);
}
});
mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);
// Load image in background
final BitmapRegionTileSource.UriBitmapSource bitmapSource =
new BitmapRegionTileSource.UriBitmapSource(getContext(), imageUri);
mSetWallpaperButton.setEnabled(false);
Runnable onLoad = new Runnable() {
public void run() {
if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
Toast.makeText(getContext(), R.string.wallpaper_load_fail,
Toast.LENGTH_LONG).show();
finish();
} else {
mSetWallpaperButton.setEnabled(true);
}
}
};
setCropViewTileSource(bitmapSource, true, false, null, onLoad);
}
开发者ID:RunasSudo,项目名称:FLauncher,代码行数:52,代码来源:WallpaperCropActivity.java
示例10: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
public void setCropViewTileSource(
final BitmapRegionTileSource.BitmapSource bitmapSource, final boolean touchEnabled,
final boolean moveToLeft, final Runnable postExecute) {
final Context context = WallpaperCropActivity.this;
final View progressView = findViewById(R.id.loading);
final AsyncTask<Void, Void, Void> loadBitmapTask = new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void...args) {
if (!isCancelled()) {
try {
bitmapSource.loadInBackground();
} catch (SecurityException securityException) {
if (isDestroyed()) {
// Temporarily granted permissions are revoked when the activity
// finishes, potentially resulting in a SecurityException here.
// Even though {@link #isDestroyed} might also return true in different
// situations where the configuration changes, we are fine with
// catching these cases here as well.
cancel(false);
} else {
// otherwise it had a different cause and we throw it further
throw securityException;
}
}
}
return null;
}
protected void onPostExecute(Void arg) {
if (!isCancelled()) {
progressView.setVisibility(View.INVISIBLE);
if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
mCropView.setTileSource(
new BitmapRegionTileSource(context, bitmapSource), null);
mCropView.setTouchEnabled(touchEnabled);
if (moveToLeft) {
mCropView.moveToLeft();
}
}
}
if (postExecute != null) {
postExecute.run();
}
}
};
// We don't want to show the spinner every time we load an image, because that would be
// annoying; instead, only start showing the spinner if loading the image has taken
// longer than 1 sec (ie 1000 ms)
progressView.postDelayed(new Runnable() {
public void run() {
if (loadBitmapTask.getStatus() != AsyncTask.Status.FINISHED) {
progressView.setVisibility(View.VISIBLE);
}
}
}, 1000);
loadBitmapTask.execute();
}
开发者ID:AndroidDeveloperLB,项目名称:LB-Launcher,代码行数:56,代码来源:WallpaperCropActivity.java
注:本文中的com.android.photos.BitmapRegionTileSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论