Search in sources :

Example 71 with ImageView

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);
}
Also used : GridLayout(android.widget.GridLayout) LayoutParams(android.view.ViewGroup.LayoutParams) ScrollView(android.widget.ScrollView) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 72 with ImageView

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);
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) LayoutDirection(com.android.resources.LayoutDirection) InputStream(java.io.InputStream) ImageView(android.widget.ImageView) IOException(java.io.IOException) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 73 with ImageView

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
                        }
                    }
                }
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) ResourceReference(com.android.ide.common.rendering.api.ResourceReference) Checkable(android.widget.Checkable) ImageView(android.widget.ImageView)

Example 74 with ImageView

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;
}
Also used : ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 75 with ImageView

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);
        }
    }
}
Also used : ImageView(android.widget.ImageView)

Aggregations

ImageView (android.widget.ImageView)2257 View (android.view.View)1144 TextView (android.widget.TextView)1005 Intent (android.content.Intent)200 Drawable (android.graphics.drawable.Drawable)197 LinearLayout (android.widget.LinearLayout)192 Bitmap (android.graphics.Bitmap)178 ViewGroup (android.view.ViewGroup)163 LayoutInflater (android.view.LayoutInflater)159 OnClickListener (android.view.View.OnClickListener)145 AdapterView (android.widget.AdapterView)111 ListView (android.widget.ListView)103 RecyclerView (android.support.v7.widget.RecyclerView)102 FrameLayout (android.widget.FrameLayout)97 Button (android.widget.Button)83 Bundle (android.os.Bundle)81 BitmapDrawable (android.graphics.drawable.BitmapDrawable)80 RelativeLayout (android.widget.RelativeLayout)72 Test (org.junit.Test)70 Context (android.content.Context)69