|
|
@@ -1,11 +1,13 @@
|
|
|
package com.xzjmyk.pm.activity.ui.erp.fragment;
|
|
|
|
|
|
+import android.content.Intent;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.util.Log;
|
|
|
import android.util.TypedValue;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.View;
|
|
|
+import android.widget.AdapterView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.RadioButton;
|
|
|
@@ -17,6 +19,7 @@ import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.adapter.AllSubscriptionAdapter;
|
|
|
import com.xzjmyk.pm.activity.bean.SubscriptionNumber;
|
|
|
import com.xzjmyk.pm.activity.bean.message.AllSubscriptonKindMessage;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.activity.SubscribeDetailActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
@@ -48,6 +51,8 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
private RadioGroup mRadioGroup;
|
|
|
private int rbPos = 0;
|
|
|
private List<String> keyStrings = new ArrayList<>();
|
|
|
+ private final static int SUBSCRIBE_DETAIL_REQUEST = 33;
|
|
|
+ private static int mClickedPos = -1;
|
|
|
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
@@ -61,9 +66,9 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
mPullToRefreshListView = (PullToRefreshListView) root.findViewById(R.id.subscription_all_ptlv);
|
|
|
mAllSubscriptonKindMessages = new ArrayList<>();
|
|
|
mSubscriptionNumbers = new ArrayList<>();
|
|
|
- mAllSubscriptionAdapter = new AllSubscriptionAdapter(getActivity(),mSubscriptionNumbers);
|
|
|
+ mAllSubscriptionAdapter = new AllSubscriptionAdapter(getActivity(), mSubscriptionNumbers);
|
|
|
|
|
|
- mEmptyLayout = new EmptyLayout(getActivity(),mPullToRefreshListView.getRefreshableView());
|
|
|
+ mEmptyLayout = new EmptyLayout(getActivity(), mPullToRefreshListView.getRefreshableView());
|
|
|
mEmptyLayout.setShowLoadingButton(false);
|
|
|
mEmptyLayout.setShowEmptyButton(false);
|
|
|
mEmptyLayout.setShowErrorButton(false);
|
|
|
@@ -93,8 +98,20 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
}, 1000);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
mRadioGroup.setOnCheckedChangeListener(this);
|
|
|
+ mPullToRefreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ mClickedPos = position;
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setClass(getActivity(), SubscribeDetailActivity.class);
|
|
|
+ intent.putExtra("flag","all");
|
|
|
+ intent.putExtra("subId", mSubscriptionNumbers.get(position - 1).getId());
|
|
|
+ intent.putExtra("subTitle", mSubscriptionNumbers.get(position - 1).getTitle());
|
|
|
+ intent.putExtra("subStatus", mSubscriptionNumbers.get(position - 1).getStatus());
|
|
|
+ startActivityForResult(intent, SUBSCRIBE_DETAIL_REQUEST);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -109,18 +126,18 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
progressDialog.show();
|
|
|
String allSubsUrl = Constants.getAppBaseUrl(getActivity()) + "common/charts/getApplySubs.action";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("em_code", CommonUtil.getSharedPreferences(getActivity(),"erp_username"));
|
|
|
+ params.put("em_code", CommonUtil.getSharedPreferences(getActivity(), "erp_username"));
|
|
|
|
|
|
LinkedHashMap headers = new LinkedHashMap();
|
|
|
- headers.put("Cookie","JSESSIONID="+CommonUtil.getSharedPreferences(getActivity(),"sessionId"));
|
|
|
- ViewUtil.httpSendRequest(getActivity(),allSubsUrl,params,mHandler,headers,GET_ALL_SUBSCRIPTION,null,null,"post");
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(getActivity(), "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(getActivity(), allSubsUrl, params, mHandler, headers, GET_ALL_SUBSCRIPTION, null, null, "post");
|
|
|
}
|
|
|
|
|
|
private final static int GET_ALL_SUBSCRIPTION = 44;
|
|
|
- private Handler mHandler = new Handler(){
|
|
|
+ private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
- switch (msg.what){
|
|
|
+ switch (msg.what) {
|
|
|
case GET_ALL_SUBSCRIPTION:
|
|
|
progressDialog.dismiss();
|
|
|
String resultJson = msg.getData().getString("result");
|
|
|
@@ -130,23 +147,23 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
JSONArray datasArray = resultObject.getJSONArray("datas");
|
|
|
JSONObject datasObject = datasArray.getJSONObject(0);
|
|
|
Iterator<String> iterator = datasObject.keys();
|
|
|
- if (!iterator.hasNext()){
|
|
|
+ if (!iterator.hasNext()) {
|
|
|
mEmptyLayout.showEmpty();
|
|
|
- if (mPullToRefreshListView.isRefreshing()){
|
|
|
+ if (mPullToRefreshListView.isRefreshing()) {
|
|
|
mPullToRefreshListView.onRefreshComplete();
|
|
|
- Crouton.makeText(getActivity(),"没有订阅数据", 0xff99cc00,1500).show();
|
|
|
+ Crouton.makeText(getActivity(), "没有订阅数据", 0xff99cc00, 1500).show();
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
keyStrings.clear();
|
|
|
mRadioGroup.removeAllViews();
|
|
|
- while (iterator.hasNext()){
|
|
|
+ while (iterator.hasNext()) {
|
|
|
String key = iterator.next().toString();
|
|
|
|
|
|
keyStrings.add(key);
|
|
|
|
|
|
- Log.d("allsubskeys: ",key);
|
|
|
+ Log.d("allsubskeys: ", key);
|
|
|
AllSubscriptonKindMessage subscriptonKindMessage = new AllSubscriptonKindMessage();
|
|
|
subscriptonKindMessage.setSubscriptionKind(key);
|
|
|
List<SubscriptionNumber> subscriptionNumbers = new ArrayList<>();
|
|
|
@@ -160,11 +177,11 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
subscriptionNumber.setTitle(subsObject.getString("title"));
|
|
|
subscriptionNumber.setKind(subsObject.getString("kind"));
|
|
|
subscriptionNumber.setStatus(subsObject.getInt("status"));
|
|
|
- if (subsObject.getInt("status") != 1){
|
|
|
+ if (subsObject.getInt("status") != 1) {
|
|
|
subscriptionNumbers.add(subscriptionNumber);
|
|
|
}
|
|
|
}
|
|
|
- if (subscriptionNumbers.size() != 0){
|
|
|
+ if (subscriptionNumbers.size() != 0) {
|
|
|
subscriptonKindMessage.setSubscriptionNumbers(subscriptionNumbers);
|
|
|
mAllSubscriptonKindMessages.add(subscriptonKindMessage);
|
|
|
}
|
|
|
@@ -174,9 +191,9 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- if (keyStrings.size() == 0){
|
|
|
+ if (keyStrings.size() == 0) {
|
|
|
mRadioGroup.setVisibility(View.GONE);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
mRadioGroup.setVisibility(View.VISIBLE);
|
|
|
for (int i = 0; i < keyStrings.size(); i++) {
|
|
|
RadioButton radioButton = new RadioButton(getActivity());
|
|
|
@@ -185,13 +202,14 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
radioButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
|
|
radioButton.setBackground(getResources().getDrawable(R.drawable.selector_subscribe_bg));
|
|
|
radioButton.setText(keyStrings.get(i));
|
|
|
+ radioButton.setTextColor(getResources().getColor(R.color.selector_subscribe_tv));
|
|
|
radioButton.setPadding(0, 30, 0, 30);
|
|
|
radioButton.setId(i);
|
|
|
|
|
|
- if (i == rbPos){
|
|
|
+ if (i == rbPos) {
|
|
|
// radioButton.setTextColor(getResources().getColor(R.color.red));
|
|
|
radioButton.setChecked(true);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// radioButton.setTextColor(getResources().getColor(R.color.black));
|
|
|
radioButton.setChecked(false);
|
|
|
}
|
|
|
@@ -201,16 +219,16 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
}
|
|
|
mSubscriptionNumbers.clear();
|
|
|
mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
- Log.d("allsubscription:",mSubscriptionNumbers.toString());
|
|
|
+ Log.d("allsubscription:", mSubscriptionNumbers.toString());
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
- if (mPullToRefreshListView.isRefreshing()){
|
|
|
+ if (mPullToRefreshListView.isRefreshing()) {
|
|
|
mPullToRefreshListView.onRefreshComplete();
|
|
|
- Crouton.makeText(getActivity(),"刷新成功", 0xff99cc00,1500).show();
|
|
|
+ Crouton.makeText(getActivity(), "刷新成功", 0xff99cc00, 1500).show();
|
|
|
}
|
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
progressDialog.dismiss();
|
|
|
- Crouton.makeText(getActivity(),msg.getData().getString("result"), Style.ALERT).show();
|
|
|
+ Crouton.makeText(getActivity(), msg.getData().getString("result"), Style.ALERT).show();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -232,4 +250,16 @@ public class SubscriptionAllFragment extends BaseFragment implements RadioGroup.
|
|
|
mSubscriptionNumbers.addAll(mAllSubscriptonKindMessages.get(rbPos).getSubscriptionNumbers());
|
|
|
mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ if (requestCode == SUBSCRIBE_DETAIL_REQUEST && resultCode == 9 && data != null) {
|
|
|
+ int statu = data.getIntExtra("status", 0);
|
|
|
+ if (mClickedPos != -1){
|
|
|
+ mSubscriptionNumbers.get(mClickedPos - 1).setStatus(statu);
|
|
|
+ mAllSubscriptionAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|