// Path: app/src/main/java/com/ccjeng/news/controler/HttpClient.java
// public class HttpClient {
// 
//     private static OkHttpClient client;
// 
//     private HttpClient(){
//     }
// 
//     /* OkHttpClient Singleton
//     * */
//     public static OkHttpClient getHttpClient() {
//         if (client == null) {
//             synchronized (HttpClient.class) {
//                 if (client == null) {
//                     client = new OkHttpClient();
//                 }
//             }
//         }
//         return client;
//     }
// 
// }


import android.util.Log;
import com.ccjeng.news.controler.HttpClient;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import rx.Observable;
import rx.Subscriber;
package com.ccjeng.news.controler.web;





/**
 * Created by andycheng on 2015/11/15.
 */
public class NewsHandler {

    private static final String TAG = "NewsHandler";
    private String url;

    public NewsHandler( String url) {
        this.url = url;
    }

    public Observable<String> getNewsContent(final String charset) {

        return Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(final Subscriber<? super String> subscriber) {
                final Request request = new Request.Builder()
                        .url(url)
                        .build();

// Path: app/src/main/java/com/ccjeng/news/controler/HttpClient.java
// public class HttpClient {
// 
//     private static OkHttpClient client;
// 
//     private HttpClient(){
//     }
// 
//     /* OkHttpClient Singleton
//     * */
//     public static OkHttpClient getHttpClient() {
//         if (client == null) {
//             synchronized (HttpClient.class) {
//                 if (client == null) {
//                     client = new OkHttpClient();
//                 }
//             }
//         }
//         return client;
//     }
// 
// }


// Path: app/src/main/java/com/ccjeng/news/controler/web/NewsHandler.java
import android.util.Log;
import com.ccjeng.news.controler.HttpClient;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import rx.Observable;
import rx.Subscriber;

package com.ccjeng.news.controler.web;





/**
 * Created by andycheng on 2015/11/15.
 */
public class NewsHandler {

    private static final String TAG = "NewsHandler";
    private String url;

    public NewsHandler( String url) {
        this.url = url;
    }

    public Observable<String> getNewsContent(final String charset) {

        return Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(final Subscriber<? super String> subscriber) {
                final Request request = new Request.Builder()
                        .url(url)
                        .build();

                HttpClient.getHttpClient().newCall(request).enqueue(new Callback() {