Commit 42f41ee5 authored by 姜敏's avatar 姜敏

添加颜色

parent aca816ff
package com.xingdata.zzdpos.ui.vip; package com.xingdata.zzdpos.ui.vip;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity; import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.databinding.ActivityVipBinding; import com.xingdata.zzdpos.databinding.ActivityVipBinding;
import com.xingdata.zzdpos.model.Level; import com.xingdata.zzdpos.model.Level;
import com.xingdata.zzdpos.model.Pager; import com.xingdata.zzdpos.model.Pager;
import com.xingdata.zzdpos.model.Vip; import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.vip.fragment.VipFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipInfoFragment; import com.xingdata.zzdpos.ui.vip.fragment.VipInfoFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipLevleFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipListFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipTitleFragment;
import com.xingdata.zzdpos.util.OnClickListener;
public class VipActivity extends BaseActivity<VipPresenter, ActivityVipBinding> implements VipContract.View { public class VipActivity extends BaseActivity<VipPresenter, ActivityVipBinding> implements VipContract.View {
...@@ -23,31 +19,28 @@ public class VipActivity extends BaseActivity<VipPresenter, ActivityVipBinding> ...@@ -23,31 +19,28 @@ public class VipActivity extends BaseActivity<VipPresenter, ActivityVipBinding>
@Override @Override
public void initView() { public void initView() {
loadRootFragment(R.id.vip_list_frame, mPresenter.vipListFragment, false, false); loadRootFragment(R.id.vip_frame, new VipFragment(), true, false);
loadRootFragment(R.id.vip_level_frame, mPresenter.vipLevleFragment, false, false);
loadRootFragment(R.id.vip_title_frame, mPresenter.vipTitleFragment, false, false);
} }
@Override @Override
public void addVip() { public void addVip() {
start(mPresenter.vipFragment);
} }
@Override @Override
public String addVipSus() { public String addVipSus(Vip vip) {
return null; return null;
} }
@Override @Override
public void getVipLevelSus(Pager<Level> levelPager) { public void getVipLevelSus(Pager<Level> levelPager) {
mPresenter.vipLevleFragment.getVipLevelSus(levelPager); mPresenter.vipFragment.getVipLevelSus(levelPager);
} }
@Override @Override
public void getVipListSus(Pager<Vip> vipPager,int pageNumber) { public void getVipListSus(Pager<Vip> vipPager, int pageNumber) {
mPresenter.vipListFragment.getVipListSus(vipPager,pageNumber); mPresenter.vipFragment.getVipListSus(vipPager, pageNumber);
} }
......
...@@ -12,7 +12,7 @@ public interface VipContract { ...@@ -12,7 +12,7 @@ public interface VipContract {
interface View extends BaseView { interface View extends BaseView {
void addVip(); void addVip();
String addVipSus(); String addVipSus(Vip vip);
void getVipLevelSus(Pager<Level> levelPager); void getVipLevelSus(Pager<Level> levelPager);
...@@ -30,6 +30,6 @@ public interface VipContract { ...@@ -30,6 +30,6 @@ public interface VipContract {
public abstract void getVipNumber(); public abstract void getVipNumber();
public abstract void addVip(); public abstract void addVip(Vip vip);
} }
} }
\ No newline at end of file
...@@ -3,17 +3,13 @@ package com.xingdata.zzdpos.ui.vip; ...@@ -3,17 +3,13 @@ package com.xingdata.zzdpos.ui.vip;
import com.blankj.utilcode.util.ToastUtils; import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.api.ApiFactory; import com.xingdata.zzdpos.api.ApiFactory;
import com.xingdata.zzdpos.ui.vip.fragment.VipExpenseListFragment; import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.vip.fragment.VipFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipInfoFragment; import com.xingdata.zzdpos.ui.vip.fragment.VipInfoFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipLevleFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipListFragment;
import com.xingdata.zzdpos.ui.vip.fragment.VipTitleFragment;
public class VipPresenter extends VipContract.Presenter { public class VipPresenter extends VipContract.Presenter {
public VipFragment vipFragment = new VipFragment();
public VipInfoFragment vipInfoFragment = new VipInfoFragment(); public VipInfoFragment vipInfoFragment = new VipInfoFragment();
public VipListFragment vipListFragment = new VipListFragment();
public VipLevleFragment vipLevleFragment = new VipLevleFragment();
public VipTitleFragment vipTitleFragment = new VipTitleFragment();
@Override @Override
public void onAttached() { public void onAttached() {
...@@ -22,8 +18,8 @@ public class VipPresenter extends VipContract.Presenter { ...@@ -22,8 +18,8 @@ public class VipPresenter extends VipContract.Presenter {
@Override @Override
public void getVipList(int pageNumber, String vipLevel) { public void getVipList(int pageNumber, String vipLevel) {
ApiFactory.User.getVipList(pageNumber,vipLevel).subscribe(vipPager -> { ApiFactory.User.getVipList(pageNumber, vipLevel).subscribe(vipPager -> {
mView.getVipListSus(vipPager,pageNumber); mView.getVipListSus(vipPager, pageNumber);
}, throwable -> { }, throwable -> {
ToastUtils.showShort(throwable.getMessage()); ToastUtils.showShort(throwable.getMessage());
}); });
...@@ -46,7 +42,11 @@ public class VipPresenter extends VipContract.Presenter { ...@@ -46,7 +42,11 @@ public class VipPresenter extends VipContract.Presenter {
} }
@Override @Override
public void addVip() { public void addVip(Vip vip) {
mView.addVip(); ApiFactory.User.addVip(vip).subscribe(mVip -> {
mView.addVipSus(mVip);
}, throwable -> {
ToastUtils.showShort(throwable.getMessage());
});
} }
} }
...@@ -4,6 +4,7 @@ package com.xingdata.zzdpos.ui.vip.fragment; ...@@ -4,6 +4,7 @@ package com.xingdata.zzdpos.ui.vip.fragment;
* Created by JM_DEV on 2017/12/21. * Created by JM_DEV on 2017/12/21.
*/ */
import android.annotation.SuppressLint;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import com.blankj.utilcode.util.ToastUtils; import com.blankj.utilcode.util.ToastUtils;
...@@ -11,6 +12,7 @@ import com.xingdata.zzdpos.R; ...@@ -11,6 +12,7 @@ import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity; import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentVipExpenseListBinding; import com.xingdata.zzdpos.databinding.FragmentVipExpenseListBinding;
import com.xingdata.zzdpos.model.Level;
import com.xingdata.zzdpos.model.VipRechargeOrder; import com.xingdata.zzdpos.model.VipRechargeOrder;
import com.xingdata.zzdpos.ui.vip.VipPresenter; import com.xingdata.zzdpos.ui.vip.VipPresenter;
import com.xingdata.zzdpos.ui.vip.adapter.VipRechargeAdapter; import com.xingdata.zzdpos.ui.vip.adapter.VipRechargeAdapter;
...@@ -22,9 +24,12 @@ import java.util.List; ...@@ -22,9 +24,12 @@ import java.util.List;
/** /**
* 会员消费记录 * 会员消费记录
*/ */
@SuppressLint("ValidFragment")
public class VipExpenseListFragment extends BaseFragment<VipPresenter, FragmentVipExpenseListBinding> { public class VipExpenseListFragment extends BaseFragment<VipPresenter, FragmentVipExpenseListBinding> {
private VipRechargeAdapter vipRechargeAdapter; private VipRechargeAdapter vipRechargeAdapter;
private List<VipRechargeOrder> orders = new ArrayList<>(); private List<VipRechargeOrder> orders = new ArrayList<>();
private List<Level> levels=null;
@Override @Override
public int getLayoutId() { public int getLayoutId() {
...@@ -67,4 +72,6 @@ public class VipExpenseListFragment extends BaseFragment<VipPresenter, FragmentV ...@@ -67,4 +72,6 @@ public class VipExpenseListFragment extends BaseFragment<VipPresenter, FragmentV
pop(); pop();
return true; return true;
} }
} }
...@@ -5,54 +5,86 @@ package com.xingdata.zzdpos.ui.vip.fragment; ...@@ -5,54 +5,86 @@ package com.xingdata.zzdpos.ui.vip.fragment;
*/ */
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.Color; import android.support.v7.widget.LinearLayoutManager;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity; import android.view.Gravity;
import android.widget.GridView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import com.blankj.utilcode.util.ToastUtils; import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentViplevelTitleBinding; import com.xingdata.zzdpos.databinding.FragmentVipBinding;
import com.xingdata.zzdpos.model.Level; import com.xingdata.zzdpos.model.Level;
import com.xingdata.zzdpos.model.Pager; import com.xingdata.zzdpos.model.Pager;
import com.xingdata.zzdpos.model.Vip; import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.vip.VipActivity;
import com.xingdata.zzdpos.ui.vip.VipContract;
import com.xingdata.zzdpos.ui.vip.VipPresenter; import com.xingdata.zzdpos.ui.vip.VipPresenter;
import com.xingdata.zzdpos.ui.vip.adapter.VipListAdapter;
import java.util.ArrayList;
import java.util.List;
/** /**
* 会员等级列表 * 会员信息界面
*/ */
public class VipLevleFragment extends BaseFragment<VipPresenter, FragmentViplevelTitleBinding> { public class VipFragment extends BaseFragment<VipPresenter, FragmentVipBinding> {
private VipListAdapter vipListAdapter;
private List<Vip> vips = new ArrayList<>();
private List<Level> levels = null;
private int pageNumber = 0;
private String strVipLevle;
private RadioGroup radioGroup = mViewBinding.vipLevelR;
@Override @Override
public int getLayoutId() { public int getLayoutId() {
return R.layout.fragment_viplevel_title; return R.layout.fragment_vip;
} }
@Override @Override
public void initView() { public void initView() {
vipListAdapter = new VipListAdapter(getActivity(), vips);
mViewBinding.vipRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mViewBinding.vipRecyclerView.setAdapter(vipListAdapter);
mViewBinding.vipRefresh.setOnRefreshListener(this::onRefresh);
vipListAdapter.setOnItemClickListener((adapter, view, position) -> {
toStartVipInfo(vipListAdapter.getData().get(position));
});
vipListAdapter.setOnLoadMoreListener(this::onLoadMore, mViewBinding.vipRecyclerView);
vipListAdapter.setEnableLoadMore(true);
mViewBinding.titleSearch.onBack.setOnClickListener(view -> {
getActivity().finish();
});
mViewBinding.setOnClickListener(view -> {
switch (view.getId()) {
case R.id.addVip:
toStartVipInfo(null);
break;
}
});
mPresenter.getVipLevel(0, 200); mPresenter.getVipLevel(0, 200);
} }
/** /**
* 设置按钮选中 * 设置按钮选中
* *
* @param buttonID * @param buttonID
*/ */
private void setRadioButtonChecked(int buttonID) { private void setRadioButtonChecked(int buttonID) {
RadioButton radioButton= ((RadioButton) mViewBinding.vipLevelRadioGroup.findViewById(buttonID));
if (radioButton.isChecked()){ RadioButton radioButton = ((RadioButton) mViewBinding.vipLevelR.findViewById(buttonID));
if (radioButton.isChecked()) {
strVipLevle = radioButton.getTag().toString();
radioButton.getPaint().setFakeBoldText(true); radioButton.getPaint().setFakeBoldText(true);
radioButton.setTextSize(17); radioButton.setTextSize(17);
mPresenter.vipListFragment.setEnableLoadMore(); vipListAdapter.setEnableLoadMore(true);
mPresenter.getVipList(0, radioButton.getTag().toString()); mPresenter.getVipList(0, strVipLevle);
}else { } else {
radioButton.setTextSize(15); radioButton.setTextSize(15);
} }
} }
...@@ -73,31 +105,66 @@ public class VipLevleFragment extends BaseFragment<VipPresenter, FragmentVipleve ...@@ -73,31 +105,66 @@ public class VipLevleFragment extends BaseFragment<VipPresenter, FragmentVipleve
} }
public void getVipLevelSus(Pager<Level> levelPager) { public void getVipLevelSus(Pager<Level> levelPager) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
layoutParams.height = 120; layoutParams.height = 120;
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
for (int i = 0; i < levelPager.getPageSize(); i++) { for (int i = 0; i < levelPager.getPageSize(); i++) {
mViewBinding.vipLevelRadioGroup.addView(addRadioButton(layoutParams, levelPager.getList().get(i))); mViewBinding.vipLevelR.addView(addRadioButton(layoutParams, levelPager.getList().get(i)));
} }
mViewBinding.vipLevelRadioGroup.setOnCheckedChangeListener((radioGroup, id) -> { mViewBinding.vipLevelR.setOnCheckedChangeListener((radioGroup, id) -> {
mPresenter.vipListFragment.setVipLevel(mViewBinding.vipLevelRadioGroup.findViewById(id).getTag().toString()); // setVipLevel(levelPager.getList(), mViewBinding.vipLevelRadioGroup.findViewById(id).getTag().toString());
for (int i = 0; i < mViewBinding.vipLevelRadioGroup.getChildCount(); i++) { for (int i = 0; i < mViewBinding.vipLevelR.getChildCount(); i++) {
//动态设置按钮颜色 //动态设置按钮颜色
setRadioButtonChecked(id); setRadioButtonChecked(id);
} }
}); });
if (levelPager.getList().size()!=0){ if (levelPager.getList().size() != 0) {
((RadioButton) mViewBinding.vipLevelRadioGroup.getChildAt(0)).setChecked(true); ((RadioButton) mViewBinding.vipLevelR.getChildAt(0)).setChecked(true);
mPresenter.getVipList(0, mViewBinding.vipLevelRadioGroup.getChildAt(0).getTag().toString()); mPresenter.getVipList(0, mViewBinding.vipLevelR.getChildAt(0).getTag().toString());
} }
levels = levelPager.getList();
}
private void onLoadMore() {
mPresenter.getVipList(pageNumber, strVipLevle);
}
private void onRefresh() {
pageNumber = 0;
mPresenter.getVipList(pageNumber, strVipLevle);
}
public void getVipListSus(Pager<Vip> vipPager, int mPageNumber) {
vipListAdapter.loadMoreComplete();
mViewBinding.vipRefresh.setRefreshing(false);
if (mPageNumber == 0) {
vipListAdapter.getData().clear();
}
if (vipPager.isLastPage()) {
vipListAdapter.setEnableLoadMore(false);
vipListAdapter.notifyDataSetChanged();
pageNumber = 0;
ToastUtils.showShort("没有更多数据");
return;
}
vipListAdapter.addData(vipPager.getList());
pageNumber = vipPager.getPageNumber() + 1;
}
public void toStartVipInfo(Vip vip) {
mPresenter.vipInfoFragment.setVip(vip);
mPresenter.vipInfoFragment.setVipLevel(levels);
((BaseActivity) getActivity()).start(mPresenter.vipInfoFragment);
} }
// @Override
// public boolean onBackPressedSupport() {
// return false;
// }
} }
...@@ -4,37 +4,85 @@ package com.xingdata.zzdpos.ui.vip.fragment; ...@@ -4,37 +4,85 @@ package com.xingdata.zzdpos.ui.vip.fragment;
* Created by JM_DEV on 2017/12/21. * Created by JM_DEV on 2017/12/21.
*/ */
import android.app.DatePickerDialog;
import android.graphics.Color; import android.graphics.Color;
import android.view.View; import android.view.View;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.bigkoo.pickerview.OptionsPickerView; import com.bigkoo.pickerview.OptionsPickerView;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseFragment; import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentViplevelTitleBinding; import com.xingdata.zzdpos.databinding.FragmentVipInfoBinding;
import com.xingdata.zzdpos.model.Level; import com.xingdata.zzdpos.model.Level;
import com.xingdata.zzdpos.model.VipRechargeOrder; import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.vip.VipPresenter; import com.xingdata.zzdpos.ui.vip.VipPresenter;
import com.xingdata.zzdpos.ui.vip.adapter.VipRechargeAdapter; import com.xingdata.zzdpos.util.ConvertUtil;
import com.xingdata.zzdpos.util.StringUtil;
import java.util.ArrayList; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 会员信息界面 * 会员信息界面
*/ */
public class VipInfoFragment extends BaseFragment<VipPresenter, FragmentViplevelTitleBinding> { public class VipInfoFragment extends BaseFragment<VipPresenter, FragmentVipInfoBinding> {
private VipRechargeAdapter vipRechargeAdapter; private List<Level> levels;
private List<VipRechargeOrder> orders = new ArrayList<>(); private Vip mVip;
@Override @Override
public int getLayoutId() { public int getLayoutId() {
return R.layout.fragment_viplevel_title; return R.layout.fragment_vip_info;
} }
@Override @Override
public void initView() { public void initView() {
if (mVip != null) {
mViewBinding.infoTitle.tvTitle.setText("修改会员");
mViewBinding.vipDiscounts.setText(mVip.getVipLevelName() + mVip.getVipDefDiscount() + "折");
mViewBinding.vipBirthday.setText(StringUtil.format(new Date(mVip.getVipBirthday())));
mViewBinding.vipName.setText(mVip.getVipName());
mViewBinding.vipPhone.setText(mVip.getVipMobile() + "");
((CheckBox) mViewBinding.vipSuper).setChecked(mVip.getVipTag() == 1);
RadioButton radioButton = mViewBinding.vipSex.findViewWithTag(mVip.getVipSex().toString());
if (radioButton != null) {
radioButton.setChecked(true);
}
} else {
mViewBinding.infoTitle.tvTitle.setText("添加会员");
}
if (levels.size() != 0) {
mViewBinding.vipDiscounts.setText(levels.get(0).getVipLevelName() + " " + ConvertUtil.discount(levels.get(0).getVipDefDiscount()) + "折");
}
mViewBinding.setOnClickListener(view -> {
switch (view.getId()) {
case R.id.vip_discounts:
ShowPickerViewStoreAddress();
break;
case R.id.vip_birthday:
showDialogPick(mViewBinding.vipBirthday);
break;
case R.id.onSure:
mVip.setVipName(mViewBinding.vipName.getText().toString().trim());
mVip.setVipMobile(Long.parseLong(mViewBinding.vipPhone.getText().toString().trim()));
int sexId = mViewBinding.vipSex.getCheckedRadioButtonId();
if (sexId != -1) {
mVip.setVipSex(Byte.parseByte(mViewBinding.vipSex.findViewById(sexId).getTag().toString()));
}
mPresenter.addVip(mVip);
break;
}
});
mViewBinding.infoTitle.ivBack.setOnClickListener(view -> {
pop();
});
} }
...@@ -43,13 +91,12 @@ public class VipInfoFragment extends BaseFragment<VipPresenter, FragmentViplevel ...@@ -43,13 +91,12 @@ public class VipInfoFragment extends BaseFragment<VipPresenter, FragmentViplevel
* 弹出选择会员P * 弹出选择会员P
*/ */
private void ShowPickerViewStoreAddress() {// 弹出选择器 private void ShowPickerViewStoreAddress() {// 弹出选择器
ArrayList<Level> list = new ArrayList<>();
OptionsPickerView pvOptions = new OptionsPickerView.Builder(getActivity(), new OptionsPickerView pvOptions = new OptionsPickerView.Builder(getActivity(), new
OptionsPickerView.OnOptionsSelectListener() { OptionsPickerView.OnOptionsSelectListener() {
@Override @Override
public void onOptionsSelect(int options1, int options2, int options3, View v) { public void onOptionsSelect(int options1, int options2, int options3, View v) {
String tx = list.get(options1).getPickerViewText(); String tx = levels.get(options1).getPickerViewText();
ToastUtils.showShort(tx); mViewBinding.vipDiscounts.setText(tx + " " + ConvertUtil.discount(levels.get(options1).getVipDefDiscount()) + "折");
// mViewBinding.tvSelectStore.setText(tx); // mViewBinding.tvSelectStore.setText(tx);
// shops = list.get(options1); // shops = list.get(options1);
} }
...@@ -59,7 +106,42 @@ public class VipInfoFragment extends BaseFragment<VipPresenter, FragmentViplevel ...@@ -59,7 +106,42 @@ public class VipInfoFragment extends BaseFragment<VipPresenter, FragmentViplevel
.setContentTextSize(20) .setContentTextSize(20)
.build(); .build();
pvOptions.setPicker(list); pvOptions.setPicker(levels);
pvOptions.show(); pvOptions.show();
} }
public void setVipLevel(List<Level> levels) {
this.levels = levels;
}
public void setVip(Vip mVip) {
this.mVip = mVip;
}
//将两个选择时间的dialog放在该函数中
private void showDialogPick(final View btn) {
//获取Calendar对象,用于获取当前时间
final Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
//实例化DatePickerDialog对象
DatePickerDialog datePickerDialog = new DatePickerDialog(mContext, new
DatePickerDialog.OnDateSetListener() {
//选择完日期后会调用该回调函数
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int
dayOfMonth) {
//因为monthOfYear会比实际月份少一月所以这边要加1
((TextView) btn).setText(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth);
}
}, year, month, day);
//弹出选择日期对话框
datePickerDialog.show();
}
@Override
public boolean onBackPressedSupport() {
return false;
}
} }
package com.xingdata.zzdpos.ui.vip.fragment;
/**
* Created by JM_DEV on 2017/12/21.
*/
import android.support.v7.widget.LinearLayoutManager;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentVipListBinding;
import com.xingdata.zzdpos.model.Level;
import com.xingdata.zzdpos.model.Pager;
import com.xingdata.zzdpos.model.Vip;
import com.xingdata.zzdpos.ui.vip.VipContract;
import com.xingdata.zzdpos.ui.vip.VipPresenter;
import com.xingdata.zzdpos.ui.vip.adapter.VipListAdapter;
import java.util.ArrayList;
import java.util.List;
/**
* 会员列表
*/
public class VipListFragment extends BaseFragment<VipPresenter, FragmentVipListBinding> {
private VipListAdapter vipListAdapter;
private List<Vip> vips = new ArrayList<>();
private String vipLevel;
private int pageNumber=0;
@Override
public int getLayoutId() {
return R.layout.fragment_vip_list;
}
@Override
public void initView() {
vipListAdapter = new VipListAdapter(getActivity(), vips);
mViewBinding.vipRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mViewBinding.vipRecyclerView.setAdapter(vipListAdapter);
mViewBinding.vipRefresh.setOnRefreshListener(this::onRefresh);
vipListAdapter.setOnItemClickListener((adapter, view, position) -> {
((BaseActivity) getActivity()).start(new VipExpenseListFragment());
});
vipListAdapter.setOnLoadMoreListener(this::onLoadMore, mViewBinding.vipRecyclerView);
vipListAdapter.setEnableLoadMore(true);
}
//
// public void getVipList(String strViplevel){
// mPresenter.getVipList(0, strViplevel);
// }
private void onLoadMore() {
mPresenter.getVipList(pageNumber,this.vipLevel);
}
private void onRefresh() {
pageNumber = 0;
mPresenter.getVipList(pageNumber,vipLevel);
}
public void getVipListSus(Pager<Vip> vipPager,int mPageNumber) {
vipListAdapter.loadMoreComplete();
mViewBinding.vipRefresh.setRefreshing(false);
if (mPageNumber == 0) {
vipListAdapter.getData().clear();
}
if (vipPager.isLastPage()) {
vipListAdapter.setEnableLoadMore(false);
vipListAdapter.notifyDataSetChanged();
pageNumber=0;
ToastUtils.showShort("没有更多数据");
return;
}
vipListAdapter.addData(vipPager.getList());
pageNumber=vipPager.getPageNumber()+1;
}
public void setVipLevel(String vipLevel) {
this.vipLevel = vipLevel;
}
public void setEnableLoadMore(){
vipListAdapter.setEnableLoadMore(true);
}
}
package com.xingdata.zzdpos.ui.vip.fragment;
/**
* Created by JM_DEV on 2017/12/21.
*/
import android.annotation.SuppressLint;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
import com.xingdata.zzdpos.base.BaseFragment;
import com.xingdata.zzdpos.databinding.FragmentViplevelTitleBinding;
import com.xingdata.zzdpos.databinding.FragmentViptitleBinding;
import com.xingdata.zzdpos.ui.vip.VipPresenter;
public class VipTitleFragment extends BaseFragment<VipPresenter, FragmentViptitleBinding> {
@Override
public int getLayoutId() {
return R.layout.fragment_viptitle;
}
@Override
public void initView() {
mViewBinding.setOnClickListener(view -> {
switch (view.getId()){
case R.id.addVip:
((BaseActivity) getActivity()).start(mPresenter.vipInfoFragment);
break;
}
});
mViewBinding.titleSearch.onBack.setOnClickListener(view -> {
getActivity().finish();
});
}
}
...@@ -5,28 +5,9 @@ ...@@ -5,28 +5,9 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout
android:id="@+id/vip_title_frame" android:id="@+id/vip_frame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/all_margin_left"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/vip_level_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"></FrameLayout>
<FrameLayout
android:id="@+id/vip_list_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"></FrameLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="onClickListener"
type="android.view.View.OnClickListener" />
<variable
name="onCheckedChangeListener"
type="android.widget.RadioGroup.OnCheckedChangeListener" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<include
android:id="@+id/title_search"
layout="@layout/title_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@mipmap/swipe_card_bg" />
<ImageView
android:id="@+id/onScan"
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@mipmap/scan_bg"
android:onClick="@{onClickListener}" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="@dimen/view_line_L5"
android:background="@color/line1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/default_blacktext_smallstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="本店会员" />
<TextView
style="@style/default_blacktext_smallstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="今日新增" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/default_blacktext_bigstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="150"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
style="@style/default_blacktext_bigstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="10"
android:textSize="22sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/addVip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{onClickListener}"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="@mipmap/add_bg" />
<TextView
style="@style/default_blacktext_bigstyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="添加会员"
android:textColor="@color/deep_red"
android:textSize="22sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="@dimen/view_line_L5"
android:background="@color/line1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/all_margin_left"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3">
<RadioGroup
android:id="@+id/vip_level_R"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"></RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/vip_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/vipRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<variable <variable
name="onClickListener" name="onClickListener"
type="com.xingdata.zzdpos.util.OnClickListener" /> type="android.view.View.OnClickListener" />
</data> </data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
...@@ -32,26 +32,26 @@ ...@@ -32,26 +32,26 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/all_margin_left" android:background="@color/white"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/default_blacktext_smallstyle" style="@style/default_blacktext_margin_smallstyle"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/all_margin_left"
android:text="姓名" /> android:text="姓名" />
<EditText <EditText
android:id="@+id/vip_name"
style="@style/dialog_edit" style="@style/dialog_edit"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@null" android:background="@null"
android:hint="请输入手机号" /> android:hint="请输入姓名" />
</LinearLayout> </LinearLayout>
<View <View
...@@ -63,21 +63,26 @@ ...@@ -63,21 +63,26 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/all_margin_left" android:background="@color/white"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/default_blacktext_smallstyle" style="@style/default_blacktext_margin_smallstyle"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/all_margin_left"
android:digits="0123456789"
android:inputType="phone"
android:maxLines="11"
android:text="手机号" /> android:text="手机号" />
<EditText <EditText
android:id="@+id/vip_phone"
style="@style/dialog_edit" style="@style/dialog_edit"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null" android:background="@null"
android:hint="请输入姓名" /> android:hint="请输入手机号" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -98,16 +103,18 @@ ...@@ -98,16 +103,18 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/all_margin_left" android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/default_blacktext_smallstyle" style="@style/default_blacktext_margin_smallstyle"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="手机号号" /> android:text="性别" />
<RadioGroup <RadioGroup
android:id="@+id/vip_sex"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="12sp" android:layout_marginLeft="12sp"
...@@ -116,15 +123,21 @@ ...@@ -116,15 +123,21 @@
<RadioButton <RadioButton
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/selector_checkbox_bg"
android:button="@null" android:button="@null"
android:background="@drawable/radio_select" android:tag="1"
android:text="男" /> android:text="男" />
<RadioButton <RadioButton
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/selector_checkbox_bg"
android:button="@null"
android:tag="0"
android:text="女" /> android:text="女" />
</RadioGroup> </RadioGroup>
...@@ -134,6 +147,85 @@ ...@@ -134,6 +147,85 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="@color/line_bg" /> android:background="@color/line_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/default_blacktext_margin_smallstyle"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="级别" />
<TextView
android:id="@+id/vip_discounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/sp_12"
android:drawableRight="@mipmap/ic_expand"
android:onClick="@{onClickListener}" />
<CheckBox
android:id="@+id/vip_super"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_weight="1"
android:background="@drawable/selector_checkbox_bg"
android:button="@null"
android:text="超级VIP" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/line_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/default_blacktext_margin_smallstyle"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="生日" />
<TextView
android:id="@+id/vip_birthday"
style="@style/default_blacktext_smallstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请选择"
android:onClick="@{onClickListener}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom"
android:orientation="horizontal">
<Button
android:id="@+id/onSure"
style="@style/button_positive_noradius"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:onClick="@{onClickListener}"
android:text="确认" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -5,15 +5,7 @@ ...@@ -5,15 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/vip_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/vipRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -6,12 +6,7 @@ ...@@ -6,12 +6,7 @@
android:background="@color/white" android:background="@color/white"
android:orientation="vertical"> android:orientation="vertical">
<RadioGroup
android:id="@+id/vip_level_RadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"></RadioGroup>
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -20,126 +20,7 @@ ...@@ -20,126 +20,7 @@
android:background="@color/white" android:background="@color/white"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<include
android:id="@+id/title_search"
layout="@layout/title_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@mipmap/swipe_card_bg" />
<ImageView
android:id="@+id/onScan"
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@mipmap/scan_bg"
android:onClick="@{onClickListener}" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="@dimen/view_line_L5"
android:background="@color/line1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/default_blacktext_smallstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="本店会员" />
<TextView
style="@style/default_blacktext_smallstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="今日新增" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/default_blacktext_bigstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="150"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
style="@style/default_blacktext_bigstyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="10"
android:textSize="22sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/addVip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{onClickListener}"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="@mipmap/add_bg" />
<TextView
style="@style/default_blacktext_bigstyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="添加会员"
android:textColor="@color/deep_red"
android:textSize="22sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="@dimen/view_line_L5"
android:background="@color/line1" />
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -39,7 +39,19 @@ ...@@ -39,7 +39,19 @@
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">match_parent</item>
<item name="android:gravity">center_vertical</item> <item name="android:gravity">center_vertical</item>
<item name="android:singleLine">true</item> <item name="android:singleLine">true</item>
<item name="android:padding">@dimen/dp_4</item> <item name="android:padding">@dimen/sp_12</item>
<item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/detail_textview_size</item>
</style>
<style name="default_blacktext_margin_smallstyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:gravity">center_vertical</item>
<item name="android:singleLine">true</item>
<item name="android:layout_marginLeft">17dp</item>
<item name="android:padding">@dimen/sp_12</item>
<item name="android:paddingBottom">@dimen/sp_12</item>
<item name="android:paddingTop">@dimen/sp_12</item>
<item name="android:textColor">@color/black</item> <item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/detail_textview_size</item> <item name="android:textSize">@dimen/detail_textview_size</item>
</style> </style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment