Commit a2566532 by 罗翻

增加自建单

parent 2435571d
Showing with 4549 additions and 190 deletions
......@@ -66,6 +66,7 @@ public interface APIService {
/**
* 上传地理位置.
*
* @param body
* @return
*/
......
......@@ -13,17 +13,12 @@ public interface MainContract {
interface View extends BaseView {
/**
* 是否显示小红点.
*
* @param flag
*/
void isShowRedIcon(boolean flag);
/**
* 跳转到待接单.
*/
void dumpReceActivity();
void isShowRedIcon(int num);
void showUpdateDialog(VersionInfo info);
void initNotification();
......@@ -82,6 +77,7 @@ public interface MainContract {
/**
* 获取用户信息.
*
* @param accountId
*/
public abstract void getUserInfo(int accountId);
......
......@@ -117,9 +117,8 @@ public class MainPresenter extends MainContract.Presenter {
@Override
public void getHxNum(String accountId) {
ApiFactory.getHxNum(accountId).subscribe(baseObserver(integer -> {
if (integer > 0) {
mView.isShowRedIcon(true);
}
SPUtils.put(Constants.HX_NUM, integer);
mView.isShowRedIcon(integer);
}));
}
......
......@@ -11,8 +11,8 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.FileProvider;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
......@@ -37,13 +37,16 @@ import com.dayu.managercenter.ui.fragment.ManagerFragment;
import com.dayu.message.ui.fragment.HomeMessageFragment;
import com.dayu.order.ui.activity.ReceivingActivity;
import com.dayu.order.ui.fragment.HomeOrderFragment;
import com.dayu.provider.event.RefreshHxNum;
import com.dayu.provider.event.RefreshReceivingNum;
import com.dayu.provider.event.SwtichFragment;
import com.dayu.provider.router.RouterPath;
import com.dayu.usercenter.ui.fragment.HomePersonFragment;
import com.dayu.utils.SPUtils;
import com.dayu.utils.TimeUtils;
import com.dayu.utils.UserManager;
import com.dayu.utils.badgeNumberManger.BadgeNumberManager;
import com.dayu.widgets.BadgeView;
import com.dayu.widgets.CustomDialog;
import com.dayu.widgets.listener.onDownloadListener;
import com.umeng.analytics.MobclickAgent;
......@@ -74,6 +77,7 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
private HomeMessageFragment thirdFragment;
private HomePersonFragment fourFragment;
private int mFirstPositon = 0;
private BadgeView mBadgeView;
@Override
public int getLayoutId() {
......@@ -92,7 +96,7 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
} else if (UserManager.getInstance().getRole() == Constants.MANAGER_ENGINEER) {
managerFragment = ManagerFragment.newInstance();
mFragments = new Fragment[]{managerFragment, secondFragment, thirdFragment, fourFragment};
mFirstPositon=0;
mFirstPositon = 0;
mBind.tabFirst.setText(getString(R.string.send_order));
}
mTabs = new TextView[]{mBind.tabFirst, mBind.tabSecond, mBind.tabThird, mBind.tabFour};
......@@ -113,7 +117,6 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
mBind.tabSecond.setOnClickListener(o -> showHideFragment(1, mPosition));
mBind.tabThird.setOnClickListener(o -> {
showHideFragment(2, mPosition);
mBind.ivMessage.setVisibility(View.GONE);
});
mBind.tabFour.setOnClickListener(o -> showHideFragment(3, mPosition));
}
......@@ -170,16 +173,22 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
/**
* 消息小红点.
*
* @param flag
*/
@Override
public void isShowRedIcon(boolean flag) {
if (mPosition != 2) {
mBind.ivMessage.setVisibility(View.VISIBLE);
public void isShowRedIcon(int num) {
num = (int) SPUtils.get(Constants.HX_NUM, 0);
if (mBadgeView == null) {
mBadgeView = new BadgeView(this);
}
if (num < 100) {
mBadgeView.setText(num + "", TextView.BufferType.NORMAL);
} else {
mBind.ivMessage.setVisibility(View.GONE);
mBadgeView.setText("99+");
}
mBadgeView.setTargetView(mBind.tabThird);
mBadgeView.setBadgeGravity(Gravity.CENTER);
mBadgeView.setBadgeMargin(12, 0, 0, 12);
thirdFragment.getNum(num);
}
@Override
......@@ -280,7 +289,6 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
map_ekv.put("type", mActivity.getString(com.dayu.order.R.string.message_dayu));
}
showHideFragment(2, mPosition);
mBind.ivMessage.setVisibility(View.GONE);
if (thirdFragment != null) {
thirdFragment.setIndex(secondIndex);
thirdFragment.swtichFragment(secondIndex);
......@@ -347,6 +355,11 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void setHxNum(RefreshHxNum event) {
mPresenter.getHxNum(UserManager.getInstance().getUser().getHxAccount());
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onDownloadEvent(DownloadBean event) {
int progress = (int) Math.round(event.getBytesReaded() / (double) event.getTotal() * 100);
if (builder == null) {
......
......@@ -83,7 +83,7 @@ public class LocationService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
String accounid = intent.getStringExtra(Constants.ACCOUNT_ID);
Integer siteID = intent.getIntExtra(Constants.ID,0);
Integer siteID = intent.getIntExtra(Constants.ID, 0);
if (accounid != null) {
mAccountId = Integer.parseInt(accounid);
}
......
......@@ -19,6 +19,8 @@ import com.dayu.bigfish.ui.MainActivity;
import com.dayu.bigfish.ui.ManagerActivity;
import com.dayu.common.BaseConstant;
import com.dayu.common.Constants;
import com.dayu.provider.event.RefreshHxList;
import com.dayu.provider.event.RefreshHxNum;
import com.dayu.usercenter.ui.activity.LicenceDetailActivity;
import com.dayu.utils.AppManager;
import com.dayu.utils.SPUtils;
......@@ -35,12 +37,15 @@ import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.chat.EMOptions;
import org.greenrobot.eventbus.EventBus;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
import static com.dayu.common.Constants.IS_DEBUG;
......@@ -113,7 +118,7 @@ public class HxManager {
} else {
time = 100;
}
Observable.timer(time, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())
Disposable disposable = Observable.timer(time, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())
.subscribeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
Context activity = AppManager.getInstance().currentActivity();
mDialog = new LicenceDialog(activity, R.style.custom_dialog2, content);
......@@ -130,6 +135,10 @@ public class HxManager {
}
});
} else {
int num = (int) SPUtils.get(Constants.HX_NUM, 0);
SPUtils.put(Constants.HX_NUM, num + 1);
EventBus.getDefault().post(new RefreshHxNum());
EventBus.getDefault().post(new RefreshHxList());
if (!(boolean) SPUtils.get(Constants.HX_STATE, true)) {
return;
}
......@@ -219,7 +228,8 @@ public class HxManager {
//注册环信消息监听
EMClient.getInstance().chatManager().addMessageListener(msgListener);
//注册一个监听连接状态的listener
EMClient.getInstance().addConnectionListener(new MyConnectionListener());
// TODO hx
// EMClient.getInstance().addConnectionListener(new MyConnectionListener());
}
//实现ConnectionListener接口
......
......@@ -5,7 +5,7 @@
<variable
name="presenter"
type="com.dayu.bigfish.presenter.main.MainPresenter"/>
type="com.dayu.bigfish.presenter.main.MainPresenter" />
</data>
<LinearLayout
......@@ -16,22 +16,19 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
android:layout_weight="1">
<FrameLayout
android:id="@+id/fl_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
android:layout_weight="1" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/actionbar_shadow_up"
/>
android:background="@drawable/actionbar_shadow_up" />
</RelativeLayout>
......@@ -41,8 +38,7 @@
android:layout_height="53.3dp"
android:background="@color/cl_home_listview_bg"
android:orientation="horizontal"
android:visibility="visible"
>
android:visibility="visible">
<TextView
android:id="@+id/tab_first"
......@@ -55,8 +51,7 @@
android:gravity="center"
android:text="@string/schedule"
android:textColor="#585858"
android:textSize="10sp"
/>
android:textSize="10sp" />
<TextView
android:id="@+id/tab_second"
......@@ -69,8 +64,7 @@
android:gravity="center"
android:text="@string/order"
android:textColor="#585858"
android:textSize="10sp"
/>
android:textSize="10sp" />
<LinearLayout
android:id="@+id/tab_get_order"
......@@ -81,8 +75,7 @@
android:background="@drawable/tab_blue_react"
android:gravity="center"
android:onClick="@{()->presenter.dumpReceActivity()}"
android:orientation="vertical"
>
android:orientation="vertical">
<TextView
android:id="@+id/tab_order_num"
......@@ -90,49 +83,30 @@
android:layout_height="wrap_content"
android:text="@{presenter.tabRecive}"
android:textColor="@color/cl_white"
android:textSize="16.7sp"
/>
android:textSize="16.7sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_receive_order"
android:textColor="@color/cl_white"
android:textSize="10sp"
/>
android:textSize="10sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
>
<TextView
android:id="@+id/tab_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawablePadding="2dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_gravity="center"
android:drawableTop="@drawable/tab_third_selector"
android:gravity="center"
android:text="@string/message"
android:textColor="#585858"
android:textSize="10sp"
/>
<ImageView
android:id="@+id/iv_message"
android:layout_width="8.3dp"
android:layout_height="8.3dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="25dp"
android:src="@mipmap/renwu_numbg"
android:visibility="gone"/>
</RelativeLayout>
android:textSize="10sp" />
<TextView
android:id="@+id/tab_four"
......@@ -145,10 +119,7 @@
android:gravity="center"
android:text="@string/personal"
android:textColor="#585858"
android:textSize="10sp"
/>
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -70,5 +70,4 @@ dependencies {
api project(':locationComponent')
api project(':pickerview')
}
package com.dayu.base.ui.activity;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.dayu.baselibrary.R;
import com.dayu.baselibrary.databinding.AcitivityPreviewBinding;
import com.dayu.common.Constants;
import com.dayu.utils.GlideImageLoader;
import java.util.ArrayList;
/**
* 选中图片页面
* on 2016/12/2.
* Created by MrWang
*/
public class PreviewActivty extends DataBindingActivity<AcitivityPreviewBinding> {
private MyPageAdapter adapter;
private Context mContext;
public ArrayList<String> mInfos = new ArrayList<>();
@Override
public int getLayoutId() {
return R.layout.acitivity_preview;
}
@Override
public void initView() {
mContext = this;
mInfos = getIntent().getStringArrayListExtra(Constants.BUNDLE_KEY_ID);
adapter = new MyPageAdapter(mInfos);
mBind.vpPreview.setAdapter(adapter);
mBind.vpPreview.setCurrentItem(getIntent().getIntExtra(Constants.BUNDLE_KEY_ID, 0));
mBind.titileBack.setOnClickListener(o -> finish());
}
class MyPageAdapter extends PagerAdapter {
private ArrayList<String> listViews;
public MyPageAdapter(ArrayList<String> listViews) {
this.listViews = listViews;
}
public int getCount() {
return listViews.size();
}
public int getItemPosition(Object object) {
return POSITION_NONE;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(mContext);
GlideImageLoader.load(mContext, listViews.get(position), imageView);
container.addView(imageView);
return imageView;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
}
}
package com.dayu.base.ui.adapter;
import android.app.Activity;
import android.content.Intent;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.dayu.base.ui.activity.PreviewActivty;
import com.dayu.baselibrary.R;
import com.dayu.common.Constants;
import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.UtilsScreen;
import com.dayu.widgets.listener.OnItemClickListener;
import com.luck.picture.lib.PictureSelectionModel;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import java.io.File;
import java.util.ArrayList;
/**
* Created by luofan
* on 2018/11/30.
*/
public class PhotoViewAdapter extends RecyclerView.Adapter<PhotoViewAdapter.Holder> {
private final int mIvSize;
private Activity context;
private ArrayList<String> list;
private OnItemClickListener<PhotoViewAdapter.Holder, Integer> listener;
public PhotoViewAdapter(ArrayList<String> list, Activity context) {
mIvSize = (UtilsScreen.getScreenWidth(context) - UtilsScreen.dip2px(context, 20)) / 5;
this.context = context;
this.list = list;
}
public void setData(ArrayList<String> list) {
this.list = list;
notifyDataSetChanged();
}
@NonNull
@Override
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.item_picture_select, parent, false);
view.setLayoutParams(new RelativeLayout.LayoutParams(mIvSize, mIvSize));
view.setPadding(0, 0, 10, 10);
return new Holder(view);
}
@Override
public void onBindViewHolder(@NonNull Holder holder, int position) {
if (list.get(position).equals("add")) {
holder.picture.setImageResource(R.drawable.icon_submit_photo);
holder.delete.setVisibility(View.GONE);
holder.picture.setOnClickListener(v -> showPicDialog());
} else {
GlideImageLoader.load(context, list.get(position), holder.picture);
holder.delete.setVisibility(View.VISIBLE);
holder.delete.setOnClickListener(v -> removeItem(position));
holder.picture.setOnClickListener(v -> {
ArrayList temp = new ArrayList();
temp.addAll(list);
temp.remove("add");
dumpPic(temp);
});
}
}
@Override
public int getItemCount() {
return list.size();
}
private void removeItem(int position) {
if (list.size() == 10 && !list.contains("add")) {
list.remove(position);
list.add("add");
} else {
list.remove(position);
}
notifyDataSetChanged();
}
class Holder extends RecyclerView.ViewHolder {
private final ImageView picture;
private final ImageView delete;
Holder(View itemView) {
super(itemView);
picture = itemView.findViewById(R.id.iv_picture);
delete = itemView.findViewById(R.id.iv_picture_delete);
}
}
public void setOnItemClickListener(OnItemClickListener<PhotoViewAdapter.Holder, Integer> listener) {
this.listener = listener;
}
public void showPicDialog() {
int size;
size = 11 - list.size();
PictureSelectionModel selector = PictureSelector.create(context)
.openGallery(PictureMimeType.ofImage())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()
.maxSelectNum(size)// 最大图片选择数量 int
.imageSpanCount(4)// 每行显示个数 int
.selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
.previewImage(true)// 是否可预览图片 true or false
.isCamera(true)// 是否显示拍照按钮 true or false
.isZoomAnim(true)// 图片列表点击 缩放效果 默认true
.sizeMultiplier(0.1f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效
.setOutputCameraPath("/CustomPath")// 自定义拍、照保存路径,可不填
.compress(true)// 是否压缩 true or false
.glideOverride(300, 500)// int glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
.hideBottomControls(true)// 是否显示uCrop工具栏,默认不显示 true or false
.compressSavePath(getPath())//压缩图片保存地址
.previewEggs(true)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) true or false
// .minimumCompressSize(100)// 小于100kb的图片不压缩
.synOrAsy(true);//同步true或异步false 压缩 默认同步、
// .enableCrop(true)//是否裁剪
// .freeStyleCropEnabled(true)
selector.forResult(PictureConfig.CHOOSE_REQUEST);
}
private String getPath() {
String path = Environment.getExternalStorageDirectory() + "/dayu/image/";
File file = new File(path);
if (file.mkdirs()) {
return path;
}
return path;
}
private void dumpPic(ArrayList<String> list) {
Intent intent = new Intent(context, PreviewActivty.class);
intent.putStringArrayListExtra(Constants.BUNDLE_KEY_ID, list);
int DELETECODE = 0;
context.startActivityForResult(intent, DELETECODE);
}
}
package com.dayu.base.ui.adapter;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* Created by luofan
* on 2018/11/30.
*/
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
private final int space;
public SpacesItemDecoration(int space) {
this.space = space;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.right = space;
outRect.bottom = space;
}
}
......@@ -12,16 +12,16 @@ public class Constants {
/**
* 测试环境配置.
*/
// public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static final String ENVIROMENT = "debug";
// public static final String BASE_URL = "http://47.94.101.239:3112";
// public final static String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply";
// public final static String WEB_SOP = "http://47.94.101.239:9004/#/sop";
// public final static String CHECK_MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manyServiceResult";
// public final static String MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manySop";
// public final static String WEB_SOP_DETAIL = "http://47.94.101.239:9004/#/sopdetail";
// public final static String WEB_ZHI_SHI = "http://47.94.101.239:9004/#/detail";
// public static final boolean IS_DEBUG = true;
public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
public static final String ENVIROMENT = "debug";
public static final String BASE_URL = "http://47.94.101.239:3112";
public final static String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply";
public final static String WEB_SOP = "http://47.94.101.239:9004/#/sop";
public final static String CHECK_MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manyServiceResult";
public final static String MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manySop";
public final static String WEB_SOP_DETAIL = "http://47.94.101.239:9004/#/sopdetail";
public final static String WEB_ZHI_SHI = "http://47.94.101.239:9004/#/detail";
public static final boolean IS_DEBUG = true;
/**
* uat环境配置.
......@@ -40,16 +40,16 @@ public class Constants {
/**
* 正式环境.
*/
public static final String ENVIROMENT = "release";
public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
public static final String BASE_URL = "https://mobile.kf.ai";
public final static String UP_PHOTO = "/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply";
public final static String WEB_SOP = "https://sop.kf.ai/#/sop";
public final static String WEB_SOP_DETAIL = "https://sop.kf.ai/#/sopdetail";
public final static String WEB_ZHI_SHI = "https://sop.kf.ai/#/detail";
public final static String CHECK_MULTI_WEB_SOP = "https://sop.kf.ai/#/manyServiceResult";
public final static String MULTI_WEB_SOP = "https://sop.kf.ai/#/manySop";
public static final boolean IS_DEBUG = false;
// public static final String ENVIROMENT = "release";
// public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static final String BASE_URL = "https://mobile.kf.ai";
// public final static String UP_PHOTO = "/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply";
// public final static String WEB_SOP = "https://sop.kf.ai/#/sop";
// public final static String WEB_SOP_DETAIL = "https://sop.kf.ai/#/sopdetail";
// public final static String WEB_ZHI_SHI = "https://sop.kf.ai/#/detail";
// public final static String CHECK_MULTI_WEB_SOP = "https://sop.kf.ai/#/manyServiceResult";
// public final static String MULTI_WEB_SOP = "https://sop.kf.ai/#/manySop";
// public static final boolean IS_DEBUG = false;
/**
* 演示环境
......@@ -141,6 +141,8 @@ public class Constants {
public final static String MESSAGE_INFO = "message_info";
//环信message
public final static String HX_MESSAGE = "hx_message";
//消息数量
public final static String HX_NUM = "hx_num";
public static final int FLAG_MULTI_VH = 0x000001;
//订单状态
public final static int WATING_ORDER = 1;
......
package com.dayu.test;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by luofan
* on 2018/10/26.
*/
public class MyViewGroup extends ViewGroup {
private static final int OFFSET = 100;
public MyViewGroup(Context context) {
super(context);
}
public MyViewGroup(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
int width = 0;
int height = 0;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
ViewGroup.LayoutParams lp = child.getLayoutParams();
int childWidthSpec = getChildMeasureSpec(widthMeasureSpec, 0, lp.width);
int childHeightSpec = getChildMeasureSpec(heightMeasureSpec, 0, lp.height);
child.measure(childWidthSpec, childHeightSpec);
}
switch (widthMode) {
case MeasureSpec.EXACTLY:
width = widthSize;
break;
case MeasureSpec.AT_MOST:
case MeasureSpec.UNSPECIFIED:
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
int widthAddOffset = i * OFFSET + child.getMeasuredWidth();
width = Math.max(width, widthAddOffset);
}
break;
default:
break;
}
switch (heightMode) {
case MeasureSpec.EXACTLY:
height = heightSize;
break;
case MeasureSpec.AT_MOST:
case MeasureSpec.UNSPECIFIED:
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
height = height + child.getMeasuredHeight();
}
break;
default:
break;
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// for (遍历子View) {
// /**
// 根据如下数据计算。
// 1、自己当前布局规则。比如垂直排放或者水平排放。
// 2、子View的测量尺寸。
// 3、子View在所有子View中的位置。比如位置索引,第一个或者第二个等。
// */
// 计算每一个子View的位置信息;
//
// child.layout(上面计算出来的位置信息);
// }
int left = 0;
int right = 0;
int top = 0;
int bottom = 0;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
left = i * OFFSET;
right = left + child.getMeasuredWidth();
bottom = top + child.getMeasuredHeight();
child.layout(left, top, right, bottom);
top += child.getMeasuredHeight();
}
}
}
package com.dayu.utils;
import android.content.Context;
import android.content.res.AssetManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* <读取Json文件的工具类>
*
*/
public class GetJsonDataUtil {
public String getJson(Context context, String fileName) {
StringBuilder stringBuilder = new StringBuilder();
try {
AssetManager assetManager = context.getAssets();
BufferedReader bf = new BufferedReader(new InputStreamReader(
assetManager.open(fileName)));
String line;
while ((line = bf.readLine()) != null) {
stringBuilder.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return stringBuilder.toString();
}
}
package com.dayu.widgets;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.TabWidget;
/**
* Created by luofan
* on 2018/12/14.
*/
public class BadgeView extends android.support.v7.widget.AppCompatTextView {
private boolean mHideOnNull = true;
public BadgeView(Context context) {
this(context, null);
}
public BadgeView(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.textViewStyle);
}
public BadgeView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
if (!(getLayoutParams() instanceof LayoutParams)) {
LayoutParams layoutParams =
new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.RIGHT | Gravity.TOP);
setLayoutParams(layoutParams);
}
// set default font
setTextColor(Color.WHITE);
setTypeface(Typeface.DEFAULT_BOLD);
setTextSize(TypedValue.COMPLEX_UNIT_SP, 11);
setPadding(dip2Px(5), dip2Px(1), dip2Px(5), dip2Px(1));
// set default background
setBackground(9, Color.parseColor("#d3321b"));
setGravity(Gravity.CENTER);
// default values
setHideOnNull(true);
setBadgeCount(0);
}
public void setBackground(int dipRadius, int badgeColor) {
int radius = dip2Px(dipRadius);
float[] radiusArray = new float[] { radius, radius, radius, radius, radius, radius, radius, radius };
RoundRectShape roundRect = new RoundRectShape(radiusArray, null, null);
ShapeDrawable bgDrawable = new ShapeDrawable(roundRect);
bgDrawable.getPaint().setColor(badgeColor);
setBackground(bgDrawable);
}
/**
* @return Returns true if view is hidden on badge value 0 or null;
*/
public boolean isHideOnNull() {
return mHideOnNull;
}
/**
* @param hideOnNull the hideOnNull to set
*/
public void setHideOnNull(boolean hideOnNull) {
mHideOnNull = hideOnNull;
setText(getText());
}
/*
* (non-Javadoc)
*
* @see android.widget.TextView#setText(java.lang.CharSequence, android.widget.TextView.BufferType)
*/
@Override
public void setText(CharSequence text, BufferType type) {
if (isHideOnNull() && (text == null || text.toString().equalsIgnoreCase("0"))) {
setVisibility(View.GONE);
} else {
setVisibility(View.VISIBLE);
}
super.setText(text, type);
}
public void setBadgeCount(int count) {
setText(String.valueOf(count));
}
public Integer getBadgeCount() {
if (getText() == null) {
return null;
}
String text = getText().toString();
try {
return Integer.parseInt(text);
} catch (NumberFormatException e) {
return null;
}
}
public void setBadgeGravity(int gravity) {
LayoutParams params = (LayoutParams) getLayoutParams();
params.gravity = gravity;
setLayoutParams(params);
}
public int getBadgeGravity() {
LayoutParams params = (LayoutParams) getLayoutParams();
return params.gravity;
}
public void setBadgeMargin(int dipMargin) {
setBadgeMargin(dipMargin, dipMargin, dipMargin, dipMargin);
}
public void setBadgeMargin(int leftDipMargin, int topDipMargin, int rightDipMargin, int bottomDipMargin) {
LayoutParams params = (LayoutParams) getLayoutParams();
params.leftMargin = dip2Px(leftDipMargin);
params.topMargin = dip2Px(topDipMargin);
params.rightMargin = dip2Px(rightDipMargin);
params.bottomMargin = dip2Px(bottomDipMargin);
setLayoutParams(params);
}
public int[] getBadgeMargin() {
LayoutParams params = (LayoutParams) getLayoutParams();
return new int[] { params.leftMargin, params.topMargin, params.rightMargin, params.bottomMargin };
}
public void incrementBadgeCount(int increment) {
Integer count = getBadgeCount();
if (count == null) {
setBadgeCount(increment);
} else {
setBadgeCount(increment + count);
}
}
public void decrementBadgeCount(int decrement) {
incrementBadgeCount(-decrement);
}
/*
* Attach the BadgeView to the TabWidget
*
* @param target the TabWidget to attach the BadgeView
*
* @param tabIndex index of the tab
*/
public void setTargetView(TabWidget target, int tabIndex) {
View tabView = target.getChildTabViewAt(tabIndex);
setTargetView(tabView);
}
/*
* Attach the BadgeView to the target view
*
* @param target the view to attach the BadgeView
*/
public void setTargetView(View target) {
if (getParent() != null) {
((ViewGroup) getParent()).removeView(this);
}
if (target == null) {
return;
}
if (target.getParent() instanceof FrameLayout) {
((FrameLayout) target.getParent()).addView(this);
} else if (target.getParent() instanceof ViewGroup) {
// use a new Framelayout container for adding badge
ViewGroup parentContainer = (ViewGroup) target.getParent();
int groupIndex = parentContainer.indexOfChild(target);
parentContainer.removeView(target);
FrameLayout badgeContainer = new FrameLayout(getContext());
ViewGroup.LayoutParams parentLayoutParams = target.getLayoutParams();
badgeContainer.setLayoutParams(parentLayoutParams);
target.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
parentContainer.addView(badgeContainer, groupIndex, parentLayoutParams);
badgeContainer.addView(target);
badgeContainer.addView(this);
} else if (target.getParent() == null) {
Log.e(getClass().getSimpleName(), "ParentView is needed");
}
}
/*
* converts dip to px
*/
private int dip2Px(float dip) {
return (int) (dip * getContext().getResources().getDisplayMetrics().density + 0.5f);
}
}
package com.dayu.widgets;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.dayu.baselibrary.R;
import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.UtilsScreen;
import com.luck.picture.lib.PictureSelectionModel;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import java.io.File;
import java.util.ArrayList;
/**
* Created by luofan
* on 2018/11/30.
*/
public class PhotoView extends LinearLayout {
private int mPhotoNum;
private int mIvSize;
private ImageView mAddIV;
private Activity mContext;
private ArrayList<String> mImgs;
public PhotoView(Context context) {
super(context);
init(context, null);
}
public PhotoView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public PhotoView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
private void init(Context context, @Nullable AttributeSet attrs) {
mContext = (Activity) context;
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LRecyclerView);
mPhotoNum = ta.getResourceId(R.styleable.photoView_photoNum, 10);
ta.recycle();
mIvSize = (UtilsScreen.getScreenWidth(context) - UtilsScreen.dip2px(context, 20)) / 5;
mAddIV = new ImageView(context);
mAddIV.setLayoutParams(new ViewGroup.LayoutParams(mIvSize, mIvSize));
mAddIV.setImageResource(R.drawable.icon_submit_photo);
mAddIV.setOnClickListener(v -> showPicDialog());
ArrayList list = new ArrayList();
mImgs = new ArrayList<>();
addImgs(list);
}
public void addImgs(ArrayList<String> list) {
this.removeAllViews();
int size = list.size() / 5 + 1;
for (int i = 0; i < size; i++) {
ArrayList<String> temp = new ArrayList<>();
LinearLayout layout = new LinearLayout(mContext);
layout.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mIvSize));
layout.setOrientation(HORIZONTAL);
layout.setPadding(0, 0, 0, 10);
for (int j = i * 5; j < (i + 1) * 5 && j < list.size(); j++) {
temp.add(list.get(j));
}
addImages(temp, layout);
this.addView(layout);
}
}
private void addImages(ArrayList<String> list, LinearLayout layout) {
layout.removeAllViews();
for (int i = 0; i < list.size(); i++) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_picture_select, null);
view.setLayoutParams(new RelativeLayout.LayoutParams(mIvSize, mIvSize));
view.setPadding(0, 0, 10, 0);
ImageView ivDelete = view.findViewById(R.id.iv_picture_delete);
ImageView imageView = view.findViewById(R.id.iv_picture);
String path = list.get(i);
GlideImageLoader.load(mContext, path, imageView);
imageView.setOnClickListener(v -> dumpPic(list));
ivDelete.setOnClickListener(v -> {
if (list.size() == 5) {
layout.addView(mAddIV);
}
layout.removeView(view);
list.remove(path);
});
layout.addView(view);
}
if (list.size() < 5) {
layout.addView(mAddIV);
}
}
public void showPicDialog() {
int size;
size = 10 - mImgs.size();
PictureSelectionModel selector = PictureSelector.create(mContext)
.openGallery(PictureMimeType.ofImage())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()
.maxSelectNum(size)// 最大图片选择数量 int
.imageSpanCount(4)// 每行显示个数 int
.selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
.previewImage(true)// 是否可预览图片 true or false
.isCamera(true)// 是否显示拍照按钮 true or false
.isZoomAnim(true)// 图片列表点击 缩放效果 默认true
.sizeMultiplier(0.1f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效
.setOutputCameraPath("/CustomPath")// 自定义拍、照保存路径,可不填
.compress(true)// 是否压缩 true or false
.glideOverride(300, 500)// int glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
.hideBottomControls(true)// 是否显示uCrop工具栏,默认不显示 true or false
.compressSavePath(getPath())//压缩图片保存地址
.previewEggs(true)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中) true or false
// .minimumCompressSize(100)// 小于100kb的图片不压缩
.synOrAsy(true);//同步true或异步false 压缩 默认同步、
// .enableCrop(true)//是否裁剪
// .freeStyleCropEnabled(true)
selector.forResult(PictureConfig.CHOOSE_REQUEST);
}
private String getPath() {
String path = Environment.getExternalStorageDirectory() + "/dayu/image/";
File file = new File(path);
if (file.mkdirs()) {
return path;
}
return path;
}
private void dumpPic(ArrayList<String> list) {
// Intent intent = new Intent(this, PreviewActivty.class);
// intent.putStringArrayListExtra(Constants.BUNDLE_KEY_ID, list);
// int DELETECODE = 0;
// startActivityForResult(intent, DELETECODE);
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="3dp"/>
<solid android:color="@color/cl_receiving_order_item_data"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="0.5dp"
android:color="@color/cl_tab_init"/>
<corners android:radius="3dp"/>
<solid android:color="@color/cl_white"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_home_edit_text"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/title_finish"
style="@style/title">
<TextView
style="@style/text_title"
android:text="@string/pre_look" />
<ImageView
android:id="@+id/titile_back"
style="@style/title_image_back" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/vp_preview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/cl_order_text_one"
android:unselectedAlpha="1" />
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_picture"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/iv_picture_delete"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/img_photo_delete" />
</RelativeLayout>
</layout>
\ No newline at end of file
......@@ -254,6 +254,7 @@
<string name="open_webview">浏览器打开</string>
<string name="select_webview">请选择浏览器</string>
<string name="history_order">历史工单</string>
<string name="all_read">全部已读</string>
<string name="order_commite_success">数据提交成功</string>
<string name="receive_order_success">接单成功</string>
<string name="choose_file">文件选择</string>
......@@ -262,7 +263,8 @@
<string name="sop_finish">标准操作已完成,点击此处进行查看或修改</string>
<string name="now_no">暂无</string>
<string name="submit_order">提交验收</string>
<string name="find_customer_mobile">搜索客户手机号</string>
<string name="find_customer_mobile">姓名/手机号/地址/单号/备注</string>
<string name="search">搜索</string>
<string name="pre_look">预览</string>
<string name="loading">加载中...</string>
<string name="order_subsidy">工单补贴</string>
......@@ -316,9 +318,9 @@
<string name="order_num">工单编号</string>
<string name="order_state">工单状态</string>
<string name="server_name">服务名称</string>
<string name="prodcut">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</string>
<string name="prodcut">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</string>
<string name="photo">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</string>
<string name="prodcut_type">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</string>
<string name="prodcut_type">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</string>
<string name="door_time">上门时间</string>
<string name="order_remark">工单备注</string>
<string name="server_desc">任务描述</string>
......@@ -411,6 +413,7 @@
<string name="next_step_process_order">您的工单已全部完成,点击下一步去提交验收</string>
<string name="create_time">下单时间</string>
<string name="designate_order">立即指派</string>
<string name="cancle_orders">取消工单</string>
<string name="designate">指派</string>
<string name="order_price">授权单价</string>
<string name="refuse">拒绝</string>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -94,6 +94,17 @@ public class ManagerApiFactory {
return Api.getService(ManagerService.class).querySonProduct(siteId, parentCategoryId).compose(Api.applySchedulers());
}
/**
* 查询当前节点的父节点.
*
* @param siteId 站点id.
* @param categoryId 当前节点的categoryId.
* @return
*/
public static Observable<List<Product>> queryParentProduct(int siteId, String categoryId) {
return Api.getService(ManagerService.class).queryParentProduct(siteId, categoryId).compose(Api.applySchedulers());
}
public static Observable<List<ServerType>> querySerVerType(int siteId) {
return Api.getService(ManagerService.class).querySerVerType(siteId).compose(Api.applySchedulers());
}
......@@ -109,4 +120,28 @@ public class ManagerApiFactory {
public static Observable<Boolean> createPartnerOrder(RequestBody body) {
return Api.getService(ManagerService.class).createPartnerOrder(body).compose(Api.applySchedulers());
}
public static Observable<Boolean> modifyOrder(RequestBody body) {
return Api.getService(ManagerService.class).modifyOrder(body).compose(Api.applySchedulers());
}
public static Observable<Boolean> modifyPartnerOrder(RequestBody body) {
return Api.getService(ManagerService.class).modifyPartnerOrder(body).compose(Api.applySchedulers());
}
public static Observable<ServiceStation> getStationInfo(int siteId) {
return Api.getService(ManagerService.class).getStationInfo(siteId).compose(Api.applySchedulers());
}
/**
* 取消工单.
*
* @param id 工单id.
* @param reason 取消原因.
* @param name 取消人.
* @return
*/
public static Observable<Boolean> cancelOrder(int id, String reason, String name) {
return Api.getService(ManagerService.class).cancelOrder(id, reason, name).compose(Api.applySchedulers());
}
}
......@@ -22,6 +22,7 @@ import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
......@@ -223,6 +224,17 @@ public interface ManagerService {
@GET(ManagerConstant.QUERY_SON_PRODUCT)
Observable<BaseResponse<List<Product>>> querySonProduct(@Path("siteId") int siteId, @Path("parentCategoryId") String parentCategoryId);
/**
* 查询产品的父节点.
*
* @param siteId
* @param categoryId
* @return
*/
@GET(ManagerConstant.QUERY_PARENT_PRODUCT)
Observable<BaseResponse<List<Product>>> queryParentProduct(@Path("siteId") int siteId, @Path("categoryId") String categoryId);
/**
* 查询服务类型.
*
......@@ -244,6 +256,7 @@ public interface ManagerService {
/**
* 创建工单.
*
* @param body
* @return
*/
......@@ -252,9 +265,49 @@ public interface ManagerService {
/**
* 创建合作商工单
*
* @param body
* @return
*/
@POST(ManagerConstant.CREATE_PARTNER_ORDER)
Observable<BaseResponse<Boolean>> createPartnerOrder(@Body RequestBody body);
/**
* 创建工单.
*
* @param body
* @return
*/
@PUT(ManagerConstant.CREATE_NEW_ORDER)
Observable<BaseResponse<Boolean>> modifyOrder(@Body RequestBody body);
/**
* 创建合作商工单
*
* @param body
* @return
*/
@PUT(ManagerConstant.CREATE_PARTNER_ORDER)
Observable<BaseResponse<Boolean>> modifyPartnerOrder(@Body RequestBody body);
/**
* 获取服务站信息.
*
* @param siteId
* @return
*/
@GET(ManagerConstant.QUERY_STATAION_INFO)
Observable<BaseResponse<ServiceStation>> getStationInfo(@Path("siteId") int siteId);
/**
* 取消工单》
*
* @param id 工单id.
* @param reason 取消原因.
* @param name 取消人.
* @return
*/
@POST(ManagerConstant.CANCEL_ORDER)
Observable<BaseResponse<Boolean>> cancelOrder(@Query("id") int id, @Query("reason") String reason, @Query("updated") String name);
}
......@@ -20,6 +20,12 @@ public class ManagerConstant {
public final static int BARGAIN_ORDER = 11;
public final static int Eu_ORDER = 2;
public final static int CHANGE_ORDER = 3;
public final static int CHANGE_ORDER_REASON = 4;
public final static int MODIFY_ORDER = 5;
public final static int AGIN_ORDER = 6;
public final static int CREATE_ORDER = 7;
/**
* 获取服务站列表.
*/
......@@ -102,6 +108,11 @@ public class ManagerConstant {
public static final String QUERY_SON_PRODUCT = "/api-user/" + "siteCustomoCategory/parent/{siteId}/{parentCategoryId}";
/**
* 查询父节点.
*/
public static final String QUERY_PARENT_PRODUCT = "/api-user/" + "siteCustomoCategory/parents/{siteId}/{categoryId}";
/**
* 查询服务类型.
*/
public static final String QUERY_SERVER_TYPE = "/api-user/" + "serviceProviderSite/getServiceProviderTypeBySiteId/{siteId}";
......@@ -117,7 +128,17 @@ public class ManagerConstant {
public static final String CREATE_NEW_ORDER = "/api-order/" + "orders";
/**
* 合作商自建工单
* 合作商自建工单.
*/
public static final String CREATE_PARTNER_ORDER = "/api-order/" + "orders/partner";
/**
* 获取服务站信息.
*/
public static final String QUERY_STATAION_INFO = "/api-user/" + "serviceProviderSite/findSiteDetailInfo/siteId/{siteId}";
/**
* 取消工单.
*/
public static final String CANCEL_ORDER = "api-order" + "/orders/cancel";
}
package com.dayu.managercenter.data;
import com.contrarywind.interfaces.IPickerViewData;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class Area {
private ArrayList<Province> data;
public ArrayList<Province> getData() {
return data;
}
public void setData(ArrayList<Province> data) {
this.data = data;
}
public static class Province implements IPickerViewData {
private String i;
private String t;
private String p;
private List<City> c;
public String getI() {
return i;
}
public void setI(String i) {
this.i = i;
}
public String getName() {
return t;
}
public void setName(String t) {
this.t = t;
}
public String getP() {
return p;
}
public void setP(String p) {
this.p = p;
}
public List<City> getCity() {
return c;
}
public void setCity(List<City> c) {
this.c = c;
}
public static class City {
private String i;
private String t;
private String p;
private List<County> c;
public String getI() {
return i;
}
public void setI(String i) {
this.i = i;
}
public String getName() {
return t;
}
public void setName(String t) {
this.t = t;
}
public String getP() {
return p;
}
public void setP(String p) {
this.p = p;
}
public List<County> getCounty() {
return c;
}
public void setCounty(List<County> c) {
this.c = c;
}
public static class County {
/**
* i : 3
* t : 东城区
* c : []
* p : 2
*/
private String i;
private String t;
public String getName() {
return t;
}
public void setName(String t) {
this.t = t;
}
public String getI() {
return i;
}
public void setI(String i) {
this.i = i;
}
}
}
// 实现 IPickerViewData 接口,
// 这个用来显示在PickerView上面的字符串,
// PickerView会通过IPickerViewData获取getPickerViewText方法显示出来。
@Override
public String getPickerViewText() {
return this.t;
}
}
}
......@@ -79,6 +79,24 @@ public class OrderDetail implements Serializable {
private Integer payStatus;//或null:未支付 2.已支付3.支付成功4.支付失败
private Double paymentPrice;//发单价
private String companyName;
private int faceSwitch;
private int isCheck;
public int getFaceSwitch() {
return faceSwitch;
}
public void setFaceSwitch(int faceSwitch) {
this.faceSwitch = faceSwitch;
}
public int getIsCheck() {
return isCheck;
}
public void setIsCheck(int isCheck) {
this.isCheck = isCheck;
}
public String getTaskDesc() {
return taskDesc;
......
package com.dayu.managercenter.data;
import android.os.Parcel;
import android.os.Parcelable;
import java.io.Serializable;
/**
* Created by luofan
* on 2018/11/20.
*/
public class Pic implements Serializable,Parcelable{
private int id;
private int ordersRelationSpuItemId;
private String pictureUrl;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getOrdersRelationSpuItemId() {
return ordersRelationSpuItemId;
}
public void setOrdersRelationSpuItemId(int ordersRelationSpuItemId) {
this.ordersRelationSpuItemId = ordersRelationSpuItemId;
}
public String getPictureUrl() {
return pictureUrl;
}
public void setPictureUrl(String pictureUrl) {
this.pictureUrl = pictureUrl;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeInt(this.ordersRelationSpuItemId);
dest.writeString(this.pictureUrl);
}
public Pic() {
}
protected Pic(Parcel in) {
this.id = in.readInt();
this.ordersRelationSpuItemId = in.readInt();
this.pictureUrl = in.readString();
}
public static final Creator<Pic> CREATOR = new Creator<Pic>() {
@Override
public Pic createFromParcel(Parcel source) {
return new Pic(source);
}
@Override
public Pic[] newArray(int size) {
return new Pic[size];
}
};
}
package com.dayu.managercenter.data;
/**
* Created by luofan
* on 2018/11/29.
*/
public class Product {
/**
* id : 18363
* categoryId : 1148
* parentId : 1144
* name : 大鱼小海棠
* level : 2
* siteId : 590
* source : 1
* status : 1
* providerId : null
*/
private int id;
private String categoryId;
private String parentId;
private String name;
private int level;
private int siteId;
private int source;
private int status;
private Object providerId;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getSiteId() {
return siteId;
}
public void setSiteId(int siteId) {
this.siteId = siteId;
}
public int getSource() {
return source;
}
public void setSource(int source) {
this.source = source;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Object getProviderId() {
return providerId;
}
public void setProviderId(Object providerId) {
this.providerId = providerId;
}
}
package com.dayu.managercenter.data;
/**
* Created by luofan
* on 2018/11/29.
*/
public class ServerType {
/**
* id : 2045
* siteId : 590
* providerTypeId : 1
* providerName : 安装
* status : 1
*/
private int id;
private int siteId;
private int providerTypeId;
private String providerName;
private int status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getSiteId() {
return siteId;
}
public void setSiteId(int siteId) {
this.siteId = siteId;
}
public int getProviderTypeId() {
return providerTypeId;
}
public void setProviderTypeId(int providerTypeId) {
this.providerTypeId = providerTypeId;
}
public String getProviderName() {
return providerName;
}
public void setProviderName(String providerName) {
this.providerName = providerName;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
package com.dayu.managercenter.data;
/**
* Created by luofan
* on 2018/11/29.
*/
public class SpuServer {
/**
* id : 13
* name : 安装小米电视
* providerTypeId : 1
* providerTypeName : 安装
* categoryOneId : 896
* categoryOneName : 家用电器
* categoryTwoId : 897
* categoryTwoName : 电视
* categoryThreeId : 1142
* categoryThreeName : 小米电视
* accessoryUrl :
* accessoryName : null
* partnerId : 12
* partnerName : 小米
* providerId : 448
* createTime : 2018-08-10 09:52:23
*/
private int id;
private String name;
private int providerTypeId;
private String providerTypeName;
private int categoryOneId;
private String categoryOneName;
private int categoryTwoId;
private String categoryTwoName;
private int categoryThreeId;
private String categoryThreeName;
private String accessoryUrl;
private Object accessoryName;
private int partnerId;
private String partnerName;
private int providerId;
private String createTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getProviderTypeId() {
return providerTypeId;
}
public void setProviderTypeId(int providerTypeId) {
this.providerTypeId = providerTypeId;
}
public String getProviderTypeName() {
return providerTypeName;
}
public void setProviderTypeName(String providerTypeName) {
this.providerTypeName = providerTypeName;
}
public int getCategoryOneId() {
return categoryOneId;
}
public void setCategoryOneId(int categoryOneId) {
this.categoryOneId = categoryOneId;
}
public String getCategoryOneName() {
return categoryOneName;
}
public void setCategoryOneName(String categoryOneName) {
this.categoryOneName = categoryOneName;
}
public int getCategoryTwoId() {
return categoryTwoId;
}
public void setCategoryTwoId(int categoryTwoId) {
this.categoryTwoId = categoryTwoId;
}
public String getCategoryTwoName() {
return categoryTwoName;
}
public void setCategoryTwoName(String categoryTwoName) {
this.categoryTwoName = categoryTwoName;
}
public int getCategoryThreeId() {
return categoryThreeId;
}
public void setCategoryThreeId(int categoryThreeId) {
this.categoryThreeId = categoryThreeId;
}
public String getCategoryThreeName() {
return categoryThreeName;
}
public void setCategoryThreeName(String categoryThreeName) {
this.categoryThreeName = categoryThreeName;
}
public String getAccessoryUrl() {
return accessoryUrl;
}
public void setAccessoryUrl(String accessoryUrl) {
this.accessoryUrl = accessoryUrl;
}
public Object getAccessoryName() {
return accessoryName;
}
public void setAccessoryName(Object accessoryName) {
this.accessoryName = accessoryName;
}
public int getPartnerId() {
return partnerId;
}
public void setPartnerId(int partnerId) {
this.partnerId = partnerId;
}
public String getPartnerName() {
return partnerName;
}
public void setPartnerName(String partnerName) {
this.partnerName = partnerName;
}
public int getProviderId() {
return providerId;
}
public void setProviderId(int providerId) {
this.providerId = providerId;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}
......@@ -20,5 +20,9 @@ public interface ChangeOrderContract {
public abstract void getDesignateList();
public abstract void getEngineers(int id);
public abstract void modifyOrder(int id);
public abstract void createAgain(int id);
}
}
......@@ -6,8 +6,10 @@ import android.os.Bundle;
import com.dayu.common.Constants;
import com.dayu.event.ServiceStation;
import com.dayu.managercenter.api.ManagerApiFactory;
import com.dayu.managercenter.common.ManagerConstant;
import com.dayu.managercenter.data.Engineer;
import com.dayu.managercenter.ui.activity.ChangeReasonActivity;
import com.dayu.managercenter.ui.activity.CreateOrderActivity;
import com.dayu.utils.StationManager;
import java.util.ArrayList;
......@@ -47,6 +49,24 @@ public class ChangeOrderPresenter extends ChangeOrderContract.Presenter {
engineers -> showEngineerDialog(engineers, id)));
}
@Override
public void modifyOrder(int id) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.STATE, ManagerConstant.MODIFY_ORDER);
bundle.putInt(Constants.ORDER_ID, id);
mView.startActivity(CreateOrderActivity.class, bundle);
}
@Override
public void createAgain(int id) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.ORDER_ID, id);
bundle.putInt(Constants.STATE, ManagerConstant.AGIN_ORDER);
mView.startActivity(CreateOrderActivity.class, bundle);
}
private void showEngineerDialog(List<Engineer> engineers, int id) {
List<String> list = new ArrayList<>();
for (Engineer info : engineers) {
......@@ -57,6 +77,7 @@ public class ChangeOrderPresenter extends ChangeOrderContract.Presenter {
Bundle bundle = new Bundle();
bundle.putInt(Constants.ACCOUNT_ID, engineers.get(options1).getAccountId());
bundle.putInt(Constants.ID, id);
bundle.putInt(Constants.TYPE, ManagerConstant.CHANGE_ORDER_REASON);
mView.startActivity(ChangeReasonActivity.class, bundle);
});
}
......
......@@ -17,5 +17,7 @@ public interface ChangeReasonContract {
abstract class Presenter extends BasePresenter<View> {
public abstract void changeEngineer();
public abstract void cancleOrder(int type);
}
}
......@@ -4,10 +4,15 @@ import android.databinding.ObservableField;
import android.text.TextUtils;
import com.dayu.common.Constants;
import com.dayu.managercenter.R;
import com.dayu.managercenter.api.ManagerApiFactory;
import com.dayu.managercenter.common.ManagerConstant;
import com.dayu.managercenter.ui.activity.SendOrderDetailActivity;
import com.dayu.provider.event.RefreshManagerEvent;
import com.dayu.utils.AppManager;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UserManager;
import com.dayu.utils.UtilsUserAccountMatcher;
import org.greenrobot.eventbus.EventBus;
......@@ -32,7 +37,11 @@ public class ChangeReasonPresenter extends ChangeReasonContract.Presenter {
@Override
public void changeEngineer() {
if (TextUtils.isEmpty(mReason.get())) {
ToastUtils.showShortToast("请输入改派原因");
ToastUtils.showShortToast("请输入原因");
return;
}
if (!TextUtils.isEmpty(mReason.get()) && UtilsUserAccountMatcher.containsEmoji(mReason.get())) {
mView.showToast(R.string.no_emoij);
return;
}
mView.showDialog();
......@@ -48,4 +57,20 @@ public class ChangeReasonPresenter extends ChangeReasonContract.Presenter {
})
);
}
@Override
public void cancleOrder(int type) {
mView.showDialog();
ManagerApiFactory.cancelOrder(mId, mReason.get(), UserManager.getInstance().getUserName())
.subscribe(baseObserver(aBoolean -> {
mView.dumpBack();
if (type == ManagerConstant.SEND_ORDER) {
EventBus.getDefault().post(new RefreshManagerEvent(ManagerConstant.SEND_ORDER));
} else {
EventBus.getDefault().post(new RefreshManagerEvent(ManagerConstant.CHANGE_ORDER));
}
AppManager.getInstance().finishActivity(SendOrderDetailActivity.class);
ToastUtils.showShortToast("工单取消成功");
}));
}
}
package com.dayu.managercenter.presenter.createorder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.dayu.base.ui.presenter.BasePresenter;
import com.dayu.common.BaseView;
import com.dayu.event.ServiceStation;
import com.dayu.managercenter.data.Engineer;
import com.dayu.managercenter.data.OrderDetail;
import com.dayu.managercenter.data.Product;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Created by luo on 2016/8/4.
*/
public interface CreateOrderContract {
interface View extends BaseView {
void selectTime(boolean[] type, OnTimeSelectListener listener);
void showSelectDilog(List<String> list, OnOptionsSelectListener listener);
boolean checkParam();
HashMap<String, Object> getParams();
ArrayList<String> getImgs();
void setStation(ServiceStation mStation);
/**
* 设置用户信息.
* @param detail
*/
void setInfo(OrderDetail detail,List<Product> products);
}
abstract class Presenter extends BasePresenter<View> {
public abstract void selectDay();
public abstract void selectTime();
/**
* 选择服务.
*/
public abstract void selectServer();
/**
* 选择服务类型
*/
public abstract void selectServerType();
/**
* 选择产品线
*/
public abstract void selectProductLine();
public abstract void selectBProduct();
public abstract void selectSProduct();
public abstract void getEngineers();
/**
* 选择工程师.
*/
public abstract void selectEngineer(List<Engineer> engineers);
public abstract void swtichAcceptance();
public abstract void swtichSignature();
public abstract void createNewOrder(int state);
/**
* 创建工单.
* @param state
*/
public abstract void createOrder(int state);
public abstract void commitePhoto(ArrayList<String> list, int state);
public abstract void getStationInfo(int siteId);
/**
* 获取工单信息.
* @param id
*/
public abstract void getOrderInfo(int id);
}
}
package com.dayu.managercenter.presenter.createorder;
import android.databinding.ObservableBoolean;
import android.databinding.ObservableField;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import com.dayu.base.api.BaseApiFactory;
import com.dayu.common.Constants;
import com.dayu.event.ServiceStation;
import com.dayu.event.UserInfo;
import com.dayu.managercenter.R;
import com.dayu.managercenter.api.ManagerApiFactory;
import com.dayu.managercenter.common.ManagerConstant;
import com.dayu.managercenter.data.Engineer;
import com.dayu.managercenter.data.OrderDetail;
import com.dayu.managercenter.data.Product;
import com.dayu.managercenter.data.ServerType;
import com.dayu.managercenter.data.SpuServer;
import com.dayu.managercenter.ui.activity.CreateOrderActivity;
import com.dayu.provider.event.RefreshManagerEvent;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UIUtils;
import com.dayu.utils.UserManager;
import com.dayu.utils.UtilsDate;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import static com.dayu.utils.UtilsDate.LONG_TIME_FORMAT_TWO;
/**
* Created by luofan
* on 2017/11/8.
*/
public class CreateOrderPresenter extends CreateOrderContract.Presenter {
private int mType;
private boolean mIsToday;
private ArrayList<String> mHttpUrl = new ArrayList<>();
public ObservableField<String> mDay = new ObservableField<>();
public ObservableField<String> mHour = new ObservableField<>();
public ObservableField<String> serverName = new ObservableField<>();
public ObservableField<String> serverType = new ObservableField<>();
public ObservableField<String> productLine = new ObservableField<>();
public ObservableField<String> bProduct = new ObservableField<>();
public ObservableField<String> sProduct = new ObservableField<>();
public ObservableBoolean isacceptance = new ObservableBoolean();
public ObservableBoolean isSignature = new ObservableBoolean();
public ObservableField<String> engineerName = new ObservableField<>();
private int mSiteId;
private Engineer mEngineer;
private String mLineId;
private String mBId;
private int mServerTypeId;
private int mProviderId;
private String mCategoryId;
private int mSpuServerId;
private int mSource;
private ArrayList<OrderDetail.accessories> mAccessorites;
private int mRole;
private UserInfo mUser;
private ServiceStation mStation;
private int mState;
private int mId;
private OrderDetail mDetail;
@Override
public void onAttached() {
mRole = UserManager.getInstance().getRole();
mUser = UserManager.getInstance().getUser();
mSiteId = UserManager.getInstance().getUser().getSiteId();
mState = mView.getBundle().getInt(Constants.STATE);
mId = mView.getBundle().getInt(Constants.ORDER_ID, -1);
if (mId != -1) {
getOrderInfo(mId);
}
getStationInfo(mSiteId);
}
@Override
public void selectDay() {
mType = 1;
mView.selectTime(new boolean[]{true, true, true, false, false, false}, this::onTimeSelect);
}
@Override
public void selectTime() {
if (TextUtils.isEmpty(mDay.get())) {
mView.showToast(R.string.input_day_first);
return;
}
mType = 2;
mView.selectTime(new boolean[]{false, false, false, true, true, false}, this::onTimeSelect);
}
@Override
public void selectServer() {
mView.showDialog();
List<String> list = new ArrayList<>();
ManagerApiFactory.getSpuServer(mProviderId, mSiteId)
.subscribe(baseObserver(spuServers -> {
for (SpuServer serverType : spuServers) {
list.add(serverType.getName());
}
mView.showSelectDilog(list, (options1, options2, options3, v)
-> {
serverName.set(list.get(options1));
mSpuServerId = spuServers.get(options1).getId();
});
}));
}
@Override
public void selectServerType() {
mView.showDialog();
List<String> list = new ArrayList<>();
ManagerApiFactory.querySerVerType(mSiteId)
.subscribe(baseObserver(serverTypes -> {
for (ServerType serverType : serverTypes) {
list.add(serverType.getProviderName());
}
mView.showSelectDilog(list, (options1, options2, options3, v)
-> {
serverType.set(list.get(options1));
mServerTypeId = serverTypes.get(options1).getProviderTypeId();
});
}));
}
@Override
public void selectProductLine() {
mView.showDialog();
List<String> list = new ArrayList<>();
ManagerApiFactory.querySonProduct(mSiteId, "-1")
.subscribe(baseObserver(products -> {
for (Product product : products) {
list.add(product.getName());
}
mView.showSelectDilog(list, (options1, options2, options3, v)
-> {
productLine.set(list.get(options1));
String id = products.get(options1).getCategoryId();
if (mLineId != null && !mLineId.equals(id)) {
bProduct.set("");
sProduct.set("");
}
mLineId = id;
});
}));
}
private void queryProduct(OrderDetail detail, String categorId) {
mView.showDialog();
ManagerApiFactory.queryParentProduct(mSiteId, categorId)
.subscribe(baseObserver(new Consumer<List<Product>>() {
@Override
public void accept(List<Product> products) throws Exception {
mView.setInfo(detail, products);
mDetail = detail;
mSpuServerId = detail.getSpuId();
serverName.set(detail.getSpuName());
serverType.set(detail.getProviderName());
sProduct.set(detail.getCategoryName());
mCategoryId = detail.getCategoryId();
mServerTypeId = detail.getProviderTypeId();
if (!TextUtils.isEmpty(detail.getEngineerName())){
mEngineer = new Engineer();
mEngineer.setRealName(detail.getEngineerName());
mEngineer.setAccountId(detail.getEngineerId());
}
}
}));
}
@Override
public void selectBProduct() {
if (TextUtils.isEmpty(mLineId)) {
ToastUtils.showShortToast(R.string.select_product_line_first);
return;
}
mView.showDialog();
List<String> list = new ArrayList<>();
ManagerApiFactory.querySonProduct(mSiteId, mLineId)
.subscribe(baseObserver(products -> {
for (Product product : products) {
list.add(product.getName());
}
mView.showSelectDilog(list, (options1, options2, options3, v)
-> {
bProduct.set(list.get(options1));
String id = products.get(options1).getCategoryId();
if (mBId != null && !mBId.equals(id)) {
sProduct.set("");
}
mBId = id;
});
}));
}
@Override
public void selectSProduct() {
if (TextUtils.isEmpty(mBId)) {
ToastUtils.showShortToast(R.string.select_big_product_first);
return;
}
mView.showDialog();
List<String> list = new ArrayList<>();
ManagerApiFactory.querySonProduct(mSiteId, mBId)
.subscribe(baseObserver(products -> {
for (Product product : products) {
list.add(product.getName());
}
mView.showSelectDilog(list, (options1, options2, options3, v)
-> {
sProduct.set(list.get(options1));
mCategoryId = products.get(options1).getCategoryId();
});
}));
}
@Override
public void getEngineers() {
if (mRole == Constants.ENGINEER) {
List<Engineer> engineers = new ArrayList<>();
Engineer engineer = new Engineer();
engineer.setAccountId(Integer.parseInt(mUser.getAccountId()));
engineer.setRealName(mUser.getAccountName());
engineers.add(engineer);
selectEngineer(engineers);
} else {
mView.showDialog();
ManagerApiFactory.getEngineers(mSiteId).subscribe(baseObserver(
this::selectEngineer));
}
}
@Override
public void selectEngineer(List<Engineer> engineers) {
List<String> list = new ArrayList<>();
list.add(UIUtils.getString(R.string.no_designate));
for (Engineer info : engineers) {
list.add(info.getRealName());
}
mView.showSelectDilog(list, (options1, options2, options3, v)
-> {
String name = list.get(options1);
engineerName.set(name);
if (!name.equals(UIUtils.getString(R.string.no_designate))) {
mEngineer = engineers.get(options1 - 1);
} else {
mEngineer = null;
}
});
}
@Override
public void swtichAcceptance() {
isacceptance.set(!isacceptance.get());
}
@Override
public void swtichSignature() {
isSignature.set(!isSignature.get());
}
@Override
public void createNewOrder(int state) {
RequestBody body = getBody();
if (body == null) {
return;
}
Observable<Boolean> observable;
String desc;
if (mState == ManagerConstant.MODIFY_ORDER) {
if (mSource == 1) {
desc = "工单修改成功!";
observable = ManagerApiFactory.modifyOrder(body);
} else {
desc = "工单修改成功!";
observable = ManagerApiFactory.modifyPartnerOrder(body);
}
} else {
if (mSource == 1) {
desc = "工单创建成功!";
observable = ManagerApiFactory.createOrder(body);
} else {
desc = "工单创建成功!";
observable = ManagerApiFactory.createPartnerOrder(body);
}
}
mView.showDialog();
observable.subscribe(baseObserver(aBoolean -> {
ToastUtils.showShortToast(desc);
if (state == 0) {
Disposable disposable = Observable.timer(300, TimeUnit.MILLISECONDS)
.subscribe(aLong -> {
if (mEngineer == null) {
EventBus.getDefault().post(new RefreshManagerEvent(ManagerConstant.SEND_ORDER));
} else {
EventBus.getDefault().post(new RefreshManagerEvent(ManagerConstant.CHANGE_ORDER));
}
});
mView.dumpBack();
} else {
mView.dumpBack();
Bundle bundle = new Bundle();
bundle.putInt(Constants.TYPE, mType);
bundle.putInt(Constants.STATE, mState);
mView.startActivity(CreateOrderActivity.class);
}
}));
}
@Override
public void createOrder(int state) {
if (!mView.checkParam()) {
return;
}
if (mView.getImgs().size() > 0) {
commitePhoto(mView.getImgs(), state);
} else {
createNewOrder(state);
}
}
@Override
public void commitePhoto(ArrayList<String> imgs, int state) {
mView.showDialog();
MultipartBody.Part[] parts = packPhoto(imgs);
mAccessorites = new ArrayList<>();
if (mHttpUrl.size() > 0) {
for (String str : mHttpUrl) {
OrderDetail.accessories accessories = new OrderDetail.accessories();
accessories.setUrl(str);
accessories.setUid(System.currentTimeMillis());
accessories.setName(getFileName(str));
mAccessorites.add(accessories);
}
}
if (parts.length > 0) {
BaseApiFactory.uploadPhoto(parts).subscribe(baseObserver(list -> {
if (list == null) {
return;
}
for (int i = 0; i < list.size(); i++) {
OrderDetail.accessories accessories = new OrderDetail.accessories();
accessories.setUrl(list.get(i));
accessories.setUid(System.currentTimeMillis());
accessories.setName(getFileName(imgs.get(i)));
mAccessorites.add(accessories);
}
createNewOrder(state);
}));
} else {
createNewOrder(state);
}
}
@Override
public void getStationInfo(int siteId) {
mView.showDialog();
ManagerApiFactory.getStationInfo(mSiteId)
.subscribe(baseObserver(serviceStation -> {
mStation = serviceStation;
mProviderId = serviceStation.getProviderId();
mView.setStation(mStation);
}));
}
@Override
public void getOrderInfo(int id) {
ManagerApiFactory.getOrderInfo(id).subscribe(baseObserver(new Consumer<OrderDetail>() {
@Override
public void accept(OrderDetail detail) throws Exception {
queryProduct(detail, detail.getCategoryId());
}
}));
}
private String getFileName(String pathandname) {
int start = pathandname.lastIndexOf("/");
if (start != -1) {
return pathandname.substring(start + 1);
} else {
return null;
}
}
private MultipartBody.Part[] packPhoto(List<String> imageUrl) {
ArrayList<File> files = new ArrayList<>();
mHttpUrl.clear();
if (imageUrl != null && imageUrl.size() > 0) {
for (int i = 0; i < imageUrl.size(); i++) {
if (imageUrl.get(i).contains("http")) {
mHttpUrl.add(imageUrl.get(i));
} else {
files.add(new File(imageUrl.get(i)));
}
}
}
MultipartBody.Part[] part = new MultipartBody.Part[files.size()];
for (int i = 0; i < files.size(); i++) {
RequestBody requestFile =
RequestBody.create(MediaType.parse("multipart/form-data"), files.get(i));
MultipartBody.Part body =
MultipartBody.Part.createFormData("fileUpload", files.get(i).getName(), requestFile);
part[i] = body;
}
return part;
}
private RequestBody getBody() {
HashMap<String, Object> params = mView.getParams();
if (params == null) {
return null;
}
if (mEngineer != null) {
params.put("engineerName", engineerName.get());
params.put("engineerId", mEngineer.getAccountId());
}
params.put("categoryName", sProduct.get());
params.put("categoryOneVal", mLineId);
params.put("categoryTwoVal", mBId);
params.put("categoryId", mCategoryId);
params.put("spuName", serverName.get());
params.put("spuId", mSpuServerId);
params.put("providerName", serverType.get());
params.put("providerTypeId", mServerTypeId);
if (mState == ManagerConstant.MODIFY_ORDER) {
params.put("id", mId);
}
JSONObject jsonObject = new JSONObject(params);
if (mAccessorites != null && mAccessorites.size() > 0) {
JSONArray jsonArray = new JSONArray();
JSONObject object;
try {
for (int i = 0; i < mAccessorites.size(); i++) {
object = new JSONObject();
object.put("name", mAccessorites.get(i).getName());
object.put("url", mAccessorites.get(i).getUrl());
object.put("uid", mAccessorites.get(i).getUid());
jsonArray.put(object);
}
jsonObject.put("orderAccessorites", jsonArray);
} catch (JSONException e) {
e.printStackTrace();
}
}
mSource = (int) params.get("source");
return RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
}
private void onTimeSelect(Date date, View v) {
if (mType == 1) {
String time = UtilsDate.getTime(date);
if (UtilsDate.dayDiff(UtilsDate.getNowDate(), date) >= 0) {
mDay.set(time);
} else {
mView.showToast(R.string.input_right_time);
return;
}
int year = UtilsDate.getYear(date);
int month = UtilsDate.getMonth(date);
int day = UtilsDate.getDay(date);
mIsToday = year == UtilsDate.getToYear() && month == UtilsDate.getToMonth() && day == UtilsDate.getToday();
} else {
String nowtime = UtilsDate.getCurrDate(LONG_TIME_FORMAT_TWO);
String hour = UtilsDate.dateToString(date, LONG_TIME_FORMAT_TWO);
if (mIsToday && UtilsDate.stringtoDate(nowtime, LONG_TIME_FORMAT_TWO).getTime() - UtilsDate.stringtoDate(hour, LONG_TIME_FORMAT_TWO).getTime() >= 0) {
mView.showToast(R.string.input_right_time);
} else {
mHour.set(hour);
}
}
}
public void setLineId(String id) {
mLineId = id;
}
public void setBigId(String id) {
mBId = id;
}
}
......@@ -53,5 +53,6 @@ public interface SendDetailContract {
*/
public abstract void getBargainPrice(int kaOrderId);
public abstract void cancleOrder(int mState);
}
}
......@@ -112,6 +112,7 @@ public class SendDetailPresenter extends SendDetailContract.Presenter {
bundle.putInt(Constants.ACCOUNT_ID, engineers.get(options1).getAccountId());
bundle.putInt(Constants.ID, mId);
bundle.putInt(Constants.STATE, 1);
bundle.putInt(Constants.TYPE, ManagerConstant.CHANGE_ORDER_REASON);
mView.startActivityForReult(ChangeReasonActivity.class, bundle, 100);
} else if (type == ManagerConstant.GRAB_ORDER) {
receive(accountId, name);
......@@ -192,4 +193,12 @@ public class SendDetailPresenter extends SendDetailContract.Presenter {
}
}));
}
@Override
public void cancleOrder(int mState) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.ID, mId);
bundle.putInt(Constants.TYPE, mState);
mView.startActivity(ChangeReasonActivity.class, bundle);
}
}
......@@ -31,5 +31,14 @@ public interface SendOrderContract {
* 获取工程师列表.
*/
public abstract void getEngineers(int id);
/**
* 再来一单.
*/
public abstract void createAgain(int id);
/**
* 修改工单.
*/
public abstract void modifyOrder(int id);
}
}
package com.dayu.managercenter.presenter.sendorder;
import android.databinding.ObservableField;
import android.os.Bundle;
import com.dayu.common.Constants;
import com.dayu.event.ServiceStation;
import com.dayu.event.UserInfo;
import com.dayu.managercenter.R;
import com.dayu.managercenter.api.ManagerApiFactory;
import com.dayu.managercenter.common.ManagerConstant;
import com.dayu.managercenter.data.Engineer;
import com.dayu.managercenter.ui.activity.CreateOrderActivity;
import com.dayu.utils.StationManager;
import com.dayu.utils.UserManager;
......@@ -61,6 +64,22 @@ public class SendOrderPresenter extends SendOrderContract.Presenter {
engineers -> showEngineerDialog(engineers, id)));
}
@Override
public void modifyOrder(int id) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.STATE, ManagerConstant.MODIFY_ORDER);
bundle.putInt(Constants.ORDER_ID, id);
mView.startActivity(CreateOrderActivity.class, bundle);
}
@Override
public void createAgain(int id) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.ORDER_ID, id);
bundle.putInt(Constants.STATE, ManagerConstant.AGIN_ORDER);
mView.startActivity(CreateOrderActivity.class, bundle);
}
private void showEngineerDialog(List<Engineer> engineers, int id) {
List<String> list = new ArrayList<>();
for (Engineer info : engineers) {
......
package com.dayu.managercenter.ui.activity;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.common.Constants;
import com.dayu.managercenter.R;
import com.dayu.managercenter.common.ManagerConstant;
import com.dayu.managercenter.databinding.ActivityChangeReasonBinding;
import com.dayu.managercenter.presenter.changereason.ChangeReasonContract;
import com.dayu.managercenter.presenter.changereason.ChangeReasonPresenter;
......@@ -21,7 +23,16 @@ public class ChangeReasonActivity extends BaseActivity<ChangeReasonPresenter, Ac
@Override
public void initView() {
int type = getBundle().getInt(Constants.TYPE);
if (type == ManagerConstant.CHANGE_ORDER_REASON) {
mBind.text.setText("改派原因");
mBind.tvRightTitle.setOnClickListener(v -> mPresenter.changeEngineer());
} else if (type == ManagerConstant.SEND_ORDER || type == ManagerConstant.CHANGE_ORDER) {
mBind.text.setText("取消原因");
mBind.tvRightTitle.setOnClickListener(v -> mPresenter.cancleOrder(type));
}
}
@Override
public void setPresenter() {
mBind.setPresenter(mPresenter);
......
package com.dayu.managercenter.ui.activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.widget.GridLayoutManager;
import android.text.TextUtils;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.bigkoo.pickerview.view.TimePickerView;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.base.ui.adapter.PhotoViewAdapter;
import com.dayu.base.ui.adapter.SpacesItemDecoration;
import com.dayu.common.Constants;
import com.dayu.event.ServiceStation;
import com.dayu.event.UserInfo;
import com.dayu.managercenter.R;
import com.dayu.managercenter.common.ManagerConstant;
import com.dayu.managercenter.data.Area;
import com.dayu.managercenter.data.OrderDetail;
import com.dayu.managercenter.data.Product;
import com.dayu.managercenter.databinding.ActivityCreateOrderLayoutBinding;
import com.dayu.managercenter.presenter.createorder.CreateOrderContract;
import com.dayu.managercenter.presenter.createorder.CreateOrderPresenter;
import com.dayu.provider.router.RouterPath;
import com.dayu.utils.GetJsonDataUtil;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UIUtils;
import com.dayu.utils.UserManager;
import com.dayu.utils.UtilsDate;
import com.dayu.utils.UtilsUserAccountMatcher;
import com.google.gson.Gson;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.entity.LocalMedia;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import static com.dayu.utils.UtilsDate.FORMAT_ONE;
import static com.dayu.utils.UtilsDate.LONG_DATE;
import static com.dayu.utils.UtilsDate.LONG_DATE_FORMAT;
import static com.dayu.utils.UtilsDate.LONG_TIME_FORMAT_TWO;
/**
* Created by luofan
* on 2018/11/27.
*/
@Route(path = RouterPath.PATH_MANAGER_CREATE_ORDER)
public class CreateOrderActivity extends BaseActivity<CreateOrderPresenter, ActivityCreateOrderLayoutBinding> implements CreateOrderContract.View {
private ArrayList<Area.Province> options1Items = new ArrayList<>();
private ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();
private String mProvince;
private int mProvinceId;
private String mCity;
private int mCityId;
private String mDistrict;
private int mDistrictId;
private String mTime;
private int mCustomerType = 1;
private int mSource = 1;
private int mRepairType = 2;
private ServiceStation mStation;
private ArrayList<String> mImages = new ArrayList<>();
private PhotoViewAdapter mAdapter;
private int mState;
@Override
public void setPresenter() {
mBind.setPresenter(mPresenter);
}
@Override
public int getLayoutId() {
return R.layout.activity_create_order_layout;
}
@Override
public void initView() {
mState = getBundle().getInt(Constants.STATE);
mBind.toolbar.setNavigationOnClickListener(v -> dumpBack());
mBind.tvTitle.setText(getString(R.string.create_order));
mBind.otherCustomer.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
mSource = 1;
mRepairType = 2;//散客
mBind.llSelectServer.setVisibility(View.GONE);
mBind.llServerType.setVisibility(View.VISIBLE);
mBind.llProductType.setVisibility(View.VISIBLE);
} else {
mSource = 2;
mRepairType = 1;//自签约合作商.
mBind.llSelectServer.setVisibility(View.VISIBLE);
mBind.llServerType.setVisibility(View.GONE);
mBind.llProductType.setVisibility(View.GONE);
}
});
mBind.personalCustomer.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
mCustomerType = 1;
mBind.llCompanyName.setVisibility(View.GONE);
} else {
mCustomerType = 2;
mBind.llCompanyName.setVisibility(View.VISIBLE);
}
});
mBind.customerAddress.setOnClickListener(v -> {
showDialog();
Disposable disposable = Observable.create((ObservableOnSubscribe<String>) e -> e.onNext("area.json"))
.map(s -> {
String JsonData = new GetJsonDataUtil().getJson(mActivity, "area.json");
return parseData(JsonData);
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::initData);
mPresenter.getDisposable().add(disposable);
});
initPhotoView();
}
private void initPhotoView() {
mImages.add("add");
mBind.photoView.addItemDecoration(new SpacesItemDecoration(10));
mBind.photoView.setLayoutManager(new GridLayoutManager(mActivity, 5));
mAdapter = new PhotoViewAdapter(mImages, mActivity);
mBind.photoView.setAdapter(mAdapter);
mAdapter.setData(mImages);
}
@Override
public void selectTime(boolean[] type, OnTimeSelectListener listener) {
try {
InputMethodManager imm = (InputMethodManager) mActivity
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), 0);
} catch (NullPointerException e) {
}
TimePickerView pvTime = new TimePickerBuilder(mActivity, listener)
.setType(type)//默认全部显示
.setCancelText(getString(R.string.cancle))//取消按钮文字
.setSubmitText(getString(R.string.comfirm))//确认按钮文字
.setContentTextSize(20)//滚轮文字大小
.setOutSideCancelable(true)//点击屏幕,点在控件外部范围时,是否取消显示
.isCyclic(false)//是否循环滚动
.setTextColorCenter(Color.BLACK)//设置选中项的颜色
.setSubmitColor(Color.BLACK)//确定按钮文字颜色
.setCancelColor(Color.BLACK)//取消按钮文字颜色
.isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
.isDialog(false)//是否显示为对话框样式
.setLineSpacingMultiplier(2.0f)
.build();
pvTime.setDate(Calendar.getInstance());
pvTime.show();
}
private void showPickerView() {
hideDialog();
OptionsPickerView pvOptions = new OptionsPickerBuilder(this, (options1, options2, options3, v) -> {
mProvince = options1Items.get(options1).getPickerViewText();
mProvinceId = Integer.parseInt(options1Items.get(options1).getI());
mCity = options2Items.get(options1).get(options2);
mCityId = Integer.parseInt(options1Items.get(options1).getCity().get(options2).getI());
mDistrict = options3Items.get(options1).get(options2).get(options3);
mDistrictId = Integer.parseInt(options1Items.get(options1).getCity().get(options2).getCounty().get(options3).getI());
mBind.customerAddress.setText(mProvince + mCity + mDistrict);
})
.setTitleText("城市选择")
.setDividerColor(Color.BLACK)
.setTextColorCenter(Color.BLACK) //设置选中项文字颜色
.setContentTextSize(20)
.build();
pvOptions.setPicker(options1Items, options2Items, options3Items);//三级选择器
pvOptions.show();
}
@Override
public void showSelectDilog(List<String> list, OnOptionsSelectListener listener) {
OptionsPickerView pvOptions = new OptionsPickerBuilder(mActivity, listener)
.setContentTextSize(18)
.setLineSpacingMultiplier(2.0f)
.build();
pvOptions.setPicker(list);
pvOptions.show();
}
@Override
public boolean checkParam() {
if (!mBind.otherCustomer.isChecked()) {
if (TextUtils.isEmpty(mBind.selectServer.getText())) {
ToastUtils.showShortToast(R.string.please_input_server);
return false;
}
} else {
if (TextUtils.isEmpty(mBind.serverType.getText())) {
ToastUtils.showShortToast(R.string.please_input_server_type);
return false;
}
if (TextUtils.isEmpty(mBind.productSmall.getText())) {
ToastUtils.showShortToast(R.string.please_select_product_type);
return false;
}
}
if (!mBind.personalCustomer.isChecked()) {
if (TextUtils.isEmpty(mBind.companyName.getText())) {
ToastUtils.showShortToast(R.string.please_input_company_name);
return false;
}
if ( UtilsUserAccountMatcher.containsEmoji(mBind.companyName.getText().toString())) {
showToast(R.string.no_emoij);
return false;
}
}
if (TextUtils.isEmpty(mBind.customerName.getText())) {
ToastUtils.showShortToast(R.string.please_input_name);
return false;
}
if ( UtilsUserAccountMatcher.containsEmoji(mBind.customerName.getText().toString())) {
showToast(R.string.no_emoij);
return false;
}
if (TextUtils.isEmpty(mBind.customerMobile.getText())) {
ToastUtils.showShortToast(R.string.please_input_mobile_first);
return false;
}
if (TextUtils.isEmpty(mBind.customerAddress.getText())) {
ToastUtils.showShortToast(R.string.please_input_address);
return false;
}
if (TextUtils.isEmpty(mBind.customerDetailAddress.getText())) {
ToastUtils.showShortToast(R.string.please_input_detail_address_first);
return false;
}
if ( UtilsUserAccountMatcher.containsEmoji(mBind.customerDetailAddress.getText().toString())) {
showToast(R.string.no_emoij);
return false;
}
if (TextUtils.isEmpty(mBind.hourTime.getText())) {
ToastUtils.showShortToast(R.string.please_input_time);
return false;
}
if (!TextUtils.isEmpty(mBind.etInfo.getText()) && UtilsUserAccountMatcher.containsEmoji(mBind.etInfo.getText().toString())) {
showToast(R.string.no_emoij);
return false;
}
if (!TextUtils.isEmpty(mBind.serverInfo.getText()) && UtilsUserAccountMatcher.containsEmoji(mBind.serverInfo.getText().toString())) {
showToast(R.string.no_emoij);
return false;
}
return true;
}
@Override
public HashMap<String, Object> getParams() {
try {
String d = UtilsDate.changeFormat(mBind.dayTime.getText().toString().trim(), LONG_DATE, LONG_DATE_FORMAT);
mTime = d + " " + mBind.hourTime.getText().toString().trim() + ":00";
} catch (ParseException e) {
e.printStackTrace();
}
if (!isLegal()) {
showToast(R.string.input_right_time);
return null;
}
int isSignature;
if (mPresenter.isSignature.get()) {
isSignature = 1;
} else {
isSignature = 2;
}
int isCheck;
if (mPresenter.isacceptance.get()) {
isCheck = 1;
} else {
isCheck = 0;
}
if (mProvinceId == 0) {
mProvince = mStation.getProvinceName();
mCity = mStation.getCityName();
mDistrict = mStation.getDistrictName();
mProvinceId = mStation.getProvinceId();
mCityId = mStation.getCityId();
mDistrictId = mStation.getDistrictId();
}
UserInfo user = UserManager.getInstance().getUser();
HashMap<String, Object> params = new HashMap<>();
params.put("source", mSource);
if (mCustomerType == 2) {
params.put("customerCompany", mBind.companyName.getText().toString().trim());
}
params.put("customerName", mBind.customerName.getText().toString().trim());
params.put("customerType", mCustomerType);
params.put("customerMobile", mBind.customerMobile.getText().toString().trim());
params.put("provinceName", mProvince);
params.put("provinceId", mProvinceId);
params.put("cityName", mCity);
params.put("cityId", mCityId);
params.put("districtName", mDistrict);
params.put("districtId", mDistrictId);
params.put("address", mBind.customerDetailAddress.getText().toString().trim());
params.put("appointmentTime", mTime);
params.put("categoryName", mBind.productSmall.getText().toString().trim());
params.put("brandName", mBind.brand.getText().toString().trim());
params.put("productModel", mBind.productModel.getText().toString().trim());
params.put("sn", mBind.sn.getText().toString().trim());
params.put("needEsignature", isSignature);
params.put("isCheck", isCheck);
params.put("comment", mBind.etInfo.getText().toString().trim());
params.put("taskDesc", mBind.serverInfo.getText().toString().trim());
params.put("created", user.getAccountName());
params.put("createId", Integer.parseInt(user.getAccountId()));
params.put("siteId", user.getSiteId());
params.put("repairType", mRepairType);
return params;
}
@Override
public ArrayList<String> getImgs() {
mImages.remove("add");
return mImages;
}
@Override
public void setStation(ServiceStation station) {
mStation = station;
mBind.customerAddress.setText(mStation.getProvinceName() + mStation.getCityName() + mStation.getDistrictName());
}
@Override
public void setInfo(OrderDetail detail, List<Product> products) {
mRepairType = detail.getRepairType();
mSource = detail.getSource();
mCustomerType = detail.getCustomerType();
mProvince = detail.getProvinceName();
mProvinceId = detail.getProvinceId();
mCity = detail.getCityName();
mCityId = detail.getCityId();
mDistrict = detail.getDistrictName();
mDistrictId = detail.getDistrictId();
for (OrderDetail.accessories accessorie : detail.getAccessories()) {
mImages.add(accessorie.getUrl());
}
if (mImages.size() > 0) {
mImages.remove("add");
}
if (mImages.size() < 10) {
mImages.add("add");
}
mAdapter.setData(mImages);
if (detail.getSource() == 1) {
mBind.otherCustomer.setChecked(true);
} else {
mBind.signCustomer.setChecked(true);
}
if (detail.getCustomerType() == 1) {
mBind.personalCustomer.setChecked(true);
} else {
mBind.enterpriseCustomer.setChecked(true);
}
if (detail.getNeedEsignature() != null && detail.getNeedEsignature() == 1) {
mBind.electronicSignature.setSwitchButton(true);
} else {
mBind.electronicSignature.setSwitchButton(false);
}
if (detail.getIsCheck() == 1) {
mBind.customerAcceptance.setSwitchButton(true);
} else {
mBind.customerAcceptance.setSwitchButton(false);
}
try {
String hour = UtilsDate.changeFormat(detail.getAppointmentTime(), FORMAT_ONE, LONG_TIME_FORMAT_TWO);
String day = UtilsDate.changeFormat(detail.getAppointmentTime(), FORMAT_ONE, LONG_DATE);
mBind.hourTime.setText(hour);
mBind.dayTime.setText(day);
} catch (ParseException e) {
e.printStackTrace();
}
mBind.customerName.setText(detail.getCustomerName());
mBind.customerMobile.setText(detail.getCustomerMobile());
mBind.customerAddress.setText(detail.getProvinceName() + detail.getCityName() + detail.getDistrictName());
mBind.customerDetailAddress.setText(detail.getAddress());
mBind.companyName.setText(detail.getCustomerCompany());
mBind.serverType.setText(detail.getProviderName());
mBind.brand.setText(detail.getBrandName());
mBind.productModel.setText(detail.getProductModel());
mBind.sn.setText(detail.getSn());
mBind.serverInfo.setText(detail.getTaskDesc());
mBind.etInfo.setText(detail.getComment());
if (TextUtils.isEmpty(detail.getEngineerName())) {
mBind.engineerName.setText(UIUtils.getString(R.string.no_designate));
} else {
mBind.engineerName.setText(detail.getEngineerName());
}
mBind.productSmall.setText(detail.getCategoryName());
for (Product product : products) {
if (product.getLevel() == 1) {
mBind.productLine.setText(product.getName());
mPresenter.setLineId(product.getCategoryId());
} else if (product.getLevel() == 2) {
mBind.productBig.setText(product.getName());
mPresenter.setBigId(product.getCategoryId());
}
}
mBind.otherCustomer.setClickable(false);
mBind.signCustomer.setClickable(false);
mBind.otherCustomer.setTextColor(UIUtils.getColor(R.color.default_editext_color));
mBind.signCustomer.setTextColor(UIUtils.getColor(R.color.default_editext_color));
mBind.createNext.setVisibility(View.GONE);
if (mState == ManagerConstant.MODIFY_ORDER) {
mBind.ivHour.setVisibility(View.GONE);
mBind.ivTime.setVisibility(View.GONE);
mBind.llDay.setEnabled(false);
mBind.llHour.setEnabled(false);
mBind.ivServerType.setVisibility(View.GONE);
mBind.serverType.setEnabled(false);
mBind.llProductType.setEnabled(false);
mBind.ivLine.setVisibility(View.GONE);
mBind.ivBig.setVisibility(View.GONE);
mBind.ivSmall.setVisibility(View.GONE);
mBind.engineerName.setEnabled(false);
mBind.productLine.setEnabled(false);
mBind.productBig.setEnabled(false);
mBind.productSmall.setEnabled(false);
mBind.ivEngineer.setVisibility(View.GONE);
} else {
mBind.dayTime.setText("");
mBind.hourTime.setText("");
}
}
private void initData(ArrayList<Area.Province> provinces) {//解析数据
options1Items = provinces;
for (int i = 0; i < provinces.size(); i++) {//遍历省份
ArrayList<String> CityList = new ArrayList<>();//该省的城市列表(第二级)
ArrayList<ArrayList<String>> Province_AreaList = new ArrayList<>();//该省的所有地区列表(第三极)
for (int c = 0; c < provinces.get(i).getCity().size(); c++) {//遍历该省份的所有城市
String CityName = provinces.get(i).getCity().get(c).getName();
CityList.add(CityName);//添加城市
ArrayList<String> City_AreaList = new ArrayList<>();//该城市的所有地区列表
//如果无地区数据,建议添加空字符串,防止数据为null 导致三个选项长度不匹配造成崩溃
if (provinces.get(i).getCity().get(c).getCounty() == null
|| provinces.get(i).getCity().get(c).getCounty().size() == 0) {
City_AreaList.add("");
} else {
List<Area.Province.City.County> counties = provinces.get(i).getCity().get(c).getCounty();
for (Area.Province.City.County county : counties) {
City_AreaList.add(county.getName());
}
}
Province_AreaList.add(City_AreaList);//添加该省所有地区数据
}
options2Items.add(CityList);
options3Items.add(Province_AreaList);
}
showPickerView();
}
public ArrayList<Area.Province> parseData(String result) {
try {
Gson gson = new Gson();
Area area = gson.fromJson(result, Area.class);
return area.getData();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private boolean isLegal() {
return UtilsDate.getLongFromyyyyMMddHHmmss(mTime) - System.currentTimeMillis() > 0;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case PictureConfig.CHOOSE_REQUEST:
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
if (selectList != null && selectList.size() > 0) {
mImages.remove("add");
for (int a = 0; a < selectList.size(); a++) {
mImages.add(selectList.get(a).getCompressPath());
}
if (mImages.size() < 10) {
mImages.add("add");
}
mAdapter.setData(mImages);
}
break;
}
}
}
}
......@@ -64,8 +64,6 @@ public class SendOrderDetailActivity extends BaseActivity<SendDetailPresenter, A
mBind.tvOrderState.setVisibility(View.GONE);
mBind.tvEngineer.setVisibility(View.GONE);
mBind.engineerName.setVisibility(View.GONE);
mBind.customerAcceptance.setText(getString(R.string.designate_order));
mBind.customerAcceptance.setOnClickListener(v -> mPresenter.getEngineers());
} else if (mState == ManagerConstant.GRAB_ORDER) {
mBind.tvState.setVisibility(View.GONE);
mBind.tvOrderState.setVisibility(View.GONE);
......@@ -100,8 +98,6 @@ public class SendOrderDetailActivity extends BaseActivity<SendDetailPresenter, A
mBind.tvOrderState.setVisibility(View.VISIBLE);
mBind.tvEngineer.setVisibility(View.VISIBLE);
mBind.engineerName.setVisibility(View.VISIBLE);
mBind.customerAcceptance.setText(getString(R.string.change));
mBind.customerAcceptance.setOnClickListener(v -> mPresenter.getEngineers());
}
}
......@@ -135,9 +131,15 @@ public class SendOrderDetailActivity extends BaseActivity<SendDetailPresenter, A
if (mBind.leftTime.getVisibility() == View.VISIBLE) {
setTime(detail.getAppointmentTime(), mBind.leftTime);
}
// if (mState == ManagerConstant.SEND_ORDER) {
// mBind.customerAcceptance.setVisibility(View.GONE);
// }
if (mState == ManagerConstant.SEND_ORDER||mState == ManagerConstant.CHANGE_ORDER) {
if (mDetail.getCreatedSource() == 1) {
mBind.customerAcceptance.setText(getString(R.string.cancle_orders));
mBind.customerAcceptance.setOnClickListener(v -> mPresenter.cancleOrder(mState));
mBind.customerAcceptance.setVisibility(View.VISIBLE);
} else {
mBind.customerAcceptance.setVisibility(View.GONE);
}
}
}
@Override
......
......@@ -83,6 +83,12 @@ public class ManagerOrderAdapter extends CoreAdapter<Order, ItemManagerOrderBind
mOnChildClickListener.OnChildClick(holder.itemUpdataTime, this, position);
}
});
holder.tvItemProcess.setOnClickListener(v -> {
if (mOnChildClickListener != null) {
mOnChildClickListener.OnChildClick(holder.tvItemProcess, this, position);
}
});
String time = item.getAppointmentTime();
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
......@@ -90,25 +96,48 @@ public class ManagerOrderAdapter extends CoreAdapter<Order, ItemManagerOrderBind
holder.llWeixiu.setLayoutParams(param);
switch (state) {
case ManagerConstant.SEND_ORDER:
holder.itemTextPhone.setText(mContext.getString(R.string.designate));
holder.itemUpdataTime.setVisibility(View.GONE);
holder.orderLineOne.setVisibility(View.GONE);
holder.itemUpdataTime.setText(R.string.designate);
holder.itemTextPhone.setText("修改");
holder.tvItemProcess.setText("再来一单");
if (item.getCreatedSource() == 1) {
holder.tvOrderDetail.setVisibility(View.VISIBLE);
holder.orderLineOne.setVisibility(View.VISIBLE);
holder.orderLineTwo.setVisibility(View.VISIBLE);
holder.tvItemProcess.setVisibility(View.VISIBLE);
holder.itemTextPhone.setVisibility(View.VISIBLE);
} else {
holder.itemTextPhone.setVisibility(View.GONE);
holder.tvItemProcess.setVisibility(View.GONE);
holder.orderLineOne.setVisibility(View.GONE);
holder.orderLineTwo.setVisibility(View.GONE);
}
break;
case ManagerConstant.Eu_ORDER:
param.topMargin = UIUtils.dp2px(10);
holder.llWeixiu.setLayoutParams(param);
holder.itemTextPhone.setText(mContext.getString(R.string.refuse));
holder.itemUpdataTime.setText(mContext.getString(R.string.designate));
holder.itemUpdataTime.setVisibility(View.VISIBLE);
holder.orderLineOne.setVisibility(View.VISIBLE);
holder.tvOrderDetail.setVisibility(View.GONE);
holder.tvItemProcess.setVisibility(View.GONE);
holder.orderLineTwo.setVisibility(View.GONE);
break;
case ManagerConstant.CHANGE_ORDER:
holder.itemTextPhone.setText(UIUtils.getString(R.string.change_engineer));
holder.itemUpdataTime.setVisibility(View.GONE);
holder.orderLineOne.setVisibility(View.GONE);
holder.itemUpdataTime.setText(R.string.designate);
holder.itemTextPhone.setText("修改");
holder.tvItemProcess.setText("再来一单");
if (item.getCreatedSource() == 1) {
holder.tvOrderDetail.setVisibility(View.VISIBLE);
holder.orderLineOne.setVisibility(View.VISIBLE);
holder.orderLineTwo.setVisibility(View.VISIBLE);
holder.tvItemProcess.setVisibility(View.VISIBLE);
holder.itemTextPhone.setVisibility(View.VISIBLE);
} else {
holder.itemTextPhone.setVisibility(View.GONE);
holder.tvItemProcess.setVisibility(View.GONE);
holder.orderLineOne.setVisibility(View.GONE);
holder.orderLineTwo.setVisibility(View.GONE);
}
if (item.getStatus() == 2) {
time = item.getAppointmentTime();
holder.tvOrderTime.setText(mContext.getString(R.string.have_appointment));
......
......@@ -65,9 +65,14 @@ public class ChangeOrderFragment extends BaseFragment<ChangeOrderPresenter, Frag
});
mBind.recyclerView.mCoreAdapter.setOnChildClickListener((view, adapter1, position) -> {
Order order = (Order) mBind.recyclerView.getDatas().get(position);
if (view.getId() == R.id.item_text_phone) {
mPresenter.getEngineers(order.getId());
int id = ((Order) mBind.recyclerView.getDatas().get(position)).getId();
if (view.getId() == R.id.item_updata_time) {
showDialog();
mPresenter.getEngineers(id);
} else if (view.getId() == R.id.item_text_phone) {
mPresenter.modifyOrder(id);
} else if (view.getId() == R.id.tv_item_process) {
mPresenter.createAgain(id);
}
});
}
......@@ -84,7 +89,7 @@ public class ChangeOrderFragment extends BaseFragment<ChangeOrderPresenter, Frag
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void swtichfragment(RefreshManagerEvent event) {
public void refresh(RefreshManagerEvent event) {
if (event.getState() == ManagerConstant.CHANGE_ORDER) {
mPresenter.refresh();
}
......
......@@ -76,7 +76,10 @@ public class ManagerFragment extends DataBindingFragment<FragmentManagerBinding>
startActivity(intent);
});
mBind.createOrder.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(Constants.STATE, ManagerConstant.CREATE_ORDER);
Intent intent = new Intent(mActivity, CreateOrderActivity.class);
intent.putExtra(Constants.BUNDLE, bundle);
startActivity(intent);
});
List<Fragment> mFragments = new ArrayList<>();
......
......@@ -16,6 +16,7 @@ import com.dayu.managercenter.presenter.sendorder.SendOrderPresenter;
import com.dayu.managercenter.ui.activity.SendOrderDetailActivity;
import com.dayu.managercenter.ui.adapter.ManagerOrderAdapter;
import com.dayu.provider.event.DesignateEvent;
import com.dayu.provider.event.RefreshManagerEvent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
......@@ -62,9 +63,16 @@ public class SendOrderFragment extends BaseFragment<SendOrderPresenter, Fragment
});
mBind.recyclerView.mCoreAdapter.setOnChildClickListener((view, adapter1, position) -> {
showDialog();
int id = ((Order) mBind.recyclerView.getDatas().get(position)).getId();
if (view.getId() == R.id.item_updata_time) {
showDialog();
mPresenter.getEngineers(id);
} else if (view.getId() == R.id.item_text_phone) {
mPresenter.modifyOrder(id);
} else if (view.getId() == R.id.tv_item_process) {
mPresenter.createAgain(id);
}
});
EventBus.getDefault().register(this);
}
......@@ -84,4 +92,11 @@ public class SendOrderFragment extends BaseFragment<SendOrderPresenter, Fragment
public void swtichfragment(DesignateEvent event) {
mPresenter.refresh();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void refresh(RefreshManagerEvent event) {
if (event.getState()==ManagerConstant.SEND_ORDER){
mPresenter.refresh();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="0.5dp"
android:color="#cccccc" />
<corners android:radius="3dp" />
</shape>
\ No newline at end of file
......@@ -20,9 +20,8 @@
style="@style/title">
<TextView
android:id="@+id/text_idea"
style="@style/text_title"
android:text="改派原因" />
android:id="@+id/text"
style="@style/text_title" />
<ImageView
android:id="@+id/title_back"
......@@ -33,7 +32,6 @@
<TextView
android:id="@+id/tv_right_title"
style="@style/title_right_text"
android:onClick="@{()->presenter.changeEngineer()}"
android:text="@string/submit"
android:textColor="@color/cl_home_button"
android:textSize="15sp" />
......@@ -49,7 +47,7 @@
android:layout_gravity="center"
android:background="@color/white"
android:gravity="top"
android:hint="请填写改派原因"
android:hint="请填写原因"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_17"
android:maxLength="200"
......
<?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">
<data>
<variable
name="presenter"
type="com.dayu.managercenter.presenter.createorder.CreateOrderPresenter" />
<variable
name="detail"
type="com.dayu.managercenter.data.OrderDetail" />
<import type="android.text.TextUtils" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="2dp"
android:background="?attr/colorPrimary"
app:navigationIcon="@drawable/back_btn_normal">
<TextView
android:id="@+id/tv_title"
style="@style/toolbar_title" />
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingTop="19dp"
android:text="@string/customer_info"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="40dp"
android:text="@string/order_from"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<RadioGroup
android:id="@+id/rb_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/other_customer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:checked="true"
android:text="@string/other_customer"
android:theme="@style/MyRadioButton" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/sign_customer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sign_customer"
android:theme="@style/MyRadioButton" />
</RadioGroup>
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:id="@+id/ll_select_server"
android:layout_width="match_parent"
android:layout_height="50.5dp"
android:background="@color/white"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/select_server"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<TextView
android:id="@+id/select_server"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="@string/please_input_server"
android:onClick="@{()->presenter.selectServer()}"
android:text="@{presenter.serverName}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:src="@drawable/icon_arrow_right" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="40dp"
android:text="@string/customer_type"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<RadioGroup
android:id="@+id/rb_personal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/personal_customer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:checked="true"
android:text="@string/personal_customer"
android:theme="@style/MyRadioButton" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/enterprise_customer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/enterprise_customer"
android:theme="@style/MyRadioButton" />
</RadioGroup>
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:id="@+id/ll_company_name"
android:layout_width="match_parent"
android:layout_height="50.5dp"
android:background="@color/white"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/company_name"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/company_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="@string/please_input_company_name"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/customer_name"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/customer_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/please_input_name"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/customer_mobile"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/customer_mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/please_input_moblie"
android:inputType="phone"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/customer_address"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<TextView
android:id="@+id/customer_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="@string/please_input_address"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:src="@drawable/icon_arrow_right" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/customer_detail_address"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/customer_detail_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:ellipsize="end"
android:hint="@string/please_input_detail_address"
android:maxLines="2"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingTop="19dp"
android:text="@string/server_info"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/appointment_time"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<LinearLayout
android:id="@+id/ll_day"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:onClick="@{()->presenter.selectDay()}"
android:orientation="horizontal">
<TextView
android:id="@+id/day_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/day"
android:text="@{presenter.mDay}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_hour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_arrow_down" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_hour"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:onClick="@{()->presenter.selectTime()}"
android:orientation="horizontal">
<TextView
android:id="@+id/hour_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/hour"
android:text="@{presenter.mHour}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_arrow_down" />
</LinearLayout>
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:id="@+id/ll_server_type"
android:layout_width="match_parent"
android:layout_height="50.5dp"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/order_serve_type"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<TextView
android:id="@+id/server_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="@string/please_input_server_type"
android:onClick="@{()->presenter.selectServerType()}"
android:text="@{presenter.serverType}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_server_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:src="@drawable/icon_arrow_right" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_product_type"
android:layout_width="match_parent"
android:layout_height="50.5dp"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="7dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="*"
android:textColor="#F74848"
android:textSize="@dimen/sp_15" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/product_type"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/product_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/product_line"
android:onClick="@{()->presenter.selectProductLine()}"
android:text="@{presenter.productLine}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:src="@drawable/icon_arrow_down" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/product_big"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/product_big"
android:onClick="@{()->presenter.selectBProduct()}"
android:text="@{presenter.bProduct}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_big"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:src="@drawable/icon_arrow_down" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/product_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/product_small"
android:onClick="@{()->presenter.selectSProduct()}"
android:text="@{presenter.sProduct}"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:src="@drawable/icon_arrow_down" />
</LinearLayout>
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/prodcut_brand"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/brand"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/order_pinpai_text"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/prodcut_num"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/product_model"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/please_input_product"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/sn_num"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<EditText
android:id="@+id/sn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/please_input_sn"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingTop="19dp"
android:text="@string/order_info"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/engi"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<TextView
android:id="@+id/engineer_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:onClick="@{()->presenter.getEngineers()}"
android:text='@{!TextUtils.isEmpty(presenter.engineerName)?presenter.engineerName:@string/no_designate }'
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_engineer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:src="@drawable/icon_arrow_right" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/custom_acceptance"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<com.dayu.widgets.SwitchImage
android:id="@+id/customer_acceptance"
chageButton="@{presenter.isacceptance}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:onClick="@{()->presenter.swtichAcceptance()}"
android:src="@drawable/set_switch_off" />
</RelativeLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:background="@color/white"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="@string/electronic_signature"
android:textColor="@color/default_text_color"
android:textSize="15sp" />
<com.dayu.widgets.SwitchImage
android:id="@+id/electronic_signature"
chageButton="@{presenter.isSignature}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:onClick="@{()->presenter.swtichSignature()}"
android:src="@drawable/set_switch_off" />
</RelativeLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cl_white"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="18dp"
android:text="@string/order_attachment"
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
<android.support.v7.widget.RecyclerView
android:id="@+id/photoView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cl_white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="18dp"
android:text="@string/server_instruction"
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
<EditText
android:id="@+id/server_info"
android:layout_width="@dimen/dp_267"
android:layout_height="@dimen/dp_147"
android:layout_marginBottom="10dp"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginTop="18dp"
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:hint="@string/max_text_500"
android:inputType="text"
android:maxLength="500"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_11"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" />
</LinearLayout>
<View
style="@style/line"
android:layout_marginLeft="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cl_white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="18dp"
android:text="@string/remark"
android:textColor="@color/default_text_color"
android:textSize="@dimen/sp_15" />
<EditText
android:id="@+id/et_info"
android:layout_width="@dimen/dp_267"
android:layout_height="@dimen/dp_147"
android:layout_marginBottom="10dp"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginTop="18dp"
android:background="@drawable/subscribe_time_shape"
android:gravity="top"
android:hint="@string/max_text_500"
android:inputType="text"
android:maxLength="500"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_11"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:background="@color/cl_white"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/create_next"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:background="@drawable/btn_blue_whitecontent"
android:gravity="center"
android:onClick="@{()->presenter.createOrder(1)}"
android:paddingBottom="18dp"
android:paddingTop="18dp"
android:text="@string/comform_and_next"
android:textColor="@color/bg_button"
android:textSize="16sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="@drawable/blue_commom"
android:gravity="center"
android:onClick="@{()->presenter.createOrder(0)}"
android:paddingBottom="18dp"
android:paddingTop="18dp"
android:text="@string/comform_order"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_home_edit_text"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/title_finish"
style="@style/title">
<TextView
style="@style/text_title"
android:text="@string/pre_look" />
<ImageView
android:id="@+id/titile_back"
style="@style/title_image_back" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/vp_preview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/cl_order_text_one"
android:unselectedAlpha="1"/>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -255,6 +255,23 @@
android:textColor="@color/cl_receiving_order_item_data"
android:textSize="@dimen/sp_15" />
<ImageView
android:id="@+id/order_line_two"
android:layout_width="@dimen/dp_0.7"
android:layout_height="match_parent"
android:layout_marginBottom="11.7dp"
android:layout_marginTop="11.7dp"
android:background="@color/cl_receiving_order_item_data" />
<TextView
android:id="@+id/tv_item_process"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/tv_home_tab_start"
android:textColor="@color/cl_receiving_order_item_data"
android:textSize="@dimen/sp_15" />
</LinearLayout>
</LinearLayout>
......
package com.dayu.message.api;
import com.dayu.base.api.APIService;
import com.dayu.base.api.Api;
import com.dayu.base.api.protocol.BasePageBean;
import com.dayu.message.data.protocol.NewMessage;
......@@ -20,4 +21,17 @@ public class MessageApiFactory {
return Api.getService(MessageService.class).readMessage(body).compose(Api.applySchedulers());
}
/**
* 全部已读.
*
* @param hxAccount 环信账号.
* @return
*/
public static Observable<Boolean> readAllHx(String hxAccount) {
return Api.getService(MessageService.class).readAllHx(hxAccount).compose(Api.applySchedulers());
}
public static Observable<Integer> getHxNum(String hxAccount) {
return Api.getService(MessageService.class).getHxNum(hxAccount).compose(Api.applySchedulers());
}
}
......@@ -3,6 +3,7 @@ package com.dayu.message.api;
import com.dayu.base.api.protocol.BasePageBean;
import com.dayu.base.api.protocol.BaseResponse;
import com.dayu.common.Constants;
import com.dayu.message.common.MessageConstant;
import com.dayu.message.data.protocol.NewMessage;
......@@ -42,4 +43,22 @@ public interface MessageService {
*/
@PUT(MessageConstant.MESSAGE_HX)
Observable<BaseResponse<Boolean>> readMessage(@Body RequestBody body);
/**
* 全部已读.
*
* @param hxAccount
* @return
*/
@PUT(MessageConstant.READ_ALL_MESSAGE)
Observable<BaseResponse<Boolean>> readAllHx(@Path("hxAccount") String hxAccount);
/**
* 获取环信信息数量.
*
* @param hxAccount
* @return
*/
@GET(Constants.MESSAGE_NUM)
Observable<BaseResponse<Integer>> getHxNum(@Path("hxAccount") String hxAccount);
}
......@@ -15,4 +15,8 @@ public class MessageConstant {
*/
public final static String MESSAGE_HX_LIST = "/api-message/hXMessage/hxAccount/{hxAccount}/category/{category}";
/**
* 全部已读.
*/
public final static String READ_ALL_MESSAGE = " /api-message/" + "hXMessage/all2Read/hxAccount/{hxAccount}";
}
package com.dayu.message.presenter.homeMessage;
import com.dayu.base.ui.presenter.BasePresenter;
import com.dayu.common.BaseView;
/**
* Created by luo on 2016/8/4.
*/
public interface HomeMessageContract {
interface View extends BaseView {
void readAllHx();
void getNum(int num);
}
abstract class Presenter extends BasePresenter<View> {
public abstract void readAllHx();
public abstract void getHxNum();
}
}
package com.dayu.message.presenter.homeMessage;
import com.dayu.message.api.MessageApiFactory;
import com.dayu.utils.UserManager;
/**
* Created by luofan
* on 2017/11/8.
*/
public class HomeMessagePresenter extends HomeMessageContract.Presenter {
private String mHxId;
@Override
public void readAllHx() {
mView.showDialog();
MessageApiFactory.readAllHx(mHxId)
.subscribe(baseObserver(aBoolean -> mView.readAllHx()));
}
@Override
public void getHxNum() {
MessageApiFactory.getHxNum(mHxId).subscribe(baseObserver(integer -> mView.getNum(integer)));
}
@Override
public void onAttached() {
mHxId = UserManager.getInstance().getUser().getHxAccount();
// getHxNum();
}
}
......@@ -11,9 +11,12 @@ import com.dayu.message.api.MessageApiFactory;
import com.dayu.message.data.protocol.NewMessage;
import com.dayu.message.ui.activity.MessageDetailActivity;
import com.dayu.message.ui.fragment.MessageFragment;
import com.dayu.provider.event.RefreshHxNum;
import com.dayu.utils.SPUtils;
import com.dayu.utils.UserManager;
import com.umeng.analytics.MobclickAgent;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -75,6 +78,9 @@ public class messagePresenter extends messageContract.Presenter {
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
MessageApiFactory.readMessage(requestBody).subscribe(baseObserver(aBoolean -> {
int num = (int) SPUtils.get(Constants.HX_NUM, 0);
SPUtils.put(Constants.HX_NUM, num - 1);
EventBus.getDefault().post(new RefreshHxNum(num));
}));
}
......
......@@ -5,23 +5,32 @@ import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import com.dayu.base.ui.adapter.FragmentBaseAdapter;
import com.dayu.base.ui.fragment.DataBindingFragment;
import com.dayu.base.ui.fragment.BaseFragment;
import com.dayu.common.Constants;
import com.dayu.message.R;
import com.dayu.message.databinding.FragmentMessageBinding;
import com.dayu.message.presenter.homeMessage.HomeMessageContract;
import com.dayu.message.presenter.homeMessage.HomeMessagePresenter;
import com.dayu.provider.event.RefreshHxNum;
import com.dayu.utils.SPUtils;
import com.dayu.utils.TabLayoutUtils;
import com.dayu.utils.UIUtils;
import com.umeng.analytics.MobclickAgent;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
/**
* Created by luofan
* on 2017/11/20.
*/
public class HomeMessageFragment extends DataBindingFragment<FragmentMessageBinding> {
public class HomeMessageFragment extends BaseFragment<HomeMessagePresenter, FragmentMessageBinding> implements HomeMessageContract.View {
private int mIndex = 0;
private String mUmTag = "serverMessage";
......@@ -46,7 +55,7 @@ public class HomeMessageFragment extends DataBindingFragment<FragmentMessageBind
titles.add(getString(R.string.message_dayu));
args.add(1);
args.add(2);
Observable.fromIterable(args).map((Function<Integer, Fragment>) MessageFragment::newInstance).toList()
Disposable disposable = Observable.fromIterable(args).map((Function<Integer, Fragment>) MessageFragment::newInstance).toList()
.map(fragments -> FragmentBaseAdapter.newInstance(getChildFragmentManager(), fragments, titles))
.subscribe(fragmentBaseAdapter -> {
mBind.vpMessage.setAdapter(fragmentBaseAdapter);
......@@ -58,7 +67,10 @@ public class HomeMessageFragment extends DataBindingFragment<FragmentMessageBind
mBind.vpMessage.setCurrentItem(mIndex);
mBind.tbMessage.getTabAt(mIndex).select();
}
mBind.tvRightTitle.setOnClickListener(v ->
mPresenter.readAllHx());
initUM();
// EventBus.getDefault().register(this);
}
public void swtichFragment(int position) {
......@@ -113,4 +125,29 @@ public class HomeMessageFragment extends DataBindingFragment<FragmentMessageBind
MobclickAgent.onPageStart(mUmTag);
}
}
@Override
public void setPresenter() {
}
@Override
public void readAllHx() {
initView();
EventBus.getDefault().post(new RefreshHxNum(0));
mBind.tvRightTitle.setEnabled(false);
mBind.tvRightTitle.setTextColor(UIUtils.getColor(R.color.tv_cl));
}
@Override
public void getNum(int num) {
SPUtils.put(Constants.HX_NUM, num);
if (num > 0) {
mBind.tvRightTitle.setEnabled(true);
mBind.tvRightTitle.setTextColor(UIUtils.getColor(R.color.default_text_color));
} else {
mBind.tvRightTitle.setEnabled(false);
mBind.tvRightTitle.setTextColor(UIUtils.getColor(R.color.tv_cl));
}
}
}
......@@ -9,8 +9,13 @@ import com.dayu.message.databinding.ItemMessageLayoutBinding;
import com.dayu.message.databinding.LrecyclerViewBinding;
import com.dayu.message.presenter.message.messageContract;
import com.dayu.message.presenter.message.messagePresenter;
import com.dayu.provider.event.RefreshHxList;
import com.dayu.widgets.listener.OnItemClickListener;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/**
* 系统工单状态通知
......@@ -42,10 +47,16 @@ public class MessageFragment extends BaseFragment<messagePresenter, LrecyclerVie
mPresenter.readAndDump(item, bind.readState);
}
});
EventBus.getDefault().register(this);
}
@Override
public void setPresenter() {
mBind.setPresenter(mPresenter);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void refresh(RefreshHxList event) {
mPresenter.refresh();
}
}
......@@ -16,6 +16,12 @@
style="@style/text_title"
android:text="@string/tv_message" />
<TextView
android:id="@+id/tv_right_title"
style="@style/title_right_text"
android:text="@string/all_read"
android:textSize="@dimen/dp_13.3" />
</RelativeLayout>
<android.support.design.widget.TabLayout
......
......@@ -3,13 +3,13 @@
<data>
<import type="android.view.View"/>
<import type="android.view.View" />
<import type="com.dayu.utils.UtilsDate"/>
<import type="com.dayu.utils.UtilsDate" />
<variable
name="item"
type="com.dayu.message.data.protocol.NewMessage"/>
type="com.dayu.message.data.protocol.NewMessage" />
</data>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
......@@ -23,41 +23,37 @@
android:layout_height="@dimen/dp_80"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="@drawable/item_shape"
>
android:background="@drawable/item_shape">
<TextView
android:id="@+id/line_textView"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="89dp"
android:background="@color/line_color"
/>
android:background="@color/line_color" />
<TextView
android:id="@+id/message_date"
formartDay="@{item.createTime}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/line_textView"
android:layout_marginRight="@dimen/dp_12"
android:layout_marginTop="@dimen/dp_18"
formartDay="@{item.createTime}"
android:textColor="@color/cl_home_title_text_color"
android:textSize="@dimen/sp_12"
android:typeface="@{@string/tv_fonts}"
/>
android:typeface="@{@string/tv_fonts}" />
<TextView
android:id="@+id/message_time"
formartTime="@{item.createTime}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/line_textView"
android:layout_marginRight="@dimen/dp_12"
android:layout_marginTop="@dimen/dp_34"
formartTime="@{item.createTime}"
android:textColor="@color/cl_home_title_text_color"
android:textSize="24sp"
/>
android:textSize="24sp" />
<LinearLayout
android:layout_width="match_parent"
......@@ -66,8 +62,7 @@
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_16"
android:gravity="center_vertical"
android:orientation="horizontal"
>
android:orientation="horizontal">
<TextView
android:id="@+id/message_text_content"
......@@ -78,8 +73,7 @@
android:maxLines="2"
android:text="@{item.title}"
android:textColor="@color/cl_home_title_text_color"
android:textSize="@dimen/sp_13.3"
/>
android:textSize="@dimen/sp_13.3" />
<TextView
android:id="@+id/read_state"
......@@ -92,8 +86,7 @@
android:text="@string/not_read"
android:textColor="@color/cl_tab_read"
android:textSize="@dimen/sp_10"
android:visibility='@{item.read ==1?View.GONE:View.VISIBLE}'
/>
android:visibility='@{item.read ==1?View.GONE:View.VISIBLE}' />
</LinearLayout>
</RelativeLayout>
......
......@@ -149,4 +149,8 @@ public class OrderApiFactory {
public static Observable<Boolean> modifyOrder(RequestBody body) {
return Api.getService(OrderService.class).modifyOrder(body).compose(Api.applySchedulers());
}
public static Observable<BasePageBean<Order>> searchOrder(String key, int siteId,int userAccount, int status, int page, int pageSize) {
return Api.getService(OrderService.class).searchOrder(key, siteId,userAccount, status, page, pageSize).compose(Api.applySchedulers());
}
}
......@@ -333,4 +333,22 @@ interface OrderService {
*/
@PUT(OrderConstant.MODIFY_NEW_ORDER)
Observable<BaseResponse<Boolean>> modifyOrder(@Body RequestBody body);
/**
* 搜索.
*
* @param key
* @param status
* @param page
* @param pageSize
* @return
*/
@GET(OrderConstant.SEARCH_ORDER)
Observable<BaseResponse<BasePageBean<Order>>> searchOrder(@Query("key") String key,
@Query("siteId") int siteId,
@Query("engineerId") int engineerId,
@Query("status") int status,
@Query("page") int page,
@Query("pageSize") int pageSize);
}
package com.dayu.order.api.protocol;
import android.os.Parcel;
import android.os.Parcelable;
import java.io.Serializable;
/**
* Created by luofan
* on 2018/11/20.
*/
public class Pic implements Serializable,Parcelable{
private int id;
private int ordersRelationSpuItemId;
private String pictureUrl;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getOrdersRelationSpuItemId() {
return ordersRelationSpuItemId;
}
public void setOrdersRelationSpuItemId(int ordersRelationSpuItemId) {
this.ordersRelationSpuItemId = ordersRelationSpuItemId;
}
public String getPictureUrl() {
return pictureUrl;
}
public void setPictureUrl(String pictureUrl) {
this.pictureUrl = pictureUrl;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeInt(this.ordersRelationSpuItemId);
dest.writeString(this.pictureUrl);
}
public Pic() {
}
protected Pic(Parcel in) {
this.id = in.readInt();
this.ordersRelationSpuItemId = in.readInt();
this.pictureUrl = in.readString();
}
public static final Creator<Pic> CREATOR = new Creator<Pic>() {
@Override
public Pic createFromParcel(Parcel source) {
return new Pic(source);
}
@Override
public Pic[] newArray(int size) {
return new Pic[size];
}
};
}
......@@ -169,4 +169,9 @@ public class OrderConstant {
*/
public static final String MODIFY_NEW_ORDER = "/api-order/" + "orders";
/**
* 模糊搜索
*/
public static final String SEARCH_ORDER = "/api-order/" + "orders/provider";
}
package com.dayu.order.presenter.detailedite;
import com.dayu.base.ui.presenter.BasePresenter;
import com.dayu.common.BaseView;
/**
* Created by luo
* on 2016/8/4.
*/
public interface EditeContract {
interface View extends BaseView {
}
abstract class Presenter extends BasePresenter<View> {
public abstract void commite();
}
}
package com.dayu.order.presenter.detailedite;
import android.databinding.ObservableField;
import android.text.TextUtils;
import com.dayu.common.Constants;
import com.dayu.order.R;
import com.dayu.order.api.OrderApiFactory;
import com.dayu.provider.event.RefreshDetailEvent;
import com.dayu.utils.UIUtils;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
import java.util.HashMap;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* Created by luofan
* on 2017/11/8.
*/
public class EditePresenter extends EditeContract.Presenter {
private int mState;
public ObservableField<String> info = new ObservableField<>();
private int mOrderId;
@Override
public void onAttached() {
mState = mView.getBundle().getInt(Constants.STATE);
mOrderId = mView.getBundle().getInt(Constants.ID);
String infos = mView.getBundle().getString(Constants.MESSAGE_INFO, "");
if (!infos.equals(UIUtils.getString(R.string.no_data))) {
info.set(infos);
}
}
@Override
public void commite() {
HashMap<String, Object> params = new HashMap<>();
params.put("id", mOrderId);
if (mState == 0) {
if (!TextUtils.isEmpty(info.get())) {
params.put("comment", info.get());
} else {
params.put("comment", "");
}
} else {
if (!TextUtils.isEmpty(info.get())) {
params.put("taskDesc", info.get());
} else {
params.put("taskDesc", "");
}
}
JSONObject jsonObject = new JSONObject(params);
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
OrderApiFactory.modifyOrder(body).subscribe(baseObserver(aBoolean -> {
mView.showToast(R.string.modify_order_success);
EventBus.getDefault().post(new RefreshDetailEvent());
mView.dumpBack();
}));
}
}
......@@ -162,11 +162,8 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
params.put("engineerId", engineerId);
params.put("id", orderId);
params.put("materialCost", materialCost);
params.put("materialCostComment", "");
params.put("otherPrice", otherPrice);
params.put("otherPriceComment", "");
params.put("servicePrice", servicePrice);
params.put("servicePriceComment", "");
// params.put("categoryName")
// params.put("brandName", brandName);
......
......@@ -25,6 +25,7 @@ public interface OrderRecordContract {
}
abstract class Presenter extends BaseOrderPresenter<View> {
/**
* 关闭搜索.
*/
......@@ -35,5 +36,15 @@ public interface OrderRecordContract {
*/
public abstract void showSearch();
/**
* 获取工单.
*/
public abstract void getOrder();
/**
* 搜索
*/
public abstract void search();
}
}
package com.dayu.order.presenter.worksRecord;
import android.databinding.Observable;
import android.databinding.ObservableField;
import android.os.Bundle;
import android.text.TextUtils;
import com.dayu.common.BaseApplication;
import com.dayu.common.Constants;
import com.dayu.event.UserInfo;
import com.dayu.order.api.OrderApiFactory;
import com.dayu.order.api.protocol.Order;
import com.dayu.order.ui.activity.OrderDetailsActivity;
import com.dayu.utils.UserManager;
import com.umeng.analytics.MobclickAgent;
import java.util.ArrayList;
import java.util.List;
/**
* Created by luofan
* on 2017/11/8.
......@@ -27,20 +21,13 @@ public class OrderRecordPresenter extends OrderRecordContract.Presenter {
private int mPage;
private int mUserId;
private int mSiteId;
private List<Order> mList;
@Override
public void onAttached() {
UserInfo userInfo = UserManager.getInstance().getUser();
mUserId = Integer.parseInt(userInfo.getAccountId());
mSiteId = userInfo.getSiteId();
serchStr.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable observable, int i) {
doSearch(serchStr.get());
}
});
refresh();
search();
}
@Override
......@@ -59,20 +46,35 @@ public class OrderRecordPresenter extends OrderRecordContract.Presenter {
@Override
public void showSearch() {
mList = mView.getAdapter().getDatas();
mView.showSearch();
}
@Override
public void getOrder() {
mView.showDialog();
OrderApiFactory.searchOrder(serchStr.get(), mSiteId, mUserId, Constants.FINISH_ORDER, mPage, Constants.PAGESIZE)
.subscribe(baseObserver(orderBasePageBean -> {
datas.set(orderBasePageBean);
mPage++;
}, throwable -> datas.set(Constants.FAILED)));
}
@Override
public void refresh() {
hideSearch();
mPage = 1;
getOrders(Constants.FINISH_ORDER, mUserId, mSiteId, mPage, Constants.PAGESIZE);
getOrder();
}
@Override
public void search() {
hideSearch();
refresh();
}
@Override
public void loadMore() {
getOrders(Constants.FINISH_ORDER, mUserId, mSiteId, mPage, Constants.PAGESIZE);
getOrder();
}
@Override
......@@ -83,23 +85,8 @@ public class OrderRecordPresenter extends OrderRecordContract.Presenter {
@Override
public void dumpDetail(int orderId) {
Bundle bundle = new Bundle();
bundle.putInt(Constants.ORDER_ID,orderId);
mView.startActivity(OrderDetailsActivity.class,bundle);
bundle.putInt(Constants.ORDER_ID, orderId);
mView.startActivity(OrderDetailsActivity.class, bundle);
MobclickAgent.onEvent(BaseApplication.getContext(), "check_order_detail");
}
private void doSearch(String str) {
if (mList == null || TextUtils.isEmpty(str)) {
return;
}
ArrayList<Order> list = new ArrayList<>();
for (Order data : mList) {
if (TextUtils.isEmpty(str) || (data.getCustomerMobile().contains(str) && data.getAnyContacts() == 1)) {
list.add(data);
}
}
datas.set(list);
mView.getAdapter().setLoadMore(false);
}
}
package com.dayu.order.ui.activity;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.order.R;
import com.dayu.order.databinding.ActivityEditeLayoutBinding;
import com.dayu.order.presenter.detailedite.EditeContract;
import com.dayu.order.presenter.detailedite.EditePresenter;
/**
* Created by luofan
* on 2018/12/5.
*/
public class EditeDetailActivity extends BaseActivity<EditePresenter, ActivityEditeLayoutBinding> implements EditeContract.View{
@Override
public void setPresenter() {
mBind.setPresenter(mPresenter);
}
@Override
public int getLayoutId() {
return R.layout.activity_edite_layout;
}
@Override
public void initView() {
}
}
......@@ -2,6 +2,7 @@ package com.dayu.order.ui.activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import com.alibaba.android.arouter.facade.annotation.Route;
......@@ -39,11 +40,17 @@ public class OrderRecordActivity extends BaseActivity<OrderRecordPresenter, Acti
mAdapter = new OrderAdapter(true);
mAdapter.setViewType(R.layout.fragment_orderdoing_item);
mBind.recyclerView.setAdapter(mAdapter);
mBind.recyclerView.setOnItemClickListener(new OnItemClickListener<Order, FragmentOrderdoingItemBinding>() {
@Override
public void OnItemClick(Order item, FragmentOrderdoingItemBinding bind) {
mPresenter.dumpDetail(item.getId());
mBind.recyclerView.setOnItemClickListener((OnItemClickListener<Order, FragmentOrderdoingItemBinding>)
(item, bind) -> mPresenter.dumpDetail(item.getId()));
mBind.etSeacher.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
mPresenter.refresh();
InputMethodManager imm = (InputMethodManager) mActivity
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), 0);
return true;
}
return false;
});
}
......@@ -76,5 +83,4 @@ public class OrderRecordActivity extends BaseActivity<OrderRecordPresenter, Acti
public OrderAdapter getAdapter() {
return mAdapter;
}
}
......@@ -9,15 +9,19 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.dayu.base.ui.adapter.FragmentAdapter;
import com.dayu.base.ui.fragment.BaseFragment;
import com.dayu.common.Constants;
import com.dayu.order.R;
import com.dayu.order.api.protocol.Tab;
import com.dayu.order.databinding.FragmentOrderHomeBinding;
import com.dayu.order.presenter.homeorder.HomeOrderContract;
import com.dayu.order.presenter.homeorder.HomeOrderPresenter;
import com.dayu.provider.event.RefreshTab;
import com.dayu.provider.router.RouterPath;
import com.dayu.utils.TabLayoutUtils;
import com.dayu.utils.UserManager;
import com.umeng.analytics.MobclickAgent;
import org.greenrobot.eventbus.EventBus;
......@@ -58,6 +62,11 @@ public class HomeOrderFragment extends BaseFragment<HomeOrderPresenter, Fragment
@Override
public void initView() {
tabDesc = new String[]{mActivity.getString(R.string.waite_appointemnt), mActivity.getString(R.string.waite_server), mActivity.getString(R.string.order_exception), mActivity.getString(R.string.cancle_order)};
if (UserManager.getInstance().getRole() == Constants.ENGINEER) {
mBind.createOrder.setVisibility(View.VISIBLE);
mBind.createOrder.setOnClickListener(v ->
ARouter.getInstance().build(RouterPath.PATH_MANAGER_CREATE_ORDER).navigation());
}
EventBus.getDefault().register(this);
initData();
}
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="presenter"
type="com.dayu.order.presenter.detailedite.EditePresenter" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_home_listview_bg"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/title_idea"
style="@style/title">
<TextView
android:id="@+id/text_idea"
android:text="@string/modify_order"
style="@style/text_title" />
<ImageView
android:id="@+id/title_back"
style="@style/title_image_back"
android:onClick="@{()->presenter.dumpBack()}" />
<TextView
android:id="@+id/tv_right_title"
style="@style/title_right_text"
android:onClick="@{()->presenter.commite()}"
android:text="@string/submit"
android:textColor="@color/cl_home_button"
android:textSize="15sp" />
</RelativeLayout>
<ImageView style="@style/card_line" />
<EditText
android:id="@+id/et_content"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_163"
android:layout_gravity="center"
android:background="@color/white"
android:gravity="top"
android:maxLength="200"
android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_17"
android:text="@={presenter.info}"
android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" />
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -62,10 +62,12 @@
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/iv"
android:background="@null"
android:textSize="16sp"
android:inputType="phone"
android:hint="@string/find_customer_mobile"
android:text="@={presenter.serchStr}" />
android:imeOptions="actionSearch"
android:inputType="text"
android:singleLine="true"
android:text="@={presenter.serchStr}"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv"
......@@ -80,7 +82,7 @@
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:gravity="center"
android:onClick="@{()->presenter.hideSearch()}"
android:onClick="@{()->presenter.search()}"
android:text="@string/cancle"
android:textColor="@color/cl_black"
android:textSize="@dimen/dp_18"
......
......@@ -9,6 +9,10 @@
type="com.dayu.order.presenter.homeorder.HomeOrderPresenter" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -47,4 +51,16 @@
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<ImageView
android:id="@+id/create_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="10dp"
android:src="@drawable/icon_create_order"
android:visibility="gone" />
</RelativeLayout>
</layout>
\ No newline at end of file
......@@ -29,4 +29,6 @@ dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api project(':baseSDK')
// api project(':apt')
}
package com.dayu.provider.event;
/**
* Created by luofan
* on 2018/12/5.
*/
public class RefreshDetailEvent {
private int state;
public RefreshDetailEvent() {
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
}
package com.dayu.provider.event;
/**
* 刷新消息列表.
* Created by luofan
* on 2018/12/5.
*/
public class RefreshHxList {
public RefreshHxList() {
}
}
package com.dayu.provider.event;
/**
* 刷新环信消息数量.
* Created by luofan
* on 2018/12/5.
*/
public class RefreshHxNum {
private int num;
public RefreshHxNum(int num) {
this.num = num;
}
public RefreshHxNum() {
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
package com.dayu.provider.event;
/**
* 刷新可改派列表.
* Created by luofan
* on 2018/9/4.
*/
......
......@@ -34,4 +34,6 @@ public class RouterPath {
public final static String PATH_SUBDETAIL = "/manager/subdetail";
public final static String PATH_SENDDETAIL = "/manager/send_detail";
public final static String PATH_MANAGER_CREATE_ORDER = "/manager/create_order";
}
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 sign in to comment