|
|
@@ -12,6 +12,7 @@ import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
@@ -23,7 +24,13 @@ import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
import android.widget.ViewSwitcher;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.common.data.JSONUtil;
|
|
|
import com.core.base.activity.BaseMVPActivity;
|
|
|
+import com.core.net.http.http.Request;
|
|
|
+import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.StatusBarUtil;
|
|
|
import com.core.widget.RecycleViewDivider;
|
|
|
import com.scwang.smartrefresh.layout.api.RefreshHeader;
|
|
|
@@ -34,7 +41,7 @@ import com.uas.appworks.R;
|
|
|
import com.uas.appworks.adapter.CityIndustryCircleFuncAdapter;
|
|
|
import com.uas.appworks.adapter.CityIndustryNewsListAdapter;
|
|
|
import com.uas.appworks.model.bean.CityIndustryAnnounceBean;
|
|
|
-import com.uas.appworks.model.bean.CityIndustryMenuBean;
|
|
|
+import com.uas.appworks.model.bean.CityIndustryServiceBean;
|
|
|
import com.uas.appworks.presenter.WorkPlatPresenter;
|
|
|
import com.uas.appworks.view.WorkPlatView;
|
|
|
import com.youth.banner.Banner;
|
|
|
@@ -42,7 +49,10 @@ import com.youth.banner.loader.ImageLoader;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author RaoMeng
|
|
|
@@ -52,6 +62,7 @@ import java.util.List;
|
|
|
|
|
|
public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPresenter> implements WorkPlatView {
|
|
|
private final int ANNOUNCE_LOOP_FLAG = 0x01;
|
|
|
+ private final int GET_DEFAULT_SERVICE = 0x02;
|
|
|
|
|
|
private AppBarLayout mAppBarLayout;
|
|
|
private RecyclerView mFuncRecyclerView, mNewsRecyclerView;
|
|
|
@@ -59,10 +70,12 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
private TextSwitcher mAnnounceTextSwitcher;
|
|
|
private Banner mBanner;
|
|
|
private RefreshLayout mRefreshLayout;
|
|
|
+ private ImageView mBackImageView;
|
|
|
+ private View mFuncLine;
|
|
|
private List<CityIndustryAnnounceBean> mCityIndustryAnnounceBeans;
|
|
|
private int mSwitcherCount = 0;
|
|
|
private CityIndustryCircleFuncAdapter mCityIndustryFuncAdapter;
|
|
|
- private List<CityIndustryMenuBean.ServesBean> mServesBeans;
|
|
|
+ private List<CityIndustryServiceBean> mServesBeans;
|
|
|
private CityIndustryNewsListAdapter mCityIndustryNewsListAdapter;
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
@@ -100,11 +113,13 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
StatusBarUtil.setPaddingSmart(this, mToolbar);
|
|
|
|
|
|
mAppBarLayout = $(R.id.city_industry_service_main_appbar);
|
|
|
+ mBackImageView = $(R.id.city_industry_service_main_back_iv);
|
|
|
mFuncRecyclerView = $(R.id.city_industry_service_main_func_rv);
|
|
|
mNewsRecyclerView = $(R.id.city_industry_service_main_news_rv);
|
|
|
mAnnounceTextSwitcher = $(R.id.city_industry_service_main_announce_ts);
|
|
|
mBanner = $(R.id.city_industry_service_main_banner);
|
|
|
mRefreshLayout = $(R.id.city_industry_service_main_refreshlayout);
|
|
|
+ mFuncLine = $(R.id.city_industry_service_main_func_line);
|
|
|
|
|
|
RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
|
|
|
viewPool.setMaxRecycledViews(0, 10);
|
|
|
@@ -136,6 +151,13 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
|
|
|
@Override
|
|
|
protected void initEvent() {
|
|
|
+ mBackImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ onBackPressed();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
|
|
@Override
|
|
|
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
|
|
@@ -165,13 +187,7 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
@Override
|
|
|
public void onRefresh(final RefreshLayout refreshLayout) {
|
|
|
- refreshLayout.getLayout().postDelayed(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- Toast.makeText(CityIndustryServiceMainActivity.this, "刷新成功", Toast.LENGTH_SHORT).show();
|
|
|
- refreshLayout.finishRefresh();
|
|
|
- }
|
|
|
- }, 2000);
|
|
|
+ getDefaultService();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -183,7 +199,10 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
intent.setClass(CityIndustryServiceMainActivity.this, CityIndustryFuncSetActivity.class);
|
|
|
startActivity(intent);
|
|
|
} else {
|
|
|
- toast(mServesBeans.get(position).getSv_name());
|
|
|
+ Intent intent = new Intent("com.modular.work.CommonDataFormActivity");
|
|
|
+ intent.putExtra("serve_id", mServesBeans.get(position).getSv_id() + "");
|
|
|
+ intent.putExtra("mTitle", mServesBeans.get(position).getSv_name() + "");
|
|
|
+ mContext.startActivity(intent);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -191,32 +210,36 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
|
|
|
@Override
|
|
|
protected void initData() {
|
|
|
+ mRefreshLayout.autoRefresh(200, 1f);
|
|
|
+
|
|
|
initTextSwitcher();
|
|
|
|
|
|
mBanner.setImageLoader(new BannerImageLoader());
|
|
|
mBanner.setImages(Arrays.asList(R.drawable.ic_city_industry_loop1, R.drawable.ic_city_industry_loop2, R.drawable.ic_city_industry_loop3));
|
|
|
mBanner.start();
|
|
|
|
|
|
- mRefreshLayout.autoRefresh(200, 1f);
|
|
|
-
|
|
|
- for (int i = 1; i <= 9; i++) {
|
|
|
- CityIndustryMenuBean.ServesBean servesBean = new CityIndustryMenuBean.ServesBean();
|
|
|
- servesBean.setSv_name("服务" + i);
|
|
|
- CityIndustryMenuBean.ServesBean.SvLogourlBean svLogourlBean = new CityIndustryMenuBean.ServesBean.SvLogourlBean();
|
|
|
- svLogourlBean.setMobile("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1511716062774&di=155838f806a1eda977ea2ecd71050b1f&imgtype=0&src=http%3A%2F%2Fpic1.cxtuku.com%2F00%2F13%2F05%2Fb894360c182e.jpg");
|
|
|
- servesBean.setSv_logourl(svLogourlBean);
|
|
|
- mServesBeans.add(servesBean);
|
|
|
- }
|
|
|
- CityIndustryMenuBean.ServesBean servesBean = new CityIndustryMenuBean.ServesBean();
|
|
|
- servesBean.setSv_name("全部服务");
|
|
|
- CityIndustryMenuBean.ServesBean.SvLogourlBean svLogourlBean = new CityIndustryMenuBean.ServesBean.SvLogourlBean();
|
|
|
- svLogourlBean.setMobile("http://www.iconpng.com/download/png/67384");
|
|
|
- servesBean.setSv_logourl(svLogourlBean);
|
|
|
- mServesBeans.add(servesBean);
|
|
|
-
|
|
|
mCityIndustryFuncAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
+ private void getDefaultService() {
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("kind", "cc");
|
|
|
+ params.put("client_type", "cc");
|
|
|
+ params.put("access_token", "123456");
|
|
|
+
|
|
|
+ LinkedHashMap<String, Object> header = new LinkedHashMap<>();
|
|
|
+ header.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+
|
|
|
+ Request request = new Request.Bulider()
|
|
|
+ .setUrl("api/serve/getDefaultServices.action")
|
|
|
+ .setWhat(GET_DEFAULT_SERVICE)
|
|
|
+ .setParam(params)
|
|
|
+ .setHeaders(header)
|
|
|
+ .setMode(Request.Mode.GET)
|
|
|
+ .bulid();
|
|
|
+ mPresenter.cityRequest(this, request);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void initTextSwitcher() {
|
|
|
mCityIndustryAnnounceBeans = new ArrayList<>();
|
|
|
@@ -274,13 +297,56 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void loadSuccess(int what, Object object) {
|
|
|
-
|
|
|
+ public void requestSuccess(int what, Object object) {
|
|
|
+ switch (what) {
|
|
|
+ case GET_DEFAULT_SERVICE:
|
|
|
+ if (mRefreshLayout.isRefreshing()) {
|
|
|
+ mRefreshLayout.finishRefresh();
|
|
|
+ }
|
|
|
+ String result = object.toString();
|
|
|
+ Log.d("citydefaultservice", result);
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray serviceArray = resultObject.getJSONArray("serves");
|
|
|
+ if (serviceArray != null) {
|
|
|
+ mServesBeans.clear();
|
|
|
+ for (int i = 0; i < serviceArray.size(); i++) {
|
|
|
+ JSONObject serviceObject = serviceArray.getJSONObject(i);
|
|
|
+ if (serviceObject != null) {
|
|
|
+ CityIndustryServiceBean cityIndustryServiceBean = new CityIndustryServiceBean();
|
|
|
+ cityIndustryServiceBean.setSv_id(JSONUtil.getInt(serviceObject, "sv_id"));
|
|
|
+ cityIndustryServiceBean.setSv_name(JSONUtil.getText(serviceObject, "sv_name"));
|
|
|
+ cityIndustryServiceBean.setSv_logourl(JSONUtil.getText(serviceObject, "sv_logourl"));
|
|
|
+
|
|
|
+ mServesBeans.add(cityIndustryServiceBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CityIndustryServiceBean cityIndustryServiceBean = new CityIndustryServiceBean();
|
|
|
+ cityIndustryServiceBean.setSv_name("全部服务");
|
|
|
+ cityIndustryServiceBean.setSv_logourl("moreMenu");
|
|
|
+ mServesBeans.add(cityIndustryServiceBean);
|
|
|
+
|
|
|
+ mFuncRecyclerView.setVisibility(View.VISIBLE);
|
|
|
+ mFuncLine.setVisibility(View.VISIBLE);
|
|
|
+ mCityIndustryFuncAdapter.notifyDataSetChanged();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void showError(String errorMsg) {
|
|
|
-
|
|
|
+ public void requestError(int what, String errorMsg) {
|
|
|
+ switch (what) {
|
|
|
+ case GET_DEFAULT_SERVICE:
|
|
|
+ if (mRefreshLayout.isRefreshing()) {
|
|
|
+ mRefreshLayout.finishRefresh();
|
|
|
+ }
|
|
|
+ Toast.makeText(this, errorMsg, Toast.LENGTH_SHORT).show();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|