Search in sources :

Example 1 with LayoutDirection

use of com.android.resources.LayoutDirection 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 2 with LayoutDirection

use of com.android.resources.LayoutDirection in project android_frameworks_base by DirtyUnicorns.

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 3 with LayoutDirection

use of com.android.resources.LayoutDirection in project android_frameworks_base by crdroidandroid.

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 4 with LayoutDirection

use of com.android.resources.LayoutDirection in project android_frameworks_base by AOSPA.

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 5 with LayoutDirection

use of com.android.resources.LayoutDirection in project android_frameworks_base by ResurrectionRemix.

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)

Aggregations

Bitmap (android.graphics.Bitmap)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 LayoutDirection (com.android.resources.LayoutDirection)5 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5