京东首页

Fragment+viewpage       actvity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.yuekao_moni.activity.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <android.support.v4.view.ViewPager
            android:id="@+id/main_vp"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"></android.support.v4.view.ViewPager>


        <RadioGroup
            android:id="@+id/main_rg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">


            <RadioButton
                android:id="@+id/one"
                android:layout_width="0dp"
                android:layout_height="40dp"
                android:layout_weight="1"
                android:text="首页"
                android:gravity="center_horizontal"
                android:button="@null" />


            <RadioButton
                android:id="@+id/two"
                android:layout_width="0dp"
                android:layout_height="40dp"
                android:layout_weight="1"
                android:gravity="center_horizontal"
                android:text="购物车"
                android:button="@null" />


        </RadioGroup>


首页的XML     activity_home
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="#f00"
        android:orientation="horizontal">

        <Button
            android:id="@+id/sao"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            />

        <EditText
            android:id="@+id/et_search_home"
            android:layout_width="0dp"
            android:layout_height="30dp"
            android:layout_centerVertical="true"
            android:layout_weight="1"
            android:background="#fff"
            android:focusable="false"
            android:hint="  618京东购物狂欢" />


        <Button
            android:id="@+id/xiao"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            />
    </LinearLayout>

    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:id="@+id/refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="vertical"
                    android:layout_height="wrap_content">
                    <com.youth.banner.Banner
                        android:id="@+id/banner"
                        android:layout_width="match_parent"
                        android:layout_weight="1"
                        android:layout_height="200dp"></com.youth.banner.Banner>
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/home_rece"
                        android:layout_width="match_parent"
                        android:layout_height="150dp"></android.support.v7.widget.RecyclerView>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_height="wrap_content"
                        android:text="---秒杀---"
                        android:textSize="30dp" />
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/home_rece02"
                        android:layout_width="match_parent"
                        android:layout_height="80dp"></android.support.v7.widget.RecyclerView>
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_height="wrap_content"
                        android:text="---推荐---"
                        android:textSize="30dp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/home_rece03"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </com.scwang.smartrefresh.layout.SmartRefreshLayout>



</LinearLayout>
秒杀  home_miaosha 
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
     <com.facebook.drawee.view.SimpleDraweeView
         android:id="@+id/home_miaosha"
         android:layout_width="80dp"
         android:layout_height="80dp" />
</LinearLayout>
九宫格xml   home_recycler
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
     <com.facebook.drawee.view.SimpleDraweeView
         android:id="@+id/home_srl"
         android:layout_width="80dp"
         android:layout_height="80dp" />
</LinearLayout>

推荐     xml   home_tuijian

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:layout_height="wrap_content">

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/tuijian_image"
            android:layout_width="150dp"
            android:layout_height="150dp"/>
        <TextView
            android:id="@+id/tuijian_title"
            android:text="gfggfdgdf"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/tuijian_price"
            android:text="343434"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

</LinearLayout>

详情  activity_peoduct_dedails

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">



        <com.youth.banner.Banner
            android:id="@+id/product_banner"
            android:layout_width="match_parent"
            android:layout_height="500dp"
            android:layout_marginTop="100sp"></com.youth.banner.Banner>



    <RelativeLayout
        android:layout_marginTop="35dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/product_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="商品标题" />


        <TextView
            android:id="@+id/product_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="商品简介"
            android:layout_below="@id/product_title"
            />

        <TextView
            android:id="@+id/product_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="¥0.0"
            android:textColor="#ff5656"
            android:layout_below="@id/product_content"
            />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="150dp"

        >

        <Button
            android:id="@+id/add_cart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="380dp"
            android:background="#ff6622"
            android:text="加入购物车"
            android:textColor="#fff" />

        <Button
            android:id="@+id/go_buy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:background="#ff6622"
            android:text="立即购买"
            android:textColor="#fff" />
    </RelativeLayout>

</LinearLayout>
MainActivity 
public class MainActivity extends AppCompatActivity {
 private ViewPager viewPager;
    private RadioGroup radioGroup;
    private List<Fragment> fs=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();


