需要使用的依赖和方法
//retrofit implementation 'com.squareup.retrofit2:retrofit:2.3.0' //rxjava implementation 'io.reactivex.rxjava2:rxjava:2.1.1' //rxandroid implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' //配合Rxjava 使用 implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' //转换器 将结果通过gson将json串转换为model implementation 'com.squareup.retrofit2:converter-gson:2.3.0' //GSON库 implementation 'com.google.code.gson:gson:2.8.1' //okhttp implementation 'com.squareup.okhttp3:okhttp:3.10.0' //okhttp日志拦截器 implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' //recyclerview implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:support-v4:27.1.1' //fresco implementation 'com.facebook.fresco:fresco:0.12.0' //ecentBus implementation 'org.greenrobot:eventbus:3.1.1' //gaode implementation 'com.amap.api:3dmap:latest.integration' //定位功能 implementation 'com.amap.api:location:latest.integration' //刷新 implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-7'
<!-- 允许程序打开网络套接字 --> <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" />
activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<FrameLayout
android:id="@+id/mylf"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9">
</FrameLayout>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<RadioButton
android:id="@+id/home"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:button="@null"
android:background="@drawable/radiobutton_home_bg"/>
<RadioButton
android:id="@+id/order"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:button="@null"
android:background="@drawable/radiobutton_order_bg"/>
<RadioButton
android:id="@+id/mine"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:button="@null"
android:background="@drawable/radiobutton_mine_bg"/>
</RadioGroup>
</LinearLayout>
activity_gad_map
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GadMapActivity">
<com.amap.api.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.amap.api.maps.MapView>
</RelativeLayout>
home_fragment
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_home_fragment"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="36dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="6dp"
android:textColor="#000"
android:textSize="18dp"
android:text="麦当当外卖"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<Button
android:id="@+id/ditu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="位置信息"/>
<EditText
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginLeft="120dp"
android:hint="请输入信息"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/food"
android:layout_centerHorizontal="true"
android:id="@+id/foodimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/foodimage"
android:layout_centerHorizontal="true"
android:text="美食" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/meituan"
android:layout_centerHorizontal="true"
android:id="@+id/meituanimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/meituanimage"
android:layout_centerHorizontal="true"
android:text="美团超市" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/vegetables"
android:layout_centerHorizontal="true"
android:id="@+id/vegetablesimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/vegetablesimage"
android:layout_centerHorizontal="true"
android:text="生鲜果蔬" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/afternoontea"
android:layout_centerHorizontal="true"
android:id="@+id/afternoonteaimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/afternoonteaimage"
android:layout_centerHorizontal="true"
android:text="下午茶" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/preference"
android:layout_centerHorizontal="true"
android:id="@+id/preferenceimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/preferenceimage"
android:layout_centerHorizontal="true"
android:text="正餐优选" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/hamburgerpizza"
android:layout_centerHorizontal="true"
android:id="@+id/hamburgerpizzaimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/hamburgerpizzaimage"
android:layout_centerHorizontal="true"
android:text="汉堡披萨" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/running"
android:layout_centerHorizontal="true"
android:id="@+id/runningimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/runningimage"
android:layout_centerHorizontal="true"
android:text="跑腿代购" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/snackbar"
android:layout_centerHorizontal="true"
android:id="@+id/snackbarimage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/snackbarimage"
android:layout_centerHorizontal="true"
android:text="快餐简餐" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="---- 附近商家 ----"
android:layout_centerInParent="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="综合排序"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="销量最高"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="距离最近"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="筛选"
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/home_shop_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</ScrollView>
</FrameLayout>
home_recycleview_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/img_headportrait"
android:layout_width="100dp"
android:layout_height="70dp">
</com.facebook.drawee.view.SimpleDraweeView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"/>
<TextView
android:id="@+id/monthlysale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:background="@drawable/minus"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="满20减18,满45减40,满60减53"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:background="@drawable/fold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="折扣商品7.33折起"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
order_fragment
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/my_order_fragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/title"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起送 ¥10 | 配送 ¥0 | 50分钟"
android:textColor="#fff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="理工短号615592(原大学生粗粮坊)..."
android:textColor="#fff"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000"
android:layout_marginTop="3dp">
<ImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:background="@drawable/minus"
android:id="@+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="5dp"
android:layout_toEndOf="@+id/imageView"
android:text="满20减18,满45减40,满60减53"
android:textColor="#fff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="11dp"
android:text="3个活动 >"
android:textColor="#fff" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#fff"
android:text="点菜"
android:textColor="#FFD700"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#fff"
android:text="评价"
android:textColor="#000"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#fff"
android:text="商家"
android:textColor="#000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:id="@+id/order_leftRecyclerView"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:id="@+id/order_rightRecyclerView"
android:layout_width="0dp"
android:layout_weight="8"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#696969"/>
<ImageView
android:id="@+id/order_shop_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/ic_shopping_cart_grey_700_24dp"/>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
order_left_item
<?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="horizontal">
<TextView
android:id="@+id/restaurant_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
order_right_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/commoditypreview"
android:layout_width="30dp"
android:layout_height="30dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/packagenum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="54534534354"/>
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/packagenum"
android:layout_marginTop="10dp"
android:text="50.00" />
<Button
android:id="@+id/add"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="+" />
</RelativeLayout>
</LinearLayout>
drawable文件夹下radiobutton_home_bg
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/index_active"/>
<item android:state_checked="false" android:drawable="@drawable/index"/>
</selector>
radiobutton_order_bg
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/order_active"/>
<item android:state_checked="false" android:drawable="@drawable/order"/>
</selector>
radiobutton_mine_bg
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/home_active"/>
<item android:state_checked="false" android:drawable="@drawable/home"/>
</selector>
shop_order_bg
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@drawable/ic_shopping_cart_grey_700_24dp"/>
<item android:state_selected="false"
android:drawable="@drawable/ic_shopping_cart_grey_700_24dp"/>
</selector>
MainActivity
import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.FrameLayout; import android.widget.RadioButton; import android.widget.Toast; import com.bwie.test.mymonthtest.fragment.HomeFragment; import com.bwie.test.mymonthtest.fragment.OrderFragment; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private RadioButton home; private RadioButton Order; private RadioButton mine; private HomeFragment homeFragment; private FragmentManager fragmentManager; private OrderFragment orderFragment; private int home_commit; private int order_commit; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView();//初始化控件 fragmentManager = getSupportFragmentManager(); homeFragment = new HomeFragment(); orderFragment = new OrderFragment(); home_commit = fragmentManager.beginTransaction().replace(R.id.mylf, homeFragment).commit(); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.home: if (home_commit == 0){ fragmentManager.beginTransaction().replace(R.id.mylf, homeFragment).commit(); } else { fragmentManager.beginTransaction().replace(R.id.mylf, homeFragment).commit(); Toast.makeText(this,"home显示", Toast.LENGTH_SHORT).show(); } Toast.makeText(this, "home点击", Toast.LENGTH_SHORT).show(); break; case R.id.order: if(order_commit == 0){ order_commit = fragmentManager.beginTransaction().replace(R.id.mylf, orderFragment) .commit(); } else { fragmentManager.beginTransaction().replace(R.id.mylf, orderFragment).commit(); Toast.makeText(this,"Order点击",Toast.LENGTH_SHORT).show(); } break; } } private void initView() { home = (RadioButton) findViewById(R.id.home); Order = (RadioButton) findViewById(R.id.order); mine = (RadioButton) findViewById(R.id.mine); home.setOnClickListener(this); Order.setOnClickListener(this); } }
GadMapActivity
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; 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.LocationSource; import com.amap.api.maps.MapView; import com.amap.api.maps.model.MyLocationStyle; public class GadMapActivity extends AppCompatActivity implements LocationSource, AMapLocationListener{ MapView mMapView = null; AMap aMap; OnLocationChangedListener mListener; AMapLocationClient mlocationClient; AMapLocationClientOption mLocationOption; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gad_map); //查找控件 mMapView = (MapView) findViewById(R.id.map); //在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图 mMapView.onCreate(savedInstanceState); if (aMap == null) { aMap = mMapView.getMap(); } // aMap.setLocationSource(this); //aMap.setMyLocationEnabled(true); //aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); MyLocationStyle myLocationStyle; myLocationStyle = new MyLocationStyle(); myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE); myLocationStyle.interval(2000); aMap.setMyLocationStyle(myLocationStyle); aMap.getUiSettings().setMyLocationButtonEnabled(true); aMap.setMyLocationEnabled(true); } @Override protected void onDestroy() { super.onDestroy(); mMapView.onDestroy(); } @Override protected void onResume() { super.onResume(); mMapView.onResume(); } @Override protected void onPause() { super.onPause(); mMapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mMapView.onSaveInstanceState(outState); } @Override public void activate(OnLocationChangedListener onLocationChangedListener) { mListener = onLocationChangedListener; if (mlocationClient == null) { //初始化定位 mlocationClient = new AMapLocationClient(this); //初始化定位参数 mLocationOption = new AMapLocationClientOption(); //设置定位回调监听 mlocationClient.setLocationListener(this); //设置为高精度定位模式 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //设置定位参数 mlocationClient.setLocationOption(mLocationOption); mlocationClient.startLocation(); } } @Override public void deactivate() { mListener = null; if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); } mlocationClient = null; } @Override public void onLocationChanged(AMapLocation aMapLocation) { if (mListener != null&& aMapLocation != null) { if (aMapLocation != null &&aMapLocation.getErrorCode() == 0) { mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点 } else { String errText = "定位失败," + aMapLocation.getErrorCode()+ ": " + aMapLocation.getErrorInfo(); Log.e("AmapErr",errText); } } } }
app文件夹下MyApp
import android.app.Application; import com.facebook.drawee.backends.pipeline.Fresco; public class MyApp extends Application{ @Override public void onCreate() { super.onCreate(); //初始化fresco Fresco.initialize(this); } }
fragment文件夹下HomeFragment
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.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.FrameLayout; import com.bwie.test.adapter.HomeAdapter; import com.bwie.test.bean.RestaurantData; import com.bwie.test.mymonthtest.GadMapActivity; import com.bwie.test.mymonthtest.R; import com.bwie.test.mymonthtest.inter.HomeView; import com.bwie.test.presenter.HomePresenter; import java.util.List; public class HomeFragment extends Fragment implements HomeView, View.OnClickListener{ private FrameLayout myHomeFragment; private RecyclerView homeOrderRecyclerView; private RecyclerView homeShopRecyclerView; private Button btnMap; private HomePresenter homePresenter; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.home_fragment, null); initView(view); homePresenter = new HomePresenter(this); homePresenter.getHomeData(); return view; } @Override public void onDestroy() { super.onDestroy(); homePresenter.closeView(); } private void initView(View view) { myHomeFragment = (FrameLayout) view.findViewById(R.id.my_home_fragment); homeShopRecyclerView = (RecyclerView) view.findViewById(R.id.home_shop_recyclerView); homeShopRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); btnMap = (Button) view.findViewById(R.id.ditu); btnMap.setOnClickListener(this); } @Override public void showData(RestaurantData restaurantData) { List<RestaurantData.DataBean> data = restaurantData.getData(); HomeAdapter homeAdapter = new HomeAdapter(getContext(), data); homeShopRecyclerView.setAdapter(homeAdapter); } @Override public void onClick(View v) { btnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), GadMapActivity.class); startActivity(intent); } }); } }
OrderFragment
import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import com.bwie.test.adapter.OrderLeftAdapter; import com.bwie.test.adapter.OrderRightAdapter; import com.bwie.test.bean.ProductDetailsData; import com.bwie.test.mymonthtest.R; import com.bwie.test.mymonthtest.inter.OrderView; import com.bwie.test.presenter.OrderPresenter; import java.util.List; public class OrderFragment extends Fragment implements OrderView{ private RecyclerView orderLeftRecyclerView; private RecyclerView orderRightRecyclerView; private OrderPresenter orderPresenter; private OrderLeftAdapter orderLeftAdapter; private List<ProductDetailsData.DataBean> data; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.order_fragment, null); initView(view); orderPresenter = new OrderPresenter(this); orderPresenter.getOrderData(); return view; } @Override public void onDestroy() { super.onDestroy(); orderPresenter.closeView(); } private void initView(View view) { orderLeftRecyclerView = (RecyclerView) view.findViewById(R.id.order_leftRecyclerView); orderRightRecyclerView = (RecyclerView) view.findViewById(R.id.order_rightRecyclerView); orderLeftRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); orderRightRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); } @Override public void showData(ProductDetailsData productDetailsData) { data = productDetailsData.getData(); orderLeftAdapter = new OrderLeftAdapter(getContext(), data); orderLeftRecyclerView.setAdapter(orderLeftAdapter); orderLeftAdapter.setOnClickListener(new OrderLeftAdapter.OnItemClickListener() { @Override public void onItemClick(int position) { Toast.makeText(getContext(), "点击了下标为"+position+"的条目", Toast.LENGTH_SHORT).show(); List<ProductDetailsData.DataBean.SpusBean> spus = data.get(position).getSpus(); OrderRightAdapter orderRightAdapter = new OrderRightAdapter(getContext(), spus); orderRightRecyclerView.setAdapter(orderRightAdapter); } }); } private void initRightData(ProductDetailsData productDetailsData,int position) { List<ProductDetailsData.DataBean> data = productDetailsData.getData(); List<ProductDetailsData.DataBean.SpusBean> spus = data.get(position).getSpus(); OrderRightAdapter orderRightAdapter = new OrderRightAdapter(getContext(), spus); orderRightRecyclerView.setAdapter(orderRightAdapter); } }
inter文件夹下HomeView
import com.bwie.test.bean.RestaurantData; public interface HomeView { void showData(RestaurantData restaurantData); }
OrderView
import com.bwie.test.bean.ProductDetailsData; public interface OrderView { void showData(ProductDetailsData productDetailsData); }
model文件夹下HomeModel
import android.util.Log; import com.bwie.test.bean.RestaurantData; import com.bwie.test.model.inter_model.IHomeModel; import com.bwie.test.net.ApiService; import com.bwie.test.net.RetrofitUtils; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class HomeModel implements IHomeModel{ @Override public void getHome(final OnHomeListener onHomeListener) { ApiService apiService = RetrofitUtils.getInstener().getCreate(); apiService.getHome() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<RestaurantData>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(RestaurantData restaurantData) { onHomeListener.onHomeListener(restaurantData); } @Override public void onError(Throwable e) { Log.d("HomeModel","e:" + e); } @Override public void onComplete() { } }); } }
OrderModel
import android.util.Log; import com.bwie.test.bean.ProductDetailsData; import com.bwie.test.model.inter_model.IOrderModel; import com.bwie.test.net.ApiService; import com.bwie.test.net.RetrofitUtils; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class OrderModel implements IOrderModel{ @Override public void getOrder(final OnOrderListener onOrderListener) { ApiService apiService = RetrofitUtils.getInstener().getCreate(); apiService.getOrder() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<ProductDetailsData>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(ProductDetailsData productDetailsData) { onOrderListener.onOrderListener(productDetailsData); } @Override public void onError(Throwable e) { Log.d("OrderModel", "e:" + e); } @Override public void onComplete() { } }); } }
inter_model文件夹下IHomeModel
import com.bwie.test.bean.RestaurantData; public interface IHomeModel { void getHome(OnHomeListener onHomeListener); interface OnHomeListener{ void onHomeListener(RestaurantData restaurantData); } }
IOrderModel
import com.bwie.test.bean.ProductDetailsData; public interface IOrderModel { void getOrder(OnOrderListener onOrderListener); interface OnOrderListener{ void onOrderListener(ProductDetailsData productDetailsData); } }
presenter文件夹下HomePresenter
import com.bwie.test.bean.RestaurantData; import com.bwie.test.model.HomeModel; import com.bwie.test.model.inter_model.IHomeModel; import com.bwie.test.mymonthtest.inter.HomeView; import com.bwie.test.presenter.inter_presenter.IHomePresenter; public class HomePresenter implements IHomePresenter{ private HomeView homeView; private final HomeModel homeModel; public HomePresenter(HomeView homeView) { this.homeView = homeView; homeModel = new HomeModel(); } @Override public void getHomeData() { //调用M层方法获取数据,传给V层 homeModel.getHome(new HomeModel.OnHomeListener() { @Override public void onHomeListener(RestaurantData restaurantData) { homeView.showData(restaurantData); } }); } public void closeView(){ if (homeView != null){ homeView = null; } } }
OrderPresenter
import com.bwie.test.bean.ProductDetailsData; import com.bwie.test.model.OrderModel; import com.bwie.test.mymonthtest.inter.OrderView; import com.bwie.test.presenter.inter_presenter.IOrderPresenter; public class OrderPresenter implements IOrderPresenter{ private OrderView orderView; private final OrderModel orderModel; public OrderPresenter(OrderView orderView) { this.orderView = orderView; orderModel = new OrderModel(); } @Override public void getOrderData() { orderModel.getOrder(new OrderModel.OnOrderListener(){ @Override public void onOrderListener(ProductDetailsData productDetailsData) { orderView.showData(productDetailsData); } }); } //解耦 public void closeView(){ if (orderView!=null) orderView=null; } }
inter_presenter文件夹下IHomePresenter
public interface IHomePresenter { void getHomeData(); }
IOrderPresenter
public interface IOrderPresenter { void getOrderData(); }
adapter文件夹下HomeAdapter
import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.bwie.test.bean.RestaurantData; import com.bwie.test.mymonthtest.R; import com.facebook.drawee.view.SimpleDraweeView; import java.util.List; public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.HomeViewHolder>{ private Context context; private List<RestaurantData.DataBean> list; private final LayoutInflater inflater; public HomeAdapter(Context context, List<RestaurantData.DataBean> data) { this.context = context; list = data; inflater = LayoutInflater.from(context); } @NonNull @Override public HomeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = inflater.inflate(R.layout.home_recycleview_item, null); HomeViewHolder holder = new HomeViewHolder(view); return holder; } @Override public void onBindViewHolder(@NonNull HomeViewHolder holder, int position) { holder.imgHeadportrait.setImageURI(Uri.parse(list.get(position).getPic_url())); holder.title.setText(list.get(position).getName()); holder.monthlysale.setText(list.get(position).getMonth_sales_tip()); holder.price.setText(list.get(position).getMin_price_tip()+" | "+list.get(position) .getShipping_fee_tip()+" | "+list.get(position).getAverage_price_tip()); } @Override public int getItemCount() { return list.size(); } class HomeViewHolder extends RecyclerView.ViewHolder { private SimpleDraweeView imgHeadportrait; private TextView title; private TextView monthlysale; private TextView price; public HomeViewHolder(View itemView) { super(itemView); imgHeadportrait = (SimpleDraweeView) itemView.findViewById(R.id.img_headportrait); title = (TextView) itemView.findViewById(R.id.title); monthlysale = (TextView) itemView.findViewById(R.id.monthlysale); price = (TextView) itemView.findViewById(R.id.price); } } }
OrderLeftAdapter
import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.bwie.test.bean.ProductDetailsData; import com.bwie.test.mymonthtest.R; import java.util.List; public class OrderLeftAdapter extends RecyclerView.Adapter<OrderLeftAdapter.OrderViewHolder>{ private Context context; private List<ProductDetailsData.DataBean> list; private final LayoutInflater inflater; private OnItemClickListener onItemClickListener; public OrderLeftAdapter(Context context, List<ProductDetailsData.DataBean> data) { this.context = context; list = data; inflater = LayoutInflater.from(context); } public void setOnClickListener(OnItemClickListener onClickListener){ onItemClickListener = onClickListener; } public interface OnItemClickListener{ void onItemClick(int position); } @NonNull @Override public OrderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = inflater.inflate(R.layout.order_left_item, null); OrderViewHolder holder = new OrderViewHolder(view); return holder; } @Override public void onBindViewHolder(@NonNull OrderViewHolder holder,final int position) { holder.title.setText(list.get(position).getName()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null!=onItemClickListener) onItemClickListener.onItemClick(position); } }); } @Override public int getItemCount() { return list.size(); } class OrderViewHolder extends RecyclerView.ViewHolder { private TextView title; public OrderViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.restaurant_name); } } }
OrderRightAdapter
import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import com.bwie.test.bean.ProductDetailsData; import com.bwie.test.mymonthtest.R; import com.facebook.drawee.view.SimpleDraweeView; import java.util.List; public class OrderRightAdapter extends RecyclerView.Adapter<OrderRightAdapter.OrderViewHolder>{ private Context context; private List<ProductDetailsData.DataBean.SpusBean> list; private final LayoutInflater inflater; public OrderRightAdapter(Context context, List<ProductDetailsData.DataBean.SpusBean> spus) { this.context = context; list = spus; inflater = LayoutInflater.from(context); } @NonNull @Override public OrderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = inflater.inflate(R.layout.order_right_item, null); OrderViewHolder holder = new OrderViewHolder(view); return holder; } @Override public void onBindViewHolder(@NonNull OrderViewHolder holder, int position) { holder.commoditypreview.setImageURI(Uri.parse(list.get(position).getPic_url())); holder.packagenum.setText(list.get(position).getName()); holder.price.setText(list.get(position).getSkus().get(0).getPrice()); } @Override public int getItemCount() { return list.size(); } class OrderViewHolder extends RecyclerView.ViewHolder { private SimpleDraweeView commoditypreview; private TextView packagenum; private TextView price; private Button add; public OrderViewHolder(View itemView) { super(itemView); commoditypreview = (SimpleDraweeView) itemView.findViewById(R.id.commoditypreview); packagenum = (TextView) itemView.findViewById(R.id.packagenum); price = (TextView) itemView.findViewById(R.id.price); add = (Button) itemView.findViewById(R.id.add); } } }
net文件夹下ApiService
import com.bwie.test.bean.ProductDetailsData; import com.bwie.test.bean.RestaurantData; import io.reactivex.Observable; import retrofit2.http.GET; public interface ApiService { @GET("restaurants_offset_0_limit_4") Observable<RestaurantData> getHome(); @GET("restaurant-list") Observable<ProductDetailsData> getOrder(); }
RetrofitUtils
import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; public class RetrofitUtils { private static RetrofitUtils instener; private final OkHttpClient okHttpClient; private final Retrofit retrofit; private RetrofitUtils(){ HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BODY); okHttpClient = new OkHttpClient.Builder() .connectTimeout(5, TimeUnit.SECONDS) .readTimeout(5, TimeUnit.SECONDS) .writeTimeout(5, TimeUnit.SECONDS) .build(); retrofit = new Retrofit.Builder() .baseUrl("http://www.wanandroid.com/tools/mockapi/6523/") .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .client(okHttpClient) .build(); } public static synchronized RetrofitUtils getInstener(){ synchronized (RetrofitUtils.class){ if (instener == null){ instener = new RetrofitUtils(); } } return instener; } public ApiService getCreate(){ return retrofit.create(ApiService.class); } }
bean文件夹下ProductDetailsData
import java.util.List; public class ProductDetailsData { private int status; private String message; private List<DataBean> data; public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public List<DataBean> getData() { return data; } public void setData(List<DataBean> data) { this.data = data; } public static class DataBean { private int id; private String name; private int restaurant_id; private String created_at; private int __v; private List<SpusBean> spus; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getRestaurant_id() { return restaurant_id; } public void setRestaurant_id(int restaurant_id) { this.restaurant_id = restaurant_id; } public String getCreated_at() { return created_at; } public void setCreated_at(String created_at) { this.created_at = created_at; } public int get__v() { return __v; } public void set__v(int __v) { this.__v = __v; } public List<SpusBean> getSpus() { return spus; } public void setSpus(List<SpusBean> spus) { this.spus = spus; } public static class SpusBean { private String _id; private int id; private int restaurant_id; private int category_id; private String name; private int praise_num; private String praise_content; private int month_saled; private String month_saled_content; private String pic_url; private int __v; private String created_at; private List<SkusBean> skus; private List<?> attrs; private List<?> status_remind_list; public String get_id() { return _id; } public void set_id(String _id) { this._id = _id; } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getRestaurant_id() { return restaurant_id; } public void setRestaurant_id(int restaurant_id) { this.restaurant_id = restaurant_id; } public int getCategory_id() { return category_id; } public void setCategory_id(int category_id) { this.category_id = category_id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getPraise_num() { return praise_num; } public void setPraise_num(int praise_num) { this.praise_num = praise_num; } public String getPraise_content() { return praise_content; } public void setPraise_content(String praise_content) { this.praise_content = praise_content; } public int getMonth_saled() { return month_saled; } public void setMonth_saled(int month_saled) { this.month_saled = month_saled; } public String getMonth_saled_content() { return month_saled_content; } public void setMonth_saled_content(String month_saled_content) { this.month_saled_content = month_saled_content; } public String getPic_url() { return pic_url; } public void setPic_url(String pic_url) { this.pic_url = pic_url; } public int get__v() { return __v; } public void set__v(int __v) { this.__v = __v; } public String getCreated_at() { return created_at; } public void setCreated_at(String created_at) { this.created_at = created_at; } public List<SkusBean> getSkus() { return skus; } public void setSkus(List<SkusBean> skus) { this.skus = skus; } public List<?> getAttrs() { return attrs; } public void setAttrs(List<?> attrs) { this.attrs = attrs; } public List<?> getStatus_remind_list() { return status_remind_list; } public void setStatus_remind_list(List<?> status_remind_list) { this.status_remind_list = status_remind_list; } public static class SkusBean { private String description; private String price; private int id; private String _id; public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String get_id() { return _id; } public void set_id(String _id) { this._id = _id; } } } } }
RestaurantData
import java.util.List; public class RestaurantData { private int status; private String message; private List<DataBean> data; public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public List<DataBean> getData() { return data; } public void setData(List<DataBean> data) { this.data = data; } public static class DataBean { private String _id; private int id; private String name; private double month_sales; private String month_sales_tip; private double wm_poi_score; private double delivery_score; private double quality_score; private double pack_score; private double food_score; private String delivery_time_tip; private String third_category; private String pic_url; private String shopping_time_start; private String shopping_time_end; private double min_price; private String min_price_tip; private double shipping_fee; private String shipping_fee_tip; private String bulletin; private String address; private String call_center; private String distance; private String average_price_tip; private double comment_number; private String lng; private String lat; private double __v; private String created_at; private List<Discounts2Bean> discounts2; public String get_id() { return _id; } public void set_id(String _id) { this._id = _id; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getMonth_sales() { return month_sales; } public void setMonth_sales(double month_sales) { this.month_sales = month_sales; } public String getMonth_sales_tip() { return month_sales_tip; } public void setMonth_sales_tip(String month_sales_tip) { this.month_sales_tip = month_sales_tip; } public double getWm_poi_score() { return wm_poi_score; } public void setWm_poi_score(double wm_poi_score) { this.wm_poi_score = wm_poi_score; } public double getDelivery_score() { return delivery_score; } public void setDelivery_score(double delivery_score) { this.delivery_score = delivery_score; } public double getQuality_score() { return quality_score; } public void setQuality_score(double quality_score) { this.quality_score = quality_score; } public double getPack_score() { return pack_score; } public void setPack_score(double pack_score) { this.pack_score = pack_score; } public double getFood_score() { return food_score; } public void setFood_score(double food_score) { this.food_score = food_score; } public String getDelivery_time_tip() { return delivery_time_tip; } public void setDelivery_time_tip(String delivery_time_tip) { this.delivery_time_tip = delivery_time_tip; } public String getThird_category() { return third_category; } public void setThird_category(String third_category) { this.third_category = third_category; } public String getPic_url() { return pic_url; } public void setPic_url(String pic_url) { this.pic_url = pic_url; } public String getShopping_time_start() { return shopping_time_start; } public void setShopping_time_start(String shopping_time_start) { this.shopping_time_start = shopping_time_start; } public String getShopping_time_end() { return shopping_time_end; } public void setShopping_time_end(String shopping_time_end) { this.shopping_time_end = shopping_time_end; } public double getMin_price() { return min_price; } public void setMin_price(double min_price) { this.min_price = min_price; } public String getMin_price_tip() { return min_price_tip; } public void setMin_price_tip(String min_price_tip) { this.min_price_tip = min_price_tip; } public double getShipping_fee() { return shipping_fee; } public void setShipping_fee(double shipping_fee) { this.shipping_fee = shipping_fee; } public String getShipping_fee_tip() { return shipping_fee_tip; } public void setShipping_fee_tip(String shipping_fee_tip) { this.shipping_fee_tip = shipping_fee_tip; } public String getBulletin() { return bulletin; } public void setBulletin(String bulletin) { this.bulletin = bulletin; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getCall_center() { return call_center; } public void setCall_center(String call_center) { this.call_center = call_center; } public String getDistance() { return distance; } public void setDistance(String distance) { this.distance = distance; } public String getAverage_price_tip() { return average_price_tip; } public void setAverage_price_tip(String average_price_tip) { this.average_price_tip = average_price_tip; } public double getComment_number() { return comment_number; } public void setComment_number(double comment_number) { this.comment_number = comment_number; } public String getLng() { return lng; } public void setLng(String lng) { this.lng = lng; } public String getLat() { return lat; } public void setLat(String lat) { this.lat = lat; } public double get__v() { return __v; } public void set__v(double __v) { this.__v = __v; } public String getCreated_at() { return created_at; } public void setCreated_at(String created_at) { this.created_at = created_at; } public List<Discounts2Bean> getDiscounts2() { return discounts2; } public void setDiscounts2(List<Discounts2Bean> discounts2) { this.discounts2 = discounts2; } public static class Discounts2Bean { private String info; private String icon_url; private double promotion_type; public String getInfo() { return info; } public void setInfo(String info) { this.info = info; } public String getIcon_url() { return icon_url; } public void setIcon_url(String icon_url) { this.icon_url = icon_url; } public double getPromotion_type() { return promotion_type; } public void setPromotion_type(double promotion_type) { this.promotion_type = promotion_type; } } } }