|
|
@@ -3,20 +3,11 @@ package com.xzjmyk.pm.activity.ui.erp.fragment;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.util.Log;
|
|
|
-import android.view.Gravity;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.PopupWindow;
|
|
|
import android.widget.ScrollView;
|
|
|
-import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
-import com.baoyz.swipemenulistview.MySwipeMenuListView;
|
|
|
-import com.baoyz.swipemenulistview.SwipeMenu;
|
|
|
-import com.baoyz.swipemenulistview.SwipeMenuListView;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
|
|
|
-import com.xzjmyk.pm.activity.MySwipeMenuCreator;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.adapter.MySubscriptionAdapter;
|
|
|
import com.xzjmyk.pm.activity.bean.PersonalSubscriptionBean;
|
|
|
@@ -24,7 +15,7 @@ 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;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
-import com.xzjmyk.pm.activity.util.DisplayUtil;
|
|
|
+import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
@@ -43,18 +34,12 @@ import java.util.Map;
|
|
|
*/
|
|
|
public class SubscriptionMyFragment extends BaseFragment {
|
|
|
private PullToRefreshScrollView mPullToRefreshScrollView;
|
|
|
- private MySwipeMenuListView mSwipeMenuListView;
|
|
|
+ private MyListView mMyListView;
|
|
|
private List<PersonalSubscriptionBean> mPersonalSubscriptionBeans;
|
|
|
- private MySwipeMenuCreator mMySwipeMenuCreator;
|
|
|
private MySubscriptionAdapter mMySubscriptionAdapter;
|
|
|
- private PopupWindow mCancleWindow;
|
|
|
- private int mStartSwipe;
|
|
|
- private int mEndSwipe;
|
|
|
|
|
|
private final static int GET_MY_SUBSCRIPTION = 12;
|
|
|
- private final static int REMOVE_MY_SUBSCRIPTION = 13;
|
|
|
|
|
|
- private int mCanclePosition;
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
@@ -65,12 +50,9 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
protected void initViews() {
|
|
|
mPersonalSubscriptionBeans = new ArrayList<>();
|
|
|
mPullToRefreshScrollView = (PullToRefreshScrollView) root.findViewById(R.id.my_subscription_ptrsv);
|
|
|
- mSwipeMenuListView = (MySwipeMenuListView) root.findViewById(R.id.my_subscripton_smlv);
|
|
|
+ mMyListView = (MyListView) root.findViewById(R.id.my_subscripton_smlv);
|
|
|
mMySubscriptionAdapter = new MySubscriptionAdapter(getActivity(),mPersonalSubscriptionBeans);
|
|
|
- mMySwipeMenuCreator = new MySwipeMenuCreator(getActivity());
|
|
|
-
|
|
|
-
|
|
|
- mEmptyLayout = new EmptyLayout(getActivity(),mSwipeMenuListView);
|
|
|
+ mEmptyLayout = new EmptyLayout(getActivity(),mMyListView);
|
|
|
mEmptyLayout.setShowLoadingButton(false);
|
|
|
mEmptyLayout.setShowEmptyButton(false);
|
|
|
mEmptyLayout.setShowErrorButton(false);
|
|
|
@@ -79,63 +61,7 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
- mSwipeMenuListView.setAdapter(mMySubscriptionAdapter);
|
|
|
- mSwipeMenuListView.setMenuCreator(mMySwipeMenuCreator);
|
|
|
- mSwipeMenuListView.setSwipeDirection(SwipeMenuListView.DIRECTION_LEFT);
|
|
|
-
|
|
|
- mSwipeMenuListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() {
|
|
|
- @Override
|
|
|
- public void onSwipeStart(int position) {
|
|
|
- mStartSwipe = position;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onSwipeEnd(int position) {
|
|
|
- mEndSwipe = position;
|
|
|
- if (mPersonalSubscriptionBeans.get(mStartSwipe).getISAPPLED() == 0) {
|
|
|
- mSwipeMenuListView.smoothCloseMenu();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- mSwipeMenuListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
|
|
|
- @Override
|
|
|
- public boolean onMenuItemClick(final int position, SwipeMenu menu, int index) {
|
|
|
- View cancleView = View.inflate(getActivity(), R.layout.pop_cancle_my_subscribe, null);
|
|
|
- TextView cancleTextView = (TextView) cancleView.findViewById(R.id.cancel_subscribe_cancle_tv);
|
|
|
- TextView contineTextView = (TextView) cancleView.findViewById(R.id.cancel_subscribe_contine_tv);
|
|
|
-
|
|
|
- cancleTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
-// Crouton.makeText(getActivity(), "取消成功", 0xff99cc00, 1500).show();
|
|
|
- mCanclePosition = position;
|
|
|
- sendRemoveRequest(mCanclePosition);
|
|
|
- closeWarningPopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- contineTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- closeWarningPopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- mCancleWindow = new PopupWindow(cancleView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
- mCancleWindow.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
- mCancleWindow.showAtLocation(mSwipeMenuListView, Gravity.BOTTOM, 0, 0);
|
|
|
- DisplayUtil.backgroundAlpha(getActivity(), 0.5f);
|
|
|
-
|
|
|
- mCancleWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
- @Override
|
|
|
- public void onDismiss() {
|
|
|
- closeWarningPopupWindow();
|
|
|
- }
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
+ mMyListView.setAdapter(mMySubscriptionAdapter);
|
|
|
|
|
|
mPullToRefreshScrollView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
|
|
mPullToRefreshScrollView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ScrollView>() {
|
|
|
@@ -172,23 +98,6 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
ViewUtil.httpSendRequest(getActivity(), subsUrl, params, mHandler, headers, GET_MY_SUBSCRIPTION, null, null, "post");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 取消订阅
|
|
|
- */
|
|
|
- private void sendRemoveRequest(int position) {
|
|
|
- progressDialog.show();
|
|
|
- String subsUrl = Constants.getAppBaseUrl(getActivity()) + "common/charts/removeSubsMans.action";
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("emcode", CommonUtil.getSharedPreferences(getActivity(),"erp_username"));
|
|
|
- params.put("numIds", mPersonalSubscriptionBeans.get(position).getNUM_ID());
|
|
|
-
|
|
|
- LinkedHashMap headers = new LinkedHashMap();
|
|
|
- headers.put("Cookie","JSESSIONID=" + CommonUtil.getSharedPreferences(getActivity(),"sessionId"));
|
|
|
- ViewUtil.httpSendRequest(getActivity(), subsUrl, params, mHandler, headers, REMOVE_MY_SUBSCRIPTION, null, null, "post");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
private Handler mHandler = new Handler(){
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
@@ -234,14 +143,6 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
-
|
|
|
- case REMOVE_MY_SUBSCRIPTION:
|
|
|
- progressDialog.dismiss();
|
|
|
- Crouton.makeText(getActivity(), "取消订阅成功", 0xff99cc00, 1500).show();
|
|
|
- mPersonalSubscriptionBeans.remove(mCanclePosition);
|
|
|
- mMySubscriptionAdapter.notifyDataSetChanged();
|
|
|
- break;
|
|
|
-
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
progressDialog.dismiss();
|
|
|
Crouton.makeText(getActivity(), msg.getData().getString("result"), 0xff99cc00, 1500).show();
|
|
|
@@ -253,14 +154,4 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
- private void closeWarningPopupWindow() {
|
|
|
- if (mCancleWindow != null) {
|
|
|
- mCancleWindow.dismiss();
|
|
|
- mCancleWindow = null;
|
|
|
- DisplayUtil.backgroundAlpha(getActivity(), 1f);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
}
|