|
|
@@ -1,7 +1,9 @@
|
|
|
package com.modular.booking.activity.services;
|
|
|
|
|
|
+import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.view.View;
|
|
|
+import android.widget.AdapterView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -22,7 +24,7 @@ import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
import com.modular.booking.R;
|
|
|
import com.modular.booking.adapter.ItemBserviceStoremanListAdapter;
|
|
|
-import com.modular.booking.model.SBMenuModel;
|
|
|
+import com.modular.booking.model.SBListModel;
|
|
|
import com.modular.booking.model.SBStoremanModel;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
@@ -34,104 +36,115 @@ import java.util.List;
|
|
|
*/
|
|
|
|
|
|
public class BServiceDetailActivity extends OABaseActivity implements View.OnClickListener {
|
|
|
- private TextView mBookStoreTv;
|
|
|
- private PullToRefreshListView mBookDetailPtlv;
|
|
|
- private HttpClient mHttpClient;
|
|
|
- private ItemBserviceStoremanListAdapter mStoremanListAdapter;
|
|
|
- private List<SBStoremanModel> mStoremanModels;
|
|
|
- private EmptyLayout mEmptyLayout;
|
|
|
- private String mCompanyId, mServiceId;
|
|
|
- private SBMenuModel mMenuModel;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setContentView(R.layout.activity_book_service_detail);
|
|
|
-
|
|
|
- initViews();
|
|
|
- initEvents();
|
|
|
- initDatas();
|
|
|
- }
|
|
|
-
|
|
|
- private void initDatas() {
|
|
|
- progressDialog.show();
|
|
|
- mCompanyId = "201";
|
|
|
- mServiceId = "10001";
|
|
|
-
|
|
|
- mHttpClient.Api().send(new HttpClient.Builder()
|
|
|
- .url("/user/appStoreman")
|
|
|
- .add("companyid", mCompanyId)
|
|
|
- .add("serviceid", mServiceId)
|
|
|
- .add("Token", MyApplication.getInstance().mAccessToken)
|
|
|
- .method(Method.POST)
|
|
|
- .build(), new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
- @Override
|
|
|
- public void onResponse(Object o) {
|
|
|
- progressDialog.dismiss();
|
|
|
- try {
|
|
|
- LogUtil.d("appstoreman", o.toString());
|
|
|
- if (JSONUtil.validate(o.toString())) {
|
|
|
- JSONObject resultObject = JSON.parseObject(o.toString());
|
|
|
- JSONArray resultArray = resultObject.getJSONArray("result");
|
|
|
- if (!ListUtils.isEmpty(resultArray)) {
|
|
|
- for (int i = 0; i < resultArray.size(); i++) {
|
|
|
- JSONObject jsonObject = resultArray.getJSONObject(i);
|
|
|
- SBStoremanModel sbStoremanModel = new SBStoremanModel();
|
|
|
- sbStoremanModel.setSm_companyid(jsonObject.getString("sm_companyid"));
|
|
|
- sbStoremanModel.setSm_companyname(jsonObject.getString("sm_companyname"));
|
|
|
- sbStoremanModel.setSm_id(jsonObject.getString("sm_id"));
|
|
|
- sbStoremanModel.setSm_level(jsonObject.getString("sm_level"));
|
|
|
- sbStoremanModel.setSm_stid(jsonObject.getString("sm_stid"));
|
|
|
- sbStoremanModel.setSm_stname(jsonObject.getString("sm_stname"));
|
|
|
- sbStoremanModel.setSm_telephone(jsonObject.getString("sm_telephone"));
|
|
|
- sbStoremanModel.setSm_userid(jsonObject.getString("sm_userid"));
|
|
|
- sbStoremanModel.setSm_username(jsonObject.getString("sm_username"));
|
|
|
-
|
|
|
- mStoremanModels.add(sbStoremanModel);
|
|
|
- }
|
|
|
- mStoremanListAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- }
|
|
|
- if (mStoremanModels.size() == 0) {
|
|
|
- mEmptyLayout.showEmpty();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }));
|
|
|
- }
|
|
|
-
|
|
|
- private void initEvents() {
|
|
|
- mBookStoreTv.setOnClickListener(this);
|
|
|
- }
|
|
|
-
|
|
|
- private void initViews() {
|
|
|
- mBookStoreTv = (TextView) findViewById(R.id.book_service_detail_store_tv);
|
|
|
- mBookDetailPtlv = (PullToRefreshListView) findViewById(R.id.book_service_detail_ptlv);
|
|
|
- mBookDetailPtlv.setMode(PullToRefreshBase.Mode.DISABLED);
|
|
|
-
|
|
|
- mEmptyLayout = new EmptyLayout(this, mBookDetailPtlv.getRefreshableView());
|
|
|
- mEmptyLayout.setShowLoadingButton(false);
|
|
|
- mEmptyLayout.setShowErrorButton(false);
|
|
|
- mEmptyLayout.setShowEmptyButton(false);
|
|
|
-
|
|
|
- if (getIntent() != null) {
|
|
|
- mMenuModel = getIntent().getParcelableExtra("SBMenuModel");
|
|
|
- LogUtil.d("myTest", "mMenuModel:" + JSON.toJSONString(mMenuModel));
|
|
|
- }
|
|
|
-
|
|
|
- mHttpClient = new HttpClient.Builder(Constants.IM_BASE_URL).isDebug(true).build();
|
|
|
- mStoremanModels = new ArrayList<>();
|
|
|
- mStoremanListAdapter = new ItemBserviceStoremanListAdapter(this, mStoremanModels);
|
|
|
- mBookDetailPtlv.setAdapter(mStoremanListAdapter);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- int id = v.getId();
|
|
|
- if (id == R.id.book_service_detail_store_tv) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ private TextView mBookStoreTv;
|
|
|
+ private PullToRefreshListView mBookDetailPtlv;
|
|
|
+ private HttpClient mHttpClient;
|
|
|
+ private ItemBserviceStoremanListAdapter mStoremanListAdapter;
|
|
|
+ private List<SBStoremanModel> mStoremanModels;
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+ private String mCompanyId, mServiceId;
|
|
|
+ private SBListModel model;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_book_service_detail);
|
|
|
+
|
|
|
+ initViews();
|
|
|
+ initEvents();
|
|
|
+ initDatas();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initDatas() {
|
|
|
+ progressDialog.show();
|
|
|
+ mCompanyId = model.getCompanyid();
|
|
|
+ mServiceId = "0";
|
|
|
+ mHttpClient.Api().send(new HttpClient.Builder()
|
|
|
+ .url("/user/appStoreman")
|
|
|
+ .add("companyid", mCompanyId)
|
|
|
+ .add("serviceid", mServiceId)
|
|
|
+ .add("Token", MyApplication.getInstance().mAccessToken)
|
|
|
+ .method(Method.POST)
|
|
|
+ .build(), new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(Object o) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ try {
|
|
|
+ LogUtil.d("appstoreman", o.toString());
|
|
|
+ if (JSONUtil.validate(o.toString())) {
|
|
|
+ JSONObject resultObject = JSON.parseObject(o.toString());
|
|
|
+ JSONArray resultArray = resultObject.getJSONArray("result");
|
|
|
+ if (!ListUtils.isEmpty(resultArray)) {
|
|
|
+ for (int i = 0; i < resultArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = resultArray.getJSONObject(i);
|
|
|
+ SBStoremanModel sbStoremanModel = new SBStoremanModel();
|
|
|
+ sbStoremanModel.setSm_companyid(jsonObject.getString("sm_companyid"));
|
|
|
+ sbStoremanModel.setSm_companyname(jsonObject.getString("sm_companyname"));
|
|
|
+ sbStoremanModel.setSm_id(jsonObject.getString("sm_id"));
|
|
|
+ sbStoremanModel.setSm_level(jsonObject.getString("sm_level"));
|
|
|
+ sbStoremanModel.setSm_stid(jsonObject.getString("sm_stid"));
|
|
|
+ sbStoremanModel.setSm_stname(jsonObject.getString("sm_stname"));
|
|
|
+ sbStoremanModel.setSm_telephone(jsonObject.getString("sm_telephone"));
|
|
|
+ sbStoremanModel.setSm_userid(jsonObject.getString("sm_userid"));
|
|
|
+ sbStoremanModel.setSm_username(jsonObject.getString("sm_username"));
|
|
|
+ mStoremanModels.add(sbStoremanModel);
|
|
|
+ }
|
|
|
+ mStoremanListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mStoremanModels.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initEvents() {
|
|
|
+ mBookStoreTv.setOnClickListener(this);
|
|
|
+ mBookDetailPtlv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ SBStoremanModel bean = mStoremanListAdapter.getItem((int) id);
|
|
|
+ Intent intent = new Intent(ct, BServiceAddActivity.class);
|
|
|
+ intent.putExtra("model", model);
|
|
|
+ intent.putExtra("sb_userid", bean.getSm_userid());
|
|
|
+ intent.putExtra("sb_username", bean.getSm_username());
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initViews() {
|
|
|
+ mBookStoreTv = (TextView) findViewById(R.id.book_service_detail_store_tv);
|
|
|
+ mBookDetailPtlv = (PullToRefreshListView) findViewById(R.id.book_service_detail_ptlv);
|
|
|
+ mBookDetailPtlv.setMode(PullToRefreshBase.Mode.DISABLED);
|
|
|
+
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mBookDetailPtlv.getRefreshableView());
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+
|
|
|
+ if (getIntent() != null) {
|
|
|
+ model = getIntent().getParcelableExtra("model");
|
|
|
+ LogUtil.d("myTest", "model:" + JSON.toJSONString(model));
|
|
|
+ }
|
|
|
+
|
|
|
+ mHttpClient = new HttpClient.Builder(Constants.IM_BASE_URL).isDebug(true).build();
|
|
|
+ mStoremanModels = new ArrayList<>();
|
|
|
+ mStoremanListAdapter = new ItemBserviceStoremanListAdapter(this, mStoremanModels);
|
|
|
+ mBookDetailPtlv.setAdapter(mStoremanListAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ int id = v.getId();
|
|
|
+ if (id == R.id.book_service_detail_store_tv) {
|
|
|
+ Intent intent = new Intent(ct, BServiceAddActivity.class);
|
|
|
+ intent.putExtra("model", model);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|