MainActivity.java 2.1 KB
Newer Older
J
jessyan 已提交
1 2
package me.jessyan.mvparms.demo.mvp.ui.activity;

J
jessyan 已提交
3
import android.view.LayoutInflater;
J
jessyan 已提交
4 5
import android.view.View;

J
jessyan 已提交
6 7 8 9 10 11
import com.jess.arms.utils.UiUtils;

import io.rx_cache.DynamicKey;
import io.rx_cache.EvictDynamicKey;
import io.rx_cache.Reply;
import me.jessyan.mvparms.demo.R;
J
jessyan 已提交
12
import me.jessyan.mvparms.demo.di.component.AppComponent;
J
jessyan 已提交
13
import me.jessyan.mvparms.demo.mvp.model.entity.HomePicEntity;
J
jessyan 已提交
14
import me.jessyan.mvparms.demo.mvp.ui.common.WEActivity;
J
jessyan 已提交
15 16 17 18
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import timber.log.Timber;
J
jessyan 已提交
19 20 21 22 23 24


public class MainActivity extends WEActivity {

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
J
jessyan 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
        appComponent
                .cacheManager()
                .getCommonCache()
                .getDailyList(appComponent
                        .serviceManager()
                        .getCommonService()
                        .getDailyList(),new DynamicKey("15"),new EvictDynamicKey(true))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(this.<Reply<HomePicEntity>>bindToLifecycle())
                .subscribe(new Action1<Reply<HomePicEntity>>() {
                    @Override
                    public void call(Reply<HomePicEntity> homePicEntityReply) {
                        UiUtils.makeText(homePicEntityReply.getData().getIssueList().get(0).getPublishTime()+"/"+homePicEntityReply.getSource().name());
                        Timber.tag(TAG).w(homePicEntityReply.getData().getIssueList().get(0).getPublishTime()+"");
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                    }
                });
J
jessyan 已提交
47 48 49 50 51

    }

    @Override
    protected View initView() {
J
jessyan 已提交
52
        return LayoutInflater.from(this).inflate(R.layout.activity_main,null,false);
J
jessyan 已提交
53 54 55 56 57 58 59
    }

    @Override
    protected void initData() {

    }
}