        datas();
    }
    private void datas() {
        HomeFragment homeFragment = new HomeFragment();
        CartFragment cartFragment = new CartFragment();
        fs.add(homeFragment);
        fs.add(cartFragment);
        MyFragmentAdapter myFragmentAdapter = new MyFragmentAdapter(getSupportFragmentManager(), fs);
        viewPager.setAdapter(myFragmentAdapter);
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {


            }


            @Override
            public void onPageSelected(int position) {
                switch (position){
                    case 0:
                        radioGroup.check(R.id.one);
                        break;
                    case 1:
                        radioGroup.check(R.id.two);
                        break;
                }
            }


            @Override
            public void onPageScrollStateChanged(int state) {


            }
        });
    }


    private void initView() {
        viewPager = findViewById(R.id.main_vp);
        radioGroup = findViewById(R.id.main_rg);
        radioGroup.check(R.id.one);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId){
                    case R.id.one:
                        viewPager.setCurrentItem(0);
                        break;
                    case R.id.two:
                        viewPager.setCurrentItem(1);
                        break;

                }
            }
        });
    }

}
MyFragmentAdapter
public class MyFragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> list;

    public MyFragmentAdapter(FragmentManager fm, List<Fragment> list) {
        super(fm);
        this.list = list;
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }
}
MainApi

public interface MainApi {

    //轮播图
    @GET("home/getHome")
    Observable<AdBean> adByGet();

    //轮播图
    @GET("product/getProductDetail")
    Observable<ProductDetailsBean> xiang(@Query("pid") int pid);

//查询购物车
    @GET("product/getCarts")
    Observable<CartBean> cart(@Query("uid") int uid);

    //加入购物车
    @GET("product/addCart")
    Observable<AddCartBean> addcart(@Query("uid") int uid,@Query("pid")int pid);
}
model层

public class HomeModel {
       public Observable<AdBean> home(){
           return RetrofitManager.getDefaule().create(MainApi.class).adByGet();
       }
    public Observable<ProductDetailsBean> homex(int pid){
        return RetrofitManager.getDefaule().create(MainApi.class).xiang(pid);
    }
    public Observable<AddCartBean> add(int uid,int pid){
        return RetrofitManager.getDefaule().create(MainApi.class).addcart(uid,pid);
    }
}
p层

public class HomePersenter extends BasePresenter<HomeView>{
    private HomeModel homeModel;
    public HomePersenter(HomeView view) {
        super(view);
    }

