Commit 568bf94e by 罗翻

解决处理工单的一个bug,双向绑定与greendao有问题

parent 41499117
package com.dayu.event; package com.dayu.event;
import android.databinding.BaseObservable;
/** /**
* 储存用户信息的类 * 储存用户信息的类
* *
...@@ -9,7 +7,7 @@ import android.databinding.BaseObservable; ...@@ -9,7 +7,7 @@ import android.databinding.BaseObservable;
* on 2017/8/28. * on 2017/8/28.
*/ */
public class UserInfo extends BaseObservable { public class UserInfo {
/** /**
* 工程师账户id * 工程师账户id
*/ */
......
...@@ -20,8 +20,8 @@ public class HomeOrderPresenter extends HomeOrderContract.Presenter { ...@@ -20,8 +20,8 @@ public class HomeOrderPresenter extends HomeOrderContract.Presenter {
@Override @Override
public void onAttached() { public void onAttached() {
String json ="{\"accessToken\":\"40f0f4fd1d52472093055433a38d4a3f\",\"accountId\":\"692\",\"accountName\":\"罗凡\",\"headerImg\":\"http://dayuoss.oss-cn-beijing.aliyuncs.com/test/sp/mobile/android/business/checkApply/3b7165643f19bbf1c1f7ca2fa69f0d6b.png?x-oss-process\\u003dstyle/pic\",\"hxAccount\":\"0915e6394a254c51b6742e04a6c6ca3f\",\"hxPwd\":\"7583t45u\",\"siteId\":\"432\",\"status\":1,\"token\":\"8eff783de36e4d2a8b7bc66709edfc42\"}"; // String json ="{\"accessToken\":\"40f0f4fd1d52472093055433a38d4a3f\",\"accountId\":\"692\",\"accountName\":\"罗凡\",\"headerImg\":\"http://dayuoss.oss-cn-beijing.aliyuncs.com/test/sp/mobile/android/business/checkApply/3b7165643f19bbf1c1f7ca2fa69f0d6b.png?x-oss-process\\u003dstyle/pic\",\"hxAccount\":\"0915e6394a254c51b6742e04a6c6ca3f\",\"hxPwd\":\"7583t45u\",\"siteId\":\"432\",\"status\":1,\"token\":\"8eff783de36e4d2a8b7bc66709edfc42\"}";
UserManager.getInstance().saveUserForJson(json); // UserManager.getInstance().saveUserForJson(json);
UserInfo userInfo = UserManager.getInstance().getUser(); UserInfo userInfo = UserManager.getInstance().getUser();
mUserId = Integer.parseInt(userInfo.getAccountId()); mUserId = Integer.parseInt(userInfo.getAccountId());
mSiteId = Integer.parseInt(userInfo.getSiteId()); mSiteId = Integer.parseInt(userInfo.getSiteId());
......
...@@ -23,6 +23,13 @@ public interface ProcessOrderContract { ...@@ -23,6 +23,13 @@ public interface ProcessOrderContract {
* @param list * @param list
*/ */
void initPhotoView(ArrayList<String> list); void initPhotoView(ArrayList<String> list);
void clearData();
/**
* 由于databinding和greendao结合使用引起临时改变,所以在这不使用双向绑定。
*/
void getData();
} }
abstract class Presenter extends BasePresenter<View> { abstract class Presenter extends BasePresenter<View> {
......
...@@ -97,11 +97,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter { ...@@ -97,11 +97,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
public void swtichButton() { public void swtichButton() {
buttonState.set(!buttonState.get()); buttonState.set(!buttonState.get());
if (!buttonState.get()) { if (!buttonState.get()) {
mOrderField.get().setDoorPrice(""); mView.clearData();
mOrderField.get().setServerPrice("");
mOrderField.get().setMaterialCost("");
mOrderField.get().setOtherPrice("");
mOrderField.get().setOtherInfo("");
} }
MobclickAgent.onEvent(BaseApplication.getContext(), "get_customer_money"); MobclickAgent.onEvent(BaseApplication.getContext(), "get_customer_money");
} }
...@@ -179,6 +175,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter { ...@@ -179,6 +175,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
part[i] = body; part[i] = body;
} }
BaseApiFactory.uploadPhoto(part).subscribe(baseObserver(list -> { BaseApiFactory.uploadPhoto(part).subscribe(baseObserver(list -> {
mView.getData();
OrderInfo info = mOrderField.get(); OrderInfo info = mOrderField.get();
commitOrder(list, mOrderId, info.getServerRecord(), commitOrder(list, mOrderId, info.getServerRecord(),
mAccountId, isPay, info.getDoorPrice(), info.getOtherInfo(), mAccountId, isPay, info.getDoorPrice(), info.getOtherInfo(),
...@@ -191,6 +188,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter { ...@@ -191,6 +188,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
@Override @Override
public void saveOrder() { public void saveOrder() {
if (mImages != null && mImages.size() > 0) { if (mImages != null && mImages.size() > 0) {
mView.getData();
mOrderField.get().setImgPath(mImages); mOrderField.get().setImgPath(mImages);
} }
mOrderInfoDao.insertOrReplace(mOrderField.get()); mOrderInfoDao.insertOrReplace(mOrderField.get());
...@@ -211,6 +209,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter { ...@@ -211,6 +209,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
mView.showDialog(); mView.showDialog();
commitPhoto(mImages); commitPhoto(mImages);
} else { } else {
mView.getData();
OrderInfo info = mOrderField.get(); OrderInfo info = mOrderField.get();
commitOrder(null, mOrderId, info.getServerRecord(), commitOrder(null, mOrderId, info.getServerRecord(),
mAccountId, isPay, info.getDoorPrice(), info.getOtherInfo(), mAccountId, isPay, info.getDoorPrice(), info.getOtherInfo(),
......
package com.dayu.order.sqlbean; package com.dayu.order.sqlbean;
import android.databinding.BaseObservable; import android.databinding.BaseObservable;
import android.databinding.Bindable;
import com.dayu.order.BR;
import org.greenrobot.greendao.annotation.Convert; import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity; import org.greenrobot.greendao.annotation.Entity;
...@@ -14,7 +11,8 @@ import org.greenrobot.greendao.annotation.Property; ...@@ -14,7 +11,8 @@ import org.greenrobot.greendao.annotation.Property;
import java.util.List; import java.util.List;
/** /**
* Created by luofan on 2017/11/3. * Created by luofan
* on 2017/11/3.
*/ */
@Entity @Entity
...@@ -75,73 +73,59 @@ public class OrderInfo extends BaseObservable { ...@@ -75,73 +73,59 @@ public class OrderInfo extends BaseObservable {
this.engineerId = engineerId; this.engineerId = engineerId;
} }
@Bindable
public String getServerRecord() { public String getServerRecord() {
return this.serverRecord; return this.serverRecord;
} }
public void setServerRecord(String serverRecord) { public void setServerRecord(String serverRecord) {
this.serverRecord = serverRecord; this.serverRecord = serverRecord;
notifyPropertyChanged(BR.serverRecord);
} }
@Bindable
public String getDoorPrice() { public String getDoorPrice() {
return this.doorPrice; return this.doorPrice;
} }
public void setDoorPrice(String doorPrice) { public void setDoorPrice(String doorPrice) {
this.doorPrice = doorPrice; this.doorPrice = doorPrice;
notifyPropertyChanged(BR.doorPrice);
} }
@Bindable
public String getServerPrice() { public String getServerPrice() {
return this.serverPrice; return this.serverPrice;
} }
public void setServerPrice(String serverPrice) { public void setServerPrice(String serverPrice) {
this.serverPrice = serverPrice; this.serverPrice = serverPrice;
notifyPropertyChanged(BR.serverPrice);
} }
@Bindable
public String getMaterialCost() { public String getMaterialCost() {
return this.materialCost; return this.materialCost;
} }
public void setMaterialCost(String materialCost) { public void setMaterialCost(String materialCost) {
this.materialCost = materialCost; this.materialCost = materialCost;
notifyPropertyChanged(BR.materialCost);
} }
@Bindable
public String getOtherPrice() { public String getOtherPrice() {
return this.otherPrice; return this.otherPrice;
} }
public void setOtherPrice(String otherPrice) { public void setOtherPrice(String otherPrice) {
this.otherPrice = otherPrice; this.otherPrice = otherPrice;
notifyPropertyChanged(BR.otherPrice);
} }
@Bindable
public String getOtherInfo() { public String getOtherInfo() {
return this.otherInfo; return this.otherInfo;
} }
public void setOtherInfo(String otherInfo) { public void setOtherInfo(String otherInfo) {
this.otherInfo = otherInfo; this.otherInfo = otherInfo;
notifyPropertyChanged(BR.otherInfo);
} }
@Bindable
public List<String> getImgPath() { public List<String> getImgPath() {
return this.imgPath; return this.imgPath;
} }
public void setImgPath(List<String> imgPath) { public void setImgPath(List<String> imgPath) {
this.imgPath = imgPath; this.imgPath = imgPath;
notifyPropertyChanged(BR.imgPath);
} }
} }
...@@ -14,6 +14,7 @@ import com.dayu.order.R; ...@@ -14,6 +14,7 @@ import com.dayu.order.R;
import com.dayu.order.databinding.ActivityProcessOrderBinding; import com.dayu.order.databinding.ActivityProcessOrderBinding;
import com.dayu.order.presenter.processorder.ProcessOrderContract; import com.dayu.order.presenter.processorder.ProcessOrderContract;
import com.dayu.order.presenter.processorder.ProcessOrderPresenter; import com.dayu.order.presenter.processorder.ProcessOrderPresenter;
import com.dayu.order.sqlbean.OrderInfo;
import com.dayu.utils.GlideImageLoader; import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.UtilsScreen; import com.dayu.utils.UtilsScreen;
import com.luck.picture.lib.PictureSelectionModel; import com.luck.picture.lib.PictureSelectionModel;
...@@ -38,7 +39,6 @@ public class ProcessOrderActivity extends BaseActivity<ProcessOrderPresenter, Ac ...@@ -38,7 +39,6 @@ public class ProcessOrderActivity extends BaseActivity<ProcessOrderPresenter, Ac
private ImageView mAddIV; private ImageView mAddIV;
private List<LocalMedia> mSelectList; private List<LocalMedia> mSelectList;
private ArrayList<String> mImages = new ArrayList<>(); private ArrayList<String> mImages = new ArrayList<>();
private final int DELETECODE = 0;
@Override @Override
public int getLayoutId() { public int getLayoutId() {
...@@ -130,9 +130,31 @@ public class ProcessOrderActivity extends BaseActivity<ProcessOrderPresenter, Ac ...@@ -130,9 +130,31 @@ public class ProcessOrderActivity extends BaseActivity<ProcessOrderPresenter, Ac
} }
} }
@Override
public void clearData() {
mBind.etDoorInfo.setText("");
mBind.etDoorPrice.setText("");
mBind.etMaterialsPrice.setText("");
mBind.etOtherPrice.setText("");
mBind.etServePrice.setText("");
}
@Override
public void getData() {
OrderInfo info = mPresenter.mOrderField.get();
info.setDoorPrice(mBind.etDoorPrice.getText().toString());
info.setMaterialCost(mBind.etMaterialsPrice.getText().toString());
info.setOtherPrice(mBind.etOtherPrice.getText().toString());
info.setServerPrice(mBind.etServePrice.getText().toString());
info.setServerRecord(mBind.etServeInfo.getText().toString());
info.setOtherInfo(mBind.etDoorInfo.getText().toString());
mPresenter.mOrderField.set(info);
}
private void dumpPic() { private void dumpPic() {
Intent intent = new Intent(this, PreviewActivty.class); Intent intent = new Intent(this, PreviewActivty.class);
intent.putStringArrayListExtra(Constants.BUNDLE_KEY_ID, mImages); intent.putStringArrayListExtra(Constants.BUNDLE_KEY_ID, mImages);
int DELETECODE = 0;
startActivityForResult(intent, DELETECODE); startActivityForResult(intent, DELETECODE);
} }
......
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
android:hint="@string/order_hint" android:hint="@string/order_hint"
android:paddingLeft="@dimen/dp_13" android:paddingLeft="@dimen/dp_13"
android:paddingTop="@dimen/dp_11" android:paddingTop="@dimen/dp_11"
android:text="@={presenter.mOrderField.serverRecord}" android:text="@{presenter.mOrderField.serverRecord}"
android:textColor="@color/cl_home_title_text_color" android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" /> android:textSize="@dimen/sp_13.3" />
...@@ -309,7 +309,7 @@ ...@@ -309,7 +309,7 @@
android:background="@null" android:background="@null"
android:hint="@string/input_up_door_money" android:hint="@string/input_up_door_money"
android:inputType="number" android:inputType="number"
android:text="@={presenter.mOrderField.doorPrice}" android:text="@{presenter.mOrderField.doorPrice}"
android:textColor="@color/cl_home_title_text_color" android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" /> android:textSize="@dimen/sp_13.3" />
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
android:background="@null" android:background="@null"
android:hint="@string/input_up_money" android:hint="@string/input_up_money"
android:inputType="number" android:inputType="number"
android:text="@={presenter.mOrderField.serverPrice}" android:text="@{presenter.mOrderField.serverPrice}"
android:textColor="@color/cl_home_title_text_color" android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" android:textSize="@dimen/sp_13.3"
...@@ -401,7 +401,7 @@ ...@@ -401,7 +401,7 @@
android:background="@null" android:background="@null"
android:hint="@string/input_cailiao_money" android:hint="@string/input_cailiao_money"
android:inputType="number" android:inputType="number"
android:text="@={presenter.mOrderField.materialCost}" android:text="@{presenter.mOrderField.materialCost}"
android:textColor="@color/cl_home_title_text_color" android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" /> android:textSize="@dimen/sp_13.3" />
...@@ -446,7 +446,7 @@ ...@@ -446,7 +446,7 @@
android:background="@null" android:background="@null"
android:hint="@string/input_other_money" android:hint="@string/input_other_money"
android:inputType="number" android:inputType="number"
android:text="@={presenter.mOrderField.otherPrice}" android:text="@{presenter.mOrderField.otherPrice}"
android:textColor="@color/cl_home_title_text_color" android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" /> android:textSize="@dimen/sp_13.3" />
...@@ -480,7 +480,7 @@ ...@@ -480,7 +480,7 @@
android:gravity="top" android:gravity="top"
android:hint="@string/tv_order_other" android:hint="@string/tv_order_other"
android:paddingTop="@dimen/dp_11" android:paddingTop="@dimen/dp_11"
android:text="@={presenter.mOrderField.otherInfo}" android:text="@{presenter.mOrderField.otherInfo}"
android:textColor="@color/cl_home_title_text_color" android:textColor="@color/cl_home_title_text_color"
android:textColorHint="@color/cl_selector_hui" android:textColorHint="@color/cl_selector_hui"
android:textSize="@dimen/sp_13.3" /> android:textSize="@dimen/sp_13.3" />
......
...@@ -32,7 +32,8 @@ import com.dayu.widgets.CustomDialog; ...@@ -32,7 +32,8 @@ import com.dayu.widgets.CustomDialog;
import com.umeng.analytics.MobclickAgent; import com.umeng.analytics.MobclickAgent;
/** /**
* Created by luofan on 2017/11/20. * Created by luofan
* on 2017/11/20.
*/ */
public class HomePersonFragment extends BaseFragment<HomePersonPresenter, FragmentPersonalCenterBinding> public class HomePersonFragment extends BaseFragment<HomePersonPresenter, FragmentPersonalCenterBinding>
......
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