Java Code Examples for android.widget.ImageView#setScaleType()

The following examples show how to use android.widget.ImageView#setScaleType() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Ency   File: ImageAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, final int position) {
    final ImageView imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    if (isPTP && AppNetWorkUtil.getNetworkType(context) == AppNetWorkUtil.TYPE_MOBILE) {
        ImageLoader.loadDefault(context,imageView);
    } else {
        ImageLoader.loadAllAsBitmap(context,imgs.get(position),R.drawable.icon_default,imageView);
    }
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, ImageActivity.class);
            intent.putExtra("imgurl", imgs.get(position));
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, imageView, context.getString(R.string.transition_img));
            ActivityCompat.startActivity(context, intent, options.toBundle());
        }
    });
    container.addView(imageView);
    return imageView;
}
 
Example 2
private void initialize(Context context) {
    // We only want our ImageView in here. Nothing else is permitted
    removeAllViews();

    image = new ImageView(context);

    LayoutParams imageLayout = new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);

    image.setLayoutParams(imageLayout);

    // We want to prevent up-scaling the image, but still have it fit within
    // the layout bounds as best as possible.
    image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    addView(image);
}
 
Example 3
Source Project: WanAndroid   File: CustomBanner.java    License: Apache License 2.0 6 votes vote down vote up
private void displayIndicator() {
    indicatorViews.clear();
    indicatorContainer.removeAllViews();
    for (int i = 0; i < count; i++) {
        ImageView imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(indicatorWidth, indicatorHeight);
        params.leftMargin = indicatorLeftMargin;
        params.rightMargin = indicatorRightMargin;
        if (i == 0) {
            imageView.setImageResource(R.drawable.gray_radius);
        }else {
            imageView.setImageResource(R.drawable.white_radius);
        }
        indicatorViews.add(imageView);
        indicatorContainer.addView(imageView, params);
    }
}
 
Example 4
Source Project: Study_Android_Demo   File: PuBuLayout.java    License: Apache License 2.0 6 votes vote down vote up
public void addImage(Bitmap bitmap){
    //每添加一张图片,创建一个新的ImageView
    ImageView iv = new ImageView(getContext());
    //设置ImageView的拉伸模式
    iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
    //设置margin属性以及设置宽为match_parent,高:wrap_content
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(5,5,5,5);
    iv.setImageBitmap(bitmap);
    //设置Imageview保持宽高比
    iv.setAdjustViewBounds(true);

    //并添加到指定的垂直线性布局中
    //计算出当前要放的布局的索引
    int index = countImg++%childLayout.size();

    //取出对应索引的LinearLalyout
    //添加子控件
    childLayout.get(index).addView(iv,params);


}
 
Example 5
@Override
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) {
    ImageView imageView =
            (ImageView)
                    LayoutInflater.from(parent.getContext())
                            .inflate(
                                    R.layout.lb_fullwidth_details_overview_logo,
                                    parent,
                                    false);

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.detail_thumb_width);
    int height = res.getDimensionPixelSize(R.dimen.detail_thumb_height);
    imageView.setLayoutParams(new ViewGroup.MarginLayoutParams(width, height));
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    return new ViewHolder(imageView);
}
 
Example 6
public ManageChatTextCell(Context context) {
    super(context);

    textView = new SimpleTextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(16);
    textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(textView);

    valueTextView = new SimpleTextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText));
    valueTextView.setTextSize(16);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT);
    addView(valueTextView);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
    addView(imageView);
}
 
