// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/apps/AppInfo.java
// @Data @Accessors(prefix = "m") public class AppInfo implements Comparable<Object> {
// 
//   long mLastUpdateTime;
// 
//   String mName;
// 
//   String mIcon;
// 
//   public AppInfo(String name, String icon, long lastUpdateTime) {
//     mName = name;
//     mIcon = icon;
//     mLastUpdateTime = lastUpdateTime;
//   }
// 
//   @Override public int compareTo(Object another) {
//     AppInfo f = (AppInfo) another;
//     return getName().compareTo(f.getName());
//   }
// }
// 
// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/apps/ApplicationAdapter.java
// public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.ViewHolder> {
// 
//   private List<AppInfo> mApplications;
// 
//   private int mRowLayout;
// 
//   public ApplicationAdapter(List<AppInfo> applications, int rowLayout) {
//     mApplications = applications;
//     mRowLayout = rowLayout;
//   }
// 
//   public void addApplications(List<AppInfo> applications) {
//     mApplications.clear();
//     mApplications.addAll(applications);
//     notifyDataSetChanged();
//   }
// 
//   public void addApplication(int position, AppInfo appInfo) {
//     if (position < 0) {
//       position = 0;
//     }
//     mApplications.add(position, appInfo);
//     notifyItemInserted(position);
//   }
// 
//   @Override public ViewHolder onCreateViewHolder(final ViewGroup viewGroup, int i) {
//     View v = LayoutInflater.from(viewGroup.getContext()).inflate(mRowLayout, viewGroup, false);
//     return new ViewHolder(v);
//   }
// 
//   @Override public void onBindViewHolder(final ViewHolder viewHolder, int i) {
//     final AppInfo appInfo = mApplications.get(i);
//     viewHolder.name.setText(appInfo.getName());
//     getBitmap(appInfo.getIcon()).subscribeOn(Schedulers.io())
//         .observeOn(AndroidSchedulers.mainThread())
//         .subscribe(viewHolder.image::setImageBitmap);
//   }
// 
//   @Override public int getItemCount() {
//     return mApplications == null ? 0 : mApplications.size();
//   }
// 
//   private Observable<Bitmap> getBitmap(String icon) {
//     return Observable.create(subscriber -> {
//       subscriber.onNext(BitmapFactory.decodeFile(icon));
//       subscriber.onCompleted();
//     });
//   }
// 
//   public static class ViewHolder extends RecyclerView.ViewHolder {
// 
//     public TextView name;
// 
//     public ImageView image;
// 
//     public ViewHolder(View itemView) {
//       super(itemView);
//       name = (TextView) itemView.findViewById(R.id.name);
//       image = (ImageView) itemView.findViewById(R.id.image);
//     }
//   }
// }
// 
// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/apps/ApplicationsList.java
// @Accessors(prefix = "m") public class ApplicationsList {
// 
//   private static ApplicationsList ourInstance = new ApplicationsList();
// 
//   @Getter @Setter private List<AppInfo> mList;
// 
//   private ApplicationsList() {
//   }
// 
//   public static ApplicationsList getInstance() {
//     return ourInstance;
//   }
// }


import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import butterknife.ButterKnife;
import butterknife.InjectView;
import com.packtpub.apps.rxjava_essentials.App;
import com.packtpub.apps.rxjava_essentials.R;
import com.packtpub.apps.rxjava_essentials.apps.AppInfo;
import com.packtpub.apps.rxjava_essentials.apps.ApplicationAdapter;
import com.packtpub.apps.rxjava_essentials.apps.ApplicationsList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
package com.packtpub.apps.rxjava_essentials.chapter6;


public class JoinExampleFragment extends Fragment {

  @InjectView(R.id.fragment_first_example_list) RecyclerView mRecyclerView;

  @InjectView(R.id.fragment_first_example_swipe_container) SwipeRefreshLayout mSwipeRefreshLayout;

  private ApplicationAdapter mAdapter;

  private ArrayList<AppInfo> mAddedApps = new ArrayList<>();

