498 lines
20 KiB
Java
498 lines
20 KiB
Java
|
|
package com.sl.house_property;
|
||
|
|
|
||
|
|
import android.app.ProgressDialog;
|
||
|
|
import android.content.Context;
|
||
|
|
import android.content.Intent;
|
||
|
|
import android.net.Uri;
|
||
|
|
import android.os.Bundle;
|
||
|
|
import android.support.v4.app.Fragment;
|
||
|
|
import android.text.TextPaint;
|
||
|
|
import android.view.LayoutInflater;
|
||
|
|
import android.view.View;
|
||
|
|
import android.widget.ImageView;
|
||
|
|
import android.widget.LinearLayout;
|
||
|
|
import android.widget.RadioButton;
|
||
|
|
|
||
|
|
import com.cutil.ScreenUtils;
|
||
|
|
import com.dalong.refreshlayout.OnRefreshListener;
|
||
|
|
import com.google.gson.Gson;
|
||
|
|
import com.google.gson.internal.LinkedTreeMap;
|
||
|
|
import com.sl.house_property.user.MyMarketShopActivity;
|
||
|
|
import com.sl.house_property.databinding.FragmentMainBinding;
|
||
|
|
import com.sl.house_property.databinding.FragmentRecyclerviewHorizationItemBinding;
|
||
|
|
import com.sl.house_property.databinding.FragmentRecyclerviewVorizationItemBinding;
|
||
|
|
import com.squareup.picasso.Picasso;
|
||
|
|
import com.youth.banner.Banner;
|
||
|
|
import com.youth.banner.BannerConfig;
|
||
|
|
import com.youth.banner.Transformer;
|
||
|
|
import com.youth.banner.listener.OnBannerClickListener;
|
||
|
|
import com.youth.banner.loader.ImageLoader;
|
||
|
|
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
import adapter.BaseRecycleViewAdapter;
|
||
|
|
import entity.Advert_carouseleEntity;
|
||
|
|
import entity.Advertorial_listEntity;
|
||
|
|
import entity.MainF1Entity;
|
||
|
|
import entity.Message_listEntity;
|
||
|
|
import entity.RegisterUser;
|
||
|
|
import my_loader.Loader;
|
||
|
|
import my_loader.Resultcode;
|
||
|
|
import my_view.tao_bao_refresh.FullyGridLayoutManager;
|
||
|
|
import tools.Config;
|
||
|
|
import tools.PicassoRoundTransform;
|
||
|
|
import http.ApiConfig;
|
||
|
|
import rx.Subscription;
|
||
|
|
import rx.functions.Action1;
|
||
|
|
import utils.Md5;
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A simple {@link Fragment} subclass.
|
||
|
|
* Activities that contain this fragment must implement the
|
||
|
|
* {@link Main1Fragment.OnFragmentInteractionListener} interface
|
||
|
|
* to handle interaction events.
|
||
|
|
* Use the {@link Main1Fragment#newInstance} factory method to
|
||
|
|
* create an instance of this fragment.
|
||
|
|
*/
|
||
|
|
public class MainFragment extends BaseFragment<FragmentMainBinding> implements View.OnClickListener {
|
||
|
|
// TODO: Rename parameter arguments, choose names that match
|
||
|
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||
|
|
private static final String ARG_PARAM1 = "param1";
|
||
|
|
private static final String ARG_PARAM2 = "param2";
|
||
|
|
BaseActivity baseActivity;
|
||
|
|
// TODO: Rename and change types of parameters
|
||
|
|
private String mParam1;
|
||
|
|
private String mParam2;
|
||
|
|
|
||
|
|
private OnFragmentInteractionListener mListener;
|
||
|
|
private ProgressDialog progressDialog;
|
||
|
|
private Loader mGankLoader;
|
||
|
|
|
||
|
|
private ArrayList<String> mBannerImages;
|
||
|
|
|
||
|
|
private List<String> bannerTitile;
|
||
|
|
|
||
|
|
private BaseRecycleViewAdapter baseRecycleViewAdapterh;
|
||
|
|
|
||
|
|
private BaseRecycleViewAdapter baseRecycleViewAdapterv;
|
||
|
|
private RegisterUser user;
|
||
|
|
|
||
|
|
public MainFragment() {
|
||
|
|
// Required empty public constructor
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Use this factory method to create a new instance of
|
||
|
|
* this fragment using the provided parameters.
|
||
|
|
*
|
||
|
|
* @param param1 Parameter 1.
|
||
|
|
* @param param2 Parameter 2.
|
||
|
|
* @return A new instance of fragment Main1Fragment.
|
||
|
|
*/
|
||
|
|
// TODO: Rename and change types and number of parameters
|
||
|
|
public static MainFragment newInstance(String param1, String param2) {
|
||
|
|
MainFragment fragment = new MainFragment();
|
||
|
|
Bundle args = new Bundle();
|
||
|
|
args.putString(ARG_PARAM1, param1);
|
||
|
|
args.putString(ARG_PARAM2, param2);
|
||
|
|
fragment.setArguments(args);
|
||
|
|
return fragment;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onResume() {
|
||
|
|
super.onResume();
|
||
|
|
RegisterUser user1;
|
||
|
|
if (user == null) {
|
||
|
|
|
||
|
|
user1 =
|
||
|
|
Config.getInstance(getActivity()).getUser();
|
||
|
|
if (user1 != null) {
|
||
|
|
Map<String, String> map = new HashMap<>();
|
||
|
|
if (user1 != null) {
|
||
|
|
map.put("userid", user1.getUserid());
|
||
|
|
} else {
|
||
|
|
map.put("userid", 0 + "");
|
||
|
|
}
|
||
|
|
map.put("app", "Advert");
|
||
|
|
map.put("class", "Advertr_an_AdvertHomeList");
|
||
|
|
map.put("sign", Md5.md5("Advert" + "Advertr_an_AdvertHomeList" + Md5.secret));
|
||
|
|
getGankList(ApiConfig.BASE_URL, map, getResources().getString(R.string.requsting), 0, false);
|
||
|
|
user = user1;
|
||
|
|
}
|
||
|
|
;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onCreate(Bundle savedInstanceState) {
|
||
|
|
super.onCreate(savedInstanceState);
|
||
|
|
if (getArguments() != null) {
|
||
|
|
mParam1 = getArguments().getString(ARG_PARAM1);
|
||
|
|
mParam2 = getArguments().getString(ARG_PARAM2);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected void onCreateVew(LayoutInflater inflater, Bundle savedInstanceState) {
|
||
|
|
super.onCreateVew(inflater, savedInstanceState);
|
||
|
|
baseActivity = (BaseActivity) getActivity();
|
||
|
|
// progressDialog = new ProgressDialog(baseActivity);
|
||
|
|
// progressDialog.show();
|
||
|
|
// progressDialog.setMessage(getActivity().getString(R.string.loading));
|
||
|
|
//getGankList(ApiConfig.GETHOMEBANNER,new HashMap<String, String>(),getString(R.string.loading),0);
|
||
|
|
mDataBinding.taobaoRefreshLayout.setOnRefreshListener(onrefalshlister);
|
||
|
|
mDataBinding.taobaoRefreshLayout.postDelayed(new Runnable() {
|
||
|
|
@Override
|
||
|
|
public void run() {
|
||
|
|
/* configFragments();
|
||
|
|
intRecycleHorization();
|
||
|
|
intRecycleVerization();*/
|
||
|
|
user =
|
||
|
|
Config.getInstance(getActivity()).getUser();
|
||
|
|
Map<String, String> map = new HashMap<>();
|
||
|
|
if (user != null) {
|
||
|
|
map.put("userid", user.getUserid());
|
||
|
|
} else {
|
||
|
|
map.put("userid", 0 + "");
|
||
|
|
}
|
||
|
|
map.put("app", "Advert");
|
||
|
|
map.put("class", "Advertr_an_AdvertHomeList");
|
||
|
|
map.put("sign", Md5.md5("Advert" + "Advertr_an_AdvertHomeList" + Md5.secret));
|
||
|
|
getGankList(ApiConfig.BASE_URL, map, getResources().getString(R.string.requsting), 0, true);
|
||
|
|
}
|
||
|
|
}, 0);
|
||
|
|
mDataBinding.scan.setOnClickListener(this);
|
||
|
|
mDataBinding.entrancegurd.setOnClickListener(this);
|
||
|
|
mDataBinding.cargara.setOnClickListener(this);
|
||
|
|
mDataBinding.moew1.setOnClickListener(this);
|
||
|
|
mDataBinding.moew2.setOnClickListener(this);
|
||
|
|
View banner = mDataBinding.l3;
|
||
|
|
LinearLayout.LayoutParams bannerLP = (LinearLayout.LayoutParams) banner.getLayoutParams();
|
||
|
|
bannerLP.width = ScreenUtils.getScreenWidth();
|
||
|
|
banner.setLayoutParams(bannerLP);
|
||
|
|
mDataBinding.taobaoRefreshLayout.setAutoRefresh(true);
|
||
|
|
}
|
||
|
|
|
||
|
|
// TODO: Rename method, update argument and hook method into UI event
|
||
|
|
public void onButtonPressed(Uri uri) {
|
||
|
|
if (mListener != null) {
|
||
|
|
mListener.onFragmentInteraction(uri);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onAttach(Context context) {
|
||
|
|
super.onAttach(context);
|
||
|
|
if (context instanceof OnFragmentInteractionListener) {
|
||
|
|
mListener = (OnFragmentInteractionListener) context;
|
||
|
|
} else {
|
||
|
|
throw new RuntimeException(context.toString()
|
||
|
|
+ " must implement OnFragmentInteractionListener");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onDetach() {
|
||
|
|
super.onDetach();
|
||
|
|
mListener = null;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected int getLayoutId() {
|
||
|
|
return R.layout.fragment_main;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected void loadData() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onClick(View view) {
|
||
|
|
Intent intent = null;
|
||
|
|
switch (view.getId()) {
|
||
|
|
case R.id.scan:
|
||
|
|
if ((Config.getInstance(MainFragment.this.getContext()).getUser() == null)) {
|
||
|
|
intent = new Intent(MainFragment.this.getContext(), LoginActivity.class);
|
||
|
|
} else {
|
||
|
|
intent = new Intent(getActivity(), QRcodeActivity.class);
|
||
|
|
}
|
||
|
|
startActivity(intent);
|
||
|
|
break;
|
||
|
|
case R.id.entrancegurd://门禁
|
||
|
|
if ((Config.getInstance(MainFragment.this.getContext()).getUser() == null)) {
|
||
|
|
intent = new Intent(MainFragment.this.getContext(), LoginActivity.class);
|
||
|
|
} else {
|
||
|
|
intent = new Intent(getActivity(), EntranceguardActivity.class);
|
||
|
|
}
|
||
|
|
startActivity(intent);
|
||
|
|
break;
|
||
|
|
case R.id.cargara://车库
|
||
|
|
if ((Config.getInstance(MainFragment.this.getContext()).getUser() == null)) {
|
||
|
|
intent = new Intent(MainFragment.this.getContext(), LoginActivity.class);
|
||
|
|
} else {
|
||
|
|
intent = new Intent(getActivity(), CarGarageActivity.class);
|
||
|
|
}
|
||
|
|
startActivity(intent);
|
||
|
|
break;
|
||
|
|
case R.id.moew1:
|
||
|
|
intent = new Intent(getActivity(), MyMarketShopActivity.class);
|
||
|
|
startActivity(intent);
|
||
|
|
break;
|
||
|
|
case R.id.moew2:
|
||
|
|
if ((Config.getInstance(MainFragment.this.getContext()).getUser() == null)) {
|
||
|
|
intent = new Intent(MainFragment.this.getContext(), LoginActivity.class);
|
||
|
|
} else {
|
||
|
|
intent = new Intent(getActivity(), NewlistActivity.class);
|
||
|
|
}
|
||
|
|
startActivity(intent);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* This interface must be implemented by activities that contain this
|
||
|
|
* fragment to allow an interaction in this fragment to be communicated
|
||
|
|
* to the activity and potentially other fragments contained in that
|
||
|
|
* activity.
|
||
|
|
* <p>
|
||
|
|
* See the Android Training lesson <a href=
|
||
|
|
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||
|
|
* >Communicating with Other Fragments</a> for more information.
|
||
|
|
*/
|
||
|
|
public interface OnFragmentInteractionListener {
|
||
|
|
// TODO: Update argument type and name
|
||
|
|
void onFragmentInteraction(Uri uri);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void configFragments(ArrayList<Advert_carouseleEntity> user) {//banner事件
|
||
|
|
// mDataBinding.banner.removeAllViews();
|
||
|
|
mDataBinding.banner.releaseBanner();
|
||
|
|
bannerTitile = new ArrayList<>();
|
||
|
|
mBannerImages = new ArrayList<>();
|
||
|
|
for (int i = 0; i < user.size(); i++) {
|
||
|
|
Advert_carouseleEntity advertCarouseleEntity = user.get(i);
|
||
|
|
if (advertCarouseleEntity == null) {
|
||
|
|
bannerTitile.add("");
|
||
|
|
} else {
|
||
|
|
bannerTitile.add(advertCarouseleEntity.getAdvert_source());
|
||
|
|
}
|
||
|
|
mBannerImages.add(advertCarouseleEntity.getAdvert_img());
|
||
|
|
}
|
||
|
|
Banner banner = mDataBinding.banner;
|
||
|
|
banner.setBannerTitles(bannerTitile);
|
||
|
|
banner.setImageLoader(new ImageLoader() {
|
||
|
|
@Override
|
||
|
|
public void displayImage(Context context, Object path, ImageView imageView) {
|
||
|
|
Picasso.with(context).load((String) path)
|
||
|
|
.into(imageView);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
banner.setImages(mBannerImages);
|
||
|
|
banner.setBannerAnimation(Transformer.Default);
|
||
|
|
banner.setDelayTime(5000);
|
||
|
|
banner.isAutoPlay(true);
|
||
|
|
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
|
||
|
|
banner.setIndicatorGravity(BannerConfig.CENTER);
|
||
|
|
banner.start();
|
||
|
|
|
||
|
|
/*mDataBinding.banner.setOnBannerClickListener(new OnBannerClickListener() {
|
||
|
|
@Override
|
||
|
|
public void OnBannerClick(int i) {
|
||
|
|
Intent intent = new Intent(getContext(), NewsDetailActivity.class);
|
||
|
|
// intent.putExtra("url", homegridentityvArrayList.get(position).getMessage_url());
|
||
|
|
// intent.putExtra("titile", homegridentityvArrayList.get(position).getMessage_title());
|
||
|
|
startActivity(intent);
|
||
|
|
}
|
||
|
|
});*/
|
||
|
|
TextPaint tp = mDataBinding.usershoptextid.getPaint();
|
||
|
|
|
||
|
|
tp.setFakeBoldText(true);
|
||
|
|
TextPaint tp1 = mDataBinding.userommunitybutextid.getPaint();
|
||
|
|
tp1.setFakeBoldText(true);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public void intRecycleHorization(final ArrayList<Advertorial_listEntity> advertorial_list) {
|
||
|
|
|
||
|
|
FullyGridLayoutManager mgr = new FullyGridLayoutManager(getActivity(), 1);
|
||
|
|
mgr.setOrientation(FullyGridLayoutManager.HORIZONTAL);
|
||
|
|
mgr.setSmoothScrollbarEnabled(true);
|
||
|
|
mDataBinding.fragmentRecyclerviewHorization.setLayoutManager(mgr);
|
||
|
|
baseRecycleViewAdapterh = new BaseRecycleViewAdapter(getActivity(), R.layout.fragment_recyclerview_horization_item);
|
||
|
|
|
||
|
|
baseRecycleViewAdapterh.setOnBindViewHolder(new BaseRecycleViewAdapter.BindView() {
|
||
|
|
@Override
|
||
|
|
public void onBindViewHolder(Object b, final int position) {
|
||
|
|
FragmentRecyclerviewHorizationItemBinding homeGridAdapterItemBinding = (FragmentRecyclerviewHorizationItemBinding) b;
|
||
|
|
homeGridAdapterItemBinding.setMyentity(advertorial_list.get(position));
|
||
|
|
if (advertorial_list.get(position).getAdvertorial_picture_array().size() > 0) {
|
||
|
|
Picasso.with(getActivity()).load(advertorial_list.get(position).getAdvertorial_picture_array().get(0))
|
||
|
|
.placeholder(R.mipmap.icon_default_rectangle)
|
||
|
|
.transform(new PicassoRoundTransform())
|
||
|
|
.into(homeGridAdapterItemBinding.imageView);
|
||
|
|
}
|
||
|
|
homeGridAdapterItemBinding.fragmentRecyclerviewHorizationItem.setOnClickListener(new View.OnClickListener() {
|
||
|
|
@Override
|
||
|
|
public void onClick(View view) {
|
||
|
|
Intent intent = new Intent(getActivity(), NewsDetailActivity.class);
|
||
|
|
intent.putExtra("url", advertorial_list.get(position).getAdvertorial_url());
|
||
|
|
intent.putExtra("titile", advertorial_list.get(position).getAdvertorial_title());
|
||
|
|
startActivity(intent);
|
||
|
|
/* Intent intent=new Intent(getActivity(),CommodityActivity.class);
|
||
|
|
intent.putExtra("homegridentity",advertorial_list.get(position));
|
||
|
|
startActivity(intent);*/
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
mDataBinding.fragmentRecyclerviewHorization.setAdapter(baseRecycleViewAdapterh);
|
||
|
|
baseRecycleViewAdapterh.setData(advertorial_list);
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
private void intRecycleVerization(final ArrayList<Message_listEntity> message_list) {
|
||
|
|
mDataBinding.myversion.setVisibility(View.VISIBLE);
|
||
|
|
FullyGridLayoutManager mgr = new FullyGridLayoutManager(getActivity(), 1);
|
||
|
|
mgr.setOrientation(FullyGridLayoutManager.VERTICAL);
|
||
|
|
mgr.setSmoothScrollbarEnabled(true);
|
||
|
|
mDataBinding.recyView.setLayoutManager(mgr);
|
||
|
|
baseRecycleViewAdapterv = new BaseRecycleViewAdapter(getActivity(), R.layout.fragment_recyclerview_vorization_item);
|
||
|
|
|
||
|
|
baseRecycleViewAdapterv.setOnBindViewHolder(new BaseRecycleViewAdapter.BindView() {
|
||
|
|
@Override
|
||
|
|
public void onBindViewHolder(Object b, final int position) {
|
||
|
|
if (!(position >= message_list.size())) {
|
||
|
|
FragmentRecyclerviewVorizationItemBinding homeGridAdapterItemBinding = (FragmentRecyclerviewVorizationItemBinding) b;
|
||
|
|
homeGridAdapterItemBinding.setMyentity(message_list.get(position));
|
||
|
|
|
||
|
|
Picasso.with(getActivity()).load(message_list.get(position).getMessage_picture())
|
||
|
|
.placeholder(R.mipmap.icon_default_rectangle)
|
||
|
|
.transform(new PicassoRoundTransform())
|
||
|
|
.into(homeGridAdapterItemBinding.imageView);
|
||
|
|
homeGridAdapterItemBinding.fragmentRecyclerviewVorizationItem.setOnClickListener(new View.OnClickListener() {
|
||
|
|
@Override
|
||
|
|
public void onClick(View view) {
|
||
|
|
|
||
|
|
|
||
|
|
Intent intent = new Intent(getActivity(), NewsDetailActivity.class);
|
||
|
|
intent.putExtra("url", message_list.get(position).getMessage_url());
|
||
|
|
intent.putExtra("titile", message_list.get(position).getMessage_title());
|
||
|
|
startActivity(intent);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
mDataBinding.recyView.setAdapter(baseRecycleViewAdapterv);
|
||
|
|
baseRecycleViewAdapterv.setData(message_list);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
//如果你需要考虑更好的体验,可以这么操作
|
||
|
|
@Override
|
||
|
|
public void onStart() {
|
||
|
|
super.onStart();
|
||
|
|
//开始轮播
|
||
|
|
mDataBinding.banner.startAutoPlay();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onStop() {
|
||
|
|
super.onStop();
|
||
|
|
//结束轮播
|
||
|
|
mDataBinding.banner.stopAutoPlay();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private OnRefreshListener onrefalshlister = new OnRefreshListener() {
|
||
|
|
@Override
|
||
|
|
public void onRefresh() {
|
||
|
|
RegisterUser user =
|
||
|
|
Config.getInstance(getActivity()).getUser();
|
||
|
|
Map<String, String> map = new HashMap<>();
|
||
|
|
if (user != null) {
|
||
|
|
map.put("userid", user.getUserid());
|
||
|
|
} else {
|
||
|
|
map.put("userid", 0 + "");
|
||
|
|
}
|
||
|
|
map.put("app", "Advert");
|
||
|
|
map.put("class", "Advertr_an_AdvertHomeList");
|
||
|
|
map.put("sign", Md5.md5("Advert" + "Advertr_an_AdvertHomeList" + Md5.secret));
|
||
|
|
getGankList(ApiConfig.BASE_URL, map, getResources().getString(R.string.requsting), 0, false);
|
||
|
|
mDataBinding.taobaoRefreshLayout.postDelayed(new Runnable() {
|
||
|
|
@Override
|
||
|
|
public void run() {
|
||
|
|
mDataBinding.taobaoRefreshLayout.stopRefresh(true);
|
||
|
|
}
|
||
|
|
}, 10000);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onLoadMore() {
|
||
|
|
|
||
|
|
mDataBinding.taobaoRefreshLayout.postDelayed(new Runnable() {
|
||
|
|
@Override
|
||
|
|
public void run() {
|
||
|
|
mDataBinding.taobaoRefreshLayout.stopLoadMore(true);
|
||
|
|
}
|
||
|
|
}, 1000);
|
||
|
|
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
private void getGankList(String myurl, Map<String, String> map, String msg, final int requstecode, final boolean isshowdilaog) {
|
||
|
|
mGankLoader = new Loader();
|
||
|
|
Subscription subscription = mGankLoader.getMovie(myurl, map).subscribe(new Action1<Resultcode>() {
|
||
|
|
@Override
|
||
|
|
public void call(Resultcode resultcode) {
|
||
|
|
mDataBinding.taobaoRefreshLayout.stopRefresh(true);
|
||
|
|
mDataBinding.taobaoRefreshLayout.stopLoadMore(true);
|
||
|
|
if (!(resultcode.status == 0)) {
|
||
|
|
baseActivity.setToast(1, resultcode.msg);
|
||
|
|
}
|
||
|
|
if (resultcode.status == 0) {
|
||
|
|
// baseActivity.setToast(0,resultcode.msg);
|
||
|
|
if (requstecode == 0) {
|
||
|
|
Gson gs = new Gson();
|
||
|
|
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||
|
|
String s = gs.toJson(adta);
|
||
|
|
MainF1Entity user = gs.fromJson(s, MainF1Entity.class);//把JSON字符串转为对象
|
||
|
|
configFragments(user.getAdvert_carousel());
|
||
|
|
intRecycleHorization(user.getAdvertorial_list());
|
||
|
|
intRecycleVerization(user.getMessage_list());
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}, new Action1<Throwable>() {
|
||
|
|
@Override
|
||
|
|
public void call(Throwable throwable) {
|
||
|
|
baseActivity.setToast(2, getString(R.string.getdatafailure));
|
||
|
|
throwable.printStackTrace();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
baseActivity.addSubscription(subscription);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|