// Path: app/src/main/java/com/example/app/rxjava/AppApplication.java
// public class AppApplication extends Application {
// 
//     /*网络是否连接*/
//     public static boolean isNetConnect;/*网络连接状态监听*/
//     private ConnectionReceiver connectionReceiver = new ConnectionReceiver();
//     public static AppApplication APP_APPLICATION;
// 
//     //刷新广播监听
//     public static final String REFRESH_ACTION = "REFRESH_ACTION";
// 
//     public static AppApplication getInstance() {
//         return APP_APPLICATION;
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         // Create global configuration and initialize ImageLoader with this config
//         APP_APPLICATION = this;
//         initImageLoader(getApplicationContext());
//         registerNetReceiver();
// 
//         FlowManager.init(this);
//     }
// 
//     public static void initImageLoader(Context context) {
//         // This configuration tuning is custom. You can tune every option, you may tune some of them,
//         // or you can create default configuration by
//         //  ImageLoaderConfiguration.createDefault(this);
//         // method.
//         ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
//         config.threadPriority(Thread.NORM_PRIORITY - 2);
//         config.denyCacheImageMultipleSizesInMemory();
//         config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
//         config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
//         config.tasksProcessingOrder(QueueProcessingType.LIFO);
//         config.writeDebugLogs(); // Remove for release app
// 
//         // Initialize ImageLoader with configuration.
//         ImageLoader.getInstance().init(config.build());
//     }
// 
//     /**
//      * 注册网络连接状态监听
//      */
//     public void registerNetReceiver() {
//         IntentFilter connectionIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
//         registerReceiver(connectionReceiver, connectionIntentFilter);
//     }
// 
//     /**
//      * 注销网络连接状态监听
//      */
//     public void unregisterNetReceiver() {
//         if (connectionReceiver != null) {
//             unregisterReceiver(connectionReceiver);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/example/app/rxjava/widget/presenter/WidgetPresenter.java
// public class WidgetPresenter {
//     private UILWidgetProvider widgetProvider;
//     private WidgetIA mWidgetIA;
//     private int totalNum;
// 
//     public WidgetPresenter(UILWidgetProvider widgetProvider) {
//         this.widgetProvider = widgetProvider;
//         this.mWidgetIA = new WidgetModel();
//     }
// 
//     public void loadData() {
//         if (!AppApplication.isNetConnect) {
//             return;
//         }
//         mWidgetIA.getData()
//             .flatMap(new Func1<Picture, Observable<List<String>>>() {
//                 @Override
//                 public Observable<List<String>> call(Picture picture) {
//                     totalNum = picture.getTotalNum();
//                     List<String> imgList = getImageList(picture);
//                     return Observable.just(imgList);
//                 }
//             })
//             .subscribeOn(Schedulers.io())// 在非UI线程中执行getUser
//             .doOnSubscribe(new Action0() {
//                 @Override
//                 public void call() {
//                     // 需要在主线程执行
//                 }
//             })
//             .subscribeOn(AndroidSchedulers.mainThread()) // 指定主线程
//             .observeOn(AndroidSchedulers.mainThread())// 在UI线程中执行结果
//             .subscribe(new Subscriber<List<String>>() {
//                 @Override
//                 public void onNext(List<String> data) {
//                     widgetProvider.getData(data);
//                 }
// 
//                 @Override
//                 public void onError(Throwable e) {
// 
//                 }
// 
//                 @Override
//                 public void onCompleted() {
// 
//                 }
//             });
//     }
// 
//     /**
//      * 得到网页中图片的地址
//      */
//     private List<String> getImageList(Picture picture) {
//         List<String> imgList = new ArrayList<String>();
//         List<Data> list = picture.getData();
//         for(int i = 0, len = list.size(); i < len; i++) {
//             imgList.add(list.get(i).getThumbnail_url());
//         }
//         return imgList;
//     }
// }


import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.RemoteViews;
import com.example.app.rxjava.AppApplication;
import com.example.app.rxjava.R;
import com.example.app.rxjava.widget.presenter.WidgetPresenter;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import java.util.ArrayList;
import java.util.List;
package com.example.app.rxjava.widget;




/**
 * Example widget provider
 *
 * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
 */
public class UILWidgetProvider extends AppWidgetProvider {

    private static DisplayImageOptions displayOptions;
    private WidgetPresenter presenter;
    private UpdateWidgetListener listener;

    static {
        displayOptions = DisplayImageOptions.createSimple();
    }

