use of android.widget.ImageView in project platform_frameworks_base by android.
the class ScaleDrawableTests method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView scrollView = new ScrollView(this);
GridLayout container = new GridLayout(this);
scrollView.addView(container);
container.setColumnCount(4);
container.setBackgroundColor(0xFF888888);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
params.width = 300;
params.height = 200;
for (int i = 0; i < scaleTypes.length; i++) {
TextView t = new TextView(this);
t.setText(scaleTypes[i]);
container.addView(t);
ImageView.ScaleType scaleType = ImageView.ScaleType.values()[i];
ImageView png_view = new ImageView(this);
png_view.setLayoutParams(params);
png_view.setScaleType(scaleType);
png_view.setImageResource(icon);
container.addView(png_view);
ImageView view = new ImageView(this);
view.setLayoutParams(params);
view.setScaleType(scaleType);
view.setImageResource(vector_icon);
container.addView(view);
ImageView avd_view = new ImageView(this);
avd_view.setLayoutParams(params);
avd_view.setScaleType(scaleType);
avd_view.setImageResource(animated_vector_icon);
container.addView(avd_view);
}
setContentView(scrollView);
}
use of android.widget.ImageView in project platform_frameworks_base by android.
the class CustomBar method loadIcon.
protected void loadIcon(int index, String iconName, Density density, boolean isRtl) {
View child = getChildAt(index);
if (child instanceof ImageView) {
ImageView imageView = (ImageView) child;
LayoutDirection dir = isRtl ? LayoutDirection.RTL : null;
IconLoader iconLoader = new IconLoader(iconName, density, mSimulatedPlatformVersion, dir);
InputStream stream = iconLoader.getIcon();
if (stream != null) {
density = iconLoader.getDensity();
String path = iconLoader.getPath();
// look for a cached bitmap
Bitmap bitmap = Bridge.getCachedBitmap(path, Boolean.TRUE);
if (bitmap == null) {
try {
bitmap = Bitmap_Delegate.createBitmap(stream, false, /*isMutable*/
density);
Bridge.setCachedBitmap(path, bitmap, Boolean.TRUE);
} catch (IOException e) {
return;
}
}
if (bitmap != null) {
BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(), bitmap);
imageView.setImageDrawable(drawable);
}
}
}
}
use of android.widget.ImageView in project platform_frameworks_base by android.
the class AdapterHelper method fillView.
private static void fillView(BridgeContext context, View view, AdapterItem item, AdapterItem parentItem, LayoutlibCallback callback, ResourceReference adapterRef) {
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
final int count = group.getChildCount();
for (int i = 0; i < count; i++) {
fillView(context, group.getChildAt(i), item, parentItem, callback, adapterRef);
}
} else {
int id = view.getId();
if (id != 0) {
ResourceReference resolvedRef = context.resolveId(id);
if (resolvedRef != null) {
int fullPosition = item.getFullPosition();
int positionPerType = item.getPositionPerType();
int fullParentPosition = parentItem != null ? parentItem.getFullPosition() : 0;
int parentPositionPerType = parentItem != null ? parentItem.getPositionPerType() : 0;
if (view instanceof TextView) {
TextView tv = (TextView) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.TEXT, tv.getText().toString());
if (value != null) {
if (value.getClass() != ViewAttribute.TEXT.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for TEXT. Expected String, got %s", value.getClass().getName()), null);
} else {
tv.setText((String) value);
}
}
}
if (view instanceof Checkable) {
Checkable cb = (Checkable) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.IS_CHECKED, cb.isChecked());
if (value != null) {
if (value.getClass() != ViewAttribute.IS_CHECKED.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for IS_CHECKED. Expected Boolean, got %s", value.getClass().getName()), null);
} else {
cb.setChecked((Boolean) value);
}
}
}
if (view instanceof ImageView) {
ImageView iv = (ImageView) view;
Object value = callback.getAdapterItemValue(adapterRef, context.getViewKey(view), item.getDataBindingItem().getViewReference(), fullPosition, positionPerType, fullParentPosition, parentPositionPerType, resolvedRef, ViewAttribute.SRC, iv.getDrawable());
if (value != null) {
if (value.getClass() != ViewAttribute.SRC.getAttributeClass()) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, String.format("Wrong Adapter Item value class for SRC. Expected Boolean, got %s", value.getClass().getName()), null);
} else {
// FIXME
}
}
}
}
}
}
}
use of android.widget.ImageView in project platform_packages_apps_launcher by android.
the class LiveFolderAdapter method newView.
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view;
final ViewHolder holder = new ViewHolder();
if (!mIsList) {
view = mInflater.inflate(R.layout.application_boxed, parent, false);
} else {
view = mInflater.inflate(R.layout.application_list, parent, false);
holder.description = (TextView) view.findViewById(R.id.description);
holder.icon = (ImageView) view.findViewById(R.id.icon);
}
holder.name = (TextView) view.findViewById(R.id.name);
holder.idIndex = cursor.getColumnIndexOrThrow(LiveFolders._ID);
holder.nameIndex = cursor.getColumnIndexOrThrow(LiveFolders.NAME);
holder.descriptionIndex = cursor.getColumnIndex(LiveFolders.DESCRIPTION);
holder.intentIndex = cursor.getColumnIndex(LiveFolders.INTENT);
holder.iconBitmapIndex = cursor.getColumnIndex(LiveFolders.ICON_BITMAP);
holder.iconResourceIndex = cursor.getColumnIndex(LiveFolders.ICON_RESOURCE);
holder.iconPackageIndex = cursor.getColumnIndex(LiveFolders.ICON_PACKAGE);
view.setTag(holder);
return view;
}
use of android.widget.ImageView in project androidquery by androidquery.
the class BitmapAjaxCallback method callback.
@Override
public final void callback(String url, Bitmap bm, AjaxStatus status) {
ImageView firstView = v.get();
WeakHashMap<ImageView, BitmapAjaxCallback> ivs = queueMap.remove(url);
//check if view queue already contains first view
if (ivs == null || !ivs.containsKey(firstView)) {
checkCb(this, url, firstView, bm, status);
}
if (ivs != null) {
Set<ImageView> set = ivs.keySet();
for (ImageView view : set) {
BitmapAjaxCallback cb = ivs.get(view);
cb.status = status;
checkCb(cb, url, view, bm, status);
}
}
}
Aggregations