// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/adapter/FasterAdapter.java
// public class FasterAdapter extends RecyclerView.Adapter<FasterListViewHolder> {
// 
//     private Context context;
// 
//     private List<String> list;
// 
//     public FasterAdapter(Context context) {
//         this.context = context;
//         list = new ArrayList<>();
//     }
// 
//     @Override
//     public FasterListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View view = LayoutInflater.from(context).inflate(R.layout.item_fasterlist, parent, false);
//         return new FasterListViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(FasterListViewHolder holder, int position) {
//         Observable.just(position)
//                 .subscribeOn(Schedulers.io())
//                 .map(index -> {
// 
//                     try {
//                         Realm realm = Realm.getDefaultInstance();
//                         long count = realm.where(FasterListData.class).greaterThanOrEqualTo("position", position)
//                                 .count();
//                         Thread.sleep(10);
//                         return getItem(position) + ", count : " + count;
//                     } catch (InterruptedException e) {
//                         e.printStackTrace();
//                     }
//                     return "";
// 
//                 }).observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(s -> {
//                     holder.tvTitle.setText(s);
//                 });
//     }
// 
//     private String getItem(int position) {
//         return list.get(position);
//     }
// 
//     public void addAll(List<String> list) {
//         this.list.addAll(list);
//     }
// 
//     public void add(String value) {
//         this.list.add(value);
//     }
// 
//     @Override
//     public int getItemCount() {
//         return list.size();
//     }
// }
// 
// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/adapter/NormalAdapter.java
// public class NormalAdapter extends RecyclerView.Adapter<FasterListViewHolder> {
// 
//     private Context context;
//     private List<String> list;
// 
//     public NormalAdapter(Context context) {
//         this.context = context;
//         this.list = new ArrayList<>();
//     }
// 
//     @Override
//     public FasterListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// 
//         View view = LayoutInflater.from(context).inflate(R.layout.item_fasterlist, parent, false);
//         return new FasterListViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(FasterListViewHolder holder, int position) {
// 
// 
//         try {
//             Realm realm = Realm.getDefaultInstance();
//             long count = realm.where(FasterListData.class).greaterThanOrEqualTo("position", position)
//                     .count();
//             Thread.sleep(10);
//             holder.tvTitle.setText(getItem(position) + ", count : " + count);
//         } catch (InterruptedException e) {
//             e.printStackTrace();
//         }
// 
// 
//     }
// 
//     private String getItem(int position) {
//         return list.get(position);
//     }
// 
//     public void addAll(List<String> list) {
//         this.list.addAll(list);
//     }
// 
//     public void add(String value) {
//         this.list.add(value);
//     }
// 
// 
//     @Override
//     public int getItemCount() {
//         return list.size();
//     }
// }
// 
// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/realm/FasterListData.java
// public class FasterListData extends RealmObject {
//     @PrimaryKey
//     private long position;
// 
//     public long getPosition() {
//         return position;
//     }
// 
//     public void setPosition(long position) {
//         this.position = position;
//     }
// }


import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.gdgand.rxjava.rxjavasample.R;
import com.gdgand.rxjava.rxjavasample.scroll.adapter.FasterAdapter;
import com.gdgand.rxjava.rxjavasample.scroll.adapter.NormalAdapter;
import com.gdgand.rxjava.rxjavasample.scroll.realm.FasterListData;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import rx.Observable;
package com.gdgand.rxjava.rxjavasample.scroll;




public class FasterListActivity extends AppCompatActivity {

    @BindView(R.id.list_fasterlist)
    RecyclerView lvFasterList;