Example 7
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    if (convertView == null) {
        // this is call when new view
        
        convertView = LayoutInflater.from(this.context).inflate(R.layout.item, null, false);
        ImageView imageView = (ImageView) convertView.findViewById(R.id.image);
        TextView textView = (TextView) convertView.findViewById(R.id.text);
        imageView.setScaleType(ImageView.ScaleType.MATRIX);

        // hardcode the background image
        if (position % 2 == 0) {
            imageView.setImageResource(R.drawable.lorempixel2);
        } else if (position % 3 == 0) {
            imageView.setImageResource(R.drawable.lorempixel3);
        } else {
            imageView.setImageResource(R.drawable.lorempixel);
        }
        // since the image size is set to 400 x 300 we will hardcode the initial translation to the center for new item
        Matrix matrix = imageView.getImageMatrix();
        matrix.postTranslate(0, -100);
        imageView.setImageMatrix(matrix);

        // use the viewholder
        viewHolder = new ViewHolder();
        viewHolder.imageView = imageView;
        viewHolder.textView = textView;
        convertView.setTag(viewHolder);
    }
    viewHolder = (ViewHolder) convertView.getTag();
    viewHolder.textView.setText("Row "+ position);
    return convertView;
}
 
Example 8
public AccountSelectCell(Context context) {
    super(context);

    avatarDrawable = new AvatarDrawable();
    avatarDrawable.setTextSize(AndroidUtilities.dp(12));

    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(18));
    addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 10, 10, 0, 0));

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 61, 0, 56, 0));

    checkImageView = new ImageView(context);
    checkImageView.setImageResource(R.drawable.account_check);
    checkImageView.setScaleType(ImageView.ScaleType.CENTER);
    checkImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemCheck), PorterDuff.Mode.MULTIPLY));
    addView(checkImageView, LayoutHelper.createFrame(40, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 6, 0));
}
 
Example 9
private void init() {
    mFilledView = new ImageView(getContext());
    mFilledView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    mEmptyView = new ImageView(getContext());
    mEmptyView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    addView(mFilledView);
    addView(mEmptyView);
}
 
Example 10
Source Project: ScrollLayout   File: MainPagerAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView;
    Address address = mAllAddressList.get(position);
    if (mAllImageMap.containsKey(position)) {
        View oldView = mAllImageMap.get(position);
        Object tag = oldView.getTag();
        if (null != tag && tag instanceof Address) {
            if (tag.equals(address)) {
                itemView = oldView;
                container.addView(itemView);
                return itemView;
            }
        }
        container.removeView(oldView);
        mAllImageMap.remove(position);
    }

    ImageView imageView = new ImageView(mContext);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    Glide.with(mContext).load(address.getImageUrl()).into(imageView);
    imageView.setTag(address);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    mAllImageMap.put(position, imageView);
    itemView = imageView;
    itemView.setOnClickListener(this);
    container.addView(itemView);
    return itemView;
}
 
Example 11
Source Project: Dashboard   File: PhotoViewAttacher.java    License: MIT License 5 votes vote down vote up
/**
 * Set's the ImageView's ScaleType to Matrix.
 */
private static void setImageViewScaleTypeMatrix(ImageView imageView) {
    /**
     * PhotoView sets it's own ScaleType to Matrix, then diverts all calls
     * setScaleType to this.setScaleType automatically.
     */
    if (null != imageView && !(imageView instanceof PhotoView)) {
        if (!ScaleType.MATRIX.equals(imageView.getScaleType())) {
            imageView.setScaleType(ScaleType.MATRIX);
        }
    }
}
 
Example 12
Source Project: HeroVideo-master   File: BannerAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position)
{

    //对ViewPager页号求模取出View列表中要显示的项
    position %= mList.size();
    if (position < 0)
    {
        position = mList.size() + position;
    }
    ImageView v = mList.get(position);
    pos = position;
    v.setScaleType(ImageView.ScaleType.CENTER);
    //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
    ViewParent vp = v.getParent();
    if (vp != null)
    {
        ViewGroup parent = (ViewGroup) vp;
        parent.removeView(v);
    }
    v.setOnClickListener(v1 -> {

        if (mViewPagerOnItemClickListener != null)
        {
            mViewPagerOnItemClickListener.onItemClick();
        }
    });


    container.addView(v);
    return v;
}
 
