mirror of
https://github.com/WuXiaolong/AndroidMVPSample.git
synced 2025-12-20 10:35:41 +08:00
Initial commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package com.wuxiaolong.androidmvpsample.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.wuxiaolong.androidmvpsample.R;
|
||||
import com.wuxiaolong.androidmvpsample.model.MainModel;
|
||||
import com.wuxiaolong.androidmvpsample.presenter.MainPresenter;
|
||||
import com.wuxiaolong.androidmvpsample.view.MainView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements MainView {
|
||||
ProgressBar mProgressBar;
|
||||
TextView text;
|
||||
MainPresenter mMainPresenter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
initView();
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
text = (TextView) findViewById(R.id.text);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.mProgressBar);
|
||||
mMainPresenter = new MainPresenter();
|
||||
mMainPresenter.attachView(this);
|
||||
mMainPresenter.loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mMainPresenter.detachView();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showData(MainModel mainModel) {
|
||||
text.setText("城市:" + mainModel.getCity()
|
||||
+ "\n风向:" + mainModel.getWd()
|
||||
+ "\n风级:" + mainModel.getWs()
|
||||
+ "\n发布时间:" + mainModel.getTime());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void showProgress() {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideProgress() {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user