package com.example.yinzhiyou.guide_page.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import com.example.yinzhiyou.guide_page.R;
import com.example.yinzhiyou.guide_page.data.beans.GuideBean;
import com.example.yinzhiyou.guide_page.di.contract.IContract;
import com.example.yinzhiyou.guide_page.di.presenter.IPresenterImpl;
import com.example.yinzhiyou.guide_page.ui.adapter.GuideAdapter;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class MainActivity extends AppCompatActivity implements IContract.IView {
@BindView(R.id.guide_pager)
ViewPager guidePager;
@BindView(R.id.but_start)
Button butStart;
private IPresenterImpl iPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
initView();
}
private void initView() {
iPresenter = new IPresenterImpl();
iPresenter.onAttachView(this);
iPresenter.getResposeData();
butStart.setVisibility(View.GONE);
}
@OnClick(R.id.but_start)
public void onViewClicked() {
Intent intent=new Intent(this,LoginActivity.class);
startActivity(intent);
}
@Override
public void showData(Object data) {
final GuideBean guideBean= (GuideBean) data;
GuideAdapter guideAdapter = new GuideAdapter(this, guideBean.getData());
guidePager.setAdapter(guideAdapter);
guidePager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i1) {
}
@Override
public void onPageSelected(int i) {
if (i==guideBean.getData().size()-1){
butStart.setVisibility(View.VISIBLE);
}else {
butStart.setVisibility(View.GONE);
}
}
@Override
public void onPageScrollStateChanged(int i) {
}
});
}
}
导航页
最新推荐文章于 2020-10-15 11:17:02 发布