13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846

以下内容为反编译后的 WebUtils.java 源代码,内容仅作参考


package com.sd.ads;

import android.os.AsyncTask;
import android.os.Build;
import com.adsdk.sdk.Const;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class WebUtils {

    public interface AsyncHttpResponseListener {
        void asyncError(Throwable th);

        void asyncResponse(String str);
    }

    private WebUtils() {
    }

    public static String wrapHtml(String html) {
        return wrapHtml(html, -1, -1);
    }

    public static String wrapHtml(String html, int width, int height) {
        String header;
        if (!html.toLowerCase().contains("<html")) {
            if (width > 0 && height > 0) {
                header = String.format("<html><body style=\"margin:0;padding:0;width:%d;height:%d;\">", Integer.valueOf(width), Integer.valueOf(height));
            } else {
                header = "<html><body style=\"margin:0;padding:0;\">";
            }
            StringBuilder sb = new StringBuilder(html.length() + header.length() + "</body></html>".length());
            sb.append(header);
            sb.append(html);
            sb.append("</body></html>");
            return sb.toString();
        }
        return html;
    }

    public static boolean isGooglePlayUrl(String url) {
        return url.startsWith("market://details?") || url.startsWith("http://market.android.com/details?") || url.startsWith("https://market.android.com/details?") || url.startsWith("http://play.google.com/store/apps/details?") || url.startsWith("https://play.google.com/store/apps/details?");
    }

    public static void asyncHttpRequest(String url, final AsyncHttpResponseListener callback) {
        AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() {
            @Override
            public String doInBackground(String... urls) {
                String url2 = urls[0];
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url2);
                try {
                    HttpResponse execute = client.execute(httpGet);
                    InputStream is = execute.getEntity().getContent();
                    BufferedInputStream bIs = new BufferedInputStream(is, 8192);
                    StringBuilder sb = new StringBuilder(8192);
                    byte[] buffer = new byte[8192];
                    while (true) {
                        int i = bIs.read(buffer);
                        if (i != -1) {
                            sb.append(new String(buffer, 0, i, Const.ENCODING));
                        } else {
                            return sb.toString();
                        }
                    }
                } catch (IOException e) {
                    AsyncHttpResponseListener.this.asyncError(e);
                    return null;
                } catch (ClientProtocolException e2) {
                    AsyncHttpResponseListener.this.asyncError(e2);
                    return null;
                }
            }

            @Override
            public void onPostExecute(String result) {
                if (result != null) {
                    AsyncHttpResponseListener.this.asyncResponse(result);
                }
            }
        };
        if (Build.VERSION.SDK_INT >= 11) {
            asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url);
        } else {
            asyncTask.execute(url);
        }
    }
}