    @Override
    protected void initModel() {
         homeModel=new HomeModel();
    }
   //首页数据
    public void home(){
        homeModel.home()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<AdBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(AdBean adBean) {
                        if (view != null) {
                            Log.d("tag", "onNext: " + adBean.getMsg());
                            view.onSuccess(adBean);
                        }

                    }

                    @Override
                    public void onError(Throwable e) {
                        if(view!=null){
                             view.onFaild(e.toString());
                            Log.d("tag", "onNext: " + e.toString());
                        }
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
    //首页详情
      public void xiangqing(int pid){
          homeModel.homex(pid)
                  .subscribeOn(Schedulers.io())
                  .observeOn(AndroidSchedulers.mainThread())
                  .subscribe(new Observer<ProductDetailsBean>() {
                      @Override
                      public void onSubscribe(Disposable d) {

                      }

                      @Override
                      public void onNext(ProductDetailsBean productDetailsBean) {
                              if(view!=null){
                                  view.onSuccess(productDetailsBean);
                              }
                      }

                      @Override
                      public void onError(Throwable e) {
                             if(view!=null){
                                 view.onError(e.toString());
                             }
                      }

                      @Override
                      public void onComplete() {

                      }
                  });
      }
    //添加购物车
    public void add(int uid,int pid){
          homeModel.add(uid,pid)
                  .subscribeOn(Schedulers.io())
                  .observeOn(AndroidSchedulers.mainThread())
                  .subscribe(new Observer<AddCartBean>() {
                      @Override
                      public void onSubscribe(Disposable d) {

                      }

                      @Override
                      public void onNext(AddCartBean addCartBean) {
                    if(view!=null){
                         view.onCartSuccess(addCartBean);
                    }
                      }

                      @Override
                      public void onError(Throwable e) {
                          if(view!=null){
                               view.onCartError(e.toString());
                          }
                      }

                      @Override
                      public void onComplete() {

                      }
                  });
    }
}
v层

public interface HomeView extends IView{
    void onSuccess(AdBean adBean);
    void onFaild(String error);

    void onSuccess(ProductDetailsBean productDetailsBean);
    void onError(String error);

    //添加购物车
    void onCartSuccess(AddCartBean addCartBean);
    void onCartError(String error);
}
详情的activity   ProductDetailsActivity

public class ProductDetailsActivity extends BaseActivity<HomePersenter> implements HomeView{
    private int pid;
    private static final String TAG = "ProductDetailsActivity";
    private Banner product_banner;
    private TextView tv_title;
    private TextView tv_content;
    private TextView tv_price;
    private List<String> imgs = new ArrayList<>();
    private Button add_car;
    int uid=14789;
    @Override
    public Context context() {
        return ProductDetailsActivity.this;
    }

    @Override
    public void onSuccess(AdBean adBean) {

    }

    @Override
    public void onFaild(String error) {

    }

    @Override
    public void onSuccess(ProductDetailsBean productDetailsBean) {
        ProductDetailsBean.DataBean data = productDetailsBean.getData();
         tv_title.setText(data.getTitle());
         tv_price.setText(data.getBargainPrice()+"");
         tv_content.setText(data.getSubhead());
        String[] pic = data.getImages().split("\\|");
        List<String> list = Arrays.asList(pic);
        for (int i = 0; i < list.size(); i++) {
            imgs.add(pic[i]);
        }
        Toast.makeText(ProductDetailsActivity.this,"0000000000",Toast.LENGTH_SHORT).show();
        product_banner.setImageLoader(new GlideImageloader());
        product_banner.setBannerStyle(BannerConfig.NUM_INDICATOR);
        product_banner.setImages(list);
        product_banner.start();
    }
    private class GlideImageloader extends ImageLoader {
        @Override
        public void displayImage(Context context, Object path, ImageView imageView) {
            Uri uri = Uri.parse((String) path);
            imageView.setImageURI(uri);
        }

        @Override
        public ImageView createImageView(Context context) {
            SimpleDraweeView simpleDraweeView = new SimpleDraweeView(context);
            return simpleDraweeView;
        }
    }

    @Override
    public void onError(String error) {

    }

    @Override
    public void onCartSuccess(AddCartBean addCartBean) {
        String code = addCartBean.getCode();
        String msg = addCartBean.getMsg();
        if (code.equals("0")) {
            Toast.makeText(ProductDetailsActivity.this, "添加成功", Toast.LENGTH_SHORT).show();
        }else {
            Toast.makeText(ProductDetailsActivity.this, "添加失败"+msg, Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onCartError(String error) {

    }

    @Override
    protected void initViews() {
        product_banner = findViewById(R.id.product_banner);
        tv_title = findViewById(R.id.product_title);
        tv_content = findViewById(R.id.product_content);
        tv_price = findViewById(R.id.product_price);
        add_car = findViewById(R.id.add_cart);
     //   Log.e("tag", "initViews--------: " + pid);
        add_car.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.add(uid,pid);
                Toast.makeText(ProductDetailsActivity.this, ""+pid, Toast.LENGTH_SHORT).show();
            }
        });

    }

    @Override
    protected void initData() {
        Intent intent = getIntent();
        pid = intent.getIntExtra("pid",0);
       presenter.xiangqing(pid);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected HomePersenter providePresenter() {
        return new HomePersenter(this);
    }

    @Override
    protected int provideLayoutId() {
        return R.layout.activity_product_dedails;
    }
}
轮播的适配器  LunBoAdapter
public class LunBoAdapter extends RecyclerView.Adapter<LunBoAdapter.MyViewHolder> {
         private List<AdBean.DataBean.FenleiBean> list;

    public LunBoAdapter(List<AdBean.DataBean.FenleiBean> list) {
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_recyclerview, parent, false);
        MyViewHolder myViewHolder = new MyViewHolder(view);

        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        String icon = list.get(position).getIcon();
        holder.simpleDraweeView.setImageURI(Uri.parse(icon));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder{
        private SimpleDraweeView simpleDraweeView;
        public MyViewHolder(View itemView) {
            super(itemView);

            simpleDraweeView=itemView.findViewById(R.id.home_srl);
        }
    }
}
  秒杀的适配器 MiaoShaAdapter
public class MiaoShaAdapter extends RecyclerView.Adapter<MiaoShaAdapter.MyViewHolder> {
    private List<AdBean.DataBean.MiaoshaBean.ListBean> list;

    public MiaoShaAdapter(List<AdBean.DataBean.MiaoshaBean.ListBean> list) {
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_miaosha, parent, false);

        MyViewHolder myViewHolder = new MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        String[] split = list.get(position).getImages().split("\\|");
        holder.simpleDraweeView.setImageURI(Uri.parse(split[0]));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private SimpleDraweeView simpleDraweeView;
        public MyViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView=itemView.findViewById(R.id.home_miaosha);
        }
    }
}
推荐的适配器  TuiJianAdapter
public class TuiJianAdapter extends RecyclerView.Adapter<TuiJianAdapter.MyViewHolder>
{
     private List<AdBean.DataBean.TuijianBean.ListBeanX> list;

