// Path: app/src/main/java/com/hhxplaying/neteasedemo/netease/MyApplication.java
// public class MyApplication extends Application {
//     public static int width = 0;
//     public static int height = 0;
//     public static float density = 0;
//     public void onCreate() {
//         super.onCreate();
//         width = ScreenUtil.getWidth(this);
//         height = ScreenUtil.getHeight(this);
//         density = ScreenUtil.getDensity(this);
//         System.out.println(width);
//         System.out.println(height);
//         System.out.println(density);
// 
//         VolleyLog.DEBUG = true;
//     }
// 
// }


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.text.Html;
import android.util.Log;
import android.widget.TextView;
import com.hhxplaying.neteasedemo.netease.MyApplication;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
package com.hhxplaying.neteasedemo.netease.util;




/**
 * Created by netease on 16/2/18.
 */
public class URLImageParser implements Html.ImageGetter {
    Context c;
    TextView container;

    /***
     * Construct the URLImageParser which will execute AsyncTask and refresh the container
     * @param t
     * @param c
     */
    public URLImageParser(TextView t, Context c) {
        this.c = c;
        this.container = t;
    }

    @Override
    public Drawable getDrawable(String source) {
        URLDrawable urlDrawable = new URLDrawable();

        // get the actual source
        ImageGetterAsyncTask asyncTask =
                new ImageGetterAsyncTask( urlDrawable);

        asyncTask.execute(source);

        // return reference to URLDrawable where I will change with actual image from
        // the src tag
        return urlDrawable;
    }

    public class ImageGetterAsyncTask extends AsyncTask<String, Void, Drawable> {
        URLDrawable urlDrawable;

        public ImageGetterAsyncTask(URLDrawable d) {
            this.urlDrawable = d;
        }

        @Override
        protected Drawable doInBackground(String... params) {
            String source = params[0];
            return fetchDrawable(source);
        }

        @Override

        protected void onPostExecute(Drawable result) {
            // set the correct bound according to the result from HTTP call
            Log.i("RVA","height"+result.getIntrinsicHeight());
            Log.i("RVA", "wight" + result.getIntrinsicWidth());
            //设置图片显示占据的高度
// Path: app/src/main/java/com/hhxplaying/neteasedemo/netease/MyApplication.java
// public class MyApplication extends Application {
//     public static int width = 0;
//     public static int height = 0;
//     public static float density = 0;
//     public void onCreate() {
//         super.onCreate();
//         width = ScreenUtil.getWidth(this);
//         height = ScreenUtil.getHeight(this);
//         density = ScreenUtil.getDensity(this);
//         System.out.println(width);
//         System.out.println(height);
//         System.out.println(density);
// 
//         VolleyLog.DEBUG = true;
//     }
// 
// }


// Path: app/src/main/java/com/hhxplaying/neteasedemo/netease/util/URLImageParser.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.text.Html;
import android.util.Log;
import android.widget.TextView;
import com.hhxplaying.neteasedemo.netease.MyApplication;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

package com.hhxplaying.neteasedemo.netease.util;




/**
 * Created by netease on 16/2/18.
 */
public class URLImageParser implements Html.ImageGetter {
    Context c;
    TextView container;

    /***
     * Construct the URLImageParser which will execute AsyncTask and refresh the container
     * @param t
     * @param c
     */
    public URLImageParser(TextView t, Context c) {
        this.c = c;
        this.container = t;
    }

    @Override
    public Drawable getDrawable(String source) {
        URLDrawable urlDrawable = new URLDrawable();

        // get the actual source
        ImageGetterAsyncTask asyncTask =
                new ImageGetterAsyncTask( urlDrawable);

        asyncTask.execute(source);

        // return reference to URLDrawable where I will change with actual image from
        // the src tag
        return urlDrawable;
    }

    public class ImageGetterAsyncTask extends AsyncTask<String, Void, Drawable> {
        URLDrawable urlDrawable;

        public ImageGetterAsyncTask(URLDrawable d) {
            this.urlDrawable = d;
        }

        @Override
        protected Drawable doInBackground(String... params) {
            String source = params[0];
            return fetchDrawable(source);
        }

        @Override

        protected void onPostExecute(Drawable result) {
            // set the correct bound according to the result from HTTP call
            Log.i("RVA","height"+result.getIntrinsicHeight());
            Log.i("RVA", "wight" + result.getIntrinsicWidth());
            //设置图片显示占据的高度
            int imageWight = MyApplication.width;