|
|
@@ -18,24 +18,28 @@ import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.view.animation.Animation;
|
|
|
+import android.view.animation.AnimationUtils;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.TextSwitcher;
|
|
|
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.app.Constants;
|
|
|
import com.core.base.activity.BaseMVPActivity;
|
|
|
+import com.core.net.http.ViewUtil;
|
|
|
import com.core.net.http.http.Request;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.SpanUtils;
|
|
|
import com.core.utils.StatusBarUtil;
|
|
|
import com.core.widget.RecycleViewDivider;
|
|
|
+import com.me.imageloader.ImageLoaderUtil;
|
|
|
import com.scwang.smartrefresh.layout.api.RefreshHeader;
|
|
|
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
|
|
@@ -52,7 +56,6 @@ import com.youth.banner.Banner;
|
|
|
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;
|
|
|
@@ -67,6 +70,7 @@ import java.util.Map;
|
|
|
public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPresenter> implements WorkPlatView {
|
|
|
private final int ANNOUNCE_LOOP_FLAG = 0x01;
|
|
|
private final int GET_DEFAULT_SERVICE = 0x02;
|
|
|
+ private final int GET_LOOP_PICS = 0x03;
|
|
|
|
|
|
// private AppBarLayout mAppBarLayout;
|
|
|
private RecyclerView mFuncRecyclerView, mNewsRecyclerView;
|
|
|
@@ -78,6 +82,9 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
private ImageView mBackImageView;
|
|
|
private FrameLayout mToastLayout;
|
|
|
private View mFuncLine;
|
|
|
+ private LinearLayout mAreaLinearLayout;
|
|
|
+ private ImageView mAreaImageView;
|
|
|
+
|
|
|
private List<CityIndustryAnnounceBean> mCityIndustryAnnounceBeans;
|
|
|
private int mSwitcherCount = 0;
|
|
|
private CityIndustryCircleFuncAdapter mCityIndustryFuncAdapter;
|
|
|
@@ -85,6 +92,8 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
private CityIndustryNewsListAdapter mCityIndustryNewsListAdapter;
|
|
|
private int mScrollY = 0;
|
|
|
private SpanUtils mSpanUtils;
|
|
|
+ private boolean isAreaSpread = false, isLoopPicsFinish = false, isServiceFinish = false;
|
|
|
+ private Animation mSpreadAnimation, mFoldAnimation;
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
@@ -104,11 +113,47 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
}
|
|
|
mHandler.sendEmptyMessageDelayed(ANNOUNCE_LOOP_FLAG, 3000);
|
|
|
break;
|
|
|
+ case GET_DEFAULT_SERVICE:
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ analyzeDefaultSerivce(result);
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ result = msg.getData().getString("result");
|
|
|
+ if (JSONUtil.validate(result)) {
|
|
|
+ ToastMessage(JSON.parseObject(result).getString("exceptionInfo"));
|
|
|
+ } else {
|
|
|
+ ToastMessage(result);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onStart() {
|
|
|
+ super.onStart();
|
|
|
+ mBanner.startAutoPlay();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onStop() {
|
|
|
+ super.onStop();
|
|
|
+ mBanner.stopAutoPlay();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.activity_main_city_industry_service;
|
|
|
@@ -122,7 +167,6 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
setSupportActionBar(mToolbar);
|
|
|
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);
|
|
|
@@ -132,6 +176,12 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
mRefreshLayout = $(R.id.city_industry_service_main_refreshlayout);
|
|
|
mFuncLine = $(R.id.city_industry_service_main_func_line);
|
|
|
mToastLayout = $(R.id.city_industry_service_main_toast);
|
|
|
+ mAreaLinearLayout = $(R.id.city_industry_service_main_area_ll);
|
|
|
+ mAreaImageView = $(R.id.city_industry_service_main_area_iv);
|
|
|
+ mSpreadAnimation = AnimationUtils.loadAnimation(ct, R.anim.anim_rotate_button_spread);
|
|
|
+ mFoldAnimation = AnimationUtils.loadAnimation(ct, R.anim.anim_rotate_button_fold);
|
|
|
+
|
|
|
+ mBanner.setImageLoader(new BannerImageLoader());
|
|
|
|
|
|
RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
|
|
|
viewPool.setMaxRecycledViews(0, 10);
|
|
|
@@ -185,23 +235,6 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- /*mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
|
|
- @Override
|
|
|
- public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
|
|
- int totalScrollRange = appBarLayout.getTotalScrollRange();
|
|
|
- int measuredHeight = mToolbar.getMeasuredHeight();
|
|
|
- Log.d("appbarscroll", "totalScrollRange->" + totalScrollRange);
|
|
|
- Log.d("appbarscroll", "verticalOffset->" + Math.abs(verticalOffset));
|
|
|
- Log.d("appbarscroll", "measuredHeight->" + measuredHeight);
|
|
|
- if (totalScrollRange <= ((Math.abs(verticalOffset)) + measuredHeight)) {
|
|
|
- mToolbar.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.antionbarcolor));
|
|
|
- } else {
|
|
|
- mToolbar.setBackgroundColor(Color.TRANSPARENT);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });*/
|
|
|
-
|
|
|
mRefreshLayout.setOnMultiPurposeListener(new SimpleMultiPurposeListener() {
|
|
|
@Override
|
|
|
public void onHeaderPulling(RefreshHeader header, float percent, int offset, int headerHeight, int extendHeight) {
|
|
|
@@ -219,11 +252,11 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
public void onRefresh(final RefreshLayout refreshLayout) {
|
|
|
if (CommonUtil.isNetWorkConnected(ct)) {
|
|
|
getDefaultService();
|
|
|
+ getLoopPics();
|
|
|
} else {
|
|
|
- toast(R.string.networks_out, mToastLayout);
|
|
|
-// Toast.makeText(ct, R.string.networks_out, Toast.LENGTH_LONG).show();
|
|
|
- if (refreshLayout.isRefreshing()) {
|
|
|
- mRefreshLayout.finishRefresh();
|
|
|
+ defaultServiceError(getString(R.string.networks_out));
|
|
|
+ if (mRefreshLayout.isRefreshing()) {
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -244,32 +277,64 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ mAreaLinearLayout.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if (!isAreaSpread) {
|
|
|
+ mAreaImageView.startAnimation(mSpreadAnimation);
|
|
|
+ isAreaSpread = true;
|
|
|
+ } else {
|
|
|
+ mAreaImageView.startAnimation(mFoldAnimation);
|
|
|
+ isAreaSpread = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initData() {
|
|
|
- mRefreshLayout.autoRefresh(400, 1f);
|
|
|
+ mRefreshLayout.autoRefresh(500, 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();
|
|
|
}
|
|
|
|
|
|
private void getDefaultService() {
|
|
|
+ String url = CommonUtil.getCityBaseUrl(ct) + "api/serve/getDefaultServices.action";
|
|
|
+// String url = "http://192.168.253.200:8080/Chapter/getParam/app/json";
|
|
|
+
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("kind", "cc");
|
|
|
-// params.put("client_type", "cc");
|
|
|
-// params.put("access_token", "123456");
|
|
|
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", CommonUtil.getB2BUid(this));
|
|
|
+
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, GET_DEFAULT_SERVICE, null, null, "get");
|
|
|
+
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
+// params.put("kind", "cc");
|
|
|
+//
|
|
|
+// LinkedHashMap<String, Object> header = new LinkedHashMap<>();
|
|
|
+// header.put("Cookie", CommonUtil.getB2BUid(this));
|
|
|
+//
|
|
|
+// Request request = new Request.Bulider()
|
|
|
+// .setUrl("api/serve/getDefaultServices.action")
|
|
|
+//// .setUrl("getParam/app/json")
|
|
|
+// .setWhat(GET_DEFAULT_SERVICE)
|
|
|
+// .setParam(params)
|
|
|
+// .setHeaders(header)
|
|
|
+// .setMode(Request.Mode.GET)
|
|
|
+// .bulid();
|
|
|
+// mPresenter.cityRequest(this, request);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getLoopPics() {
|
|
|
LinkedHashMap<String, Object> header = new LinkedHashMap<>();
|
|
|
- header.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ header.put("Cookie", CommonUtil.getB2BUid(this));
|
|
|
|
|
|
Request request = new Request.Bulider()
|
|
|
- .setUrl("api/serve/getDefaultServices.action")
|
|
|
- .setWhat(GET_DEFAULT_SERVICE)
|
|
|
- .setParam(params)
|
|
|
+ .setUrl("api/serve/mainPage/getRecyclePics.action")
|
|
|
+ .setWhat(GET_LOOP_PICS)
|
|
|
.setHeaders(header)
|
|
|
.setMode(Request.Mode.GET)
|
|
|
.bulid();
|
|
|
@@ -335,103 +400,120 @@ public class CityIndustryServiceMainActivity extends BaseMVPActivity<WorkPlatPre
|
|
|
|
|
|
@Override
|
|
|
public void requestSuccess(int what, Object object) {
|
|
|
+ Log.d("industryservice", "result->" + object.toString());
|
|
|
switch (what) {
|
|
|
case GET_DEFAULT_SERVICE:
|
|
|
- if (mRefreshLayout.isRefreshing()) {
|
|
|
- mRefreshLayout.finishRefresh();
|
|
|
+ analyzeDefaultSerivce(object);
|
|
|
+ break;
|
|
|
+ case GET_LOOP_PICS:
|
|
|
+ isLoopPicsFinish = true;
|
|
|
+ if (mRefreshLayout.isRefreshing() && isServiceFinish) {
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
}
|
|
|
String result = object.toString();
|
|
|
- Log.d("citydefaultservice", result);
|
|
|
if (JSONUtil.validate(result)) {
|
|
|
- mServesBeans.clear();
|
|
|
JSONObject resultObject = JSON.parseObject(result);
|
|
|
- JSONArray serviceArray = resultObject.getJSONArray("serves");
|
|
|
- if (serviceArray != null) {
|
|
|
- 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);
|
|
|
+ JSONArray serveArray = resultObject.getJSONArray("serve");
|
|
|
+ if (serveArray != null) {
|
|
|
+ List<String> imgList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < serveArray.size(); i++) {
|
|
|
+ JSONObject serveObject = serveArray.getJSONObject(i);
|
|
|
+ if (serveObject != null) {
|
|
|
+ String url = JSONUtil.getText(serveObject, "url");
|
|
|
+ imgList.add(url);
|
|
|
}
|
|
|
}
|
|
|
+ mBanner.update(imgList);
|
|
|
+ mBanner.start();
|
|
|
}
|
|
|
-
|
|
|
- CityIndustryServiceBean cityIndustryServiceBean = new CityIndustryServiceBean();
|
|
|
- cityIndustryServiceBean.setSv_name("全部服务");
|
|
|
- cityIndustryServiceBean.setSv_logourl("moreMenu");
|
|
|
- mServesBeans.add(cityIndustryServiceBean);
|
|
|
- }
|
|
|
- if (mServesBeans.size() == 0) {
|
|
|
- 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void analyzeDefaultSerivce(Object object) {
|
|
|
+ isServiceFinish = true;
|
|
|
+ if (mRefreshLayout.isRefreshing() && isLoopPicsFinish) {
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
+ }
|
|
|
+ String result = object.toString();
|
|
|
+ Log.d("citydefaultservice", result);
|
|
|
+ if (JSONUtil.validate(result)) {
|
|
|
+ mServesBeans.clear();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray serviceArray = resultObject.getJSONArray("serves");
|
|
|
+ if (serviceArray != null) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if (mServesBeans.size() == 0) {
|
|
|
+ CityIndustryServiceBean cityIndustryServiceBean = new CityIndustryServiceBean();
|
|
|
+ cityIndustryServiceBean.setSv_name("全部服务");
|
|
|
+ cityIndustryServiceBean.setSv_logourl("moreMenu");
|
|
|
+ mServesBeans.add(cityIndustryServiceBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ mFuncRecyclerView.setVisibility(View.VISIBLE);
|
|
|
+ mFuncLine.setVisibility(View.VISIBLE);
|
|
|
+ mCityIndustryFuncAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void requestError(int what, String errorMsg) {
|
|
|
switch (what) {
|
|
|
case GET_DEFAULT_SERVICE:
|
|
|
- mServesBeans.clear();
|
|
|
- if (mRefreshLayout.isRefreshing()) {
|
|
|
- mRefreshLayout.finishRefresh();
|
|
|
+ isServiceFinish = true;
|
|
|
+ if (mRefreshLayout.isRefreshing() && isLoopPicsFinish) {
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
+ }
|
|
|
+ defaultServiceError(errorMsg);
|
|
|
+ break;
|
|
|
+ case GET_LOOP_PICS:
|
|
|
+ isLoopPicsFinish = true;
|
|
|
+ if (mRefreshLayout.isRefreshing() && isServiceFinish) {
|
|
|
+ mRefreshLayout.finishRefresh(0);
|
|
|
}
|
|
|
- CityIndustryServiceBean cityIndustryServiceBean = new CityIndustryServiceBean();
|
|
|
- cityIndustryServiceBean.setSv_name("全部服务");
|
|
|
- cityIndustryServiceBean.setSv_logourl("moreMenu");
|
|
|
- mServesBeans.add(cityIndustryServiceBean);
|
|
|
-
|
|
|
- mFuncRecyclerView.setVisibility(View.VISIBLE);
|
|
|
- mFuncLine.setVisibility(View.VISIBLE);
|
|
|
- mCityIndustryFuncAdapter.notifyDataSetChanged();
|
|
|
- Toast.makeText(this, errorMsg, Toast.LENGTH_SHORT).show();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onStart() {
|
|
|
- super.onStart();
|
|
|
- mBanner.startAutoPlay();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onResume() {
|
|
|
- super.onResume();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onStop() {
|
|
|
- super.onStop();
|
|
|
- mBanner.stopAutoPlay();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
- super.onDestroy();
|
|
|
+ private void defaultServiceError(String errorMsg) {
|
|
|
+ mServesBeans.clear();
|
|
|
+ CityIndustryServiceBean cityIndustryServiceBean = new CityIndustryServiceBean();
|
|
|
+ cityIndustryServiceBean.setSv_name("全部服务");
|
|
|
+ cityIndustryServiceBean.setSv_logourl("moreMenu");
|
|
|
+ mServesBeans.add(cityIndustryServiceBean);
|
|
|
+
|
|
|
+ mFuncRecyclerView.setVisibility(View.VISIBLE);
|
|
|
+ mFuncLine.setVisibility(View.VISIBLE);
|
|
|
+ mCityIndustryFuncAdapter.notifyDataSetChanged();
|
|
|
+ toast(errorMsg, mToastLayout);
|
|
|
}
|
|
|
|
|
|
private class BannerImageLoader extends ImageLoader {
|
|
|
@Override
|
|
|
public void displayImage(Context context, Object path, ImageView imageView) {
|
|
|
-// ImageLoaderUtil.getInstance().loadImage(path.toString(), imageView);
|
|
|
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
- imageView.setImageResource((Integer) path);
|
|
|
+ ImageLoaderUtil.getInstance().loadImage(path.toString(), imageView);
|
|
|
}
|
|
|
}
|
|
|
}
|