|
|
@@ -4,10 +4,14 @@ 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.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;
|
|
|
@@ -21,11 +25,14 @@ import java.util.List;
|
|
|
* Created by PROD on 2016/9/5.
|
|
|
*/
|
|
|
public class SubscriptionMyFragment extends BaseFragment {
|
|
|
+ private PullToRefreshScrollView mPullToRefreshScrollView;
|
|
|
private SwipeMenuListView mSwipeMenuListView;
|
|
|
private List<String> mStrings = new ArrayList<>();
|
|
|
private MySwipeMenuCreator mMySwipeMenuCreator;
|
|
|
private MySubscriptionAdapter mMySubscriptionAdapter;
|
|
|
private PopupWindow mCancleWindow;
|
|
|
+ private int mStartSwipe;
|
|
|
+ private int mEndSwipe;
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_my_subscription;
|
|
|
@@ -33,10 +40,11 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
|
|
|
@Override
|
|
|
protected void initViews() {
|
|
|
- for (int i = 0; i < 20; i++) {
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
mStrings.add("this is item "+i);
|
|
|
}
|
|
|
|
|
|
+ mPullToRefreshScrollView = (PullToRefreshScrollView) root.findViewById(R.id.my_subscription_ptrsv);
|
|
|
mSwipeMenuListView = (SwipeMenuListView) root.findViewById(R.id.my_subscripton_smlv);
|
|
|
mMySubscriptionAdapter = new MySubscriptionAdapter(getActivity(),mStrings);
|
|
|
mMySwipeMenuCreator = new MySwipeMenuCreator(getActivity());
|
|
|
@@ -52,27 +60,29 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
mSwipeMenuListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() {
|
|
|
@Override
|
|
|
public void onSwipeStart(int position) {
|
|
|
+ mStartSwipe = position;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onSwipeEnd(int position) {
|
|
|
- if ((position % 2) == 0){
|
|
|
+ mEndSwipe = position;
|
|
|
+ if ((mStartSwipe % 2) == 0) {
|
|
|
mSwipeMenuListView.smoothCloseMenu();
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
mSwipeMenuListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
|
|
|
@Override
|
|
|
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
|
|
|
- View cancleView = View.inflate(getActivity(),R.layout.pop_cancle_my_subscribe,null);
|
|
|
+ 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();
|
|
|
+ Crouton.makeText(getActivity(), "取消成功", 0xff99cc00, 1500).show();
|
|
|
closeWarningPopupWindow();
|
|
|
}
|
|
|
});
|
|
|
@@ -84,9 +94,9 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- mCancleWindow = new PopupWindow(cancleView, LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT,true);
|
|
|
+ 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);
|
|
|
+ mCancleWindow.showAtLocation(mSwipeMenuListView, Gravity.BOTTOM, 0, 0);
|
|
|
DisplayUtil.backgroundAlpha(getActivity(), 0.5f);
|
|
|
|
|
|
mCancleWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
@@ -98,6 +108,30 @@ public class SubscriptionMyFragment extends BaseFragment {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ mPullToRefreshScrollView.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ mPullToRefreshScrollView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ScrollView>() {
|
|
|
+ @Override
|
|
|
+ public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
|
|
|
+ mStrings.clear();
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ mStrings.add("this is item "+i);
|
|
|
+ }
|
|
|
+ mMySubscriptionAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ Toast.makeText(getActivity(), "refresh down success", Toast.LENGTH_SHORT).show();
|
|
|
+ mPullToRefreshScrollView.onRefreshComplete();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
|
|
|
+ mStrings.add("add item");
|
|
|
+ mMySubscriptionAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ Toast.makeText(getActivity(), "refresh up success", Toast.LENGTH_SHORT).show();
|
|
|
+ mPullToRefreshScrollView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|