Commit 8c1829cf by 王佳洋

修改昵称和简介 接口调通

parent e06a3bed
...@@ -9,7 +9,6 @@ import android.widget.SeekBar ...@@ -9,7 +9,6 @@ import android.widget.SeekBar
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper import com.ydl.media.view.PlayerFloatHelper
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.ydlcommon.base.BaseActivity import com.ydl.ydlcommon.base.BaseActivity
...@@ -42,7 +41,6 @@ import io.reactivex.schedulers.Schedulers ...@@ -42,7 +41,6 @@ import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_play_meditation.* import kotlinx.android.synthetic.main.activity_play_meditation.*
import kotlinx.android.synthetic.main.activity_play_meditation.iv_close import kotlinx.android.synthetic.main.activity_play_meditation.iv_close
import kotlinx.android.synthetic.main.activity_play_meditation.tv_title import kotlinx.android.synthetic.main.activity_play_meditation.tv_title
import kotlinx.android.synthetic.main.layout_meditation_play_float_view.*
import kotlinx.android.synthetic.main.player_control_view.* import kotlinx.android.synthetic.main.player_control_view.*
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
......
package com.yidianling.user.http package com.yidianling.user.http
import com.google.gson.internal.LinkedTreeMap import com.google.gson.internal.LinkedTreeMap
import com.ydl.ydlcommon.base.config.YDLConstants import com.ydl.ydlcommon.base.config.*
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_LOGIN_BASE_URL
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.user.api.bean.UserResponseBean import com.yidianling.user.api.bean.UserResponseBean
...@@ -251,12 +248,14 @@ interface UserApi { ...@@ -251,12 +248,14 @@ interface UserApi {
* 修改昵称、头像、简介等基本信息 * 修改昵称、头像、简介等基本信息
*/ */
@POST("user/v1/baseInfo/modify") @POST("user/v1/baseInfo/modify")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun modifyUserBaseInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<Boolean>> fun modifyUserBaseInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<Boolean>>
/** /**
* 获取用户审核信息 * 获取用户审核信息
*/ */
@POST("user/v1/getUserAuditInfo") @POST("user/v1/getUserAuditInfo")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getUserAuditInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<UserModifyAuditRespDto>> fun getUserAuditInfo(@Body map: Map<String,String>): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
/** /**
...@@ -264,6 +263,7 @@ interface UserApi { ...@@ -264,6 +263,7 @@ interface UserApi {
*/ */
@Multipart @Multipart
@POST("file/upload") @POST("file/upload")
fun uploadFile(@Query("uid") uid: String, @Query("token") token: String, @Part file: MultipartBody.Part): Observable<BaseAPIResponse<String>> @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun uploadFile(@Part file: MultipartBody.Part): Observable<BaseAPIResponse<String>>
} }
\ No newline at end of file
...@@ -79,9 +79,9 @@ interface UserHttp { ...@@ -79,9 +79,9 @@ interface UserHttp {
/**用户注销账号*/ /**用户注销账号*/
fun accountLogOff(param: UserForbidLoginParam):Observable<BaseAPIResponse<Boolean>> fun accountLogOff(param: UserForbidLoginParam):Observable<BaseAPIResponse<Boolean>>
fun modifyUserBaseInfo(uid: String, token: String, param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>> fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>>
fun getUserAuditInfo(uid: String, token: String, param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>>
fun uploadFile(uid: String, token: String, file: File): Observable<BaseAPIResponse<Boolean>> fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>>
} }
\ No newline at end of file
...@@ -112,45 +112,29 @@ class UserHttpImpl private constructor() : UserHttp { ...@@ -112,45 +112,29 @@ class UserHttpImpl private constructor() : UserHttp {
.flatMap { getUserApi().setUserInfo(it) } .flatMap { getUserApi().setUserInfo(it) }
} }
override fun modifyUserBaseInfo( override fun modifyUserBaseInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<Boolean>> {
uid: String,
token: String,
param: ModifyBaseInfo
): Observable<BaseAPIResponse<Boolean>> {
param.uid = uid
param.accessToken = token
return RxUtils.mapObservable(param) return RxUtils.mapObservable(param)
.flatMap { getUserApi().modifyUserBaseInfo(it) } .flatMap { getUserApi().modifyUserBaseInfo(it) }
} }
override fun getUserAuditInfo( override fun getUserAuditInfo(param: ModifyBaseInfo): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
uid: String,
token: String,
param: ModifyBaseInfo
): Observable<BaseAPIResponse<UserModifyAuditRespDto>> {
param.uid = uid
param.accessToken = token
return RxUtils.mapObservable(param) return RxUtils.mapObservable(param)
.flatMap { getUserApi().getUserAuditInfo(it) } .flatMap { getUserApi().getUserAuditInfo(it) }
} }
override fun uploadFile( override fun uploadFile(file: File): Observable<BaseAPIResponse<Boolean>> {
uid: String,
token: String,
file: File
): Observable<BaseAPIResponse<Boolean>> {
return Observable.empty<Boolean>() return Observable.empty<Boolean>()
.compose(RxUtils.netCheck()) .compose(RxUtils.netCheck())
.flatMap { .flatMap {
getUserApi().uploadFile( getUserApi().uploadFile(
uid, token, MultipartBody.Part.createFormData( MultipartBody.Part.createFormData(
"file", null, "file", null,
RequestBody.create(MediaType.parse("multipart/form-data"), file) RequestBody.create(MediaType.parse("multipart/form-data"), file)
) )
) )
}.flatMap { }.flatMap {
if (it.code == "200") if (it.code == "200")
modifyUserBaseInfo(uid, token, ModifyBaseInfo(it.data, 102)) modifyUserBaseInfo(ModifyBaseInfo(it.data, 102))
else else
Observable.empty() Observable.empty()
} }
......
...@@ -74,12 +74,9 @@ class ModifyAvatarActivity : BaseActivity() { ...@@ -74,12 +74,9 @@ class ModifyAvatarActivity : BaseActivity() {
override fun initDataAndEvent() { override fun initDataAndEvent() {
findView() findView()
mUserInfo ?: return mUserInfo ?: return
mDisposable.add( mDisposables.add(
UserHttpImpl.getInstance() UserHttpImpl.getInstance()
.getUserAuditInfo( .getUserAuditInfo(ModifyBaseInfo(null, 102))
mUserInfo.uid, mUserInfo.accessToken.orEmpty(),
ModifyBaseInfo(null, 102)
)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> -> .subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
...@@ -98,7 +95,8 @@ class ModifyAvatarActivity : BaseActivity() { ...@@ -98,7 +95,8 @@ class ModifyAvatarActivity : BaseActivity() {
.load(mUserInfo.head) .load(mUserInfo.head)
.into(iv_avatar) .into(iv_avatar)
iv_warn.visible() iv_warn.visible()
tv_tip2.text = SpannableString("审核失败,该头像提交不规范,请修改后重新提交审核。如有疑问联系客服小壹").also { tv_tip2.text =
SpannableString("审核失败,该头像提交不规范,请修改后重新提交审核。如有疑问联系客服小壹").also {
it.setSpan( it.setSpan(
ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)), ForegroundColorSpan(resources.getColor(R.color.color_1DA1F2)),
it.indexOf("客服"), it.indexOf("客服"),
...@@ -244,11 +242,9 @@ class ModifyAvatarActivity : BaseActivity() { ...@@ -244,11 +242,9 @@ class ModifyAvatarActivity : BaseActivity() {
bitmap = FileUtils.getZoomImage(bitmap, 200.0) bitmap = FileUtils.getZoomImage(bitmap, 200.0)
try { try {
val outPutFile = FileUtils.saveBitmap(bitmap, path) val outPutFile = FileUtils.saveBitmap(bitmap, path)
mDisposable.add( mDisposables.add(
UserHttpImpl.getInstance().uploadFile( UserHttpImpl.getInstance().uploadFile(outPutFile)
mUserInfo.uid, mUserInfo.accessToken.orEmpty(), .subscribeOn(Schedulers.io())
outPutFile
).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({}, {}) { .subscribe({}, {}) {
dismissProgressDialog() dismissProgressDialog()
......
...@@ -13,7 +13,6 @@ import com.alibaba.android.arouter.launcher.ARouter ...@@ -13,7 +13,6 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydlcommon.base.BaseActivity import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.StatusBarOptions import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.modular.ModularServiceManager.provide
import com.ydl.ydlcommon.modular.findRouteService import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.extend.visible import com.ydl.ydlcommon.utils.extend.visible
import com.ydl.ydlcommon.view.DeleteEditTextView import com.ydl.ydlcommon.view.DeleteEditTextView
...@@ -37,6 +36,7 @@ const val NICKNAME = 1 ...@@ -37,6 +36,7 @@ const val NICKNAME = 1
const val INTRODUCTION = 2 const val INTRODUCTION = 2
class ModifyInfoActivity : BaseActivity() { class ModifyInfoActivity : BaseActivity() {
override fun getStatusViewOptions(): StatusBarOptions { override fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = true) return StatusBarOptions(isAddStatusView = true, statusBarDarkMode = true)
} }
...@@ -69,13 +69,16 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -69,13 +69,16 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.title = "简介" tb_title_bar.title = "简介"
det_set_info.layoutParams.height = RxImageTool.dp2px(180f) det_set_info.layoutParams.height = RxImageTool.dp2px(180f)
det_set_info.hint = "一句话介绍下自己" det_set_info.hint = "一句话介绍下自己"
det_set_info.setShowDelete(false)
}
tb_title_bar.setOnLeftTextClick { _, _ ->
setResult(RESULT_OK)
finish()
} }
val userInfo = findRouteService(IUserService::class.java).getUserInfo() val userInfo = findRouteService(IUserService::class.java).getUserInfo()
userInfo ?: return userInfo ?: return
det_set_info.setText(userInfo.nick_name) mDisposables.add(
mDisposable.add( getInstance().getUserAuditInfo(ModifyBaseInfo(null, if (NICKNAME == from) 101 else 103))
getInstance().getUserAuditInfo(userInfo.uid, userInfo.accessToken.orEmpty(),
ModifyBaseInfo(null, if (NICKNAME == from) 101 else 103))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> -> .subscribe { response: BaseAPIResponse<UserModifyAuditRespDto> ->
...@@ -89,6 +92,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -89,6 +92,7 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.setRightTextEnable(false) tb_title_bar.setRightTextEnable(false)
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7)) tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.keyListener = null det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7)) det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setOnClickListener { det_set_info.setOnClickListener {
ToastUtil.toastShort( ToastUtil.toastShort(
...@@ -102,6 +106,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -102,6 +106,7 @@ class ModifyInfoActivity : BaseActivity() {
2 -> { // 审核失败 2 -> { // 审核失败
tv_tip1.visible() tv_tip1.visible()
tv_tip1.text = "七天内可修改一次昵称" tv_tip1.text = "七天内可修改一次昵称"
det_set_info.setText(userInfo.nick_name)
iv_warn.visible() iv_warn.visible()
customerService("审核失败 ,昵称中含有违规文字。如有疑问联系客服小壹") customerService("审核失败 ,昵称中含有违规文字。如有疑问联系客服小壹")
} }
...@@ -118,6 +123,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -118,6 +123,7 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7)) tb_title_bar.setRightTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7)) det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.keyListener = null det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setOnClickListener { det_set_info.setOnClickListener {
ToastUtil.toastShort( ToastUtil.toastShort(
"抱歉,七天内只能修改一次" "抱歉,七天内只能修改一次"
...@@ -128,10 +134,9 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -128,10 +134,9 @@ class ModifyInfoActivity : BaseActivity() {
tv_tip1.text = "七天内可修改一次昵称" tv_tip1.text = "七天内可修改一次昵称"
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2)) tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
tb_title_bar.setOnRightTextClick { _: View?, _: Boolean -> tb_title_bar.setOnRightTextClick { _: View?, _: Boolean ->
if (checkInput()) { if (checkNickInput()) {
modifyUserBaseInfo(userInfo.uid, userInfo.accessToken.orEmpty(), 101) { modifyUserBaseInfo(101) {
ToastUtil.toastShort("提交成功,昵称审核中,预计24小时内审核完成") ToastUtil.toastShort("提交成功,昵称审核中,预计24小时内审核完成")
setResult(RESULT_OK, intent)
finish() finish()
} }
} }
...@@ -146,6 +151,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -146,6 +151,7 @@ class ModifyInfoActivity : BaseActivity() {
tb_title_bar.isEnabled = false tb_title_bar.isEnabled = false
det_set_info.setText(modifyAfter) det_set_info.setText(modifyAfter)
det_set_info.keyListener = null det_set_info.keyListener = null
det_set_info.isFocusableInTouchMode = false
det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7)) det_set_info.setTextColor(resources.getColor(R.color.color_9d9ea7))
det_set_info.setOnClickListener { det_set_info.setOnClickListener {
ToastUtil.toastShort( ToastUtil.toastShort(
...@@ -157,6 +163,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -157,6 +163,7 @@ class ModifyInfoActivity : BaseActivity() {
} }
2 -> { // 审核失败 2 -> { // 审核失败
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2)) tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
det_set_info.setText(userInfo.description)
iv_warn.visible() iv_warn.visible()
customerService("审核失败,简介中含违规文字如有疑问联系客服小壹") customerService("审核失败,简介中含违规文字如有疑问联系客服小壹")
} }
...@@ -167,7 +174,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -167,7 +174,7 @@ class ModifyInfoActivity : BaseActivity() {
} }
tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2)) tb_title_bar.setRightTextColor(resources.getColor(R.color.color_1DA1F2))
tb_title_bar.setOnClickListener { tb_title_bar.setOnClickListener {
modifyUserBaseInfo(userInfo.uid, userInfo.accessToken.orEmpty(),103) { modifyUserBaseInfo(103) {
ToastUtil.toastShort("提交成功,简介审核中,预计24小时内审核完成") ToastUtil.toastShort("提交成功,简介审核中,预计24小时内审核完成")
finish() finish()
} }
...@@ -198,7 +205,7 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -198,7 +205,7 @@ class ModifyInfoActivity : BaseActivity() {
} }
} }
private fun checkInput(): Boolean { private fun checkNickInput(): Boolean {
if (det_set_info.text.isEmpty()) { if (det_set_info.text.isEmpty()) {
ToastUtil.toastShort("请输入昵称") ToastUtil.toastShort("请输入昵称")
det_set_info.startAnimation(mShake) det_set_info.startAnimation(mShake)
...@@ -212,10 +219,9 @@ class ModifyInfoActivity : BaseActivity() { ...@@ -212,10 +219,9 @@ class ModifyInfoActivity : BaseActivity() {
return true return true
} }
private fun modifyUserBaseInfo(uid: String, token: String, type: Int, block: () -> Unit) { private fun modifyUserBaseInfo(type: Int, block: () -> Unit) {
mDisposable.add( mDisposables.add(
getInstance().modifyUserBaseInfo( getInstance().modifyUserBaseInfo(
uid, token,
ModifyBaseInfo( ModifyBaseInfo(
det_set_info.text.toString(), det_set_info.text.toString(),
type type
......
package com.yidianling.user.mine; package com.yidianling.user.mine;
import static com.yidianling.user.mine.ModifyInfoActivityKt.NICKNAME;
import static com.yidianling.user.mine.ModifyInfoActivityKt.INTRODUCTION;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
...@@ -161,7 +164,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi ...@@ -161,7 +164,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
if (id == R.id.persion_head_rel) { // 头像 if (id == R.id.persion_head_rel) { // 头像
startActivityForResult(new Intent(this, ModifyAvatarActivity.class), AVATAR); startActivityForResult(new Intent(this, ModifyAvatarActivity.class), AVATAR);
} else if (id == R.id.jtv_nick) {//昵称 } else if (id == R.id.jtv_nick) {//昵称
startActivityForResult(new Intent(this, ModifyInfoActivity.class), NICK); Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("from", NICKNAME);
startActivityForResult(intent, NICK);
} else if (id == R.id.jtv_sex) {//性别 } else if (id == R.id.jtv_sex) {//性别
List<String> sexs = new ArrayList<String>(); List<String> sexs = new ArrayList<String>();
sexs.add("男"); sexs.add("男");
...@@ -265,7 +270,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi ...@@ -265,7 +270,9 @@ public class PersonalInfoActivity extends BaseActivity implements View.OnClickLi
}); });
builderm.create().show(); builderm.create().show();
} else if (id == R.id.jtv_jianjie) {//个人简介 } else if (id == R.id.jtv_jianjie) {//个人简介
startActivity(new Intent(this, ModifyInfoActivity.class)); Intent intent = new Intent(this, ModifyInfoActivity.class);
intent.putExtra("from", INTRODUCTION);
startActivity(intent);
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:textColor="@color/color_9d9ea7" android:textColor="@color/color_9d9ea7"
android:textSize="14sp" android:textSize="14sp"
android:visibility="gone" android:visibility="invisible"
tools:text="七天内可修改一次昵称" tools:text="七天内可修改一次昵称"
tools:visibility="visible" /> tools:visibility="visible" />
...@@ -37,10 +37,12 @@ ...@@ -37,10 +37,12 @@
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:background="@drawable/bg_corner_8_white" android:background="@drawable/bg_corner_8_white"
android:paddingStart="10dp" android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="15dp" android:paddingTop="15dp"
android:gravity="start"
android:textSize="14sp"
android:textColor="@color/color_1C1F28" android:textColor="@color/color_1C1F28"
android:paddingBottom="15dp" android:paddingBottom="15dp" />
android:singleLine="true" />
<LinearLayout <LinearLayout
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
......
...@@ -39,7 +39,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable { ...@@ -39,7 +39,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
private var loadingDialogFragment: LoadingDialogFragment? = null private var loadingDialogFragment: LoadingDialogFragment? = null
@JvmField @JvmField
val mDisposable = CompositeDisposable() val mDisposables = CompositeDisposable()
override fun provideLifecycleSubject(): Subject<ActivityEvent> { override fun provideLifecycleSubject(): Subject<ActivityEvent> {
return mLifecycleSubject; return mLifecycleSubject;
...@@ -161,7 +161,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable { ...@@ -161,7 +161,7 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
mDisposable.takeIf { !it.isDisposed }?.dispose() mDisposables.takeIf { !it.isDisposed }?.dispose()
ActivityManager.getInstance().removeStack(this) ActivityManager.getInstance().removeStack(this)
AndroidSystemHelper.fixInputMethodManagerLeak(this) AndroidSystemHelper.fixInputMethodManagerLeak(this)
} }
......
...@@ -21,6 +21,7 @@ import com.ydl.ydlcommon.R; ...@@ -21,6 +21,7 @@ import com.ydl.ydlcommon.R;
public class DeleteEditTextView extends EditText { public class DeleteEditTextView extends EditText {
int mCloseAreaSize; int mCloseAreaSize;
private boolean mShowDelete = true;
public DeleteEditTextView(Context context) { public DeleteEditTextView(Context context) {
super(context); super(context);
...@@ -43,6 +44,10 @@ public class DeleteEditTextView extends EditText { ...@@ -43,6 +44,10 @@ public class DeleteEditTextView extends EditText {
setSelection(text.length()); setSelection(text.length());
} }
public void setShowDelete(boolean showDelete) {
this.mShowDelete = showDelete;
}
/** /**
* 初始化视图 * 初始化视图
*/ */
...@@ -77,6 +82,7 @@ public class DeleteEditTextView extends EditText { ...@@ -77,6 +82,7 @@ public class DeleteEditTextView extends EditText {
} }
void setEditTextDrawable() { void setEditTextDrawable() {
if (!mShowDelete) return;
if (getText().length() == 0 || !isFocused()) { if (getText().length() == 0 || !isFocused()) {
setCompoundDrawablesWithIntrinsicBounds(getCompoundDrawables()[0], null, null, null); setCompoundDrawablesWithIntrinsicBounds(getCompoundDrawables()[0], null, null, null);
} else { } else {
...@@ -87,7 +93,7 @@ public class DeleteEditTextView extends EditText { ...@@ -87,7 +93,7 @@ public class DeleteEditTextView extends EditText {
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if ((event.getAction() == 1) && isFocused()) { if (mShowDelete && (event.getAction() == 1) && isFocused()) {
int i = (int) event.getRawX(); int i = (int) event.getRawX();
if (i > getRight() - mCloseAreaSize) { if (i > getRight() - mCloseAreaSize) {
setText(""); setText("");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment