Code example for ProgressBar

Methods: setIndeterminatesetIndeterminateDrawablesetVisibility, setLayoutParams

0
		mContext = context;
		 
		mImage = new ImageView(mContext);
		mImage.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		 
		mSpinner = new ProgressBar(mContext);
		mSpinner.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		 
		if(width != 0 && height != 0){
			mImage.setAdjustViewBounds(true);
			mImage.setMaxHeight(height);
			mImage.setMaxWidth(width);
			mImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);			
		} 
			 
		mSpinner.setIndeterminate(true);
		mSpinner.setIndeterminateDrawable(getContext().getResources().getDrawable(context.getResources().getIdentifier("progress", "drawable", context.getPackageName())));
		 
		 
		addView(mSpinner);
		addView(mImage);
		 
		if(imageUrl != null){
			setImageDrawable(imageUrl);
		} 
	} 
 
	public void setImageDrawable(final String imageUrl) {
		setImageDrawable(imageUrl,0,0,false);
	} 
	 
	public void setImageDrawable(final String imageUrl, final int width, final int height, final boolean scale) {
		mDrawable = null;		
		mSpinner.setVisibility(View.VISIBLE);
		mImage.setVisibility(View.GONE);
		 
		if(scale){
			mImage.setAdjustViewBounds(true);
			mImage.setMaxHeight(height);
			mImage.setMaxWidth(width);
			mImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);	
			mSpinner.setLayoutParams(new LayoutParams(width/2, height/2));
		} 
		 
		new Thread(){
			public void run() { 
				try {