    @Override
    public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
// Path: app/src/main/java/com/example/app/rxjava/AppApplication.java
// public class AppApplication extends Application {
// 
//     /*网络是否连接*/
//     public static boolean isNetConnect;/*网络连接状态监听*/
//     private ConnectionReceiver connectionReceiver = new ConnectionReceiver();
//     public static AppApplication APP_APPLICATION;
// 
//     //刷新广播监听
//     public static final String REFRESH_ACTION = "REFRESH_ACTION";
// 
//     public static AppApplication getInstance() {
//         return APP_APPLICATION;
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         // Create global configuration and initialize ImageLoader with this config
//         APP_APPLICATION = this;
//         initImageLoader(getApplicationContext());
//         registerNetReceiver();
// 
//         FlowManager.init(this);
//     }
// 
//     public static void initImageLoader(Context context) {
//         // This configuration tuning is custom. You can tune every option, you may tune some of them,
//         // or you can create default configuration by
//         //  ImageLoaderConfiguration.createDefault(this);
//         // method.
//         ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
//         config.threadPriority(Thread.NORM_PRIORITY - 2);
//         config.denyCacheImageMultipleSizesInMemory();
//         config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
//         config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
//         config.tasksProcessingOrder(QueueProcessingType.LIFO);
//         config.writeDebugLogs(); // Remove for release app
// 
//         // Initialize ImageLoader with configuration.
//         ImageLoader.getInstance().init(config.build());
//     }
// 
//     /**
//      * 注册网络连接状态监听
//      */
//     public void registerNetReceiver() {
//         IntentFilter connectionIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
//         registerReceiver(connectionReceiver, connectionIntentFilter);
//     }
// 
//     /**
//      * 注销网络连接状态监听
//      */
//     public void unregisterNetReceiver() {
//         if (connectionReceiver != null) {
//             unregisterReceiver(connectionReceiver);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/example/app/rxjava/widget/presenter/WidgetPresenter.java
// public class WidgetPresenter {
//     private UILWidgetProvider widgetProvider;
//     private WidgetIA mWidgetIA;
//     private int totalNum;
// 
//     public WidgetPresenter(UILWidgetProvider widgetProvider) {
//         this.widgetProvider = widgetProvider;
//         this.mWidgetIA = new WidgetModel();
//     }
// 
//     public void loadData() {
//         if (!AppApplication.isNetConnect) {
//             return;
//         }
//         mWidgetIA.getData()
//             .flatMap(new Func1<Picture, Observable<List<String>>>() {
//                 @Override
//                 public Observable<List<String>> call(Picture picture) {
//                     totalNum = picture.getTotalNum();
//                     List<String> imgList = getImageList(picture);
//                     return Observable.just(imgList);
//                 }
//             })
//             .subscribeOn(Schedulers.io())// 在非UI线程中执行getUser
//             .doOnSubscribe(new Action0() {
//                 @Override
//                 public void call() {
//                     // 需要在主线程执行
//                 }
//             })
//             .subscribeOn(AndroidSchedulers.mainThread()) // 指定主线程
//             .observeOn(AndroidSchedulers.mainThread())// 在UI线程中执行结果
//             .subscribe(new Subscriber<List<String>>() {
//                 @Override
//                 public void onNext(List<String> data) {
//                     widgetProvider.getData(data);
//                 }
// 
//                 @Override
//                 public void onError(Throwable e) {
// 
//                 }
// 
//                 @Override
//                 public void onCompleted() {
// 
//                 }
//             });
//     }
// 
//     /**
//      * 得到网页中图片的地址
//      */
//     private List<String> getImageList(Picture picture) {
//         List<String> imgList = new ArrayList<String>();
//         List<Data> list = picture.getData();
//         for(int i = 0, len = list.size(); i < len; i++) {
//             imgList.add(list.get(i).getThumbnail_url());
//         }
//         return imgList;
//     }
// }


// Path: app/src/main/java/com/example/app/rxjava/widget/UILWidgetProvider.java
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.RemoteViews;
import com.example.app.rxjava.AppApplication;
import com.example.app.rxjava.R;
import com.example.app.rxjava.widget.presenter.WidgetPresenter;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import java.util.ArrayList;
import java.util.List;

package com.example.app.rxjava.widget;




/**
 * Example widget provider
 *
 * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
 */
public class UILWidgetProvider extends AppWidgetProvider {

    private static DisplayImageOptions displayOptions;
    private WidgetPresenter presenter;
    private UpdateWidgetListener listener;

    static {
        displayOptions = DisplayImageOptions.createSimple();
    }

    @Override
    public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
        presenter = new WidgetPresenter(this);