Commit c846a5f6 by mReturn

user

parent 3e07c10e
Showing with 1169 additions and 80 deletions
......@@ -31,6 +31,7 @@ public abstract class BaseActivity<P extends BasePresenter, B extends ViewDataBi
public P mPresenter;
private boolean isDialogShow = false;
protected int mUserId;
protected UserInfo mUserInfo;
@Override
protected void initPresenter() {
......@@ -163,5 +164,6 @@ public abstract class BaseActivity<P extends BasePresenter, B extends ViewDataBi
protected void initUser(){
UserInfo info = UserManager.getInstance().getUser();
mUserId = Integer.parseInt(info.getAccountId());
mUserInfo = info;
}
}
package com.dayu.widgets;
import android.content.Context;
import android.support.v7.widget.AppCompatEditText;
public class DisableEditText extends AppCompatEditText {
public DisableEditText(Context context) {
super(context);
}
}
package com.dayu.widgets;
import android.app.Activity;
import android.app.Dialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dayu.baselibrary.R;
import java.util.List;
public class WheelDialog {
public static WheelDialog instance;
private int selectedPos;
public static WheelDialog getInstance() {
if (instance == null) {
instance = new WheelDialog();
}
return instance;
}
public void show(final Activity activity, List<String> strs, onItemClickListener listener) {
View mView = View.inflate(activity, R.layout.dialog_wheelview, null);
Button btnConfirm = mView.findViewById(R.id.btn_comfirm);
Button btnCancle = mView.findViewById(R.id.btn_cancel);
WheelView wv = mView.findViewById(R.id.wheel_view);
wv.setOffset(2);
wv.setItems(strs);
wv.setSeletion(0);
Dialog mDialog = new android.app.Dialog(activity, R.style.CustomDialog);
mDialog.setContentView(mView);
Window window = mDialog.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams wl = window.getAttributes();
wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
mDialog.onWindowAttributesChanged(wl);
mDialog.show();
mDialog.setCanceledOnTouchOutside(true);
mDialog.setCancelable(true);
btnConfirm.setOnClickListener(view -> {
if (listener != null)
listener.onChoosed(wv.getSeletedIndex());
mDialog.dismiss();
});
btnCancle.setOnClickListener(view -> mDialog.dismiss());
}
public interface onItemClickListener {
void onChoosed(int pos);
}
}
package com.dayu.widgets;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
* Author: wangjie
* Email: tiantian.china.2@gmail.com
* Date: 7/1/14.
*/
public class WheelView extends ScrollView {
public static final String TAG = WheelView.class.getSimpleName();
public static class OnWheelViewListener {
public void onSelected(int selectedIndex, String item) {
}
}
private Context context;
// private ScrollView scrollView;
private LinearLayout views;
public WheelView(Context context) {
super(context);
init(context);
}
public WheelView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public WheelView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
// String[] items;
List<String> items;
private List<String> getItems() {
return items;
}
public void setItems(List<String> list) {
if (null == items) {
items = new ArrayList<String>();
}
items.clear();
items.addAll(list);
// 前面和后面补全
for (int i = 0; i < offset; i++) {
items.add(0, "");
items.add("");
}
initData();
}
public static final int OFF_SET_DEFAULT = 1;
int offset = OFF_SET_DEFAULT; // 偏移量(需要在最前面和最后面补全)
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
int displayItemCount; // 每页显示的数量
int selectedIndex = 1;
private void init(Context context) {
this.context = context;
// scrollView = ((ScrollView)this.getParent());
// Log.d(TAG, "scrollview: " + scrollView);
Log.d(TAG, "parent: " + this.getParent());
// this.setOrientation(VERTICAL);
this.setVerticalScrollBarEnabled(false);
views = new LinearLayout(context);
views.setOrientation(LinearLayout.VERTICAL);
this.addView(views);
scrollerTask = new Runnable() {
public void run() {
int newY = getScrollY();
if (initialY - newY == 0) { // stopped
final int remainder = initialY % itemHeight;
final int divided = initialY / itemHeight;
// Log.d(TAG, "initialY: " + initialY);
// Log.d(TAG, "remainder: " + remainder + ", divided: " + divided);
if (remainder == 0) {
selectedIndex = divided + offset;
onSeletedCallBack();
} else {
if (remainder > itemHeight / 2) {
WheelView.this.post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, initialY - remainder + itemHeight);
selectedIndex = divided + offset + 1;
onSeletedCallBack();
}
});
} else {
WheelView.this.post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, initialY - remainder);
selectedIndex = divided + offset;
onSeletedCallBack();
}
});
}
}
} else {
initialY = getScrollY();
WheelView.this.postDelayed(scrollerTask, newCheck);
}
}
};
}
int initialY;
Runnable scrollerTask;
int newCheck = 50;
public void startScrollerTask() {
initialY = getScrollY();
this.postDelayed(scrollerTask, newCheck);
}
private void initData() {
displayItemCount = offset * 2 + 1;
for (String item : items) {
views.addView(createView(item));
}
refreshItemView(0);
}
int itemHeight = 0;
private TextView createView(String item) {
TextView tv = new TextView(context);
tv.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
tv.setSingleLine(true);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
tv.setText(item);
tv.setGravity(Gravity.CENTER);
int padding = dip2px(15);
tv.setPadding(padding, padding, padding, padding);
if (0 == itemHeight) {
itemHeight = getViewMeasuredHeight(tv);
Log.d(TAG, "itemHeight: " + itemHeight);
views.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, itemHeight * displayItemCount));
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) this.getLayoutParams();
this.setLayoutParams(new LinearLayout.LayoutParams(lp.width, itemHeight * displayItemCount));
}
return tv;
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
// Log.d(TAG, "l: " + l + ", t: " + t + ", oldl: " + oldl + ", oldt: " + oldt);
// try {
// Field field = ScrollView.class.getDeclaredField("mScroller");
// field.setAccessible(true);
// OverScroller mScroller = (OverScroller) field.get(this);
//
//
// if(mScroller.isFinished()){
// Log.d(TAG, "isFinished...");
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// }
refreshItemView(t);
if (t > oldt) {
// Log.d(TAG, "向下滚动");
scrollDirection = SCROLL_DIRECTION_DOWN;
} else {
// Log.d(TAG, "向上滚动");
scrollDirection = SCROLL_DIRECTION_UP;
}
}
private void refreshItemView(int y) {
int position = y / itemHeight + offset;
int remainder = y % itemHeight;
int divided = y / itemHeight;
if (remainder == 0) {
position = divided + offset;
} else {
if (remainder > itemHeight / 2) {
position = divided + offset + 1;
}
// if(remainder > itemHeight / 2){
// if(scrollDirection == SCROLL_DIRECTION_DOWN){
// position = divided + offset;
// Log.d(TAG, ">down...position: " + position);
// }else if(scrollDirection == SCROLL_DIRECTION_UP){
// position = divided + offset + 1;
// Log.d(TAG, ">up...position: " + position);
// }
// }else{
//// position = y / itemHeight + offset;
// if(scrollDirection == SCROLL_DIRECTION_DOWN){
// position = divided + offset;
// Log.d(TAG, "<down...position: " + position);
// }else if(scrollDirection == SCROLL_DIRECTION_UP){
// position = divided + offset + 1;
// Log.d(TAG, "<up...position: " + position);
// }
// }
// }
// if(scrollDirection == SCROLL_DIRECTION_DOWN){
// position = divided + offset;
// }else if(scrollDirection == SCROLL_DIRECTION_UP){
// position = divided + offset + 1;
}
int childSize = views.getChildCount();
for (int i = 0; i < childSize; i++) {
TextView itemView = (TextView) views.getChildAt(i);
if (null == itemView) {
return;
}
if (position == i) {
itemView.setTextColor(Color.parseColor("#0288ce"));
} else {
itemView.setTextColor(Color.parseColor("#bbbbbb"));
}
}
}
/**
* 获取选中区域的边界
*/
int[] selectedAreaBorder;
private int[] obtainSelectedAreaBorder() {
if (null == selectedAreaBorder) {
selectedAreaBorder = new int[2];
selectedAreaBorder[0] = itemHeight * offset;
selectedAreaBorder[1] = itemHeight * (offset + 1);
}
return selectedAreaBorder;
}
private int scrollDirection = -1;
private static final int SCROLL_DIRECTION_UP = 0;
private static final int SCROLL_DIRECTION_DOWN = 1;
Paint paint;
int viewWidth;
@Override
public void setBackgroundDrawable(Drawable background) {
if (viewWidth == 0) {
viewWidth = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
Log.d(TAG, "viewWidth: " + viewWidth);
}
if (null == paint) {
paint = new Paint();
paint.setColor(Color.parseColor("#83cde6"));
paint.setStrokeWidth(dip2px(1f));
}
background = new Drawable() {
@Override
public void draw(Canvas canvas) {
canvas.drawLine(viewWidth * 1 / 6, obtainSelectedAreaBorder()[0], viewWidth * 5 / 6, obtainSelectedAreaBorder()[0], paint);
canvas.drawLine(viewWidth * 1 / 6, obtainSelectedAreaBorder()[1], viewWidth * 5 / 6, obtainSelectedAreaBorder()[1], paint);
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return PixelFormat.UNKNOWN;
}
};
super.setBackgroundDrawable(background);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
Log.d(TAG, "w: " + w + ", h: " + h + ", oldw: " + oldw + ", oldh: " + oldh);
viewWidth = w;
setBackgroundDrawable(null);
}
/**
* 选中回调
*/
private void onSeletedCallBack() {
if (null != onWheelViewListener) {
onWheelViewListener.onSelected(selectedIndex, items.get(selectedIndex));
}
}
public void setSeletion(int position) {
final int p = position;
selectedIndex = p + offset;
this.post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, p * itemHeight);
}
});
}
public String getSeletedItem() {
return items.get(selectedIndex);
}
public int getSeletedIndex() {
return selectedIndex - offset;
}
@Override
public void fling(int velocityY) {
super.fling(velocityY / 3);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
startScrollerTask();
}
return super.onTouchEvent(ev);
}
private OnWheelViewListener onWheelViewListener;
public OnWheelViewListener getOnWheelViewListener() {
return onWheelViewListener;
}
public void setOnWheelViewListener(OnWheelViewListener onWheelViewListener) {
this.onWheelViewListener = onWheelViewListener;
}
private int dip2px(float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
private int getViewMeasuredHeight(View view) {
int width = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
view.measure(width, expandSpec);
return view.getMeasuredHeight();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="@color/table_border" />
</shape>
</item>
<!--这个是按钮边框设置为四周 并且宽度为1-->
<item
android:right="@dimen/dp_sale_step"
android:left="@dimen/dp_sale_step"
android:top="@dimen/dp_sale_step"
android:bottom="@dimen/dp_sale_step"
>
<shape>
<!--这个是背景颜色-->
<solid android:color="@color/table_record_title_bg" />
<!--这个是按钮中的字体与按钮内的四周边距-->
<!--<padding android:bottom="10dp"-->
<!--android:left="10dp"-->
<!--android:right="10dp"-->
<!--android:top="10dp" />-->
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="@color/table_border" />
</shape>
</item>
<!--这个是按钮边框设置为四周 并且宽度为1-->
<item
android:top="@dimen/dp_sale_step"
android:bottom="@dimen/dp_sale_step"
>
<shape>
<!--这个是背景颜色-->
<solid android:color="@color/table_record_title_bg" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 边框颜色值 -->
<item>
<shape>
<solid android:color="@color/table_border" />
</shape>
</item>
<!--这个是按钮边框设置为四周 并且宽度为1-->
<item
android:top="@dimen/dp_sale_step"
android:bottom="@dimen/dp_sale_step"
android:right="@dimen/dp_sale_step"
>
<shape>
<!--这个是背景颜色-->
<solid android:color="@color/table_record_title_bg" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?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_line"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/cl_white"
>
<com.dayu.widgets.WheelView
android:id="@+id/wheel_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
>
<Button
android:id="@+id/btn_cancel"
style="@style/btn_bottom_common"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/btn_gray_commom"
android:textColor="@color/text_common_green"
android:text="@string/cancle"
android:layout_marginRight="20dp"
/>
<Button
android:id="@+id/btn_comfirm"
style="@style/btn_bottom_common"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/btn_green_commom"
android:text="@string/comfirm"
/>
</LinearLayout>
</LinearLayout>
......@@ -45,6 +45,7 @@
<color name="color_ee">#eeeeee</color>
<color name="table_border">#666666</color>
<color name="table_title_bg">#d5d5d5</color>
<color name="table_record_title_bg">#78d3f6</color>
......
......@@ -85,6 +85,16 @@
<item name="android:maxLines">1</item>
</style>
<style name="tv_user_addr">
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:textColor">@color/default_text_color</item>
<item name="android:textSize">14sp</item>
<item name="android:maxLines">1</item>
</style>
<style name="btn_bottom_common">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">45dp</item>
......
......@@ -5,6 +5,7 @@ import com.dayu.base.api.protocol.BaseResponse;
import com.dayu.common.Constants;
import com.dayu.usercenter.model.ApplyLicenceData;
import com.dayu.usercenter.model.SaveSceneData;
import com.dayu.usercenter.model.bean.AddressInfoBean;
import com.dayu.usercenter.model.bean.BusinessSceneBean;
import com.dayu.usercenter.model.EditBankData;
import com.dayu.usercenter.model.bean.GlobelRateBean;
......@@ -50,9 +51,34 @@ public interface UserService2 {
* @param data
* @return
*/
// @POST(Constants.API_7800+"/payAccountBank")
@PUT(Constants.API_7800+"/payAccountBank")
@POST(Constants.API_7800+"/payAccountBank")
Observable<BaseResponse<Boolean>> setBankInfo(@Body EditBankData data);
/**
* 更新银行信息
*/
@PUT(Constants.API_7800+"/payAccountBank")
Observable<BaseResponse<Boolean>> updateBankInfo(@Body EditBankData data);
/**
* 获取地址信息.
* @return
*/
@GET(Constants.API_7100+"/engineerAddress/default/accountId/{accountId}")
Observable<BaseResponse<AddressInfoBean>> getAddressInfo(@Path("accountId") int accountId);
/**
* 设置地址信息
* @param data
* @return
*/
@POST(Constants.API_7100+"/engineerAddress")
Observable<BaseResponse<Boolean>> setAddressInfo(@Body AddressInfoBean data);
/**
* 更新地址信息
*/
@PUT(Constants.API_7100+"/engineerAddress")
Observable<BaseResponse<Boolean>> updateAddressInfo(@Body AddressInfoBean data);
/**
* 销售业务场景
......
package com.dayu.usercenter.common;
import com.dayu.usercenter.model.bean.TreeAddressBean;
import java.util.HashMap;
import java.util.List;
/**
* Created by luofan
* on 2018/2/9.
......@@ -11,6 +16,7 @@ public class UserConstant {
public static final String DETECT_STATE = "detect_state";
public static final String PHONE = "phone";
public static final String CODE = "code";
public static final HashMap<Integer,List<TreeAddressBean>> treeAddressMap = new HashMap<>();
/**
* 注册
......
package com.dayu.usercenter.event;
public class EditAddressEvent {
public String name;
public String phone;
public String address;
public EditAddressEvent(String name, String phone, String address) {
this.name = name;
this.phone = phone;
this.address = address;
}
}
package com.dayu.usercenter.model.bean;
public class AddressInfoBean {
/**
* accountId : 0
* address : string
* cityId : 0
* cityName : string
* createBy : string
* createTime : 2020-02-28T03:48:48.022Z
* defaultSelected : 0
* districtId : 0
* districtName : string
* id : 0
* mobile : string
* modifyBy : string
* modifyTime : 2020-02-28T03:48:48.022Z
* name : string
* provinceId : 0
* provinceName : string
*/
private int accountId;
private String address;
private int cityId;
private String cityName;
private String createBy;
private String createTime;
private int defaultSelected;
private int districtId;
private String districtName;
private int id;
private String mobile;
private String modifyBy;
private String modifyTime;
private String name;
private int provinceId;
private String provinceName;
public AddressInfoBean() {
}
public AddressInfoBean(int accountId, String address, int cityId, String cityName, int districtId,
String districtName, String mobile, String name, int provinceId, String provinceName) {
this.accountId = accountId;
this.address = address;
this.cityId = cityId;
this.cityName = cityName;
this.districtId = districtId;
this.districtName = districtName;
this.mobile = mobile;
this.name = name;
this.provinceId = provinceId;
this.provinceName = provinceName;
}
public int getAccountId() {
return accountId;
}
public void setAccountId(int accountId) {
this.accountId = accountId;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getCityId() {
return cityId;
}
public void setCityId(int cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public int getDefaultSelected() {
return defaultSelected;
}
public void setDefaultSelected(int defaultSelected) {
this.defaultSelected = defaultSelected;
}
public int getDistrictId() {
return districtId;
}
public void setDistrictId(int districtId) {
this.districtId = districtId;
}
public String getDistrictName() {
return districtName;
}
public void setDistrictName(String districtName) {
this.districtName = districtName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getModifyBy() {
return modifyBy;
}
public void setModifyBy(String modifyBy) {
this.modifyBy = modifyBy;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getProvinceId() {
return provinceId;
}
public void setProvinceId(int provinceId) {
this.provinceId = provinceId;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName;
}
}
......@@ -5,6 +5,7 @@ import android.databinding.ObservableField;
import com.dayu.base.api.Api;
import com.dayu.event.UserInfo;
import com.dayu.usercenter.api.UserService2;
import com.dayu.usercenter.model.bean.AddressInfoBean;
import com.dayu.usercenter.model.bean.UserBankInfoBean;
import com.dayu.usercenter.model.bean.UserInfoBean;
import com.dayu.utils.ToastUtils;
......@@ -18,8 +19,10 @@ import io.reactivex.Observable;
*/
public class UserInfoPresenter extends UserInfoContract.Presenter {
public ObservableField<String> mUrl = new ObservableField<>();
public ObservableField<String> detailAddress = new ObservableField<>();
public ObservableField<UserInfoBean> info = new ObservableField<>();
public ObservableField<UserBankInfoBean> bankInfo = new ObservableField<UserBankInfoBean>();
public ObservableField<UserBankInfoBean> bankInfo = new ObservableField<>();
public ObservableField<AddressInfoBean> addressInfo = new ObservableField<>();
// public ObservableField<Boolean> status = new ObservableField<>();
private int mAccountId;
private int mDetectStatus;
......@@ -35,27 +38,30 @@ public class UserInfoPresenter extends UserInfoContract.Presenter {
@Override
public void queryInfo(int accountId) {
// Api.getService(UserService2.class).getUserInfo(accountId).compose(Api.applySchedulers())
// .subscribe(baseObserver(userInfo -> {
// info.set(userInfo);
// if (!TextUtils.isEmpty(userInfo.getIdentity()) && mDetectStatus == 1) {
// status.set(false);
// } else {
// status.set(true);
// Observable.mergeDelayError(
// Api.getService(UserService2.class).getUserInfo(accountId).compose(Api.applySchedulers()),
// Api.getService(UserService2.class).getUserBankInfo(accountId).compose(Api.applySchedulers()),
// Api.getService(UserService2.class).getAddressInfo(accountId).compose(Api.applySchedulers()))
// .subscribe(baseObserver(data -> {
// if (data instanceof UserInfoBean) {
// info.set((UserInfoBean) data);
// } else if (data instanceof UserBankInfoBean) {
// bankInfo.set((UserBankInfoBean) data);
// } else if (data instanceof AddressInfoBean) {
// addressInfo.set((AddressInfoBean) data);
// detailAddress.set(((AddressInfoBean) data).getProvinceName()+" "+
// ((AddressInfoBean) data).getCityName()+" "+((AddressInfoBean) data).getDistrictName()
// +" "+((AddressInfoBean) data).getAddress());
// }
// }));
mView.showDialog();
Observable.mergeDelayError(
Api.getService(UserService2.class).getUserInfo(accountId).compose(Api.applySchedulers()),
Api.getService(UserService2.class).getUserBankInfo(accountId).compose(Api.applySchedulers()))
.subscribe(baseObserver(data -> {
if (data instanceof UserInfoBean) {
info.set((UserInfoBean) data);
} else if (data instanceof UserBankInfoBean) {
bankInfo.set((UserBankInfoBean) data);
}
}));
Api.getService(UserService2.class).getUserInfo(accountId).compose(Api.applySchedulers())
.subscribe(baseObserver(data->
info.set(data)
));
getBankInfo();
getAddrInfo();
//星级佣金
Api.getService(UserService2.class).getStarRatios().compose(Api.applySchedulers())
.subscribe(baseObserver(datas->mView.setStarRatioData(datas)));
......@@ -64,4 +70,22 @@ public class UserInfoPresenter extends UserInfoContract.Presenter {
.subscribe(baseObserver(data->mView.setGlobelRate(data)));
}
public void getBankInfo() {
Api.getService(UserService2.class).getUserBankInfo(mAccountId).compose(Api.applySchedulers())
.subscribe(baseObserver(data->
bankInfo.set(data)
));
}
public void getAddrInfo() {
Api.getService(UserService2.class).getAddressInfo(mAccountId).compose(Api.applySchedulers())
.subscribe(baseObserver(data->{
addressInfo.set(data);
detailAddress.set(data.getProvinceName()+" "+data.getCityName()
+" "+data.getDistrictName()+" "+data.getAddress());
}
));
}
}
......@@ -73,7 +73,7 @@ public class UserLicencePresent extends UserLicenceContract.Presenter{
item.getLicenceAuthorityId(),item.getLicenceAuthorityName(),0);
Api.getService(UserService2.class).applyLicence(applyData).compose(Api.applySchedulers())
.subscribe(baseObserver(result->{
ToastUtils.showShortToast("apply: "+result);
ToastUtils.showShortToast(result?"申请成功":"申请失败");
}));
}
}
......@@ -169,6 +169,8 @@ public class BusinessTypeActivity extends BaseActivity<SImplePresenter, Activity
Api.getService(UserService2.class).saveServiceType(ids, mUserId).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(bool -> {
ToastUtils.showShortToast(bool?R.string.save_success:R.string.save_fail);
if (bool)
finish();
}));
}
}
......@@ -2,6 +2,7 @@ package com.dayu.usercenter.ui.activity2;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.dayu.base.api.Api;
......@@ -10,19 +11,27 @@ import com.dayu.base.ui.presenter.SImplePresenter;
import com.dayu.common.MyTextWatcher;
import com.dayu.usercenter.R;
import com.dayu.usercenter.api.UserService2;
import com.dayu.usercenter.common.UserConstant;
import com.dayu.usercenter.databinding.ActivityEditAddressBinding;
import com.dayu.usercenter.event.EditAddressEvent;
import com.dayu.usercenter.event.EditBankEvent;
import com.dayu.usercenter.model.bean.AddressInfoBean;
import com.dayu.usercenter.model.bean.TreeAddressBean;
import com.dayu.utils.ToastUtils;
import com.dayu.utils.UtilsUserAccountMatcher;
import com.dayu.widgets.WheelDialog;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
public class EditAddressActivity extends BaseActivity<SImplePresenter,ActivityEditAddressBinding> {
public class EditAddressActivity extends BaseActivity<SImplePresenter, ActivityEditAddressBinding> {
private String name;
private String phone;
private String province;
private String city;
private String area;
private String provinceName;
private String cityName;
private String areaName;
private String detailAddr;
private int provinceId;
private int cityId;
......@@ -31,6 +40,8 @@ public class EditAddressActivity extends BaseActivity<SImplePresenter,ActivityEd
private List<TreeAddressBean> cityList = new ArrayList<>();
private List<TreeAddressBean> areaList = new ArrayList<>();
private boolean isAddrSetted; //地址是否设置过
@Override
public void setPresenter() {
......@@ -49,54 +60,178 @@ public class EditAddressActivity extends BaseActivity<SImplePresenter,ActivityEd
addEdtListener(mBind.edtPhone);
addEdtListener(mBind.edtDetailAddr);
mBind.tvSubmit.setOnClickListener(view -> submit());
initAddrListener();
initData();
getTreeAddrData(-1, 1, false);
}
//选择地址点击事件
getTreeAddrData(-1,1,false);
private void initData() {
Api.getService(UserService2.class).getAddressInfo(mUserId).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(data -> {
getTreeAddrData(data.getProvinceId(), 2, false);
getTreeAddrData(data.getCityId(), 3, false);
mBind.edtName.setText(data.getName());
mBind.edtPhone.setText(data.getMobile());
mBind.edtDetailAddr.setText(data.getAddress());
mBind.tvProvince.setText(provinceName = data.getProvinceName());
mBind.tvCity.setText(cityName = data.getCityName());
mBind.tvArea.setText(areaName = data.getDistrictName());
mBind.llCity.setVisibility(View.VISIBLE);
mBind.llArea.setVisibility(View.VISIBLE);
isAddrSetted = true;
}));
}
private void initAddrListener() {
mBind.llProvince.setOnClickListener(view -> {
if (provinceList.size() > 0) {
showAddrDialog(1, provinceList);
} else {
getTreeAddrData(-1, 1, true);
}
});
mBind.llCity.setOnClickListener(view -> {
if (cityList.size() > 0) {
showAddrDialog(2, cityList);
} else {
getTreeAddrData(provinceId, 2, true);
}
});
mBind.llArea.setOnClickListener(view -> {
if (areaList.size() > 0) {
showAddrDialog(3, areaList);
} else {
getTreeAddrData(cityId, 3, true);
}
});
}
/**
* 获取地址信息
*
* @param pId
* @param type 1.省 2.市 3.区
* @param showDialog 是否显示选择框
*/
private void getTreeAddrData(int pId,int type,boolean showDialog) {
private void getTreeAddrData(int pId, int type, boolean showDialog) {
if (UserConstant.treeAddressMap.containsKey(pId) && UserConstant.treeAddressMap.get(pId).size()>0) {
dealAddrData(type, showDialog, UserConstant.treeAddressMap.get(pId));
} else {
if (showDialog)
showDialog();
Api.getService(UserService2.class).getTreeAddress(pId).compose(Api.applySchedulers())
.safeSubscribe(mPresenter.baseObserver(datas->{
dealTreeAddrData(type, datas,showDialog);
.safeSubscribe(mPresenter.baseObserver(datas -> {
dealAddrData(type, showDialog, datas);
UserConstant.treeAddressMap.put(pId, datas);
}));
}
}
private void dealTreeAddrData(int type, List<TreeAddressBean> datas,boolean showDialog) {
ToastUtils.showShortToast("addrs: "+datas.size());
switch (type){
//处理获取到地址信息数据
private void dealAddrData(int type, boolean showDialog, List<TreeAddressBean> datas) {
switch (type) {
case 1:
provinceList = datas;
break;
case 2:
cityList = datas;
mBind.llCity.setVisibility(View.VISIBLE);
break;
case 3:
areaList = datas;
mBind.llArea.setVisibility(View.VISIBLE);
break;
}
if (showDialog)
showAddrDialog(type, datas);
}
/**
* 地址选择弹框
*
* @param type
* @param addressList
*/
private void showAddrDialog(int type, List<TreeAddressBean> addressList) {
List<String> addrs = new ArrayList<>();
for (int i = 0; i < addressList.size(); i++) {
addrs.add(addressList.get(i).getText());
}
WheelDialog.getInstance().show(this, addrs, pos -> {
onAddrChoosed(type, pos);
});
}
//选择弹框内的地址后
private void onAddrChoosed(int type, int index) {
switch (type) {
case 1:
if (provinceList.get(index).getText().equals(provinceName))
return;
provinceId = Integer.parseInt(provinceList.get(index).getId());
provinceName = provinceList.get(index).getText();
getTreeAddrData(provinceId, 2, false);
cityList.clear();
areaList.clear();
mBind.llCity.setVisibility(View.VISIBLE);
mBind.llArea.setVisibility(View.GONE);
updateAddressView();
break;
case 2:
if (cityList.get(index).getText().equals(cityName))
return;
cityId = Integer.parseInt(cityList.get(index).getId());
cityName = cityList.get(index).getText();
getTreeAddrData(cityId, 3, false);
areaList.clear();
mBind.llArea.setVisibility(View.VISIBLE);
updateAddressView();
break;
case 3:
if (areaList.get(index).getText().equals(areaName))
return;
areaId = Integer.parseInt(areaList.get(index).getId());
areaName = areaList.get(index).getText();
mBind.tvArea.setText(areaName);
updateSubmitState();
break;
}
}
//更新选择地址布局显示
private void updateAddressView() {
cityId = cityList.size() > 0 ? cityId : 0;
cityName = cityList.size() > 0 ? cityName : "";
areaId = areaList.size() > 0 ? areaId : 0;
areaName = areaList.size() > 0 ? areaName : "";
mBind.tvProvince.setText(provinceName);
mBind.tvCity.setText(cityName);
mBind.tvArea.setText(areaName);
updateSubmitState();
}
//为EditText添加监听事件
private void addEdtListener(EditText editText) {
editText.addTextChangedListener(new MyTextWatcher() {
@Override
public void afterTextChanged(Editable s) {
updateSubmitSatte();
updateSubmitState();
}
});
}
//判断是否能提交
private void updateSubmitSatte() {
private void updateSubmitState() {
name = mBind.edtName.getText().toString().trim();
phone = mBind.edtPhone.getText().toString().trim();
detailAddr = mBind.edtDetailAddr.getText().toString().trim();
boolean canSubmit = !TextUtils.isEmpty(name) && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(detailAddr);
boolean canSubmit = !TextUtils.isEmpty(name) && !TextUtils.isEmpty(phone) && !TextUtils.isEmpty(detailAddr)
&& !TextUtils.isEmpty(provinceName) && !TextUtils.isEmpty(cityName) && !TextUtils.isEmpty(areaName);
changeBtnstate(canSubmit);
}
......@@ -107,5 +242,32 @@ public class EditAddressActivity extends BaseActivity<SImplePresenter,ActivityEd
}
private void submit() {
if (!UtilsUserAccountMatcher.isPhoneNum(phone)) {
ToastUtils.showShortToast(R.string.please_input_phone_right);
} else {
showDialog();
AddressInfoBean addressData = new AddressInfoBean(mUserId, detailAddr, cityId
, cityName, areaId, areaName, phone, name, provinceId, provinceName);
addressData.setCreateBy(mUserId+"");
addressData.setModifyBy(mUserId+"");
if (isAddrSetted){
Api.getService(UserService2.class).updateAddressInfo(addressData).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(this::submitDone));
}else{
Api.getService(UserService2.class).setAddressInfo(addressData).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(this::submitDone));
}
}
}
private void submitDone(Boolean reslut) {
ToastUtils.showShortToast(reslut ? R.string.submit_success : R.string.submit_fail);
if (reslut) {
String address = provinceName + " " + cityName + " " + areaName + " " + detailAddr;
EventBus.getDefault().post(new EditAddressEvent(name, phone, address));
finish();
} else {
// ToastUtils.showShortToast(R.string.submit_fail);
}
}
}
......@@ -90,8 +90,17 @@ public class EditBankActivity extends BaseActivity<SImplePresenter, ActivityEdit
private void submit() {
showDialog();
EditBankData data = new EditBankData(bankAccount, bankName, bankHolder, mUserId, 1);
if (setted) {
Api.getService(UserService2.class).updateBankInfo(data).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(this::submitDone));
} else {
Api.getService(UserService2.class).setBankInfo(data).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(reslut -> {
.subscribe(mPresenter.baseObserver(this::submitDone));
}
}
private void submitDone(Boolean reslut) {
ToastUtils.showShortToast(reslut ? R.string.submit_success : R.string.submit_fail);
if (reslut) {
EventBus.getDefault().post(new EditBankEvent(bankName, bankAccount, bankHolder));
......@@ -99,6 +108,5 @@ public class EditBankActivity extends BaseActivity<SImplePresenter, ActivityEdit
} else {
// ToastUtils.showShortToast(R.string.submit_fail);
}
}));
}
}
......@@ -11,6 +11,7 @@ import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.event.UserInfo;
import com.dayu.usercenter.R;
import com.dayu.usercenter.databinding.ActivityUserInfoBinding;
import com.dayu.usercenter.event.EditAddressEvent;
import com.dayu.usercenter.event.EditBankEvent;
import com.dayu.usercenter.model.bean.GlobelRateBean;
import com.dayu.usercenter.model.bean.StarRatioBean;
......@@ -131,8 +132,15 @@ public class UserInfoActivity extends BaseActivity<UserInfoPresenter, ActivityUs
@Subscribe
public void onBankInfoChange(EditBankEvent event){
mBind.tvBankName.setText(event.bankName);
mBind.tvBankAccount.setText(event.bankAccount);
mBind.tvBankHolder.setText(event.bankHolder);
// mBind.tvBankName.setText(event.bankName);
// mBind.tvBankAccount.setText(event.bankAccount);
// mBind.tvBankHolder.setText(event.bankHolder);
showDialog();
mPresenter.getBankInfo();
}
@Subscribe
public void onAddressInfoChange(EditAddressEvent event){
showDialog();
mPresenter.getAddrInfo();
}
}
......@@ -60,20 +60,18 @@
<LinearLayout
android:id="@+id/ll_province"
style="@style/ll_user_edit"
android:gravity="center_vertical"
android:layout_marginTop="2dp">
<TextView
style="@style/tv_user_edit2"
android:text="@string/belong_province" />
<EditText
android:id="@+id/edt_province"
style="@style/edt_user_edit"
android:layout_width="wrap_content"
android:layout_weight="1"
android:enabled="false"
<TextView
android:id="@+id/tv_province"
style="@style/tv_user_addr"
android:hint="@string/select_province_hint"
android:inputType="number" />
/>
<ImageView
android:layout_width="wrap_content"
......@@ -83,6 +81,7 @@
</LinearLayout>
<LinearLayout
android:gravity="center_vertical"
android:id="@+id/ll_city"
style="@style/ll_user_edit"
android:layout_marginTop="2dp"
......@@ -92,14 +91,11 @@
style="@style/tv_user_edit2"
android:text="@string/setlect_ciy" />
<EditText
android:id="@+id/edt_city"
style="@style/edt_user_edit"
android:layout_width="wrap_content"
android:layout_weight="1"
android:enabled="false"
<TextView
android:id="@+id/tv_city"
style="@style/tv_user_addr"
android:hint="@string/setlect_ciy_hint"
android:inputType="number" />
/>
<ImageView
android:layout_width="wrap_content"
......@@ -109,6 +105,7 @@
</LinearLayout>
<LinearLayout
android:gravity="center_vertical"
android:id="@+id/ll_area"
style="@style/ll_user_edit"
android:layout_marginTop="2dp"
......@@ -118,14 +115,11 @@
style="@style/tv_user_edit2"
android:text="@string/setlect_area" />
<EditText
android:id="@+id/edt_area"
style="@style/edt_user_edit"
android:layout_width="wrap_content"
android:layout_weight="1"
android:enabled="false"
<TextView
android:id="@+id/tv_area"
style="@style/tv_user_addr"
android:hint="@string/setlect_area_hint"
android:inputType="number" />
/>
<ImageView
android:layout_width="wrap_content"
......
......@@ -80,7 +80,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_order_step_title1"
android:background="@drawable/bg_table_record_title1"
android:gravity="center"
android:text="@string/reward_money"
/>
......@@ -90,7 +90,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@drawable/bg_order_step_title2"
android:background="@drawable/bg_table_record_title2"
android:gravity="center"
android:text="@string/reward_company" />
......@@ -99,7 +99,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_order_step_title1"
android:background="@drawable/bg_table_record_title1"
android:gravity="center"
android:text="@string/reward_date" />
</LinearLayout>
......
......@@ -80,7 +80,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_order_step_title1"
android:background="@drawable/bg_table_record_title1"
android:gravity="center"
android:text="@string/income_money" />
......@@ -89,7 +89,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="@drawable/bg_order_step_title2"
android:background="@drawable/bg_table_record_title2"
android:gravity="center"
android:text="@string/oreder_sender_payer" />
......@@ -98,7 +98,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_order_step_title1"
android:background="@drawable/bg_table_record_title1"
android:gravity="center"
android:text="@string/pay_date" />
</LinearLayout>
......
......@@ -208,13 +208,19 @@
android:text="@string/user_addr_info"
android:textStyle="bold" />
<LinearLayout style="@style/sale_linearlayout">
<LinearLayout style="@style/sale_linearlayout"
android:layout_marginRight="75dp"
>
<TextView
style="@style/sale_item_text"
android:text="@string/user_receiver_addr" />
<TextView style="@style/sale_item_text2" />
<TextView
android:id="@+id/tv_addr_add"
style="@style/sale_item_text2"
android:text="@{presenter.detailAddress}"
/>
</LinearLayout>
<LinearLayout style="@style/sale_linearlayout">
......@@ -223,7 +229,10 @@
style="@style/sale_item_text"
android:text="@string/user_receiver_name" />
<TextView style="@style/sale_item_text2" />
<TextView
android:id="@+id/tv_addr_name"
style="@style/sale_item_text2"
android:text="@{presenter.addressInfo.name}"/>
</LinearLayout>
<LinearLayout style="@style/sale_linearlayout">
......@@ -232,7 +241,10 @@
style="@style/sale_item_text"
android:text="@string/user_receiver_phone" />
<TextView style="@style/sale_item_text2" />
<TextView
android:id="@+id/tv_addr_phone"
style="@style/sale_item_text2"
android:text="@{presenter.addressInfo.mobile}"/>
</LinearLayout>
</LinearLayout>
......
......@@ -8,15 +8,9 @@
type="com.dayu.usercenter.presenter.homeuser.HomeUserPresenter" />
</data>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<RelativeLayout
......@@ -34,6 +28,18 @@
android:src="@drawable/person_setting" />
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cl_white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -52,11 +58,10 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_arrow_right"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
/>
android:src="@drawable/icon_arrow_right" />
<com.dayu.widgets.CircleImageView
android:id="@+id/iv_header"
......@@ -315,4 +320,5 @@
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</layout>
\ No newline at end of file
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