    public TuiJianAdapter(List<AdBean.DataBean.TuijianBean.ListBeanX> list) {
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_tuijian, parent, false);

        MyViewHolder myViewHolder = new MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        String[] split = list.get(position).getImages().split("\\|");
        holder.simpleDraweeView.setImageURI(Uri.parse(split[0]));

        holder.title.setText(list.get(position).getTitle());
        holder.price.setText("价钱"+list.get(position).getBargainPrice());

        holder.simpleDraweeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onClickListener != null) {
                    onClickListener.onClick(v, position);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView title,price;
         private SimpleDraweeView simpleDraweeView;
        public MyViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView = itemView.findViewById(R.id.tuijian_image);
            title=itemView.findViewById(R.id.tuijian_title);
            price=itemView.findViewById(R.id.tuijian_price);
        }
    }
    private onClickListener onClickListener;

    public void setOnClickListener(TuiJianAdapter.onClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public interface onClickListener {
        void onClick(View view, int position);
    }
}
首页的Fragment 

public class HomeFragment extends BaseFragment<HomePersenter> implements HomeView {
      private Button xiao,sao;
      private EditText shuru;
      private Banner banner;
      private RecyclerView home_rece,home_rece02,home_rece03;
    private LunBoAdapter lunBoAdapter;
    private MiaoShaAdapter miaoShaAdapter;
    private GridLayoutManager gridLayoutManager;
    private TuiJianAdapter tuiJianAdapter;
    private List<AdBean.DataBean.TuijianBean.ListBeanX> list_tj = new ArrayList<AdBean.DataBean.TuijianBean.ListBeanX>();
    private int page = 1;
    private SmartRefreshLayout smartRefreshLayout;
    private MarqueeView marqueeView;

    @Override
    public Context context() {
        return getContext();
    }

    @Override
    public void onSuccess(final AdBean adBean) {
        final List<AdBean.DataBean.BannerBean> data = adBean.getData().getBanner();
        ArrayList<String> list = new ArrayList<>();
        for(int i=0;i<data.size();i++){
            String icon = data.get(i).getIcon();
            Log.d("tag", "onSuccess: " + icon);
            list.add(icon);
        }
        banner.setImages(list);
        banner.setImageLoader(new MyImagerLoader() );
        banner.setBannerStyle(BannerConfig.NUM_INDICATOR);
        banner.start();
    //网格布局
        List<AdBean.DataBean.FenleiBean> fenlei = adBean.getData().getFenlei();
        lunBoAdapter = new LunBoAdapter(fenlei);
        gridLayoutManager = new GridLayoutManager(getActivity(), 2);


        gridLayoutManager.setOrientation(LinearLayout.HORIZONTAL);
        home_rece.setLayoutManager(gridLayoutManager);
        home_rece.setAdapter(lunBoAdapter);

        //秒杀
        List<AdBean.DataBean.MiaoshaBean.ListBean> miaosha = adBean.getData().getMiaosha().getList();
        miaoShaAdapter = new MiaoShaAdapter(miaosha);
       gridLayoutManager = new GridLayoutManager(getActivity(), 1);
        gridLayoutManager.setOrientation(LinearLayout.HORIZONTAL);
        home_rece02.setLayoutManager(gridLayoutManager);
        home_rece02.setAdapter(miaoShaAdapter);
        //推荐

        final List<AdBean.DataBean.TuijianBean.ListBeanX> tuijian = adBean.getData().getTuijian().getList();
         if(page==1){
             list_tj.clear();
         }
         list_tj.addAll(tuijian);
        tuiJianAdapter = new TuiJianAdapter(tuijian);
        gridLayoutManager = new GridLayoutManager(getActivity(), 2);
        home_rece03.setLayoutManager(gridLayoutManager);
        home_rece03.setAdapter(tuiJianAdapter);
         tuiJianAdapter.setOnClickListener(new TuiJianAdapter.onClickListener() {
             @Override
             public void onClick(View view, int position) {

                 int pid = tuijian.get(position).getPid();
                 Log.e("tag", "onClick:+++++++++ "+pid );
                 Intent intent = new Intent(getActivity(),ProductDetailsActivity.class);
                 intent.putExtra("pid",pid);
                 startActivity(intent);
             }
         });
    }