Example 13
Source Project: BorderMenu   File: IconItem.java    License: Apache License 2.0 5 votes vote down vote up
public IconItem(BorderMenuActivity borderMenuActivity, int id, int idResource) {
	super(borderMenuActivity, id);
	icon = new ImageView(borderMenuActivity);
	setMinimumHeight(Utils.dpToPx(56, getResources()));
	setMinimumWidth(Utils.dpToPx(56, getResources()));
	icon.setAdjustViewBounds(true);
	icon.setScaleType(ScaleType.CENTER_CROP);
	icon.setImageResource(idResource);
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Utils.dpToPx(24, getResources()),Utils.dpToPx(24, getResources()));
	params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	icon.setLayoutParams(params);
	rippleSpeed = Utils.dpToPx(2, getResources());
	addView(icon);
}
 
Example 14
Source Project: sctalk   File: IndicatorLayout.java    License: Apache License 2.0 4 votes vote down vote up
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
		super(context);
		mArrowImageView = new ImageView(context);

//		Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
		Drawable arrowD = new Drawable() {
			
			@Override
			public void setColorFilter(ColorFilter cf) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void setAlpha(int alpha) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public int getOpacity() {
				// TODO Auto-generated method stub
				return 0;
			}
			
			@Override
			public void draw(Canvas canvas) {
				// TODO Auto-generated method stub
				
			}
		};
		mArrowImageView.setImageDrawable(arrowD);

//		final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
		final int padding = 0;
		mArrowImageView.setPadding(padding, padding, padding, padding);
//		addView(mArrowImageView);

		int inAnimResId, outAnimResId;
		switch (mode) {
			case PULL_FROM_END:
				inAnimResId = R.anim.slide_in_from_bottom;
				outAnimResId = R.anim.slide_out_to_bottom;
				setBackgroundResource(R.drawable.indicator_bg_bottom);

				// Rotate Arrow so it's pointing the correct way
				mArrowImageView.setScaleType(ScaleType.MATRIX);
				Matrix matrix = new Matrix();
				matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
				mArrowImageView.setImageMatrix(matrix);
				break;
			default:
			case PULL_FROM_START:
				inAnimResId = R.anim.slide_in_from_top;
				outAnimResId = R.anim.slide_out_to_top;
				setBackgroundResource(R.drawable.indicator_bg_top);
				break;
		}

		mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
		mInAnim.setAnimationListener(this);

		mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
		mOutAnim.setAnimationListener(this);

		final Interpolator interpolator = new LinearInterpolator();
		mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
				0.5f);
		mRotateAnimation.setInterpolator(interpolator);
		mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
		mRotateAnimation.setFillAfter(true);

		mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
				Animation.RELATIVE_TO_SELF, 0.5f);
		mResetRotateAnimation.setInterpolator(interpolator);
		mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
		mResetRotateAnimation.setFillAfter(true);

	}
 
Example 15
Source Project: glide-support   File: ImageChunkAdapter.java    License: The Unlicense 4 votes vote down vote up
@Override public ImageChunkViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
	ImageView view = new ImageView(parent.getContext());
	view.setScaleType(ScaleType.CENTER);
	view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int)(imageChunkHeight * ratio)));
	return new ImageChunkViewHolder(view);
}
 
