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 PROGRESS = 2;
|
||||
|
||||
private Context mContext;
|
||||
private Drawable mDrawable;
|
||||
private ProgressWheel mProgressBar;
|
||||
private ImageView mImage;
|
||||
@ -49,7 +48,7 @@ public final class LoaderImageView extends FrameLayout {
|
||||
public LoaderImageView(final Context context, final AttributeSet attrSet) {
|
||||
super(context, attrSet);
|
||||
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) {
|
||||
super(context);
|
||||
instantiate(context, imageUrl);
|
||||
instantiate(imageUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used when creating the view programmatically
|
||||
* Once you have instantiated the view you can call
|
||||
* setImageDrawable(url) to change the image
|
||||
* @param context the Activity context
|
||||
* @param imageUrl the Image URL you wish to load
|
||||
*/
|
||||
public LoaderImageView(final Context 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
|
||||
* get the required effects you want
|
||||
*/
|
||||
private void instantiate(final Context context, final String imageUrl) {
|
||||
mContext = context;
|
||||
|
||||
mImage = new ImageView(mContext);
|
||||
private void instantiate(final String imageUrl) {
|
||||
mImage = new ImageView(getContext());
|
||||
mImage.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
|
||||
mProgressBar = new ProgressWheel(mContext);
|
||||
mProgressBar = new ProgressWheel(getContext());
|
||||
mProgressBar.setLayoutParams(new LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER));
|
||||
@ -197,7 +193,7 @@ public final class LoaderImageView extends FrameLayout {
|
||||
output = null;
|
||||
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
data = null;
|
||||
return new BitmapDrawable(mContext.getResources(), bitmap);
|
||||
return new BitmapDrawable(getContext().getResources(), bitmap);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user