    @Override
    public void onFaild(String error) {
        Toast.makeText(getActivity(), "失败666", Toast.LENGTH_LONG).show();
    }

    @Override
    public void onSuccess(ProductDetailsBean productDetailsBean) {

    }

    @Override
    public void onError(String error) {

    }

    @Override
    public void onCartSuccess(AddCartBean addCartBean) {

    }

    @Override
    public void onCartError(String error) {

    }

    @Override
    protected void initViews(View view) {
          sao= view.findViewById(R.id.sao);
          xiao=view.findViewById(R.id.xiao);
          shuru=view.findViewById(R.id.et_search_home);
          banner=view.findViewById(R.id.banner);
          home_rece=view.findViewById(R.id.home_rece);
          home_rece02=view.findViewById(R.id.home_rece02);
          home_rece03=view.findViewById(R.id.home_rece03);
          smartRefreshLayout=view.findViewById(R.id.refreshLayout);
      /*  marqueeView=view.findViewById(R.id.marqueeView);
        marqueeView = view.findViewById(R.id.marqueeView);
        List<String> info = new ArrayList<>();
        info.add("苹果手机大降价啦,主要999,iphone7,iphone7sp,iphone8随意挑选");
        info.add("退一步海阔天空");
        info.add("你想一夜暴富吗,你想一夜成名吗,你想拿钞票点烟吗?");
        info.add("洗洗睡吧");
        marqueeView.startWithList(info, R.anim.anim_bottom_in, R.anim.anim_top_out);*/
    }

    @Override
    protected void initData() {

      presenter.home();
    }

    @Override
    protected void initListener() {
        smartRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                page = 1;
               presenter.home();
                tuiJianAdapter.notifyDataSetChanged();
                refreshLayout.finishRefresh();
            }

        });
        smartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                page++;
                presenter.home();
             ///   tuiJianAdapter.notifyDataSetChanged();
                refreshLayout.finishLoadMore();
            }
        });
        //设置 Header 为 贝塞尔雷达 样式                          setEnableHorizontalDrag
        smartRefreshLayout.setRefreshHeader(new BezierRadarHeader(getContext()).setEnableHorizontalDrag(true));
        //设置 Footer 为 球脉冲 样式
        smartRefreshLayout.setRefreshFooter(new BallPulseFooter(getContext()).setSpinnerStyle(SpinnerStyle.Scale));
    }

    @Override
    protected HomePersenter providePresenter() {
        return new HomePersenter(this);
    }

    @Override
    protected int privideLayoutId() {
        return R.layout.activity_home;
    }
    //图片
    private class MyImagerLoader extends ImageLoader {

        @Override
        public void displayImage(Context context, Object path, ImageView imageView) {
            //设置Url
            Uri uri = Uri.parse((String) path);
            imageView.setImageURI(uri);
        }
        @Override
        public ImageView createImageView(Context context) {
            SimpleDraweeView simpleDraweeView = new SimpleDraweeView(context);
            return simpleDraweeView;
        }
    }
}

























    </LinearLayout>

</LinearLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值