Example 16
/** display platform list */
public void afterPlatformListGot() {
	String name = String.valueOf(reqData.get("platform"));
	int size = platformList == null ? 0 : platformList.length;
	views = new View[size];

	final int dp_36 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 36);
	LinearLayout.LayoutParams lpItem = new LinearLayout.LayoutParams(dp_36, dp_36);
	final int dp_9 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 9);
	lpItem.setMargins(0, 0, dp_9, 0);
	FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpMask.gravity = Gravity.LEFT | Gravity.TOP;
	int selection = 0;
	for (int i = 0; i < size; i++) {
		FrameLayout fl = new FrameLayout(getContext());
		fl.setLayoutParams(lpItem);
		if (i >= size - 1) {
			fl.setLayoutParams(new LinearLayout.LayoutParams(dp_36, dp_36));
		}
		llPlat.addView(fl);
		fl.setOnClickListener(this);

		ImageView iv = new ImageView(getContext());
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageBitmap(getPlatLogo(platformList[i]));
		iv.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		fl.addView(iv);

		views[i] = new View(getContext());
		views[i].setBackgroundColor(0xcfffffff);
		views[i].setOnClickListener(this);
		if (name != null && name.equals(platformList[i].getName())) {
			views[i].setVisibility(View.INVISIBLE);
			selection = i;

			// a statistics of Sharing
			ShareSDK.logDemoEvent(3, platformList[i]);
		}
		views[i].setLayoutParams(lpMask);
		fl.addView(views[i]);
	}

	final int postSel = selection;
	UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
		public boolean handleMessage(Message msg) {
			HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
			hsv.scrollTo(postSel * (dp_36 + dp_9), 0);
			return false;
		}
	});
}
 
Example 17
private void buildTabsViews() {

        int selectedTab = observer.getCurrentItem();
        int tabsCount = observer.getCount();

        tabsContainer.removeAllViews();

        if (tabsCount <= 0) {
            return;
        }
        LinearLayout.LayoutParams params = null;

        switch (tabsWidth) {
            case ACTUAL:
                tabsContainer.setWeightSum(0);
                params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
                break;
            case FIT_WIDTH:
                tabsContainer.setWeightSum(tabsCount);
                params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
                break;
            case AUTO:
                tabsContainer.setWeightSum(0);
                params = new LinearLayout.LayoutParams(minTabWidth, LinearLayout.LayoutParams.MATCH_PARENT);
                calculateAutoTabsSize();
                break;
            default:
                params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
                break;
        }


        for (int i = 0; i < tabsCount; i++) {

            ImageView imageView = new ImageView(getContext());
            imageView.setImageResource(iconicProvider.getIconicDrawable(i));
            imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

            if (i == selectedTab) {
                selectedTabView = imageView;
                iconicTabsEffect.applyTabEffect(imageView, 1f, IconicTabsEffect.Status.GAINING_FOCUS);
            } else {
                iconicTabsEffect.applyTabEffect(imageView, 0f, IconicTabsEffect.Status.LOSING_FOCUS);
            }

            imageView.setOnClickListener(new TabsClickListener(i));

            tabsContainer.addView(imageView, params);
        }

        scrollToChild(selectedTab, 0);
    }
 
Example 18
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
	super(context);
	mArrowImageView = new ImageView(context);

	Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
	mArrowImageView.setImageDrawable(arrowD);

	final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
	mArrowImageView.setPadding(padding, padding, padding, padding);
	addView(mArrowImageView);

	int inAnimResId, outAnimResId;
	switch (mode) {
		case PULL_FROM_END:
			inAnimResId = R.anim.slide_in_from_bottom;
			outAnimResId = R.anim.slide_out_to_bottom;
			setBackgroundResource(R.drawable.indicator_bg_bottom);

			// Rotate Arrow so it's pointing the correct way
			mArrowImageView.setScaleType(ScaleType.MATRIX);
			Matrix matrix = new Matrix();
			matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
			mArrowImageView.setImageMatrix(matrix);
			break;
		default:
		case PULL_FROM_START:
			inAnimResId = R.anim.slide_in_from_top;
			outAnimResId = R.anim.slide_out_to_top;
			setBackgroundResource(R.drawable.indicator_bg_top);
			break;
	}

	mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
	mInAnim.setAnimationListener(this);

	mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
	mOutAnim.setAnimationListener(this);

	final Interpolator interpolator = new LinearInterpolator();
	mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(interpolator);
	mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(interpolator);
	mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);

}
 
