//布局 主页面
<?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" android:orientation="vertical" tools:context="com.bwei.www.weekmoni1109.MainActivity"> <ImageView android:src="@drawable/shop_middle_title" android:layout_width="fill_parent" android:layout_height="50dp" /> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/left_lv" android:layout_width="140dp" android:layout_height="match_parent"></ListView> <ListView android:id="@+id/right_lv" android:layout_width="match_parent" android:layout_height="match_parent"></ListView> </LinearLayout> </LinearLayout>
//左边的
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/category_name" android:padding="15dp" android:gravity="center" android:textSize="22dp" android:textColor="#000000" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
//右边的
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/name" android:textSize="22sp" android:layout_marginBottom="10dp" android:layout_width="match_parent" android:layout_height="30dp" /> <android.support.v7.widget.RecyclerView android:id="@+id/rv_child" android:layout_width="match_parent" android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView> </LinearLayout>
//右边的Recycler布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/img_shop" android:layout_width="80dp" android:layout_height="80dp" android:layout_margin="10dp" /> <TextView android:id="@+id/shop_name" android:textSize="15sp" android:layout_margin="10dp" android:gravity="center" android:textColor="#000" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout>
//IApi
package com.bwei.www.weekmoni1109.api; import com.bwei.www.weekmoni1109.bean.Category; import com.bwei.www.weekmoni1109.bean.ChildCategory; import io.reactivex.Observable; import retrofit2.http.GET; import retrofit2.http.Query; /** * Created by asus on 2018/11/9. */ public interface IApi { @GET("product/getCatagory") Observable<Category> getCatagory(); @GET("product/getProductCatagory") Observable<ChildCategory> getChildCategory(@Query("cid") String cid); }
//RetrofitManager
package com.bwei.www.weekmoni1109.HttpUtils; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; /** * Created by asus on 2018/11/9. */ public class RetrofitManager { private static final String BASE_URL = "http://www.zhaoapi.cn/"; private Retrofit mRetrofit; private static final class SINGLE_INSTANCE { private static final RetrofitManager _INSTANCE = new RetrofitManager(); } public static RetrofitManager getInstance() { return SINGLE_INSTANCE._INSTANCE; } private RetrofitManager() { mRetrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .client(buildOKHttpClient()) .build(); } private OkHttpClient buildOKHttpClient() { return new OkHttpClient.Builder() .readTimeout(5000, TimeUnit.MILLISECONDS) .writeTimeout(5000, TimeUnit.MILLISECONDS) .build(); } public Retrofit getmRetrofit() { return mRetrofit; } public <T> T creat(Class<T> clazz) { return mRetrofit.create(clazz); } }
//Model
package com.bwei.www.weekmoni1109.model; import com.bwei.www.weekmoni1109.HttpUtils.RetrofitManager; import com.bwei.www.weekmoni1109.api.IApi; import com.bwei.www.weekmoni1109.bean.Category; import com.bwei.www.weekmoni1109.bean.ChildCategory; import io.reactivex.Observable; /** * Created by asus on 2018/11/9. */ public class CategoryModel { public Observable<Category> getCategory(){ IApi iApi = RetrofitManager.getInstance().creat(IApi.class); Observable<Category> observable = iApi.getCatagory(); return observable; } public Observable<ChildCategory> getChildCategory(String uid){ IApi iApi = RetrofitManager.getInstance().creat(IApi.class); Observable<ChildCategory> observable = iApi.getChildCategory(uid); return observable; } }
//view
package com.bwei.www.weekmoni1109.view; import com.bwei.www.weekmoni1109.bean.Category; import com.bwei.www.weekmoni1109.bean.ChildCategory; /** * Created by asus on 2018/11/9. */ public interface ICategoryView { void getData(Category category); void getChildren(ChildCategory childCategory); void failed(Throwable t); }
//Presenter
package com.bwei.www.weekmoni1109.presenter; import com.bwei.www.weekmoni1109.bean.Category; import com.bwei.www.weekmoni1109.bean.ChildCategory; import com.bwei.www.weekmoni1109.model.CategoryModel; import com.bwei.www.weekmoni1109.view.ICategoryView; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; /** * Created by asus on 2018/11/9. */ public class CategoryPresenter { private ICategoryView iv; private CategoryModel categoryModel; public void attach(ICategoryView iv){ this.iv = iv; categoryModel = new CategoryModel(); } public void detach(){ if (iv != null){ iv = null; } } public void getData(){ categoryModel.getCategory() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer<Category>() { @Override public void accept(Category category) throws Exception { if (category != null){ if ("0".equals(category.getCode())){ iv.getData(category); }else { iv.getData(category); } } } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { iv.failed(throwable); } }); } public void getChildData(String uid){ categoryModel.getChildCategory(uid) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer<ChildCategory>() { @Override public void accept(ChildCategory childCategory) throws Exception { if (childCategory != null){ if ("0".equals(childCategory.getCode())){ iv.getChildren(childCategory); } }else { iv.getChildren(childCategory); } } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { iv.failed(throwable); } }); } }
//左边bean
package com.bwei.www.weekmoni1109.bean; import java.util.List; /** * Created by asus on 2018/11/9. */ public class Category { /** * msg : * code : 0 * data : [{"cid":1,"createtime":"2017-10-10T19:41:39","icon":"http://120.27.23.105/images/category/shop.png","ishome":1,"name":"京东超市"},{"cid":2,"createtime":"2017-10-10T19:41:39","icon":"http://120.27.23.105/images/category/qqg.png","ishome":1,"name":"全球购"},{"cid":3,"createtime":"2017-10-10T19:45:11","icon":"http://120.27.23.105/images/category/phone.png","ishome":1,"name":"手机数码"},{"cid":5,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/man.png","ishome":1,"name":"男装"},{"cid":6,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/girl.png","ishome":1,"name":"女装"},{"cid":7,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/manshoe.png","ishome":1,"name":"男鞋"},{"cid":8,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/girlshoe.png","ishome":1,"name":"女鞋"},{"cid":9,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/shirt.png","ishome":1,"name":"内衣配饰"},{"cid":10,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/bag.png","ishome":1,"name":"箱包手袋"},{"cid":11,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/beauty.png","ishome":1,"name":"美妆个护"},{"cid":12,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/jewel.png","ishome":1,"name":"钟表珠宝"},{"cid":13,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/luxury.png","ishome":1,"name":"奢侈品"},{"cid":14,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/computer.png","ishome":1,"name":"电脑办公"},{"cid":15,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"家用电器"},{"cid":16,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"食品生鲜"},{"cid":17,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"酒水饮料"},{"cid":18,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"母婴童装"},{"cid":19,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"玩具乐器"},{"cid":20,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"医药保健"}] */ private String msg; private String code; private List<DataBean> data; public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public List<DataBean> getData() { return data; } public void setData(List<DataBean> data) { this.data = data; } public static class DataBean { /** * cid : 1 * createtime : 2017-10-10T19:41:39 * icon : http://120.27.23.105/images/category/shop.png * ishome : 1 * name : 京东超市 */ private int cid; private String createtime; private String icon; private int ishome; private String name; public int getCid() { return cid; } public void setCid(int cid) { this.cid = cid; } public String getCreatetime() { return createtime; } public void setCreatetime(String createtime) { this.createtime = createtime; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public int getIshome() { return ishome; } public void setIshome(int ishome) { this.ishome = ishome; } public String getName() { return name; } public void setName(String name) { this.name = name; } } } //右边的Bean
package com.bwei.www.weekmoni1109.bean; import java.util.List; /** * Created by asus on 2018/11/9. */ public class ChildCategory { /** * msg : 获取子分类成功 * code : 0 * data : [{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"月饼","pcid":1,"pscid":1},{"icon":"http://120.27.23.105/images/icon.png","name":"坚果炒货","pcid":1,"pscid":2},{"icon":"http://120.27.23.105/images/icon.png","name":"糖巧","pcid":1,"pscid":3},{"icon":"http://120.27.23.105/images/icon.png","name":"休闲零食","pcid":1,"pscid":4},{"icon":"http://120.27.23.105/images/icon.png","name":"肉干肉脯","pcid":1,"pscid":5},{"icon":"http://120.27.23.105/images/icon.png","name":"饼干蛋糕","pcid":1,"pscid":6},{"icon":"http://120.27.23.105/images/icon.png","name":"蜜饯果干","pcid":1,"pscid":7},{"icon":"http://120.27.23.105/images/icon.png","name":"无糖食品","pcid":1,"pscid":8}],"name":"休闲零食","pcid":"1"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"新鲜水果","pcid":2,"pscid":9},{"icon":"http://120.27.23.105/images/icon.png","name":"海鲜水产","pcid":2,"pscid":10},{"icon":"http://120.27.23.105/images/icon.png","name":"精选肉类","pcid":2,"pscid":11},{"icon":"http://120.27.23.105/images/icon.png","name":"蛋类","pcid":2,"pscid":12},{"icon":"http://120.27.23.105/images/icon.png","name":"新鲜蔬菜","pcid":2,"pscid":13},{"icon":"http://120.27.23.105/images/icon.png","name":"冷冻食品","pcid":2,"pscid":14},{"icon":"http://120.27.23.105/images/icon.png","name":"饮品甜品","pcid":2,"pscid":15},{"icon":"http://120.27.23.105/images/icon.png","name":"大闸蟹","pcid":2,"pscid":16}],"name":"京东生鲜","pcid":"2"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"大米","pcid":3,"pscid":21},{"icon":"http://120.27.23.105/images/icon.png","name":"面粉","pcid":3,"pscid":22},{"icon":"http://120.27.23.105/images/icon.png","name":"杂粮","pcid":3,"pscid":23},{"icon":"http://120.27.23.105/images/icon.png","name":"食用油","pcid":3,"pscid":24},{"icon":"http://120.27.23.105/images/icon.png","name":"调味品","pcid":3,"pscid":25},{"icon":"http://120.27.23.105/images/icon.png","name":"方便速食","pcid":3,"pscid":26},{"icon":"http://120.27.23.105/images/icon.png","name":"有机食品","pcid":3,"pscid":27}],"name":"粮油调味","pcid":"3"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"饮用水","pcid":4,"pscid":28},{"icon":"http://120.27.23.105/images/icon.png","name":"饮料","pcid":4,"pscid":29},{"icon":"http://120.27.23.105/images/icon.png","name":"牛奶乳品","pcid":4,"pscid":30},{"icon":"http://120.27.23.105/images/icon.png","name":"名茶","pcid":4,"pscid":31},{"icon":"http://120.27.23.105/images/icon.png","name":"蜂蜜","pcid":4,"pscid":32}],"name":"水饮茗茶","pcid":"4"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"白酒","pcid":5,"pscid":33},{"icon":"http://120.27.23.105/images/icon.png","name":"葡萄酒","pcid":5,"pscid":34},{"icon":"http://120.27.23.105/images/icon.png","name":"洋酒","pcid":5,"pscid":35},{"icon":"http://120.27.23.105/images/icon.png","name":"啤酒","pcid":5,"pscid":36},{"icon":"http://120.27.23.105/images/icon.png","name":"黄酒","pcid":5,"pscid":37},{"icon":"http://120.27.23.105/images/icon.png","name":"陈年老酒","pcid":5,"pscid":38}],"name":"中外名酒","pcid":"5"}] */ private String msg; private String code; private List<DataBean> data; public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public List<DataBean> getData() { return data; } public void setData(List<DataBean> data) { this.data = data; } public static class DataBean { /** * cid : 1 * list : [{"icon":"http://120.27.23.105/images/icon.png","name":"月饼","pcid":1,"pscid":1},{"icon":"http://120.27.23.105/images/icon.png","name":"坚果炒货","pcid":1,"pscid":2},{"icon":"http://120.27.23.105/images/icon.png","name":"糖巧","pcid":1,"pscid":3},{"icon":"http://120.27.23.105/images/icon.png","name":"休闲零食","pcid":1,"pscid":4},{"icon":"http://120.27.23.105/images/icon.png","name":"肉干肉脯","pcid":1,"pscid":5},{"icon":"http://120.27.23.105/images/icon.png","name":"饼干蛋糕","pcid":1,"pscid":6},{"icon":"http://120.27.23.105/images/icon.png","name":"蜜饯果干","pcid":1,"pscid":7},{"icon":"http://120.27.23.105/images/icon.png","name":"无糖食品","pcid":1,"pscid":8}] * name : 休闲零食 * pcid : 1 */ private String cid; private String name; private String pcid; private List<ListBean> list; public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPcid() { return pcid; } public void setPcid(String pcid) { this.pcid = pcid; } public List<ListBean> getList() { return list; } public void setList(List<ListBean> list) { this.list = list; } public static class ListBean { /** * icon : http://120.27.23.105/images/icon.png * name : 月饼 * pcid : 1 * pscid : 1 */ private String icon; private String name; private int pcid; private int pscid; public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getPcid() { return pcid; } public void setPcid(int pcid) { this.pcid = pcid; } public int getPscid() { return pscid; } public void setPscid(int pscid) { this.pscid = pscid; } } } }
//左边的Adapter
package com.bwei.www.weekmoni1109.adapter; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.bwei.www.weekmoni1109.R; import com.bwei.www.weekmoni1109.bean.Category; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; /** * Created by asus on 2018/11/9. */ public class CategoryAdapter extends BaseAdapter { private List<Category.DataBean> dataBeanList; private Context context; public CategoryAdapter(List<Category.DataBean> dataBeanList, Context context) { this.dataBeanList = dataBeanList; this.context = context; } @Override public int getCount() { return dataBeanList.size(); } @Override public Object getItem(int position) { return dataBeanList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = View.inflate(context, R.layout.item_left_category, null); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.categoryName.setText(dataBeanList.get(position).getName()); return convertView; } static class ViewHolder { @BindView(R.id.category_name) TextView categoryName; ViewHolder(View view) { ButterKnife.bind(this, view); } } }
//右边的Adapter
package com.bwei.www.weekmoni1109.adapter; import android.content.Context; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.bwei.www.weekmoni1109.R; import com.bwei.www.weekmoni1109.bean.ChildCategory; import java.util.ArrayList; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; /** * Created by asus on 2018/11/9. */ public class CategoryChildAdapter extends BaseAdapter { private List<ChildCategory.DataBean> beanList; private List<ChildCategory.DataBean.ListBean> listBeans; private Context context; private CategoryChildProductAdapter adapter; public CategoryChildAdapter(List<ChildCategory.DataBean> beanList, Context context) { this.beanList = beanList; this.context = context; } @Override public int getCount() { return beanList.size(); } @Override public Object getItem(int position) { return beanList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = View.inflate(context, R.layout.item_right_category, null); holder = new ViewHolder(convertView); convertView.setTag(holder); }else { holder = (ViewHolder) convertView.getTag(); } holder.name.setText(beanList.get(position).getName()); listBeans = new ArrayList<>(); if (listBeans != null){ listBeans.clear(); } listBeans.addAll(beanList.get(position).getList()); RecyclerView.LayoutManager manager = new GridLayoutManager(context,3); holder.rvChild.setLayoutManager(manager); adapter = new CategoryChildProductAdapter(context,listBeans); holder.rvChild.setAdapter(adapter); return convertView; } static class ViewHolder { @BindView(R.id.name) TextView name; @BindView(R.id.rv_child) RecyclerView rvChild; ViewHolder(View view) { ButterKnife.bind(this, view); } } }
//右边的视图Adapter
package com.bwei.www.weekmoni1109.adapter; import android.content.Context; import android.net.Uri; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.bwei.www.weekmoni1109.R; import com.bwei.www.weekmoni1109.bean.ChildCategory; import com.facebook.drawee.view.SimpleDraweeView; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; /** * Created by asus on 2018/11/9. */ public class CategoryChildProductAdapter extends RecyclerView.Adapter<CategoryChildProductAdapter.ViewHolder> { private Context context; private List<ChildCategory.DataBean.ListBean> listBeans; public CategoryChildProductAdapter(Context context, List<ChildCategory.DataBean.ListBean> listBeans) { this.context = context; this.listBeans = listBeans; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = View.inflate(context, R.layout.item_rtight_category_child, null); ViewHolder holder = new ViewHolder(v); return holder; } @Override public void onBindViewHolder(ViewHolder holder, int position) { holder.shopName.setText(listBeans.get(position).getName()); holder.imgShop.setImageURI(Uri.parse(listBeans.get(position).getIcon())); } @Override public int getItemCount() { return listBeans.size(); } public class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.img_shop) SimpleDraweeView imgShop; @BindView(R.id.shop_name) TextView shopName; public ViewHolder(View itemView) { super(itemView); ButterKnife.bind(this,itemView); } } }
//MainActivity
package com.bwei.www.weekmoni1109; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; import android.widget.Toast; import com.bwei.www.weekmoni1109.adapter.CategoryAdapter; import com.bwei.www.weekmoni1109.adapter.CategoryChildAdapter; import com.bwei.www.weekmoni1109.bean.Category; import com.bwei.www.weekmoni1109.bean.ChildCategory; import com.bwei.www.weekmoni1109.presenter.CategoryPresenter; import com.bwei.www.weekmoni1109.view.ICategoryView; import java.util.ArrayList; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; public class MainActivity extends AppCompatActivity implements ICategoryView { @BindView(R.id.left_lv) ListView leftLv; @BindView(R.id.right_lv) ListView rightLv; private List<Category.DataBean> dataBeanList; private List<ChildCategory.DataBean> beanList; private CategoryAdapter categoryAdapter; private CategoryChildAdapter categoryChildAdapter; private CategoryPresenter categoryPresenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); dataBeanList = new ArrayList<>(); beanList = new ArrayList<>(); categoryPresenter = new CategoryPresenter(); categoryPresenter.attach(this); categoryPresenter.getData(); categoryPresenter.getChildData("1"); categoryAdapter = new CategoryAdapter(dataBeanList,this); categoryChildAdapter = new CategoryChildAdapter(beanList,this); leftLv.setAdapter(categoryAdapter); rightLv.setAdapter(categoryChildAdapter); leftLv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Toast.makeText(this,""+dataBeanList.get(position).getCid(),Toast.LENGTH_SHORT).show(); categoryPresenter.getChildData(dataBeanList.get(position).getCid()+""); } }); } @Override public void getData(Category category) { dataBeanList.clear(); dataBeanList.addAll(category.getData()); categoryAdapter.notifyDataSetChanged(); } @Override public void getChildren(ChildCategory childCategory) { if (childCategory != null){ beanList.clear(); beanList.addAll(childCategory.getData()); categoryChildAdapter.notifyDataSetChanged(); } } @Override public void failed(Throwable t) { Toast.makeText(MainActivity.this, ""+t.getMessage(), Toast.LENGTH_SHORT).show(); } @Override protected void onDestroy() { super.onDestroy(); if (categoryPresenter != null){ categoryPresenter.detach(); } } }
//App
package com.bwei.www.weekmoni1109; import android.app.Application; import com.facebook.drawee.backends.pipeline.Fresco; /** * Created by asus on 2018/11/9. */ public class App extends Application { @Override public void onCreate() { super.onCreate(); Fresco.initialize(this); } }