    private FasterAdapter fasterAdapter;
    private NormalAdapter normalAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fasterlist);

        setUpActionbar();

        ButterKnife.bind(this);

        fasterAdapter = new FasterAdapter(FasterListActivity.this);
        normalAdapter = new NormalAdapter(FasterListActivity.this);

        ProgressDialog dialog = ProgressDialog.show(FasterListActivity.this, null, "로딩 중...", true);

        Realm.setDefaultConfiguration(new RealmConfiguration.Builder(FasterListActivity.this)
                .build());
        Realm realm = Realm.getDefaultInstance();
        realm.beginTransaction();
        realm.deleteAll();
        realm.commitTransaction();
        realm.executeTransactionAsync(realm1 -> {
            Observable.range(1, 13000)
                    .subscribe(index -> {
// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/adapter/FasterAdapter.java
// public class FasterAdapter extends RecyclerView.Adapter<FasterListViewHolder> {
// 
//     private Context context;
// 
//     private List<String> list;
// 
//     public FasterAdapter(Context context) {
//         this.context = context;
//         list = new ArrayList<>();
//     }
// 
//     @Override
//     public FasterListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View view = LayoutInflater.from(context).inflate(R.layout.item_fasterlist, parent, false);
//         return new FasterListViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(FasterListViewHolder holder, int position) {
//         Observable.just(position)
//                 .subscribeOn(Schedulers.io())
//                 .map(index -> {
// 
//                     try {
//                         Realm realm = Realm.getDefaultInstance();
//                         long count = realm.where(FasterListData.class).greaterThanOrEqualTo("position", position)
//                                 .count();
//                         Thread.sleep(10);
//                         return getItem(position) + ", count : " + count;
//                     } catch (InterruptedException e) {
//                         e.printStackTrace();
//                     }
//                     return "";
// 
//                 }).observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(s -> {
//                     holder.tvTitle.setText(s);
//                 });
//     }
// 
//     private String getItem(int position) {
//         return list.get(position);
//     }
// 
//     public void addAll(List<String> list) {
//         this.list.addAll(list);
//     }
// 
//     public void add(String value) {
//         this.list.add(value);
//     }
// 
//     @Override
//     public int getItemCount() {
//         return list.size();
//     }
// }
// 
// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/adapter/NormalAdapter.java
// public class NormalAdapter extends RecyclerView.Adapter<FasterListViewHolder> {
// 
//     private Context context;
//     private List<String> list;
// 
//     public NormalAdapter(Context context) {
//         this.context = context;
//         this.list = new ArrayList<>();
//     }
// 
//     @Override
//     public FasterListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// 
//         View view = LayoutInflater.from(context).inflate(R.layout.item_fasterlist, parent, false);
//         return new FasterListViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(FasterListViewHolder holder, int position) {
// 
// 
//         try {
//             Realm realm = Realm.getDefaultInstance();
//             long count = realm.where(FasterListData.class).greaterThanOrEqualTo("position", position)
//                     .count();
//             Thread.sleep(10);
//             holder.tvTitle.setText(getItem(position) + ", count : " + count);
//         } catch (InterruptedException e) {
//             e.printStackTrace();
//         }
// 
// 
//     }
// 
//     private String getItem(int position) {
//         return list.get(position);
//     }
// 
//     public void addAll(List<String> list) {
//         this.list.addAll(list);
//     }
// 
//     public void add(String value) {
//         this.list.add(value);
//     }
// 
// 
//     @Override
//     public int getItemCount() {
//         return list.size();
//     }
// }
// 
// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/realm/FasterListData.java
// public class FasterListData extends RealmObject {
//     @PrimaryKey
//     private long position;
// 
//     public long getPosition() {
//         return position;
//     }
// 
//     public void setPosition(long position) {
//         this.position = position;
//     }
// }


// Path: 2016-06-08_queue/app/src/main/java/com/gdgand/rxjava/rxjavasample/scroll/FasterListActivity.java
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.gdgand.rxjava.rxjavasample.R;
import com.gdgand.rxjava.rxjavasample.scroll.adapter.FasterAdapter;
import com.gdgand.rxjava.rxjavasample.scroll.adapter.NormalAdapter;
import com.gdgand.rxjava.rxjavasample.scroll.realm.FasterListData;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import rx.Observable;

package com.gdgand.rxjava.rxjavasample.scroll;




public class FasterListActivity extends AppCompatActivity {

    @BindView(R.id.list_fasterlist)
    RecyclerView lvFasterList;

    private FasterAdapter fasterAdapter;
    private NormalAdapter normalAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fasterlist);

        setUpActionbar();

        ButterKnife.bind(this);

        fasterAdapter = new FasterAdapter(FasterListActivity.this);
        normalAdapter = new NormalAdapter(FasterListActivity.this);

        ProgressDialog dialog = ProgressDialog.show(FasterListActivity.this, null, "로딩 중...", true);

        Realm.setDefaultConfiguration(new RealmConfiguration.Builder(FasterListActivity.this)
                .build());
        Realm realm = Realm.getDefaultInstance();
        realm.beginTransaction();
        realm.deleteAll();
        realm.commitTransaction();
        realm.executeTransactionAsync(realm1 -> {
            Observable.range(1, 13000)
                    .subscribe(index -> {
                        FasterListData object = realm1.createObject(FasterListData.class);