use of android.graphics.drawable.BitmapDrawable in project android-app by eoecn.
the class PopupWindowUtil method showActionWindow.
public void showActionWindow(View parent, Context context, List<T> tabs) {
// final RingtoneclipModel currentData = model;
// final int res_id = currentData.getId();
int[] location = new int[2];
int popWidth = context.getResources().getDimensionPixelOffset(R.dimen.popupWindow_width);
parent.getLocationOnScreen(location);
View view = getView(context, tabs);
popupWindow = new PopupWindow(view, popWidth, // new
LayoutParams.WRAP_CONTENT);
// PopupWindow(view,
// popWidth,
// LayoutParams.WRAP_CONTENT);
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// 显示的位置为:屏幕的最右端
int xPos = (int) (windowManager.getDefaultDisplay().getWidth() - popupWindow.getWidth() - context.getResources().getDimension(R.dimen.popupWindow_margin));
// popupWindow.showAsDropDown(parent, -10,0);
popupWindow.showAtLocation(parent, Gravity.NO_GRAVITY, xPos, location[1] + parent.getHeight() - 20);
}
use of android.graphics.drawable.BitmapDrawable in project kickmaterial by byoutline.
the class CircleTransition method getStartView.
private View getStartView(ViewGroup sceneRoot, TransitionValues startValues, int[] sceneRootLoc, int[] startLoc) {
Bitmap startImage = (Bitmap) startValues.values.get(PROPERTY_IMAGE);
Drawable startBackground = new BitmapDrawable(startImage);
final View startView = addViewToOverlay(sceneRoot, startImage.getWidth(), startImage.getHeight(), startBackground);
int startTranslationX = startLoc[0] - sceneRootLoc[0];
int startTranslationY = startLoc[1] - sceneRootLoc[1];
startView.setTranslationX(startTranslationX);
startView.setTranslationY(startTranslationY);
return startView;
}
use of android.graphics.drawable.BitmapDrawable in project buck by facebook.
the class ExoMetaLogActivity method onCreate.
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
ApplicationInfo appInfo = getPackageManager().getApplicationInfo("buck.exotest", PackageManager.GET_META_DATA);
Bitmap icon = getIcon(appInfo);
Bitmap defaultIcon = ((BitmapDrawable) getPackageManager().getApplicationIcon(getApplicationInfo())).getBitmap();
if (icon == null) {
Log.i("EXOPACKAGE_TEST_META", "Found no icon");
} else if (icon.sameAs(defaultIcon)) {
Log.i("EXOPACKAGE_TEST_META", "Found default icon");
} else {
Log.i("EXOPACKAGE_TEST_META", "META_ICON=" + icon.getWidth() + "_" + icon.getHeight());
}
String name = getName(appInfo);
if (name == null) {
Log.i("EXOPACKAGE_TEST_META", "Found no name");
} else {
Log.i("EXOPACKAGE_TEST_META", "META_NAME=" + name);
}
String[] meta = getMeta(appInfo);
if (meta == null) {
Log.i("EXOPACKAGE_TEST_META", "Found no metadata");
} else {
String metaStr = "<";
for (int i = 0; i < meta.length; i++) {
metaStr += (i == 0 ? "" : ",") + meta[i];
}
metaStr += ">";
Log.i("EXOPACKAGE_TEST_META", "META_DATA=" + metaStr);
}
} catch (Exception e) {
Log.i("EXOPACKAGE_TEST_META_DEBUG", "Got an exception", e);
}
Log.i("EXOPACKAGE_TEST_META", "FINISHED");
finish();
}
use of android.graphics.drawable.BitmapDrawable in project Android-ShareEverywhere by dgmltn.
the class IcsListPopupWindow method show.
public void show() {
int height = buildDropDown();
int widthSpec = 0;
int heightSpec = 0;
boolean noInputMethod = isInputMethodNotNeeded();
if (mPopup.isShowing()) {
if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
// The call to PopupWindow's update method below can accept -1 for any
// value you do not want to update.
widthSpec = -1;
} else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
widthSpec = mDropDownAnchorView.getWidth();
} else {
widthSpec = mDropDownWidth;
}
if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
// The call to PopupWindow's update method below can accept -1 for any
// value you do not want to update.
heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT;
if (noInputMethod) {
mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, 0);
} else {
mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, ViewGroup.LayoutParams.MATCH_PARENT);
}
} else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
heightSpec = height;
} else {
heightSpec = mDropDownHeight;
}
mPopup.setOutsideTouchable(true);
mPopup.update(mDropDownAnchorView, mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec, heightSpec);
} else {
if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
widthSpec = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) {
mPopup.setWidth(mDropDownAnchorView.getWidth());
} else {
mPopup.setWidth(mDropDownWidth);
}
}
if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
heightSpec = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
mPopup.setHeight(height);
} else {
mPopup.setHeight(mDropDownHeight);
}
}
mPopup.setWindowLayoutMode(widthSpec, heightSpec);
//http://stackoverflow.com/questions/3121232/android-popup-window-dismissal
if (mPopup.getBackground() == null) {
mPopup.setBackgroundDrawable(new BitmapDrawable());
}
// use outside touchable to dismiss drop down when touching outside of it, so
// only set this if the dropdown is not always visible
mPopup.setOutsideTouchable(true);
mPopup.setTouchInterceptor(mTouchInterceptor);
mPopup.showAsDropDown(mDropDownAnchorView, mDropDownHorizontalOffset, mDropDownVerticalOffset);
mDropDownList.setSelection(ListView.INVALID_POSITION);
if (!mModal || mDropDownList.isInTouchMode()) {
clearListSelection();
}
if (!mModal) {
mHandler.post(mHideSelector);
}
}
}
use of android.graphics.drawable.BitmapDrawable in project Launcher3 by chislon.
the class WallpaperPickerActivity method getDefaultWallpaperInfo.
private ResourceWallpaperInfo getDefaultWallpaperInfo() {
Resources sysRes = Resources.getSystem();
int resId = sysRes.getIdentifier("default_wallpaper", "drawable", "android");
File defaultThumbFile = new File(getFilesDir(), "default_thumb.jpg");
Bitmap thumb = null;
boolean defaultWallpaperExists = false;
if (defaultThumbFile.exists()) {
thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath());
defaultWallpaperExists = true;
} else {
Resources res = getResources();
Point defaultThumbSize = getDefaultThumbnailSize(res);
int rotation = WallpaperCropActivity.getRotationFromExif(res, resId);
thumb = createThumbnail(defaultThumbSize, this, null, null, sysRes, resId, rotation, false);
if (thumb != null) {
try {
defaultThumbFile.createNewFile();
FileOutputStream thumbFileStream = openFileOutput(defaultThumbFile.getName(), Context.MODE_PRIVATE);
thumb.compress(Bitmap.CompressFormat.JPEG, 95, thumbFileStream);
thumbFileStream.close();
defaultWallpaperExists = true;
} catch (IOException e) {
Log.e(TAG, "Error while writing default wallpaper thumbnail to file " + e);
defaultThumbFile.delete();
}
}
}
if (defaultWallpaperExists) {
return new ResourceWallpaperInfo(sysRes, resId, new BitmapDrawable(thumb));
}
return null;
}
Aggregations