依赖=================================================================
apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.example.moni" minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" defaultConfig { ndk { //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so) abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","arm64-v8a","x86_64" } } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' implementation 'com.squareup.okhttp3:okhttp:3.3.0' implementation 'com.android.support:recyclerview-v7:27.1.0' implementation 'com.google.code.gson:gson:2.2.4' implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' implementation 'com.hjm:BottomTabBar:1.2.0' implementation 'com.github.bumptech.glide:glide:3.7.0' implementation 'org.greenrobot:eventbus:3.1.1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' //3D地图so及jar implementation 'com.amap.api:3dmap:latest.integration' //定位功能 implementation 'com.amap.api:location:latest.integration' //搜索功能 implementation 'com.amap.api:search:latest.integration' }权限 ======================================================================
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.moni"> <!--允许程序打开网络套接字--> <uses-permission android:name="android.permission.INTERNET" /> <!--允许程序设置内置sd卡的写权限--> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!--允许程序获取网络状态--> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!--允许程序访问WiFi网络信息--> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!--允许程序读写手机状态和身份--> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!--允许程序访问CellID或WiFi热点来获取粗略的位置--> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!--用于进行网络定位--> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission> <!--用于访问GPS定位--> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> <!--用于获取运营商信息,用于支持提供运营商信息相关的接口--> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <!--用于访问wifi网络信息,wifi信息会用于进行网络定位--> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> <!--用于获取wifi的获取权限,wifi信息会用来进行网络定位--> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> <!--用于读取手机当前的状态--> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <!--用于写入缓存数据到扩展存储卡--> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <!--用于申请调用A-GPS模块--> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission> <!--用于申请获取蓝牙信息进行室内定位--> <uses-permission android:name="android.permission.BLUETOOTH"></uses-permission> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission> <application android:name=".View.MyApp" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".View.activity.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".View.activity.ShowActivity"/> <activity android:name=".View.activity.DingWeiActvity"/> <meta-data android:name="com.amap.api.v2.apikey" android:value="4af6f989f15309932ee0434a7d398400"/> <service android:name="com.amap.api.location.APSService"></service> </application> </manifest>
布局====================================================================
activity_main=============================================
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context=".View.activity.MainActivity"> <com.hjm.bottomtabbar.BottomTabBar android:id="@+id/main_bottomTab" android:layout_width="match_parent" android:layout_height="match_parent"> </com.hjm.bottomtabbar.BottomTabBar> </LinearLayout>
categroup_layout==========================================================
<?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:layout_width="match_parent" android:layout_height="56dp" android:background="#990000ff" android:gravity="center" android:text="分类" android:textColor="#ff3660" android:textSize="25sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <ListView android:id="@+id/cate_listview" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3"></ListView> <FrameLayout android:id="@+id/cate_frame" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="7"></FrameLayout> </LinearLayout> </LinearLayout>
child_layout===========================================
<?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.support.v7.widget.RecyclerView android:id="@+id/child_recycker" android:layout_width="wrap_content" android:layout_height="wrap_content"> </android.support.v7.widget.RecyclerView> </LinearLayout>
childholder_layout=========================================
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:padding="20dp"> <ImageView android:id="@+id/iv" android:layout_width="50dp" android:layout_height="50dp" /> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>
dingwei_layout=======================================
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开启"/> <com.amap.api.maps.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent"/> </android.support.constraint.ConstraintLayout>
gouwu_layout=================================================
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/btn" android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="56dp" android:background="#990000ff" android:gravity="center" android:text="开启定位" android:textColor="#ff3660" /> <TextView android:layout_width="wrap_content" android:layout_weight="9" android:layout_height="56dp" android:background="#990000ff" android:gravity="center" android:text="购物车" android:textColor="#ff3660" /> </LinearLayout> <ExpandableListView android:id="@+id/elv" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentBottom="true" android:background="@android:color/white" android:gravity="center_vertical"> <CheckBox android:id="@+id/checkbox2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:focusable="false" /> <TextView android:layout_width="wrap_content" android:layout_height="50dp" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:layout_toRightOf="@+id/checkbox2" android:gravity="center_vertical" android:text="全选" android:textSize="20sp" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="合计 :" /> <TextView android:id="@+id/tv_price" android:layout_width="wrap_content" android:layout_height="50dp" android:layout_marginLeft="10dp" android:paddingRight="10dp" android:text="0" android:textColor="@android:color/holo_red_light" /> <TextView android:id="@+id/tv_num" android:layout_width="wrap_content" android:layout_height="50dp" android:background="@android:color/holo_red_dark" android:gravity="center" android:padding="10dp" android:text="结算(0)" android:textColor="@android:color/white" /> </LinearLayout> </RelativeLayout> </LinearLayout>
group_layout================================
<?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:gravity="center"> <TextView android:id="@+id/text_group" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="name" android:textSize="18dp" /> </LinearLayout>
homet_layout=================================
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:background="#aac" android:layout_height="match_parent"> </LinearLayout>
item_child_market======================================
<?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:gravity="center_vertical" android:orientation="horizontal"> <CheckBox android:id="@+id/cb_child" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="30dp" android:layout_marginLeft="40dp" android:layout_marginTop="30dp" android:focusable="false" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50dp" android:orientation="vertical"> <TextView android:id="@+id/tv_tel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="iphone6" /> <TextView android:id="@+id/tv_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="什么手机" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="2016-12-10" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:layout_weight="1" android:orientation="vertical"> <TextView android:id="@+id/tv_pri" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="¥3000.00" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical"> <ImageView android:id="@+id/iv_del" android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/jian" /> <TextView android:id="@+id/tv_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:paddingBottom="2dp" android:paddingLeft="20dp" android:paddingRight="20dp" android:paddingTop="2dp" android:text="1" /> <ImageView android:id="@+id/iv_add" android:layout_width="20dp" android:layout_height="20dp" android:layout_marginLeft="5dp" android:src="@drawable/jia" /> </LinearLayout> </LinearLayout> <TextView android:id="@+id/tv_del" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="删除" /> </LinearLayout>
item_parent_market======================
<?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="100dp" android:gravity="center_vertical" android:orientation="horizontal"> <CheckBox android:id="@+id/cb_parent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="30dp" android:layout_marginLeft="20dp" android:layout_marginTop="30dp" android:focusable="false" /> <TextView android:id="@+id/tv_sign" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="标记" /> <TextView android:id="@+id/tv_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="12345678" /> </LinearLayout>
list_layout=============================
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:gravity="center" android:layout_height="match_parent"> <TextView android:id="@+id/name" android:layout_width="100dp" android:layout_height="40dp" android:textSize="20dp" android:layout_marginTop="20dp" android:layout_gravity="center" android:text="name"/> </LinearLayout>
mobile_layout===============================
<?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"> <ExpandableListView android:id="@+id/expand_lv" android:layout_width="match_parent" android:layout_height="match_parent"> </ExpandableListView> </LinearLayout>
show_layout===================================
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.constraint.ConstraintLayout>
功能========================================================================
MainActivity=====================================================
package com.example.moni.View.activity; import android.graphics.Color; import android.os.Bundle; import com.example.moni.Presenter.presnter.MainPresenter; import com.example.moni.R; import com.example.moni.View.Iview.IMainView; import com.example.moni.View.fragment.CategroupFragment; import com.example.moni.View.fragment.FragmentShoppingCart; import com.example.moni.View.fragment.HomeFragment; import com.hjm.bottomtabbar.BottomTabBar; public class MainActivity extends BaseActivity<MainPresenter> implements IMainView { private BottomTabBar main_bottomTab; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override protected int setLayout() { return R.layout.activity_main; } @Override protected void initData() { String path = "https://www.zhaoapi.cn/product/getCatagory"; basePresenter.loadData(path); } @Override MainPresenter setPresenter() { return new MainPresenter(); } @Override protected void initView() { main_bottomTab = findViewById(R.id.main_bottomTab); //底部导航栏 main_bottomTab.init(getSupportFragmentManager(), 720, 1280) .setChangeColor(Color.RED, Color.GRAY) .setImgSize(120, 120) .setFontSize(0) .addTabItem("首页", R.drawable.aa2, R.drawable.aa1, HomeFragment.class) .addTabItem("分类", R.drawable.aa4, R.drawable.aa3, CategroupFragment.class) .addTabItem("购物车", R.drawable.aa6, R.drawable.aa5, FragmentShoppingCart.class) .addTabItem("发现", R.drawable.aa0, R.drawable.aa9, HomeFragment.class) .addTabItem("个人中心", R.drawable.aa8, R.drawable.aa7, HomeFragment.class) .isShowDivider(false); } @Override public void onSuccess(String s) { } }
BaseActivity==================================================================
package com.example.moni.View.activity; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.example.moni.Presenter.presnter.BasePresenter; import com.example.moni.View.Iview.IBaseView; public abstract class BaseActivity <P extends BasePresenter> extends AppCompatActivity implements IBaseView { public P basePresenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(setLayout()); initView(); initBaseView(); initData(); } protected abstract int setLayout(); protected abstract void initData(); private void initBaseView() { basePresenter = setPresenter(); if (basePresenter != null) { basePresenter.attachView(this); } else { try { throw new Exception("出错了"); } catch (Exception e) { e.printStackTrace(); } } } abstract P setPresenter(); protected abstract void initView(); }
DingWeiActivity=====================================
package com.example.moni.View.activity; import android.app.Activity; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; import com.amap.api.maps.AMap; import com.amap.api.maps.MapView; import com.amap.api.maps.model.MyLocationStyle; import com.example.moni.R; public class DingWeiActvity extends Activity implements View.OnClickListener { MapView mMapView = null; //声明AMapLocationClient类对象 public AMapLocationClient mLocationClient = null; //声明AMapLocationClientOption对象 public AMapLocationClientOption mLocationOption = null; //声明定位回调监听器 public AMapLocationListener mLocationListener = new AMapLocationListener() { @Override public void onLocationChanged(AMapLocation aMapLocation) { } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dingwei_layout); //获取地图控件引用 mMapView = (MapView) findViewById(R.id.map); Button btn = findViewById(R.id.btn); btn.setOnClickListener(this); //在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图 mMapView.onCreate(savedInstanceState); AMap aMap = null; if (aMap == null) { aMap = mMapView.getMap(); } MyLocationStyle myLocationStyle; myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。 myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。 myLocationStyle.showMyLocation(true); aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style //aMap.getUiSettings().setMyLocationButtonEnabled(true);设置默认定位按钮是否显示,非必需设置。 aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。 //初始化定位 mLocationClient = new AMapLocationClient(getApplicationContext()); //设置定位回调监听 mLocationClient.setLocationListener(mLocationListener); //初始化AMapLocationClientOption对象 mLocationOption = new AMapLocationClientOption(); /** * 设置定位场景,目前支持三种场景(签到、出行、运动,默认无场景) */ mLocationOption.setLocationPurpose(AMapLocationClientOption.AMapLocationPurpose.SignIn); if(null != mLocationClient){ mLocationClient.setLocationOption(mLocationOption); //设置场景模式后最好调用一次stop,再调用start以保证场景模式生效 mLocationClient.stopLocation(); mLocationClient.startLocation(); } //设置定位模式为AMapLocationMode.Hight_Accuracy,高精度模式。 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); mLocationOption.setInterval(1000); mLocationOption.setHttpTimeOut(20000); mLocationOption.setLocationCacheEnable(false); //给定位客户端对象设置定位参数 mLocationClient.setLocationOption(mLocationOption); //启动定位 } @Override protected void onDestroy() { super.onDestroy(); //在activity执行onDestroy时执行mMapView.onDestroy(),销毁地图 mMapView.onDestroy(); } @Override protected void onResume() { super.onResume(); //在activity执行onResume时执行mMapView.onResume (),重新绘制加载地图 mMapView.onResume(); } @Override protected void onPause() { super.onPause(); //在activity执行onPause时执行mMapView.onPause (),暂停地图的绘制 mMapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),保存地图当前的状态 mMapView.onSaveInstanceState(outState); } @Override public void onClick(View v) { Log.d("'sald;f'","lsdkn"); mLocationClient.startLocation(); } }
ShowActivity===================================
package com.example.moni.View.activity; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import com.example.moni.R; public class ShowActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.show_layout); } }
ChildAdapter===========================
package com.example.moni.View.adapter; import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.example.moni.Modle.bean.MobileBeans; import com.example.moni.R; import com.example.moni.View.activity.ShowActivity; import com.nostra13.universalimageloader.core.ImageLoader; import java.util.List; public class ChildAdapter extends RecyclerView.Adapter { private Context context; private List<MobileBeans.DataBean.ListBean> listBeans; public ChildAdapter(Context context, List<MobileBeans.DataBean.ListBean> listBeans) { this.context = context; this.listBeans = listBeans; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = View.inflate(context, R.layout.childholder_layout, null); return new MyViewHolder(view); } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { MyViewHolder viewHolder = (MyViewHolder) holder; viewHolder.tv.setText(listBeans.get(position).getName()); ImageLoader instance = ImageLoader.getInstance(); instance.displayImage(listBeans.get(position).getIcon(), viewHolder.iv); Log.d("zzzzzz","instance"+position); //点击图片跳转 viewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(context, ShowActivity.class); context.startActivity(intent); } }); } @Override public int getItemCount() { return listBeans.size(); } private class MyViewHolder extends RecyclerView.ViewHolder { private TextView tv; private ImageView iv; public MyViewHolder(View itemView) { super(itemView); tv = itemView.findViewById(R.id.tv); iv = itemView.findViewById(R.id.iv); } } }
EAdapter=======================
package com.example.moni.View.adapter; import android.content.Context; import android.support.v4.app.FragmentActivity; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import android.widget.TextView; import com.example.moni.Modle.bean.CartBean; import com.example.moni.Modle.bean.MobileBeans; import com.example.moni.R; import java.util.List; public class EAdapter extends BaseExpandableListAdapter { private Context context; private List<String> list;//组 private List<List<MobileBeans.DataBean.ListBean>> listAll; public EAdapter(Context context, List<String> list, List<List<MobileBeans.DataBean.ListBean>> listAll) { this.context = context; this.list = list; this.listAll = listAll; } public EAdapter(FragmentActivity activity, List<String> g_list, List<List<CartBean.DataBean.ListBean>> listAll) { } @Override public int getGroupCount() { return list.size(); } @Override public int getChildrenCount(int i) { return 1; } @Override public Object getGroup(int i) { return list.get(i); } @Override public Object getChild(int i, int i1) { return listAll.get(i).get(i1); } @Override public long getGroupId(int i) { return i; } @Override public long getChildId(int i, int i1) { return i1; } @Override public boolean hasStableIds() { return true; } @Override public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) { gViewHolder gHolder; if (view == null) { view = View.inflate(context, R.layout.group_layout, null); gHolder = new gViewHolder(); gHolder.text_group = (TextView) view.findViewById(R.id.text_group); view.setTag(gHolder); } else { gHolder = (gViewHolder) view.getTag(); } //赋值 gHolder.text_group.setText(list.get(i)); return view; } @Override public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) { cViewHolder cHolder; if (view == null) { view = View.inflate(context, R.layout.child_layout, null); cHolder = new cViewHolder(); cHolder.child_recycler = view.findViewById(R.id.child_recycker); view.setTag(cHolder); } else { cHolder = (cViewHolder) view.getTag(); } //显示数据 List<MobileBeans.DataBean.ListBean> listBeans = listAll.get(i); //设置布局管理器 GridLayoutManager gridLayoutManager = new GridLayoutManager(context, 3); cHolder.child_recycler.setLayoutManager(gridLayoutManager); ChildAdapter childAdapter = new ChildAdapter(context, listBeans); cHolder.child_recycler.setAdapter(childAdapter); return view; } @Override public boolean isChildSelectable(int i, int i1) { return true; } //创建分组的ViewHolder class gViewHolder { private TextView text_group; } //创建子条目的ViewHolder class cViewHolder { private RecyclerView child_recycler; } }
ListViewAdapter===============================
package com.example.moni.View.adapter; import android.content.Context; import android.support.v4.app.FragmentActivity; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.example.moni.Modle.bean.CartBean; import com.example.moni.Modle.bean.ProductBeans; import com.example.moni.R; import java.util.List; public class ListViewAdapter extends BaseAdapter { private Context context; private List<ProductBeans.DataBean> list; public ListViewAdapter(Context context, List<ProductBeans.DataBean> list) { this.context = context; this.list = list; } public ListViewAdapter(FragmentActivity activity, List<CartBean.DataBean> dataBeanList) { } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return list.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = View.inflate(context, R.layout.list_layout, null); holder = new ViewHolder(); holder.name = convertView.findViewById(R.id.name); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.name.setText(list.get(position).getName()); return convertView; } class ViewHolder { private TextView name; } }
MyAdapter===================================
package com.example.moni.View.adapter; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseExpandableListAdapter; import android.widget.CheckBox; import android.widget.ImageView; import android.widget.TextView; import com.example.moni.Modle.bean.GoosBean; import com.example.moni.Modle.modle.MessageEvent; import com.example.moni.Modle.modle.PriceAndCountEvent; import com.example.moni.R; import org.greenrobot.eventbus.EventBus; import java.util.List; public class MyAdapter extends BaseExpandableListAdapter { private Context context; private List<GoosBean.DataBean> groupList; private List<List<GoosBean.DataBean.DatasBean>> childList; private final LayoutInflater inflater; public MyAdapter(Context context, List<GoosBean.DataBean> groupList, List<List<GoosBean.DataBean.DatasBean>> childList) { this.context = context; this.groupList = groupList; this.childList = childList; inflater = LayoutInflater.from(context); } @Override public int getGroupCount() { return groupList.size(); } @Override public int getChildrenCount(int groupPosition) { return childList.get(groupPosition).size(); } @Override public Object getGroup(int groupPosition) { return groupList.get(groupPosition); } @Override public Object getChild(int groupPosition, int childPosition) { return childList.get(groupPosition).get(childPosition); } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public boolean hasStableIds() { return false; } @Override public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View view; final GroupViewHolder holder; if (convertView == null) { holder = new GroupViewHolder(); view = inflater.inflate(R.layout.item_parent_market, null); holder.cbGroup = (CheckBox) view.findViewById(R.id.cb_parent); holder.tv_number = (TextView) view.findViewById(R.id.tv_number); view.setTag(holder); } else { view = convertView; holder = (GroupViewHolder) view.getTag(); } final GoosBean.DataBean dataBean = groupList.get(groupPosition); holder.cbGroup.setChecked(dataBean.isChecked()); holder.tv_number.setText(dataBean.getTitle()); //一级checkbox holder.cbGroup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dataBean.setChecked(holder.cbGroup.isChecked()); changeChildCbState(groupPosition, holder.cbGroup.isChecked()); EventBus.getDefault().post(compute()); changeAllCbState(isAllGroupCbSelected()); notifyDataSetChanged(); } }); return view; } @Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View view; final ChildViewHolder holder; if (convertView == null) { holder = new ChildViewHolder(); view = inflater.inflate(R.layout.item_child_market, null); holder.cbChild = (CheckBox) view.findViewById(R.id.cb_child); holder.tv_tel = (TextView) view.findViewById(R.id.tv_tel); holder.tv_content = (TextView) view.findViewById(R.id.tv_content); holder.tv_time = (TextView) view.findViewById(R.id.tv_time); holder.tv_del = (TextView) view.findViewById(R.id.tv_del); holder.iv_add = (ImageView) view.findViewById(R.id.iv_add); holder.iv_del = (ImageView) view.findViewById(R.id.iv_del); holder.tv_price = (TextView) view.findViewById(R.id.tv_pri); holder.tv_num = (TextView) view.findViewById(R.id.tv_num); view.setTag(holder); } else { view = convertView; holder = (ChildViewHolder) view.getTag(); } final GoosBean.DataBean.DatasBean datasBean = childList.get(groupPosition).get(childPosition); holder.cbChild.setChecked(datasBean.isChecked()); holder.tv_tel.setText(datasBean.getType_name()); holder.tv_content.setText(datasBean.getMsg()); holder.tv_time.setText(datasBean.getAdd_time()); holder.tv_price.setText(datasBean.getPrice() + ""); holder.tv_num.setText(datasBean.getNum() + ""); //二级checkbox holder.cbChild.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //设置该条目对象里的checked属性值 datasBean.setChecked(holder.cbChild.isChecked()); PriceAndCountEvent priceAndCountEvent = compute(); EventBus.getDefault().post(priceAndCountEvent); if (holder.cbChild.isChecked()) { //当前checkbox是选中状态 if (isAllChildCbSelected(groupPosition)) { changGroupCbState(groupPosition, true); changeAllCbState(isAllGroupCbSelected()); } } else { changGroupCbState(groupPosition, false); changeAllCbState(isAllGroupCbSelected()); } notifyDataSetChanged(); } }); //加号 holder.iv_add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int num = datasBean.getNum(); holder.tv_num.setText(++num + ""); datasBean.setNum(num); if (holder.cbChild.isChecked()) { PriceAndCountEvent priceAndCountEvent = compute(); EventBus.getDefault().post(priceAndCountEvent); } } }); //减号 holder.iv_del.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int num = datasBean.getNum(); if (num == 1) { return; } holder.tv_num.setText(--num + ""); datasBean.setNum(num); if (holder.cbChild.isChecked()) { PriceAndCountEvent priceAndCountEvent = compute(); EventBus.getDefault().post(priceAndCountEvent); } } }); //二级checkbox holder.tv_del.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //设置该条目对象里的checked属性值 datasBean.setChecked(holder.cbChild.isChecked()); PriceAndCountEvent priceAndCountEvent = compute(); EventBus.getDefault().post(priceAndCountEvent); if (holder.cbChild.isChecked()) { //当前checkbox是选中状态 if (isAllChildCbSelected(groupPosition)) { changGroupCbState(groupPosition, true); changeAllCbState(isAllGroupCbSelected()); } } else { changGroupCbState(groupPosition, false); changeAllCbState(isAllGroupCbSelected()); } notifyDataSetChanged(); } }); //删除 holder.tv_del.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { List<GoosBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition); GoosBean.DataBean.DatasBean remove = datasBeen.remove(childPosition); if (datasBeen.size() == 0) { childList.remove(groupPosition); groupList.remove(groupPosition); } EventBus.getDefault().post(compute()); notifyDataSetChanged(); } }); return view; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } class GroupViewHolder { CheckBox cbGroup; TextView tv_number; } class ChildViewHolder { CheckBox cbChild; TextView tv_tel; TextView tv_content; TextView tv_time; TextView tv_price; TextView tv_del; ImageView iv_del; ImageView iv_add; TextView tv_num; } /** * 改变全选的状态 * * @param flag */ private void changeAllCbState(boolean flag) { MessageEvent messageEvent = new MessageEvent(); messageEvent.setChecked(flag); EventBus.getDefault().post(messageEvent); } /** * 改变一级列表checkbox状态 * * @param groupPosition */ private void changGroupCbState(int groupPosition, boolean flag) { GoosBean.DataBean dataBean = groupList.get(groupPosition); dataBean.setChecked(flag); } /** * 改变二级列表checkbox状态 * * @param groupPosition * @param flag */ private void changeChildCbState(int groupPosition, boolean flag) { List<GoosBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition); for (int i = 0; i < datasBeen.size(); i++) { GoosBean.DataBean.DatasBean datasBean = datasBeen.get(i); datasBean.setChecked(flag); } } /** * 判断一级列表是否全部选中 * * @return */ private boolean isAllGroupCbSelected() { for (int i = 0; i < groupList.size(); i++) { GoosBean.DataBean dataBean = groupList.get(i); if (!dataBean.isChecked()) { return false; } } return true; } /** * 判断二级列表是否全部选中 * * @param groupPosition * @return */ private boolean isAllChildCbSelected(int groupPosition) { List<GoosBean.DataBean.DatasBean> datasBeen = childList.get(groupPosition); for (int i = 0; i < datasBeen.size(); i++) { GoosBean.DataBean.DatasBean datasBean = datasBeen.get(i); if (!datasBean.isChecked()) { return false; } } return true; } /** * 计算列表中,选中的钱和数量 */ private PriceAndCountEvent compute() { int count = 0; int price = 0; for (int i = 0; i < childList.size(); i++) { List<GoosBean.DataBean.DatasBean> datasBeen = childList.get(i); for (int j = 0; j < datasBeen.size(); j++) { GoosBean.DataBean.DatasBean datasBean = datasBeen.get(j); if (datasBean.isChecked()) { price += datasBean.getNum() * datasBean.getPrice(); count += datasBean.getNum(); } } } PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent(); priceAndCountEvent.setCount(count); priceAndCountEvent.setPrice(price); return priceAndCountEvent; } /** * 设置全选、反选 * * @param flag */ public void changeAllListCbState(boolean flag) { for (int i = 0; i < groupList.size(); i++) { changGroupCbState(i, flag); changeChildCbState(i, flag); } EventBus.getDefault().post(compute()); notifyDataSetChanged(); } }
CategoupFragment=========================
package com.example.moni.View.fragment; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ListView; import com.example.moni.Modle.bean.ProductBeans; import com.example.moni.Modle.http.HttpCallback; import com.example.moni.Modle.http.HttpsUntils; import com.example.moni.R; import com.example.moni.View.adapter.ListViewAdapter; import com.google.gson.Gson; import java.util.ArrayList; import java.util.List; public class CategroupFragment extends Fragment { List<ProductBeans.DataBean> dataBeanList = new ArrayList<>(); private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what == 0) { //获取值 String ss = (String) msg.obj; //解析 Gson gson = new Gson(); ProductBeans productBeans = gson.fromJson(ss, ProductBeans.class); List<ProductBeans.DataBean> data = productBeans.getData(); Log.e("mm", data.get(0).getName()); dataBeanList.addAll(data); //适配器的方法 initAdapter(); listViewAdapter.notifyDataSetChanged(); } } }; private ListViewAdapter listViewAdapter; private void initAdapter() { listViewAdapter = new ListViewAdapter(getActivity(), dataBeanList); cate_listview.setAdapter(listViewAdapter); //点击条目加载 cate_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.cate_frame, new MobileFragment()).commit(); } }); } private FrameLayout cate_frame; private ListView cate_listview; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.categroup_layout, container, false); cate_frame = view.findViewById(R.id.cate_frame); cate_listview = view.findViewById(R.id.cate_listview); return view; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); initCateData(); } private void initCateData() { //默认加载 getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.cate_frame, new MobileFragment()).commit(); //获取数据 final String path = "https://www.zhaoapi.cn/product/getCatagory"; HttpsUntils httpsUntils = HttpsUntils.getInstance(); httpsUntils.doPost(path, new HttpCallback() { @Override public void onSuccess(String s) { Message msg = new Message(); msg.what = 0; msg.obj = s; handler.sendMessage(msg); } @Override public void onFail(int errCode, String errMsg) { } }); } }
FragmentShoppingCart================================
package com.example.moni.View.fragment; import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.ExpandableListView; import android.widget.TextView; import com.example.moni.Modle.bean.GoosBean; import com.example.moni.Modle.modle.MessageEvent; import com.example.moni.Modle.modle.PriceAndCountEvent; import com.example.moni.Presenter.presnter.GouPresenter; import com.example.moni.R; import com.example.moni.View.Iview.IMainActivity; import com.example.moni.View.activity.DingWeiActvity; import com.example.moni.View.adapter.MyAdapter; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import java.util.List; public class FragmentShoppingCart extends Fragment implements IMainActivity, View.OnClickListener { private ExpandableListView mElv; private CheckBox mCheckbox2; private TextView mTvPrice; private TextView mTvNum; private MyAdapter adapter; private TextView btn; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.gouwu_layout,container,false); mElv = (ExpandableListView) view.findViewById(R.id.elv); mCheckbox2 = (CheckBox) view.findViewById(R.id.checkbox2); mTvPrice = (TextView) view.findViewById(R.id.tv_price); mTvNum = (TextView) view.findViewById(R.id.tv_num); btn = view.findViewById(R.id.btn); btn.setOnClickListener(this); EventBus.getDefault().register(this); new GouPresenter(this).getGoods(); mCheckbox2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.changeAllListCbState(mCheckbox2.isChecked()); } }); return view; } public void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this); } @Override public void showList(List<GoosBean.DataBean> groupList, List<List<GoosBean.DataBean.DatasBean>> childList) { adapter = new MyAdapter(getActivity(), groupList, childList); mElv.setAdapter(adapter); mElv.setGroupIndicator(null); //默认让其全部展开 for (int i = 0; i < groupList.size(); i++) { mElv.expandGroup(i); } } @Subscribe public void onMessageEvent(MessageEvent event){ mCheckbox2.setChecked(event.isChecked()); } @Subscribe public void onMessageEvent(PriceAndCountEvent event){ mTvNum.setText("结算(" + event.getCount() + ")"); mTvPrice.setText(event.getPrice()+""); } @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), DingWeiActvity.class); getActivity().startActivity(intent); } }
HomeFragment======================================
package com.example.moni.View.fragment; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.example.moni.R; public class HomeFragment extends Fragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.homet_layout, container, false); return view; } }
MobileFfragment===================================
package com.example.moni.View.fragment; import android.annotation.SuppressLint; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ExpandableListView; import com.example.moni.Modle.bean.MobileBeans; import com.example.moni.Modle.http.HttpCallback; import com.example.moni.Modle.http.HttpExpand; import com.example.moni.R; import com.example.moni.View.adapter.EAdapter; import com.google.gson.Gson; import java.util.ArrayList; import java.util.List; public class MobileFragment extends Fragment { private ExpandableListView expand_lv; private List<String> g_list = new ArrayList<>(); private List<List<MobileBeans.DataBean.ListBean>> listAll = new ArrayList<>(); @SuppressLint("HandlerLeak") private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what == 0) { MobileBeans moblieBeans = (MobileBeans) msg.obj; List<MobileBeans.DataBean> data = moblieBeans.getData(); for (int i = 0; i < data.size(); i++) { g_list.add(data.get(i).getName());//父类里面的数据 // Log.e("哈哈", data.get(i).getName()); List<MobileBeans.DataBean.ListBean> list = data.get(i).getList();//子类里面的集合 listAll.add(list); } //设置适配器的方法 getAdapter(); //刷新适配器 eAdapter.notifyDataSetChanged(); } } }; private void getAdapter() { //设置适配器 eAdapter = new EAdapter(getActivity(), g_list, listAll); expand_lv.setAdapter(eAdapter); int groupCount = eAdapter.getGroupCount(); for (int i = 0; i < groupCount; i++) { expand_lv.expandGroup(i); } } private EAdapter eAdapter; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.mobile_layout, container, false); expand_lv = (ExpandableListView) view.findViewById(R.id.expand_lv); return view; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //获取数据 String path = "https://www.zhaoapi.cn/product/getProductCatagory"; HttpExpand instance = HttpExpand.getInstance(); instance.doPost(path, new HttpCallback() { @Override public void onSuccess(String string) { //解析 Gson gson = new Gson(); MobileBeans moblieBeans = gson.fromJson(string, MobileBeans.class); Message msg = new Message(); msg.what = 0; msg.obj = moblieBeans; handler.sendMessage(msg); } @Override public void onFail(int errCode, String errMsg) { } }); } }
IBaseView==================================
package com.example.moni.View.Iview; public interface IBaseView { }
IMainActivity=================================
package com.example.moni.View.Iview; import com.example.moni.Modle.bean.GoosBean; import java.util.List; public interface IMainActivity { public void showList(List<GoosBean.DataBean> groupList, List<List<GoosBean.DataBean.DatasBean>> childList); }
IMainView=========================================
package com.example.moni.View.Iview; public interface IMainView extends IBaseView { void onSuccess(String s); }
MyApp=============================================
package com.example.moni.View; import android.app.Application; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).build(); ImageLoader.getInstance().init(configuration); } }
BasePresenter==================================
package com.example.moni.Presenter.presnter; import com.example.moni.View.Iview.IBaseView; public class BasePresenter <V extends IBaseView> { //关联view private V iBaseView; public void attachView(V iBaseView) { this.iBaseView = iBaseView; } public V getView() { return iBaseView; } //取消关联 public void deachView() { iBaseView = null; } }
GouPresnter======================================
package com.example.moni.Presenter.presnter; import com.example.moni.Modle.bean.GoosBean; import com.example.moni.Modle.modle.IMainModel; import com.example.moni.Modle.modle.MainModel; import com.example.moni.Modle.modle.OnNetListener; import com.example.moni.View.Iview.IMainActivity; import java.util.ArrayList; import java.util.List; public class GouPresenter { private IMainModel iMainModel; private IMainActivity iMainActivity; public GouPresenter(IMainActivity iMainActivity) { this.iMainActivity = iMainActivity; iMainModel = new MainModel(); } public void getGoods() { iMainModel.getGoods(new OnNetListener<GoosBean>() { @Override public void onSuccess(GoosBean goosBean) { List<GoosBean.DataBean> dataBean = goosBean.getData(); List<List<GoosBean.DataBean.DatasBean>> childList = new ArrayList<List<GoosBean.DataBean.DatasBean>>(); for (int i = 0; i < dataBean.size(); i++) { List<GoosBean.DataBean.DatasBean> datas = dataBean.get(i).getDatas(); childList.add(datas); } iMainActivity.showList(dataBean, childList); } @Override public void onFailure(Exception e) { } }); } }
MainPresenter==================================================
package com.example.moni.Presenter.presnter; import android.util.Log; import com.example.moni.Modle.http.HttpCallback; import com.example.moni.Modle.http.HttpsUntils; public class MainPresenter extends BasePresenter { private final HttpsUntils httpsUntils; //获取OKhttp public MainPresenter() { httpsUntils = HttpsUntils.getInstance(); } //加载数据 public void loadData(String path) { httpsUntils.doPost(path, new HttpCallback() { @Override public void onSuccess(String s) { Log.e("myMessage",s); } @Override public void onFail(int errCode, String errMsg) { } }); } }
Api=================================================================
package com.example.moni.Modle.util; public class Api { public static final String url = "http://result.eolinker.com/iYXEPGn4e9c6dafce6e5cdd23287d2bb136ee7e9194d3e9?uri=evaluation"; }
IMainModel======================
package com.example.moni.Modle.modle; import com.example.moni.Modle.bean.GoosBean; public interface IMainModel { public void getGoods(OnNetListener<GoosBean> onNetListener); }
MainModel=================================
package com.example.moni.Modle.modle; import android.os.Handler; import android.os.Looper; import com.example.moni.Modle.bean.GoosBean; import com.example.moni.Modle.http.GouHttps; import com.example.moni.Modle.util.Api; import com.google.gson.Gson; import java.io.IOException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Response; public class MainModel implements IMainModel { private Handler handler = new Handler(Looper.getMainLooper()); public void getGoods(final OnNetListener<GoosBean> onNetListener){ GouHttps.getHttpUtils().doGet(Api.url, new Callback() { @Override public void onFailure(Call call, IOException e) { } @Override public void onResponse(Call call, Response response) throws IOException { String string = response.body().string(); final GoosBean goosBean = new Gson().fromJson(string, GoosBean.class); handler.post(new Runnable() { @Override public void run() { onNetListener.onSuccess(goosBean); } }); } }); } }
MessageEvent=====================================
package com.example.moni.Modle.modle; public class MessageEvent { private boolean checked; public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } }
OnNetListenter================================
package com.example.moni.Modle.modle; public interface OnNetListener<T> { public void onSuccess(T t); public void onFailure(Exception e); }
PriceAndCountEvent==================================
package com.example.moni.Modle.modle; public class PriceAndCountEvent { private int price; private int count; public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } }
GouHttps====================================
package com.example.moni.Modle.http; import okhttp3.Callback; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.logging.HttpLoggingInterceptor; public class GouHttps { private static volatile GouHttps httpUtils; private final OkHttpClient client; private GouHttps(){ HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); client = new OkHttpClient.Builder() .addInterceptor(loggingInterceptor) .build(); } public static GouHttps getHttpUtils(){ if(httpUtils==null){ synchronized (GouHttps.class){ if (httpUtils==null){ httpUtils = new GouHttps(); } } } return httpUtils; } /** * GET请求 * * @param url * @param callback */ public void doGet(String url, Callback callback){ Request request = new Request.Builder().url(url).build(); client.newCall(request).enqueue(callback); } }
HttpCallback=========================
package com.example.moni.Modle.http; public interface HttpCallback { void onSuccess(String s); void onFail(int errCode, String errMsg); }
HttpExpand================================
package com.example.moni.Modle.http; import java.io.IOException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.FormBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.logging.HttpLoggingInterceptor; public class HttpExpand implements Callback { private static HttpExpand INSTANCE; private final OkHttpClient okHttpClient; //单例模式 public static HttpExpand getInstance() { if (INSTANCE == null) { synchronized (HttpExpand.class) { if (INSTANCE == null) { INSTANCE = new HttpExpand(); } } } return INSTANCE; } //拦截器 public HttpExpand() { HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); okHttpClient = new OkHttpClient.Builder() .addInterceptor(loggingInterceptor) .build(); } private HttpCallback httpCallback; public String doPost(String path, HttpCallback httpCallback) { this.httpCallback = httpCallback; FormBody formBody = new FormBody.Builder().build(); Request request = new Request.Builder().url(path).post(formBody).build(); Call call = okHttpClient.newCall(request); call.enqueue(this); return ""; } @Override public void onFailure(Call call, IOException e) { } @Override public void onResponse(Call call, Response response) throws IOException { String string = response.body().string(); httpCallback.onSuccess(string); } }
HttpsUntils=============================
package com.example.moni.Modle.http; import java.io.IOException; import okhttp3.Call; import okhttp3.Callback; import okhttp3.FormBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.logging.HttpLoggingInterceptor; public class HttpsUntils implements Callback { private static HttpsUntils INSTANCE; private final OkHttpClient okHttpClient; //单例模式 public static HttpsUntils getInstance() { if (INSTANCE == null) { synchronized (HttpsUntils.class) { if (INSTANCE == null) { INSTANCE = new HttpsUntils(); } } } return INSTANCE; } //拦截器 public HttpsUntils() { HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); okHttpClient = new OkHttpClient.Builder() .addInterceptor(loggingInterceptor) .build(); } //get public String doGet(String path) { Request request = new Request.Builder().url(path).build(); Call call = okHttpClient.newCall(request); call.enqueue(this); return ""; } //post private HttpCallback httpCallback; public String doPost(String path, HttpCallback httpCallback) { this.httpCallback = httpCallback; FormBody formBody = new FormBody.Builder().build(); Request request = new Request.Builder().url(path).post(formBody).build(); Call call = okHttpClient.newCall(request); call.enqueue(this); return ""; } @Override public void onFailure(Call call, IOException e) { } @Override public void onResponse(Call call, Response response) throws IOException { String string = response.body().string(); httpCallback.onSuccess(string); } }
CartBean=================================
package com.example.moni.Modle.bean; import java.util.List; public class CartBean { /** * msg : 请求成功 * code : 0 * data : [{"list":[{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}],"sellerName":"商家2","sellerid":"2"}] */ 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 { /** * list : [{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}] * sellerName : 商家2 * sellerid : 2 */ private boolean checked; private String sellerName; private String sellerid; private List<ListBean> list; private boolean editor; public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public boolean isEditor() { return editor; } public void setEditor(boolean editor) { this.editor = editor; } public String getSellerName() { return sellerName; } public void setSellerName(String sellerName) { this.sellerName = sellerName; } public String getSellerid() { return sellerid; } public void setSellerid(String sellerid) { this.sellerid = sellerid; } public List<ListBean> getList() { return list; } public void setList(List<ListBean> list) { this.list = list; } public static class ListBean { /** * bargainPrice : 6666 * createtime : 2017-10-10T16:01:31 * detailUrl : https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends * images : https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg * num : 1 * pid : 46 * price : 234 * pscid : 39 * selected : 0 * sellerid : 2 * subhead : 【iPhone新品上市】新一代iPhone,让智能看起来更不一样 * title : Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机 */ private boolean checked; private double bargainPrice; private String createtime; private String detailUrl; private String images; private int num; private int pid; private double price; private int pscid; private int selected; private int sellerid; private String subhead; private String title; public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public double getBargainPrice() { return bargainPrice; } public void setBargainPrice(double bargainPrice) { this.bargainPrice = bargainPrice; } public String getCreatetime() { return createtime; } public void setCreatetime(String createtime) { this.createtime = createtime; } public String getDetailUrl() { return detailUrl; } public void setDetailUrl(String detailUrl) { this.detailUrl = detailUrl; } public String getImages() { return images; } public void setImages(String images) { this.images = images; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } public int getPid() { return pid; } public void setPid(int pid) { this.pid = pid; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public int getPscid() { return pscid; } public void setPscid(int pscid) { this.pscid = pscid; } public int getSelected() { return selected; } public void setSelected(int selected) { this.selected = selected; } public int getSellerid() { return sellerid; } public void setSellerid(int sellerid) { this.sellerid = sellerid; } public String getSubhead() { return subhead; } public void setSubhead(String subhead) { this.subhead = subhead; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } } }
GoosBean===============================
package com.example.moni.Modle.bean; import java.util.List; public class GoosBean { /** * code : 200 * data : [{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"购买渠道:大陆国行","price":500,"type_name":"苹果 iPhone 6(白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"购买渠道:水货无锁","price":1000,"type_name":"苹果 iPhone 7 (亮黑色)","type_sn_id":"tgg"}],"title":"苹果","title_id":"59280"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"小米4s (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"小米5s (亮黑色)","type_sn_id":"tgg"}],"title":"小米","title_id":"59279"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"三星 (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"三星 (亮黑色)","type_sn_id":"tgg"}],"title":"三星","title_id":"59279"},{"datas":[{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"边框背板:全新未使用","price":50,"type_name":"华为 (白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":100,"type_name":"华为 (亮黑色)","type_sn_id":"tgg"},{"add_time":"2016-12-10 4:55:28","cart_id":"445164","house_id":"1","msg":"屏幕性能:色差/亮点/轻微发黄","price":150,"type_name":"华为 (纯黑色)","type_sn_id":"hgg"}],"title":"华为","title_id":"59279"}] * flag : Success * msg : 描述 */ private String code; private String flag; private String msg; private List<DataBean> data; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getFlag() { return flag; } public void setFlag(String flag) { this.flag = flag; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public List<DataBean> getData() { return data; } public void setData(List<DataBean> data) { this.data = data; } public static class DataBean { /** * datas : [{"add_time":"2016-12-10 14:54:58","cart_id":"445162","house_id":"1","msg":"购买渠道:大陆国行","price":500,"type_name":"苹果 iPhone 6(白金色)","type_sn_id":"ggh"},{"add_time":"2016-12-10 14:55:18","cart_id":"445163","house_id":"1","msg":"购买渠道:水货无锁","price":1000,"type_name":"苹果 iPhone 7 (亮黑色)","type_sn_id":"tgg"}] * title : 苹果 * title_id : 59280 */ private boolean checked; private String title; private String title_id; private List<DatasBean> datas; public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getTitle_id() { return title_id; } public void setTitle_id(String title_id) { this.title_id = title_id; } public List<DatasBean> getDatas() { return datas; } public void setDatas(List<DatasBean> datas) { this.datas = datas; } public static class DatasBean { /** * add_time : 2016-12-10 14:54:58 * cart_id : 445162 * house_id : 1 * msg : 购买渠道:大陆国行 * price : 500 * type_name : 苹果 iPhone 6(白金色) * type_sn_id : ggh */ private boolean checked; private int num = 1; private String add_time; private String cart_id; private String house_id; private String msg; private int price; private String type_name; private String type_sn_id; public int getNum() { return num; } public void setNum(int num) { this.num = num; } public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public String getAdd_time() { return add_time; } public void setAdd_time(String add_time) { this.add_time = add_time; } public String getCart_id() { return cart_id; } public void setCart_id(String cart_id) { this.cart_id = cart_id; } public String getHouse_id() { return house_id; } public void setHouse_id(String house_id) { this.house_id = house_id; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public String getType_name() { return type_name; } public void setType_name(String type_name) { this.type_name = type_name; } public String getType_sn_id() { return type_sn_id; } public void setType_sn_id(String type_sn_id) { this.type_sn_id = type_sn_id; } } } }
MobileBeans===================================
package com.example.moni.Modle.bean; import java.util.List; public class MobileBeans { /** * 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; } } } }
ProductBeans===========================================
package com.example.moni.Modle.bean; import java.util.List; public class ProductBeans { /** * 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; } } }