Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

android / dayu

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • dayu
  • ..
  • serverinstruction
  • ServerInstructionPresenter.java
Find file
BlameHistoryPermalink
  • 罗翻's avatar
    抽离出baselibrary,新建provider作为中间件 · 00356c56
    罗翻 committed 7 years ago
    00356c56
ServerInstructionPresenter.java 1.59 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
package com.dayu.bigfish.presenter.serverinstruction;

import android.databinding.ObservableField;
import android.os.Bundle;

import com.app.annotation.apt.InstanceFactory;
import com.dayu.common.Constants;
import com.dayu.bigfish.api.ApiFactory;
import com.dayu.base.api.protocol.BasePageBean;
import com.dayu.bigfish.bean.ServerInstruction;
import com.dayu.bigfish.ui.WebViewActivity;

/**
 * Created by luofan
 * on 2017/11/8.
 */
@InstanceFactory
public class ServerInstructionPresenter extends ServerInstructionContract.Presenter {
    public ObservableField<Object> mDatas = new ObservableField<>();
    private int mSpuId;
    private int mPage;

    @Override
    public ObservableField<Object> getSourceDatas() {
        return mDatas;
    }

    @Override
    public void onAttached() {
        Bundle bundle = mView.getBundle();
        mSpuId = bundle.getInt(Constants.ID);
        refresh();
    }

    @Override
    public void getInstructs() {
        ApiFactory.getInstruction(mSpuId, mPage, Constants.PAGESIZE).subscribe(baseObserver(
                (BasePageBean<ServerInstruction> datas) -> {
                    mPage++;
                    mDatas.set(datas);
                }));
    }

    @Override
    public void dumpDetail(int id) {
        Bundle bundle = new Bundle();
        bundle.putInt(Constants.ID, id);
        mView.startActivity(WebViewActivity.class, bundle);
    }

    @Override
    public void refresh() {
        super.refresh();
        mPage = 1;
        getInstructs();
    }

    @Override
    public void loadMore() {
        super.loadMore();
        getInstructs();
    }
}