本文整理汇总了Java中com.android.photos.BitmapRegionTileSource.BitmapSource类的典型用法代码示例。如果您正苦于以下问题:Java BitmapSource类的具体用法?Java BitmapSource怎么用?Java BitmapSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitmapSource类属于com.android.photos.BitmapRegionTileSource包,在下文中一共展示了BitmapSource类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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();
}
}
}
});
}
示例2: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的package包/类
public final void setCropViewTileSource(BitmapSource bitmapSource, boolean touchEnabled,
boolean moveToLeft, CropViewScaleProvider scaleProvider, Runnable postExecute) {
final LoadRequest req = new LoadRequest();
req.moveToLeft = moveToLeft;
req.src = bitmapSource;
req.touchEnabled = touchEnabled;
req.postExecute = postExecute;
req.scaleProvider = scaleProvider;
mCurrentLoadRequest = req;
// Remove any pending requests
mLoaderHandler.removeMessages(MSG_LOAD_IMAGE);
Message.obtain(mLoaderHandler, MSG_LOAD_IMAGE, req).sendToTarget();
// 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)
mProgressView.postDelayed(new Runnable() {
public void run() {
if (mCurrentLoadRequest == req) {
mProgressView.setVisibility(View.VISIBLE);
}
}
}, 1000);
}
示例3: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的package包/类
@Override
public void setCropViewTileSource(BitmapSource bitmapSource,
boolean touchEnabled,
boolean moveToLeft,
final Runnable postExecute) {
// we also want to show our own wallpaper instead of the one in the background
Runnable showPostExecuteRunnable = new Runnable() {
@Override
public void run() {
if(postExecute != null) {
postExecute.run();
}
setSystemWallpaperVisiblity(false);
}
};
super.setCropViewTileSource(bitmapSource,
touchEnabled,
moveToLeft,
showPostExecuteRunnable);
}
示例4: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的package包/类
public final void setCropViewTileSource(BitmapSource bitmapSource, boolean touchEnabled,
boolean moveToLeft, CropViewScaleAndOffsetProvider scaleProvider, Runnable postExecute) {
final LoadRequest req = new LoadRequest();
req.moveToLeft = moveToLeft;
req.src = bitmapSource;
req.touchEnabled = touchEnabled;
req.postExecute = postExecute;
req.scaleAndOffsetProvider = scaleProvider;
mCurrentLoadRequest = req;
// Remove any pending requests
mLoaderHandler.removeMessages(MSG_LOAD_IMAGE);
Message.obtain(mLoaderHandler, MSG_LOAD_IMAGE, req).sendToTarget();
// 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)
mProgressView.postDelayed(new Runnable() {
public void run() {
if (mCurrentLoadRequest == req) {
mProgressView.setVisibility(View.VISIBLE);
}
}
}, 1000);
}
示例5: onClick
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的package包/类
@Override
public void onClick(final WallpaperPickerActivity a) {
final Runnable onLoad;
if (!mFirstClick) {
onLoad = null;
} else {
mFirstClick = false;
a.mSetWallpaperButton.setEnabled(false);
onLoad = new Runnable() {
public void run() {
if (mBitmapSource != null &&
mBitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
a.selectTile(mView);
a.mSetWallpaperButton.setEnabled(true);
} else {
ViewGroup parent = (ViewGroup) mView.getParent();
if (parent != null) {
parent.removeView(mView);
Toast.makeText(a,
a.getString(R.string.image_load_fail),
Toast.LENGTH_SHORT).show();
}
}
}
};
}
mBitmapSource = new BitmapRegionTileSource.UriBitmapSource(
a, mUri, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
a.setCropViewTileSource(mBitmapSource, true, false, onLoad);
}
示例6: init
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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);
}
示例7: handleMessage
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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;
}
示例8: init
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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);
}
示例9: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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();
}
示例10: init
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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);
}
示例11: setCropViewTileSource
import com.android.photos.BitmapRegionTileSource.BitmapSource; //导入依赖的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();
}