  public JoinExampleFragment() {
  }

  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/apps/AppInfo.java
// @Data @Accessors(prefix = "m") public class AppInfo implements Comparable<Object> {
// 
//   long mLastUpdateTime;
// 
//   String mName;
// 
//   String mIcon;
// 
//   public AppInfo(String name, String icon, long lastUpdateTime) {
//     mName = name;
//     mIcon = icon;
//     mLastUpdateTime = lastUpdateTime;
//   }
// 
//   @Override public int compareTo(Object another) {
//     AppInfo f = (AppInfo) another;
//     return getName().compareTo(f.getName());
//   }
// }
// 
// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/apps/ApplicationAdapter.java
// public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.ViewHolder> {
// 
//   private List<AppInfo> mApplications;
// 
//   private int mRowLayout;
// 
//   public ApplicationAdapter(List<AppInfo> applications, int rowLayout) {
//     mApplications = applications;
//     mRowLayout = rowLayout;
//   }
// 
//   public void addApplications(List<AppInfo> applications) {
//     mApplications.clear();
//     mApplications.addAll(applications);
//     notifyDataSetChanged();
//   }
// 
//   public void addApplication(int position, AppInfo appInfo) {
//     if (position < 0) {
//       position = 0;
//     }
//     mApplications.add(position, appInfo);
//     notifyItemInserted(position);
//   }
// 
//   @Override public ViewHolder onCreateViewHolder(final ViewGroup viewGroup, int i) {
//     View v = LayoutInflater.from(viewGroup.getContext()).inflate(mRowLayout, viewGroup, false);
//     return new ViewHolder(v);
//   }
// 
//   @Override public void onBindViewHolder(final ViewHolder viewHolder, int i) {
//     final AppInfo appInfo = mApplications.get(i);
//     viewHolder.name.setText(appInfo.getName());
//     getBitmap(appInfo.getIcon()).subscribeOn(Schedulers.io())
//         .observeOn(AndroidSchedulers.mainThread())
//         .subscribe(viewHolder.image::setImageBitmap);
//   }
// 
//   @Override public int getItemCount() {
//     return mApplications == null ? 0 : mApplications.size();
//   }
// 
//   private Observable<Bitmap> getBitmap(String icon) {
//     return Observable.create(subscriber -> {
//       subscriber.onNext(BitmapFactory.decodeFile(icon));
//       subscriber.onCompleted();
//     });
//   }
// 
//   public static class ViewHolder extends RecyclerView.ViewHolder {
// 
//     public TextView name;
// 
//     public ImageView image;
// 
//     public ViewHolder(View itemView) {
//       super(itemView);
//       name = (TextView) itemView.findViewById(R.id.name);
//       image = (ImageView) itemView.findViewById(R.id.image);
//     }
//   }
// }
// 
// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/apps/ApplicationsList.java
// @Accessors(prefix = "m") public class ApplicationsList {
// 
//   private static ApplicationsList ourInstance = new ApplicationsList();
// 
//   @Getter @Setter private List<AppInfo> mList;
// 
//   private ApplicationsList() {
//   }
// 
//   public static ApplicationsList getInstance() {
//     return ourInstance;
//   }
// }


// Path: app/src/main/java/com/packtpub/apps/rxjava_essentials/chapter6/JoinExampleFragment.java
import android.app.Fragment;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import butterknife.ButterKnife;
import butterknife.InjectView;
import com.packtpub.apps.rxjava_essentials.App;
import com.packtpub.apps.rxjava_essentials.R;
import com.packtpub.apps.rxjava_essentials.apps.AppInfo;
import com.packtpub.apps.rxjava_essentials.apps.ApplicationAdapter;
import com.packtpub.apps.rxjava_essentials.apps.ApplicationsList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;

package com.packtpub.apps.rxjava_essentials.chapter6;


public class JoinExampleFragment extends Fragment {

  @InjectView(R.id.fragment_first_example_list) RecyclerView mRecyclerView;

  @InjectView(R.id.fragment_first_example_swipe_container) SwipeRefreshLayout mSwipeRefreshLayout;

  private ApplicationAdapter mAdapter;

  private ArrayList<AppInfo> mAddedApps = new ArrayList<>();

  public JoinExampleFragment() {
  }

  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {