Commit 413e0eba authored by zhang_z's avatar zhang_z

营销计划页面;

parent 351c9955
package com.xingdata.zzdpos.ui.marketing.ms; package com.xingdata.zzdpos.ui.marketing.ms;
import com.blankj.utilcode.util.LogUtils;
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.ActivityMsBinding; import com.xingdata.zzdpos.databinding.ActivityMsBinding;
...@@ -39,8 +40,13 @@ public class MsActivity extends BaseActivity<MsPresenter, ActivityMsBinding> imp ...@@ -39,8 +40,13 @@ public class MsActivity extends BaseActivity<MsPresenter, ActivityMsBinding> imp
} }
@Override @Override
public void showEditorFragment() { public void showEditorFragment(Ms ms) {
LogUtils.e("编辑 " + ms.getMsName());
}
@Override
public void showEditorFragment(int msType) {
LogUtils.e("添加 " + msType);
} }
@Override @Override
......
...@@ -20,8 +20,20 @@ interface MsContract { ...@@ -20,8 +20,20 @@ interface MsContract {
*/ */
void showAddFragment(); void showAddFragment();
/**
* 显示编辑页面
*
* @param ms 要编辑的营销计划
*/
void showEditorFragment(Ms ms);
void showEditorFragment();
/**
* 显示编辑页面
*
* @param msType 计划类型
*/
void showEditorFragment(int msType);
/** /**
* 显示读取对话框 * 显示读取对话框
...@@ -56,6 +68,11 @@ interface MsContract { ...@@ -56,6 +68,11 @@ interface MsContract {
*/ */
public abstract void clickMsItem(Ms ms); public abstract void clickMsItem(Ms ms);
/**
* 添加页面 - 点击类型的item
*/
public abstract void clickTypeItem(int msType);
} }
} }
...@@ -34,6 +34,12 @@ public class MsPresenter extends MsContract.Presenter { ...@@ -34,6 +34,12 @@ public class MsPresenter extends MsContract.Presenter {
@Override @Override
public void clickMsItem(Ms ms) { public void clickMsItem(Ms ms) {
mView.showEditorFragment(ms);
}
@Override
public void clickTypeItem(int msType) {
mView.showEditorFragment(msType);
} }
/** /**
......
...@@ -2,6 +2,7 @@ package com.xingdata.zzdpos.ui.marketing.ms.adapter; ...@@ -2,6 +2,7 @@ package com.xingdata.zzdpos.ui.marketing.ms.adapter;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R; import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseAdapter; import com.xingdata.zzdpos.base.BaseAdapter;
import com.xingdata.zzdpos.databinding.ItemMsBinding; import com.xingdata.zzdpos.databinding.ItemMsBinding;
...@@ -20,6 +21,25 @@ public class MsAdapter extends BaseAdapter<Ms, ItemMsBinding> { ...@@ -20,6 +21,25 @@ public class MsAdapter extends BaseAdapter<Ms, ItemMsBinding> {
protected void convert(ItemMsBinding mViewBinding, Ms item) { protected void convert(ItemMsBinding mViewBinding, Ms item) {
mViewBinding.tvName.setText(item.getMsName()); mViewBinding.tvName.setText(item.getMsName());
switch (item.getMsTools()) {
case C.MS_TYPE.DIS:
mViewBinding.ivType.setImageResource(R.mipmap.icon_discount01);
break;
case C.MS_TYPE.GIFT:
mViewBinding.ivType.setImageResource(R.mipmap.icon_buy01);
break;
case C.MS_TYPE.MONEY_OFF:
mViewBinding.ivType.setImageResource(R.mipmap.icon_full01);
break;
case C.MS_TYPE.PROMOTION:
mViewBinding.ivType.setImageResource(R.mipmap.icon_sales01);
break;
case C.MS_TYPE.SECOND:
mViewBinding.ivType.setImageResource(R.mipmap.icon_discount01);
break;
}
StringBuilder sbDateBegin = new StringBuilder(item.getMsDateBegin().toString()); StringBuilder sbDateBegin = new StringBuilder(item.getMsDateBegin().toString());
StringBuilder sbDateEnd = new StringBuilder(item.getMsDateEnd().toString()); StringBuilder sbDateEnd = new StringBuilder(item.getMsDateEnd().toString());
sbDateBegin.insert(6, "-"); sbDateBegin.insert(6, "-");
......
package com.xingdata.zzdpos.ui.marketing.ms.adapter;
import android.support.annotation.Nullable;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseAdapter;
import com.xingdata.zzdpos.databinding.ItemMsTypeBinding;
import java.util.List;
public class TypeAdapter extends BaseAdapter<Integer, ItemMsTypeBinding> {
public TypeAdapter(@Nullable List<Integer> data) {
super(R.layout.item_ms_type, data);
}
@Override
protected void convert(ItemMsTypeBinding mViewBinding, Integer item) {
int resPic = -1, resStr = -1;
switch (item) {
case C.MS_TYPE.DIS:
resPic = R.mipmap.icon_discount02;
resStr = R.string.ms_type_dis;
break;
case C.MS_TYPE.PROMOTION:
resPic = R.mipmap.icon_sales02;
resStr = R.string.ms_type_promotion;
break;
case C.MS_TYPE.MONEY_OFF:
resPic = R.mipmap.icon_full02;
resStr = R.string.ms_type_money_off;
break;
case C.MS_TYPE.GIFT:
resPic = R.mipmap.icon_buy02;
resStr = R.string.ms_type_gift;
break;
case C.MS_TYPE.SECOND:
resPic = R.mipmap.icon_discount02;
resStr = R.string.ms_type_dis;
break;
}
if (resPic < 0) return;
mViewBinding.tvName.setText(resStr);
mViewBinding.ivType.setImageResource(resPic);
}
}
package com.xingdata.zzdpos.ui.marketing.ms.fragment; package com.xingdata.zzdpos.ui.marketing.ms.fragment;
import android.support.v7.widget.GridLayoutManager;
import com.xingdata.zzdpos.C;
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.FragmentMsAddBinding; import com.xingdata.zzdpos.databinding.FragmentMsAddBinding;
import com.xingdata.zzdpos.ui.marketing.ms.MsPresenter; import com.xingdata.zzdpos.ui.marketing.ms.MsPresenter;
import com.xingdata.zzdpos.ui.marketing.ms.adapter.TypeAdapter;
import com.xingdata.zzdpos.util.MyMenuItemDecoration;
import java.util.ArrayList;
import java.util.List;
public class AddFragment extends BaseFragment<MsPresenter, FragmentMsAddBinding> { public class AddFragment extends BaseFragment<MsPresenter, FragmentMsAddBinding> {
@Override @Override
public int getLayoutId() { public int getLayoutId() {
return R.layout.fragment_ms_add; return R.layout.fragment_ms_add;
...@@ -13,5 +22,25 @@ public class AddFragment extends BaseFragment<MsPresenter, FragmentMsAddBinding> ...@@ -13,5 +22,25 @@ public class AddFragment extends BaseFragment<MsPresenter, FragmentMsAddBinding>
@Override @Override
public void initView() { public void initView() {
// init type
TypeAdapter mTypeAdapter = new TypeAdapter(getTypeList());
mViewBinding.rlType.setAdapter(mTypeAdapter);
mViewBinding.rlType.setLayoutManager(new GridLayoutManager(mContext, 2));
mViewBinding.rlType.addItemDecoration(new MyMenuItemDecoration(mContext, 2, getResources().getColor(R.color.gray_kongming)));
// set t listener
mTypeAdapter.setOnItemClickListener((adapter, view, position) -> mPresenter.clickTypeItem(mTypeAdapter.getData().get(position)));
}
/**
*
*/
private List<Integer> getTypeList() {
List<Integer> msList = new ArrayList<>();
msList.add(C.MS_TYPE.DIS);
msList.add(C.MS_TYPE.PROMOTION);
msList.add(C.MS_TYPE.MONEY_OFF);
msList.add(C.MS_TYPE.GIFT);
return msList;
} }
} }
...@@ -10,6 +10,7 @@ import com.xingdata.zzdpos.databinding.FragmentMsManagerBinding; ...@@ -10,6 +10,7 @@ import com.xingdata.zzdpos.databinding.FragmentMsManagerBinding;
import com.xingdata.zzdpos.model.Ms; import com.xingdata.zzdpos.model.Ms;
import com.xingdata.zzdpos.ui.marketing.ms.MsPresenter; import com.xingdata.zzdpos.ui.marketing.ms.MsPresenter;
import com.xingdata.zzdpos.ui.marketing.ms.adapter.MsAdapter; import com.xingdata.zzdpos.ui.marketing.ms.adapter.MsAdapter;
import com.xingdata.zzdpos.util.RecyclerViewUtil;
import java.util.List; import java.util.List;
...@@ -28,6 +29,7 @@ public class ManagerFragment extends BaseFragment<MsPresenter, FragmentMsManager ...@@ -28,6 +29,7 @@ public class ManagerFragment extends BaseFragment<MsPresenter, FragmentMsManager
mMsAdapter = new MsAdapter(); mMsAdapter = new MsAdapter();
mViewBinding.rlMs.setAdapter(mMsAdapter); mViewBinding.rlMs.setAdapter(mMsAdapter);
mViewBinding.rlMs.setLayoutManager(new LinearLayoutManager(mContext)); mViewBinding.rlMs.setLayoutManager(new LinearLayoutManager(mContext));
mViewBinding.rlMs.addItemDecoration(new RecyclerViewUtil.GridSpacingItemDecoration(1, mContext.getResources().getDimensionPixelOffset(R.dimen.all_margin), true));
// set ms listener // set ms listener
mViewBinding.srlMs.setOnRefreshListener(this::refreshMs); mViewBinding.srlMs.setOnRefreshListener(this::refreshMs);
...@@ -36,6 +38,9 @@ public class ManagerFragment extends BaseFragment<MsPresenter, FragmentMsManager ...@@ -36,6 +38,9 @@ public class ManagerFragment extends BaseFragment<MsPresenter, FragmentMsManager
// set other // set other
mViewBinding.llAdd.setOnClickListener(view -> mPresenter.clickAdd()); mViewBinding.llAdd.setOnClickListener(view -> mPresenter.clickAdd());
// init data
refreshMs();
} }
/** /**
......
...@@ -7,4 +7,6 @@ ...@@ -7,4 +7,6 @@
android:width="@dimen/view_line_L1" android:width="@dimen/view_line_L1"
android:color="@color/orange_shixiu" /> android:color="@color/orange_shixiu" />
<solid android:color="@color/white_caocao" />
</shape> </shape>
\ No newline at end of file
...@@ -7,5 +7,22 @@ ...@@ -7,5 +7,22 @@
android:background="@color/gray_zhouyu" android:background="@color/gray_zhouyu"
android:orientation="vertical"> android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:layout_marginTop="@dimen/all_spacing"
android:background="@color/gray_huanggai" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rl_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white_caocao" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width"
android:background="@color/gray_huanggai" />
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/all_line_width" android:layout_height="@dimen/all_line_width"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginTop="@dimen/all_spacing" android:layout_marginTop="@dimen/all_margin"
android:background="@color/gray_huanggai" /> android:background="@color/gray_huanggai" />
<LinearLayout <LinearLayout
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="120dp" android:layout_height="130dp"
android:layout_margin="@dimen/all_margin"
android:background="@drawable/shape_orange_b1" android:background="@drawable/shape_orange_b1"
android:foreground="?android:attr/selectableItemBackground"> android:foreground="?android:attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/iv_type"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/all_spacing" android:layout_marginStart="@dimen/all_spacing"
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/all_margin_big">
<ImageView
android:id="@+id/iv_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/icon_buy02"
android:contentDescription="@null" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/all_spacing"
android:text="满减送" />
</LinearLayout>
</layout>
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