Remove Context field
This commit is contained in:
parent
104bbb68fe
commit
e350a6ef58
@ -32,7 +32,6 @@ public final class LoaderImageView extends FrameLayout {
|
|||||||
private static final int FAILED = 1;
|
private static final int FAILED = 1;
|
||||||
private static final int PROGRESS = 2;
|
private static final int PROGRESS = 2;
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private Drawable mDrawable;
|
private Drawable mDrawable;
|
||||||
private ProgressWheel mProgressBar;
|
private ProgressWheel mProgressBar;
|
||||||
private ImageView mImage;
|
private ImageView mImage;
|
||||||
@ -49,7 +48,7 @@ public final class LoaderImageView extends FrameLayout {
|
|||||||
public LoaderImageView(final Context context, final AttributeSet attrSet) {
|
public LoaderImageView(final Context context, final AttributeSet attrSet) {
|
||||||
super(context, attrSet);
|
super(context, attrSet);
|
||||||
final String url = attrSet.getAttributeValue(null, "image");
|
final String url = attrSet.getAttributeValue(null, "image");
|
||||||
instantiate(context, url);
|
instantiate(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,19 +60,18 @@ public final class LoaderImageView extends FrameLayout {
|
|||||||
*/
|
*/
|
||||||
public LoaderImageView(final Context context, final String imageUrl) {
|
public LoaderImageView(final Context context, final String imageUrl) {
|
||||||
super(context);
|
super(context);
|
||||||
instantiate(context, imageUrl);
|
instantiate(imageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used when creating the view programmatically
|
* This is used when creating the view programmatically
|
||||||
* Once you have instantiated the view you can call
|
* Once you have instantiated the view you can call
|
||||||
* setImageDrawable(url) to change the image
|
* setImageDrawable(url) to change the image
|
||||||
* @param context the Activity context
|
|
||||||
* @param imageUrl the Image URL you wish to load
|
* @param imageUrl the Image URL you wish to load
|
||||||
*/
|
*/
|
||||||
public LoaderImageView(final Context context) {
|
public LoaderImageView(final Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
instantiate(context, null);
|
instantiate(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,13 +79,11 @@ public final class LoaderImageView extends FrameLayout {
|
|||||||
* Sets up the LayoutParams of the view, you can change these to
|
* Sets up the LayoutParams of the view, you can change these to
|
||||||
* get the required effects you want
|
* get the required effects you want
|
||||||
*/
|
*/
|
||||||
private void instantiate(final Context context, final String imageUrl) {
|
private void instantiate(final String imageUrl) {
|
||||||
mContext = context;
|
mImage = new ImageView(getContext());
|
||||||
|
|
||||||
mImage = new ImageView(mContext);
|
|
||||||
mImage.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
mImage.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
mProgressBar = new ProgressWheel(mContext);
|
mProgressBar = new ProgressWheel(getContext());
|
||||||
mProgressBar.setLayoutParams(new LayoutParams(
|
mProgressBar.setLayoutParams(new LayoutParams(
|
||||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||||
Gravity.CENTER));
|
Gravity.CENTER));
|
||||||
@ -197,7 +193,7 @@ public final class LoaderImageView extends FrameLayout {
|
|||||||
output = null;
|
output = null;
|
||||||
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||||
data = null;
|
data = null;
|
||||||
return new BitmapDrawable(mContext.getResources(), bitmap);
|
return new BitmapDrawable(getContext().getResources(), bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user