mirror of
https://github.com/WuXiaolong/AndroidMVPSample.git
synced 2025-06-07 05:44:37 +08:00
77 lines
2.1 KiB
Java
77 lines
2.1 KiB
Java
package com.wuxiaolong.androidmvpsample.ui;
|
||
|
||
import android.os.Bundle;
|
||
import android.view.View;
|
||
import android.widget.ProgressBar;
|
||
import android.widget.TextView;
|
||
|
||
import com.wuxiaolong.androidmvpsample.R;
|
||
import com.wuxiaolong.androidmvpsample.mvp.MvpActivity;
|
||
import com.wuxiaolong.androidmvpsample.mvp.main.MainModel;
|
||
import com.wuxiaolong.androidmvpsample.mvp.main.MainPresenter;
|
||
import com.wuxiaolong.androidmvpsample.mvp.main.MainView;
|
||
|
||
import butterknife.Bind;
|
||
import butterknife.ButterKnife;
|
||
|
||
/**
|
||
* 由Activity/Fragment实现View里方法,包含一个Presenter的引用
|
||
* Created by WuXiaolong
|
||
* on 2015/9/23.
|
||
* github:https://github.com/WuXiaolong/
|
||
* weibo:http://weibo.com/u/2175011601
|
||
* 微信公众号:吴小龙同学
|
||
* 个人博客:http://wuxiaolong.me/
|
||
*/
|
||
public class MainActivity extends MvpActivity<MainPresenter> implements MainView {
|
||
|
||
@Bind(R.id.text)
|
||
TextView text;
|
||
@Bind(R.id.mProgressBar)
|
||
ProgressBar mProgressBar;
|
||
|
||
@Override
|
||
protected void onCreate(Bundle savedInstanceState) {
|
||
super.onCreate(savedInstanceState);
|
||
setContentView(R.layout.activity_main);
|
||
ButterKnife.bind(this);
|
||
//请求接口
|
||
mvpPresenter.loadData("101010100");
|
||
}
|
||
|
||
@Override
|
||
protected MainPresenter createPresenter() {
|
||
return new MainPresenter(this);
|
||
}
|
||
|
||
|
||
@Override
|
||
public void getDataSuccess(MainModel model) {
|
||
//接口成功回调
|
||
MainModel.WeatherinfoBean weatherinfo = model.getWeatherinfo();
|
||
String showData = getResources().getString(R.string.city) + weatherinfo.getCity()
|
||
+ getResources().getString(R.string.wd) + weatherinfo.getWD()
|
||
+ getResources().getString(R.string.ws) + weatherinfo.getWS()
|
||
+ getResources().getString(R.string.time) + weatherinfo.getTime();
|
||
text.setText(showData);
|
||
}
|
||
|
||
@Override
|
||
public void getDataFail(String msg) {
|
||
toastShow("网络不给力");
|
||
|
||
}
|
||
|
||
@Override
|
||
public void showLoading() {
|
||
mProgressBar.setVisibility(View.VISIBLE);
|
||
}
|
||
|
||
@Override
|
||
public void hideLoading() {
|
||
mProgressBar.setVisibility(View.GONE);
|
||
}
|
||
|
||
|
||
}
|