Commit 79091f26 by 严久程

信息采集

parent 6488b095
......@@ -47,6 +47,7 @@ import com.ydl.ydlcommon.utils.SharedPreferencesEditor;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.ydl.ydlcommon.utils.log.LogHelper;
import com.ydl.ydlcommon.view.CircleImageView;
import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.im.router.ImIn;
......@@ -258,18 +259,25 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
if (ChatStatusCacheHelper.getStatusCache("collectEvent")) {
String time = Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.MONTH) + Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
// if (!TextUtils.equals(time, SharedPreferencesEditor.getString("skip_time_" + YdlCommonRouterManager.INSTANCE.getYdlCommonRoute().getUid()))) {
if (!TextUtils.equals(time, SharedPreferencesEditor.getString("skip_time_" + ImIn.INSTANCE.getUserInfo().getUid()))) {
collectInfoPopupWindow = new CollectInfoPopupWindow(getActivity(), (content, result) -> {
if (TextUtils.isEmpty(content)) {//点击跳过后当天不再显示此弹窗
SharedPreferencesEditor.putString("skip_time_" + ImIn.INSTANCE.getUserInfo().getUid()
, time);
} else {
IMMessage textMessage = MessageBuilder.createTextMessage(sessionId, sessionType, content);
if (sendMessage(textMessage)) {
openOrCloseCommonQuestionLayout(false);
collectInfoPopupWindow = new CollectInfoPopupWindow(getActivity(), new CollectInfoPopupWindow.OnSendMsgListener() {
@Override
public void sendMsg(@NotNull String content, @NotNull List<UserQuestInfoBean> result) {
if (TextUtils.isEmpty(content)) {//点击跳过后当天不再显示此弹窗
SharedPreferencesEditor.putString("skip_time_" + ImIn.INSTANCE.getUserInfo().getUid()
, time);
} else {
IMMessage textMessage = MessageBuilder.createTextMessage(sessionId, sessionType, content);
if (sendMessage(textMessage)) {
openOrCloseCommonQuestionLayout(false);
}
submitUserCollect(result);
}
submitUserCollect(result);
}
@Override
public void finishPage() {
getActivity().finish();
}
});
getUserInfoCollect();
......@@ -380,6 +388,33 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
rl_doctor_name.setVisibility(View.GONE);
});
}
if (ActionHandlerStorage.getL(sessionId) != null && ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 1) {
if (TextUtils.isEmpty(SharedPreferencesEditor.getString("chat_age_ensure_" + ImIn.INSTANCE.getUserInfo().getUid()))) {
ServiceImpl.Companion.getInstance().getNewUserMes()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(hasCollectedInResp -> {
if (hasCollectedInResp.data != null && hasCollectedInResp.data.size() > 0) {
for (UserQuestInfoBean bean : hasCollectedInResp.data) {
if (TextUtils.equals(bean.getUserInfoType(), "age")) {
try {
String year = bean.getContent();
if ((Calendar.getInstance().get(Calendar.YEAR) - Integer.valueOf(year)) < 16) {
if (!getActivity().isFinishing()) {
showCheckAgeDialog();
}
}
} catch (Exception e) {
}
}
}
}
}, throwable -> {
});
}
}
}
private void addScrollListener() {
......@@ -1188,7 +1223,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(resp -> {
if (resp.data != null && resp.data.size() > 0) {
ServiceImpl.Companion.getInstance().userCollectList()
ServiceImpl.Companion.getInstance().getNewUserMes()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(hasCollectedInResp -> {
......@@ -1219,4 +1254,12 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}, throwable -> {
});
}
private void showCheckAgeDialog() {
CommonDialog.create(getActivity())
.setLeftOnclick("返回", v -> getActivity().finish())
.setRightClick("继续", v -> SharedPreferencesEditor.putString("chat_age_ensure_" + ImIn.INSTANCE.getUserInfo().getUid(), "ensure"))
.setCancelAble(false)
.show();
}
}
......@@ -31,6 +31,9 @@ class CollectInfoPopupWindow(var mContext: Context, var listener: OnSendMsgListe
listener.sendMsg("", ArrayList())
isFromBack = false
dismiss()
}, {
dismiss()
listener.finishPage()
}, { _content, _list ->
listener.sendMsg(_content, _list)
isFromBack = false
......@@ -79,6 +82,8 @@ class CollectInfoPopupWindow(var mContext: Context, var listener: OnSendMsgListe
interface OnSendMsgListener {
fun sendMsg(content: String, result: List<UserQuestInfoBean>)
fun finishPage()
}
}
\ No newline at end of file
......@@ -18,11 +18,13 @@ import android.widget.EditText
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.im.router.ImIn.getUserInfo
import com.yidianling.uikit.custom.http.response.UserQuestInfoBean
import kotlinx.android.synthetic.main.im_view_collect_user_infomation.view.*
import java.util.*
......@@ -40,14 +42,17 @@ import kotlin.collections.ArrayList
class CollectUserInformationView(
var mContext: Context,
var skipEvent: () -> Unit,
var backEvent: () -> Unit,
var sendMsgEvent: (content: String, list: List<UserQuestInfoBean>) -> Unit
) : LinearLayout(mContext) {
private var resultInfoList = ArrayList<UserQuestInfoBean>()
private var hasAge = false
private var hasGender = false
private var currentIndex = 0
private var isNeedShowCheckAgeDialog = false
private var year = 1994
private var dialog: CommonDialog? = null
private var ensureAgeDialog: CommonDialog? = null
private var ageStr = ""
private var genderStr = ""
private var questionStr = ""
......@@ -167,6 +172,9 @@ class CollectUserInformationView(
return@setOnClickListener
}
ageStr = "年龄:${(Calendar.getInstance().get(Calendar.YEAR) - year)}岁"
if ((Calendar.getInstance().get(Calendar.YEAR) - year) < 16) {
isNeedShowCheckAgeDialog = true
}
addContentView("${year}年", false)
tv_age_ensure.postDelayed({
......@@ -255,7 +263,12 @@ class CollectUserInformationView(
resultList.add(questionStyleBean)
resultList.add(questionBean)
sendMsgEvent(resultContent, resultList)
if (isNeedShowCheckAgeDialog) {
showCheckAgeEnsure(resultContent, resultList)
} else {
sendMsgEvent(resultContent, resultList)
}
}
}
......@@ -325,6 +338,30 @@ class CollectUserInformationView(
imm.showSoftInput(editTextMessage, 0)
}
private fun showCheckAgeEnsure(content: String, list: List<UserQuestInfoBean>) {
if (ensureAgeDialog == null) {
ensureAgeDialog = CommonDialog.create(mContext)
.setLeftOnclick("返回") {
backEvent()
ensureAgeDialog!!.dismiss()
}
.setRightClick("继续") {
SharedPreferencesEditor.putString(
"chat_age_ensure_${getUserInfo()!!.uid}",
"ensure"
)
sendMsgEvent(content, list)
ensureAgeDialog!!.dismiss()
}
.setMessage("由于您未满16周岁,如需咨询需要在家长陪同下进行")
.setTitle_color(R.color.im_color_242424)
.setCancelAble(true)
}
if (!ensureAgeDialog!!.isShowing) {
ensureAgeDialog!!.show()
}
}
fun showSkipDialog() {
if (dialog == null) {
dialog = CommonDialog.create(mContext)
......
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