Example 19
Source Project: Roid-Library   File: ImageLoader.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Adds load image task to execution pool. Image will be returned with
 * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
 * callback}.<br />
 * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be
 * called before this method call
 * 
 * @param uri Image URI (i.e. "http://site.com/image.png",
 *            "file:///mnt/sdcard/image.png")
 * @param targetImageSize Minimal size for {@link Bitmap} which will be
 *            returned in
 *            {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
 *            callback}. Downloaded image will be decoded and scaled to
 *            {@link Bitmap} of the size which is <b>equal or larger</b>
 *            (usually a bit larger) than incoming minImageSize .
 * @param options {@linkplain DisplayImageOptions Display image options}
 *            for image displaying. If <b>null</b> - default display image
 *            options
 *            {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
 *            from configuration} will be used.<br />
 *            Incoming options should contain {@link FakeBitmapDisplayer}
 *            as displayer.
 * @param listener {@linkplain ImageLoadingListener Listener} for image
 *            loading process. Listener fires events on UI thread.
 * @throws IllegalStateException if
 *             {@link #init(ImageLoaderConfiguration)} method wasn't
 *             called before
 */
public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options,
        ImageLoadingListener listener) {
    checkConfiguration();
    if (targetImageSize == null) {
        targetImageSize = new ImageSize(configuration.maxImageWidthForMemoryCache,
                configuration.maxImageHeightForMemoryCache);
    }
    if (options == null) {
        options = configuration.defaultDisplayImageOptions;
    }

    DisplayImageOptions optionsWithFakeDisplayer;
    if (options.getDisplayer() instanceof FakeBitmapDisplayer) {
        optionsWithFakeDisplayer = options;
    } else {
        optionsWithFakeDisplayer = new DisplayImageOptions.Builder().cloneFrom(options).displayer(
                fakeBitmapDisplayer).build();
    }

    ImageView fakeImage = new ImageView(configuration.context);
    fakeImage.setLayoutParams(new LayoutParams(targetImageSize.getWidth(), targetImageSize.getHeight()));
    fakeImage.setScaleType(ScaleType.CENTER_CROP);

    displayImage(uri, fakeImage, optionsWithFakeDisplayer, listener);
}
 
Example 20
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout rootLayout = new FrameLayout(this);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    rootLayout.setLayoutParams(layoutParams);
    ConfigXmlUtil.setStatusBarColorWithAddView(this, Color.TRANSPARENT);
    loadingBitmap = BUtility.getLoadingBitmap(this);
    if (loadingBitmap != null) {
        ImageView imageView = new ImageView(this);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setImageBitmap(loadingBitmap);
        rootLayout.addView(imageView);
    }else{
        addLoadingImage(rootLayout);
    }
    if (EBrowserActivity.develop) {
        TextView worn = new TextView(this);
        worn.setText(EUExUtil.getString("platform_only_test"));
        worn.setTextColor(0xffff0000);
        worn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        FrameLayout.LayoutParams wornPa = new FrameLayout.LayoutParams(
                Compat.FILL, Compat.WRAP);
        wornPa.gravity = Gravity.TOP;
        wornPa.leftMargin = 10;
        wornPa.topMargin = 60;
        worn.setLayoutParams(wornPa);
        rootLayout.addView(worn);
    }
    setContentView(rootLayout);
    showTime = System.currentTimeMillis();
    try {
        Intent intent = getIntent();
        if (intent != null) {
            isTemp = intent.getBooleanExtra("isTemp", false);
        }
    } catch (Exception exception) {
    }
    mBroadcastReceiver = new MyBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BROADCAST_ACTION);
    LocalBroadcastManager.getInstance(this).registerReceiver(
            mBroadcastReceiver, intentFilter);
    try {
        getWindow().clearFlags(
                WindowManager.LayoutParams.class.getField(
                        "FLAG_NEEDS_MENU_KEY").getInt(null));
    } catch (Exception e) {
    }
}