Commit 9f789df6 by konghaorui

Merge branch 'dev' into feature/组件化_ending

# Conflicts:
#	app/src/main/java/com/ydl/component/MainActivity.kt
#	m-dynamic/src/main/java/com/yidianling/dynamic/publishTrend/fragment/PublishQuestionAndTrendFragment.java
#	ydl-platform/src/main/java/com/ydl/ydlcommon/utils/log/LogHelper.kt
#	ydl-platform/src/main/java/com/ydl/ydlcommon/view/banner/GlideImageDisplayLoader.java
parents 2a690b30 8cfe99cb
......@@ -205,6 +205,7 @@ dependencies {
implementation project(':m-muse')
implementation project(':m-im')
implementation project(':m-dynamic')
implementation project(':m-audioim')
// api rootProject.ext.dependencies["ydl-m-fm-module-ydl"]
......
......@@ -30,6 +30,8 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.fm.api.service.IFMService
import com.yidianling.tests.home.NewTestHomeActivity
import com.yidianling.user.widget.SecretDescriptionDialog
import com.yidianling.user.widget.SecretDialog
import kotlinx.android.synthetic.main.activity_main.*
/**
......@@ -85,7 +87,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
.navigation()
}
bt_to_consultant.setOnClickListener {
// ARouter.getInstance()
// ARouter.getInstance()
// .build("/consult/hot_search")
// .withString(
// HOT_SEARCH_DOCTOR_NAME,
......@@ -156,6 +158,36 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
bt_to_home.setOnClickListener {
FragmentContainerActivity.start(this, "MineFragment")
// startActivity(Intent(this, TestAppActivity::class.java))
// FragmentContainerActivity.start(this, "YdlHomeFragment")
// startActivity(Intent(this, TestAppActivity::class.java))
}
bt_to_test.setOnClickListener {
val dialog = SecretDescriptionDialog(this@MainActivity, "感谢您信任并使用壹点灵APP,\\n\n" +
"我们深知个人隐私的重要性,为了您更好的使用本APP,希望您着重关注:\\n\\n1. 为向您提供交易相关基本功能,我们会收集、使用必要的信息;\\n\n" +
"2. 基于您的明示授权,我们可能会获取您的位置(为您提供附近的咨询师等)、设备号信息(以保障您账号与交易安全)等信息,您有权拒绝或取消授权;\\n\n" +
"3. 我们会采业界先进的安全措施保护您的信息安全;\\n\n" +
"4. 未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;\\n\n" +
"5. 您可以查询、更正、删除您的个人信息。", object : SecretDescriptionDialog.OnSecretDescriptionDialogListener {
override fun onCancel() {
val secretDialog = SecretDialog(this@MainActivity, object : SecretDialog.OnSecretDialogListener {
override fun onCancel() {
ToastUtil.toastShort("onCancel")
}
override fun onSure() {
ToastUtil.toastShort("nextStep")
}
})
secretDialog?.show()
}
override fun onSure() {
ToastUtil.toastShort("nextStep")
}
}
)
dialog.show()
}
}
......
......@@ -185,6 +185,23 @@
android:layout_marginRight="10dp"
android:text="动态" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingBottom="20dp">
<Button
android:id="@+id/bt_to_test"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:text="入口" />
</LinearLayout>
</LinearLayout>
<com.ydl.ydlcommon.mvp.lce.view.YDLStateView
......
ext {
kotlin_version = "1.3.21"
dev_mode = true
dev_mode = false
ydl_app = [
appName : "心理咨询壹点灵",
......@@ -42,13 +42,13 @@ ext {
ydlPublishVersion = [
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.47.1",
"m-consultant" : "0.0.57",
"m-confide" : "0.0.47.7",
"m-consultant" : "0.0.57.4",
"m-fm" : "0.0.28",
"m-user" : "0.0.56",
"m-user" : "0.0.58.2",
"m-home" : "0.0.19.1",
"m-im" : "0.0.11",
"m-dynamic" : "0.0.5.1",
"m-im" : "0.0.14.1",
"m-dynamic" : "0.0.6.1",
"m-muse" : "0.0.27",
"m-tests" : "0.0.21",
......@@ -69,13 +69,13 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.37.1",
"ydl-platform" : "0.0.38.2",
//第二步 若干
"ydl-webview" : "0.0.37.1",
"ydl-media" : "0.0.20",
"ydl-pay" : "0.0.17",
"m-audioim" : "0.0.46",
"m-audioim" : "0.0.46.5",
"ydl-flutter-base": "0.0.10",
//以下 几乎不会动
......@@ -115,13 +115,13 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.37",
"ydl-platform" : "0.0.38.2",
//第二步 若干
"ydl-webview" : "0.0.37.1",
"ydl-media" : "0.0.20",
"ydl-pay" : "0.0.17",
"m-audioim" : "0.0.46",
"m-audioim" : "0.0.46.5",
"ydl-flutter-base": "0.0.10",
//以下 几乎不会动
......@@ -260,6 +260,7 @@ ext {
"exoplayer" : "com.google.android.exoplayer:exoplayer:2.9.0",
"free_reflection" : "me.weishu:free_reflection:2.0.0",
"imagepicker" : "com.ydl:imagepicker:1.0.8.2",
"pictureselector" : "com.ydl:pictureselector:1.2.0",
"protector" : "com.ydl:protector:1.0.1-SNAPSHOT@aar",
"ydl-hnet" : "com.ydl:h-net:0.0.8",
"ydl-user-router" : "com.ydl:router:1.0.0-SNAPSHOT@aar",
......
......@@ -24,6 +24,22 @@ import android.view.animation.AccelerateInterpolator
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.tbruyelle.rxpermissions2.RxPermissions
import com.ydl.audioim.bean.AgoraLogInfoBean
import com.ydl.audioim.contract.IAudioHomeActivityContract
import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand
import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.burypointlib.ToastUtil
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.ChannelManager
import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.messge_service.bean.RTMMesssage
......@@ -36,22 +52,12 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.audioim.contract.IAudioHomeActivityContract
import com.ydl.audioim.http.command.*
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.burypointlib.ToastUtil
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
......@@ -72,7 +78,8 @@ import java.util.concurrent.TimeUnit
* @date 2018/10/30
*/
@Route(path = "/av/AudioHomeActivity")
class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),IAudioHomeActivityContract.View, SensorEventListener {
class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),
IAudioHomeActivityContract.View, SensorEventListener {
/**
* 专家头像地址
......@@ -93,7 +100,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
/**
* 通话开始时间(接通)
*/
private var callStartTime:Long? = null
private var callStartTime: Long? = null
/**
* 倾诉剩余时长(时长单位s,eg:剩余2min15s,返回135)
*/
......@@ -161,9 +168,10 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private var voiceManage: YDLVoiceManager? = null
//频道管理器
private var channelManager : ChannelManager? = null
private var channelManager: ChannelManager? = null
private var isLeavelChannel:Boolean = false
private var isLeavelChannel: Boolean = false
private var hasUpLoadLog = false
/**
* 声网事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
......@@ -186,6 +194,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
when (warn) {
103, 104, 105, 106, 107 -> {
showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
}
}
......@@ -255,6 +265,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断
if (isConnectSuccess && null != stats?.users && stats.users == 1) {
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
}
}
......@@ -264,6 +276,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if (reason == 3) {
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
}
}
......@@ -271,6 +285,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onLeaveChannel(stats: IRtcEngineEventHandler.RtcStats?) {
super.onLeaveChannel(stats)
LogUtil.e("[agora]离开频道回调")
//通话结束或挂断时,上传日志文件
uploadLog()
}
override fun onLastmileQuality(quality: Int) {
......@@ -296,6 +312,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onUserOffline(uid: Int, elapsed: Int) {
super.onUserOffline(uid, elapsed)
LogUtil.e("[agora]远端用户$uid 离开频道回调")
//通话结束或挂断时,上传日志文件
uploadLog()
showToast("专家已挂断")
if (totalDisposable != null) {
......@@ -315,7 +333,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private fun uploadException(message: String) {
var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(channelId?:"0", time, uid, "1", "999", message)
var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message)
var connectException = ConnectExceptionCommand(time, "2", "99", payLoad)
getPresenter().connectException(connectException)
}
......@@ -371,11 +389,36 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID)
commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL)
writeAgoraLog()
localRemainTime = remainTime?.toInt()
handler = Handler()
vibrator = getSystemService(Service.VIBRATOR_SERVICE) as Vibrator?
}
private fun writeAgoraLog() {
val logBean = AgoraLogInfoBean(
expertHeadUrl,
expertName,
channelId,
remainTime,
listenerUid,
totalDuration,
callId,
listenId
)
Observable.create<Any> {
try {
val content = Gson().toJson(logBean)
AudioLogUtils.writeAgoraLog(content)
} catch (e: Exception) {
}
}.subscribeOn(Schedulers.io())
.subscribe()
}
private fun initView() {
tv_change_route.isEnabled = false
//水波纹view初始化
......@@ -441,7 +484,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private fun setCallBack() {
YDLRTMClient.instances.setCallListener(object :CallListener{
YDLRTMClient.instances.setCallListener(object : CallListener {
override fun onCallRecivedByPeer(response: CallLocalResponse?) {
//返回给主叫:被叫已收到呼叫邀请
LogUtil.i("[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}")
......@@ -455,7 +498,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onCallRefused(response: CallLocalResponse?) {
//返回给主叫
LogUtil.i("[agora]${response?.calleeId}已拒绝呼叫邀请")
ToastUtil.showToast(applicationContext,"对方已挂断")
ToastUtil.showToast(applicationContext, "对方已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
}
......@@ -498,7 +543,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
LogUtil.i("[agora]其它消息:${error}")
}
})
channelManager = YDLRTMClient.instances.createChannelManager(channelId,object :ChannelListener{
channelManager = YDLRTMClient.instances.createChannelManager(channelId, object : ChannelListener {
override fun onMemberCountUpdated(memberCount: Int) {
//频道人数更新
LogUtil.i("[agora]当前频道人数:$memberCount")
......@@ -506,7 +551,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onMessageReceived(message: RTMMesssage?, member: ChannelMember?) {
//接到频道消息
LogUtil.i("[agora]接到${member?.channelId}频道${member?.userId}的消息:"+message?.text)
LogUtil.i("[agora]接到${member?.channelId}频道${member?.userId}的消息:" + message?.text)
}
override fun onMemberJoined(member: ChannelMember?) {
......@@ -527,22 +572,22 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private fun requestPermission() {
val rxPermissions = RxPermissions(this)
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO)
.subscribe { permission ->
if (permission.granted) {
init()
} else if (permission.shouldShowRequestPermissionRationale) {
requestPermission()
} else {
ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
finish()
}
.subscribe { permission ->
if (permission.granted) {
init()
} else if (permission.shouldShowRequestPermissionRationale) {
requestPermission()
} else {
ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
finish()
}
}
}
@SuppressLint("CheckResult")
......@@ -552,39 +597,42 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
initializeAgoraEngine()
//发起呼叫
var msgBean = AudioMessageBean(
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
)
YDLRTMClient.instances.call(listenerUid!!,channelId,Gson().toJson(msgBean))
YDLRTMClient.instances.call(listenerUid!!, channelId, Gson().toJson(msgBean))
//开始25s等待倒计时
Observable.interval(0, 100, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.computation())
.take(253)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
progress_view.setProgress(it.toFloat() / 2.5f)
}, {
LogUtil.d(it.message)
}, {
waittingStatus()
if (!isConnectSuccess){
.subscribeOn(Schedulers.computation())
.take(253)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
progress_view.setProgress(it.toFloat() / 2.5f)
}, {
LogUtil.d(it.message)
}, {
waittingStatus()
if (!isConnectSuccess) {
// iv_hang_up.setImageResource(R.mipmap.audioim_ico_close)
//关闭音乐
stopPlaying()
//提示切换传统线路
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid,channelId)
showChooseDialog(2)
}
})
//关闭音乐
stopPlaying()
//提示切换传统线路
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid, channelId)
//通话结束或挂断时,上传日志文件
uploadLog()
showChooseDialog(2)
}
})
//加入频道135
joinChannel()
//双重保险:加入频道成功,通过服务端发推送给专家
......@@ -611,7 +659,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* 声网加入频道
*/
private fun joinChannel() {
voiceManage!!.getVoiceApi().joinChannel(token!!, channelId!!, "Extra Optional Data", YdlCommonRouterManager.getYdlCommonRoute().getUid())
voiceManage!!.getVoiceApi().joinChannel(
token!!,
channelId!!,
"Extra Optional Data",
YdlCommonRouterManager.getYdlCommonRoute().getUid()
)
}
/**
......@@ -621,7 +674,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
*/
private fun userCloseCalling() {
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid,channelId)
YDLRTMClient.instances.cancelCall(listenerUid, channelId)
//通话结束或挂断时,上传日志文件
uploadLog()
handler!!.postDelayed({
leaveChannel()
}, 100)
......@@ -633,7 +688,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* @param finishStatus 状态值: 0:开始 1:结束
*/
private fun updateExpertStatus(isSwitchAxb: Boolean, finishStatus: Int) {
if (isSwitchAxb){
if (isSwitchAxb) {
dialPhone()
}
......@@ -659,9 +714,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
/**
* 线路选择弹窗
*/
private fun showChooseDialog(type:Int) {
private fun showChooseDialog(type: Int) {
val dialog = AxbConfirmDialog(mContext,type, object : AxbConfirmDialog.OnClickEnsureListener {
val dialog = AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
switchAXB()
}
......@@ -681,7 +736,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* 切换成axb路线请求
*/
private fun switchAXB() {
mPresenter.getAXBPhone(ConnectCommand(listenId!!,"1"))
mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
}
/**
......@@ -692,12 +747,14 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
this.axbPhone = axbPhone
isJumpDail = true
if (isConnectSuccess) {
//通话结束或挂断时,上传日志文件
uploadLog()
//已经连接成功,切换axb时需要更新专家状态
updateExpertStatus(true, 1)
} else {
//未连接成功,切换axb时:需发送消息通知专家端用户已挂断
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid,channelId)
YDLRTMClient.instances.cancelCall(listenerUid, channelId)
leaveChannel()
}
}
......@@ -730,7 +787,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
tv_change_route.isEnabled = true
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.platform_white))
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow), null)
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow),
null
)
}
......@@ -851,32 +913,39 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//剩余倾诉时长倒计时
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.take(remainTime!!.toLong() + 1)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
localRemainTime = remainTime!!.toInt() - it.toInt()
if (localRemainTime == 180) {
playNoticeMusic(3)
}
if (localRemainTime == 60) {
playNoticeMusic(1)
}
if (localRemainTime!! <= 60) {
if (tv_change_route.isEnabled) {
tv_change_route.isEnabled = false
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.audioim_color_50ffffff))
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow_unuse), null)
}
.subscribeOn(Schedulers.computation())
.take(remainTime!!.toLong() + 1)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
localRemainTime = remainTime!!.toInt() - it.toInt()
if (localRemainTime == 180) {
playNoticeMusic(3)
}
if (localRemainTime == 60) {
playNoticeMusic(1)
}
if (localRemainTime!! <= 60) {
if (tv_change_route.isEnabled) {
tv_change_route.isEnabled = false
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.audioim_color_50ffffff))
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow_unuse),
null
)
}
tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString())
}, {
LogUtil.d(it.message)
}, {
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
showToast("通话已结束")
updateExpertStatus(false, 1)
})
}
tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString())
}, {
LogUtil.d(it.message)
}, {
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
showToast("通话已结束")
//通话结束或挂断时,上传日志文件
uploadLog()
updateExpertStatus(false, 1)
})
}
/**
......@@ -907,16 +976,16 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
*/
private fun noticeServerPush(isCall: Boolean) {
var msgBean = AudioMessageBean(
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
)
var cmd = NoticePushCommand()
cmd.data = msgBean
......@@ -946,7 +1015,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onResume() {
super.onResume()
sensorManager!!.registerListener(this, sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_NORMAL)
sensorManager!!.registerListener(
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL
)
}
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
......@@ -984,14 +1057,14 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//// tv_toast.postDelayed({
//// tv_toast.visibility = View.GONE
//// }, 1000)
ToastHelper.show(msg?:"")
ToastHelper.show(msg ?: "")
}
}
override fun showProgressView() {
try {
showProgressDialog()
}catch (e : Exception){
} catch (e: Exception) {
e.printStackTrace()
}
......@@ -1000,12 +1073,19 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun dismissProgressView() {
try {
dismissProgressDialog()
}catch (e:Exception){
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun uploadLog() {
if (!hasUpLoadLog) {
hasUpLoadLog = true
LogHelper.getInstance().uploadLog(false)
}
}
override fun finishActivity() {
leaveChannel()
}
......@@ -1016,6 +1096,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
handler = null
}
hasUpLoadLog = false
if (waitDisposable != null) {
waitDisposable!!.dispose()
}
......
package com.ydl.audioim.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/2/12
*/
class AgoraLogInfoBean(
/**
* 专家头像地址
*/
private var expertHeadUrl: String? = null,
/**
* 专家姓名
*/
private var expertName: String? = null,
/**
* 声网点对点聊天房间id
*/
private var channelId: String? = null,
/**
* 倾诉剩余时长(时长单位s,eg:剩余2min15s,返回135)
*/
private var remainTime: String? = null,
/**
* listenerUid专家uid
*/
private var listenerUid: String? = null,
/**
* 倾述总时长
*/
private var totalDuration: Int? = 0,
/**
* callId
*/
private var callId: String? = null,
/**
*聆听者id(不是聆听者的uid)
*/
private var listenId: String? = null
)
\ No newline at end of file
package com.ydl.audioim.utils
import android.annotation.SuppressLint
import com.ydl.audioim.BuildConfig
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxNetTool
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
/**
* @author jiucheng
* @描述:记录声网双方信息相关的日志工具
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/2/12
*/
class AudioLogUtils {
companion object {
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeAgoraLog(content: String) {
Observable.create<Any> {
try {
writeLog(content)
if (BuildConfig.DEBUG) {
LogUtil.d("writeLog_complete")
}
} catch (e: Exception) {
}
}.subscribeOn(Schedulers.io())
.subscribe()
}
private fun writeLog(content: String) {
try {
val folder = getLogFolder()
val file = File(folder, "AgoraInfoLog")
if (!file.exists() || !file.isFile) {
file.createNewFile()
}
val fileWriter = FileWriter(file, true)
val writer = BufferedWriter(fileWriter)
writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine()
writer.write("UserUid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine()
writer.write("""DevicesInfo:${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()}""")
writer.newLine()
writer.write("""VersionInfo:${RxAppTool.getAppVersionName(BaseApp.getApp())}""")
writer.newLine()
writer.write("AgoraLog:$content")
writer.newLine()
writer.write("--------")
writer.newLine()
writer.flush()
writer.close()
} catch (e: IOException) {
e.printStackTrace()
}
}
//获取app运行日志文件夹
private fun getLogFolder(): File {
val cacheDir = BaseApp.getApp().externalCacheDir.absolutePath
val logFolder = File(cacheDir, "log")
if (!logFolder.exists() || !logFolder.isDirectory) {
logFolder.mkdir()
}
val folder = File(logFolder, "NewYdlApp")
if (!folder.exists() || !folder.isDirectory) {
folder.mkdir()
}
return folder
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
* 导医跳转私聊的中间页面,用于统一路由
*/
@Route( path = "/chat/ChatService")
@Route( path = "/consult/ChatService")
class ConsultAssistantCenterActivity : BaseActivity() {
override fun initDataAndEvent() {
supportActionBar?.hide()
......
......@@ -77,7 +77,6 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
// holder.tvDesc.text = itemBean.famousRemark
// }
//服务中
if (itemBean.inConsult || itemBean.isListening) {
holder.imgHead_online_server.visibility = View.VISIBLE
......@@ -110,59 +109,82 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
}else{
holder.tvCity.text = ""
}
//能力等级标签
if (1 == itemBean.abilityLevel){
//实习
holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_shixi)
holder.imgAbilityLevel.visibility = View.VISIBLE
}else if (2 == itemBean.abilityLevel){
//新手
holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_xinshou)
holder.imgAbilityLevel.visibility = View.VISIBLE
}
// else if (3 == itemBean.abilityLevel){
// //精英
// holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_jingying)
// holder.imgAbilityLevel.visibility = View.VISIBLE
// }
else{
holder.imgAbilityLevel.visibility = View.GONE
}
//活动图标
if (!TextUtils.isEmpty(itemBean.activityImg)){
holder.imgActivity.visibility = View.VISIBLE
GlideApp.with(context).load(itemBean.activityImg).into(holder.imgActivity)
// GlideApp.with(context).load("https://video.ydlcdn.com/2019/11/04/abdd3782c98939d0406080a6a80b8ea5.jpg").into(holder.imgActivity)
}else{
holder.imgActivity.visibility = View.GONE
}
//公益图标
if (1 == itemBean.hasServiceFree){
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.serviceFreeIcon)){
expertSearchView.showImage(itemBean.tagsIcon.serviceFreeIcon,holder.imgServiceFree)
}else{
//公益图标,不与其他图标冲突
if (1 == itemBean.hasServiceFree) {
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.serviceFreeIcon)) {
expertSearchView.showImage(
itemBean.tagsIcon.serviceFreeIcon,
holder.imgServiceFree
)
} else {
val sp = SimpleImageOpConfiger()
sp.loadingPic = R.drawable.consultant_service_free
sp.errorPic = R.drawable.consultant_service_free
expertSearchView.showImage("",holder.imgServiceFree,sp)
expertSearchView.showImage("", holder.imgServiceFree, sp)
}
holder.imgServiceFree.visibility = View.VISIBLE
}else{
} else {
holder.imgServiceFree.visibility = View.GONE
}
//新驻图标
if (itemBean.isNewEnter){
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.newEnterIcon)){
expertSearchView.showImage(itemBean.tagsIcon.newEnterIcon,holder.imgNewEnter)
}else{
val sp = SimpleImageOpConfiger()
sp.loadingPic = R.drawable.consultant_new_enter
sp.errorPic = R.drawable.consultant_new_enter
expertSearchView.showImage("",holder.imgNewEnter,sp)
// 展示了抗疫,就不展示其他标签
if (itemBean.fightEpidemicIconShow) {
itemBean.tagsIcon?.fightEpidemicIcon?.let {
GlideApp.with(context).load(itemBean.tagsIcon?.fightEpidemicIcon)
.into(holder.imgFightEpidemicIcon)
holder.imgFightEpidemicIcon.visibility = View.VISIBLE
}
holder.imgNewEnter.visibility = View.VISIBLE
}else{
//影藏其余所有标签(除公益)
holder.imgAbilityLevel.visibility = View.GONE
holder.imgActivity.visibility = View.GONE
holder.imgNewEnter.visibility = View.GONE
} else {
holder.imgFightEpidemicIcon.visibility = View.GONE
//能力等级标签
if (1 == itemBean.abilityLevel) {
//实习
holder.imgAbilityLevel.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_shixi)
holder.imgAbilityLevel.visibility = View.VISIBLE
} else if (2 == itemBean.abilityLevel) {
//新手
holder.imgAbilityLevel.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_xinshou)
holder.imgAbilityLevel.visibility = View.VISIBLE
}
// else if (3 == itemBean.abilityLevel){
// //精英
// holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_jingying)
// holder.imgAbilityLevel.visibility = View.VISIBLE
// }
else {
holder.imgAbilityLevel.visibility = View.GONE
}
//活动图标
if (!TextUtils.isEmpty(itemBean.activityImg)) {
holder.imgActivity.visibility = View.VISIBLE
GlideApp.with(context).load(itemBean.activityImg).into(holder.imgActivity)
// GlideApp.with(context).load("https://video.ydlcdn.com/2019/11/04/abdd3782c98939d0406080a6a80b8ea5.jpg").into(holder.imgActivity)
} else {
holder.imgActivity.visibility = View.GONE
}
//新驻图标
if (itemBean.isNewEnter) {
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.newEnterIcon)) {
expertSearchView.showImage(
itemBean.tagsIcon.newEnterIcon,
holder.imgNewEnter
)
} else {
val sp = SimpleImageOpConfiger()
sp.loadingPic = R.drawable.consultant_new_enter
sp.errorPic = R.drawable.consultant_new_enter
expertSearchView.showImage("", holder.imgNewEnter, sp)
}
holder.imgNewEnter.visibility = View.VISIBLE
} else {
holder.imgNewEnter.visibility = View.GONE
}
}
holder.ll_feedbackRate.removeAllViews()
for (num in 1..5){
......@@ -330,6 +352,8 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
val imgHead_online_server = itemView.imgHead_online_server!!
//多少人在问询
val chat_people_in_question = itemView.people_in_question!!
// 抗疫先锋图标
val imgFightEpidemicIcon = itemView.img_fightEpidemicIcon
init {
itemView.setOnClickListener {
......
......@@ -19,4 +19,8 @@ data class ExpertSearchTagsIconBean(
/**
* 新入驻图标
*/
val newEnterIcon : String?)
\ No newline at end of file
val newEnterIcon : String?,
/**
* 抗疫先锋图标地址
*/
var fightEpidemicIcon: String? = null)
\ No newline at end of file
......@@ -60,6 +60,10 @@ data class DoctorServiceItem(
*/
var feedbackRate: Float = 0f,
/**
* 是否抗疫先锋图标
*/
var fightEpidemicIconShow: Boolean = false,
/**
* 评价数(咨询订单数)
*/
var zixunOrderNum: Int = 0,
......
......@@ -75,18 +75,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingLeft="8dp"
android:gravity="center_vertical"
android:layout_alignTop="@+id/tvName"
android:layout_alignBottom="@+id/tvName"
android:layout_toEndOf="@+id/tvName"
android:layout_marginStart="@dimen/platform_dp_2">
<ImageView
android:id="@+id/img_fightEpidemicIcon"
android:layout_width="53dp"
android:layout_height="@dimen/platform_dp_17"
android:layout_marginRight="4dp"
android:scaleType="centerCrop"
android:visibility="gone"/>
<!--活动图标-->
<ImageView
android:id="@+id/img_activity"
android:layout_width="42dp"
android:layout_height="12dp"
android:layout_marginStart="@dimen/platform_dp_4"
android:layout_marginRight="4dp"
android:visibility="gone"/>
<!--公益图标-->
......
......@@ -20,6 +20,7 @@ import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.luck.picture.lib.photoview.PhotoView;
import com.miracle.view.imageeditor.utils.FileUtils;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseActivity;
......@@ -39,8 +40,6 @@ import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;
/**
* 预览大图
......@@ -324,12 +323,7 @@ public class BrowsePicturesActivity extends BaseActivity implements ViewPager.On
.load(uri)
.error(R.drawable.dynamic_default_img)
.into(mDatas.get(position));
mDatas.get(position).setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
finish();
}
});
mDatas.get(position).setOnPhotoTapListener((imageView, v, v1) -> finish());
((ViewPager) container).addView(mDatas.get(position), 0);
// if (lodingDialog != null) {
// lodingDialog.dismiss();
......
......@@ -17,6 +17,7 @@ import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.luck.picture.lib.photoview.PhotoView;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseActivity;
import com.yidianling.common.tools.ToastUtil;
......@@ -28,11 +29,6 @@ import com.yidianling.dynamic.common.tool.ImageDownLoadCallBack;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;
/**
* 预览大图 2 集合范型为String
*/
......@@ -257,12 +253,7 @@ public class BrowsePicturesActivity2 extends BaseActivity implements ViewPager.O
.load(mImages.get(position))
.error(R.drawable.dynamic_default_img)
.into(mDatas.get(position));
mDatas.get(position).setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
finish();
}
});
mDatas.get(position).setOnPhotoTapListener((imageView, v, v1) -> finish());
((ViewPager)container).addView(mDatas.get(position), 0);
// if (lodingDialog != null) {
// lodingDialog.dismiss();
......
......@@ -32,15 +32,14 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.view.CropImageView;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback;
import com.ydl.ydlcommon.adapter.custom.PublishImageAdapter;
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.BaseFragment;
......@@ -69,8 +68,6 @@ import com.yidianling.dynamic.publishTrend.PublishTrendActivity;
import com.yidianling.dynamic.publishTrend.SelecTopicActivity;
import com.yidianling.dynamic.router.DynamicIn;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
......@@ -197,17 +194,6 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
@Override
public void initDataAndEventLazy() {
rxPermissions = new RxPermissions(getActivity());
ImagePicker imagePicker = ImagePicker.getInstance();
imagePicker.setImageLoader(new GlideImageDisplayLoader()); //设置图片加载器
imagePicker.setShowCamera(true); //显示拍照按钮
imagePicker.setCrop(true); //允许裁剪(单选才有效)
imagePicker.setSaveRectangle(true); //是否按矩形区域保存
imagePicker.setSelectLimit(9); //选中数量限制
imagePicker.setStyle(CropImageView.Style.RECTANGLE); //裁剪框的形状
imagePicker.setFocusWidth(800); //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.setFocusHeight(800); //裁剪框的高度。单位像素(圆形自动取宽高最小值)
imagePicker.setOutPutX(1000);//保存文件的宽度。单位像素
imagePicker.setOutPutY(1000);//保存文件的高度。单位像素
imgFiles = new ArrayList<File>();
initView();
uiHandler = new Handler();
......@@ -770,25 +756,22 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
}
private static final int PICK_IMAGE_COUNT = 9;
private static final int PORTRAIT_IMAGE_WIDTH = 720;
private static final String JPG = ".jpg";
private void showSelector() {
ImagePicker.getInstance().setEdit(true);
DynamicIn.INSTANCE.startPicker((BaseActivity) activity, false, new PickerCallback() {
int selectedSize = publishTrendImgs.size()!=0?publishTrendImgs.size()-1:0;
YDLImagePicker.INSTANCE.startPicker((BaseActivity) activity, 9 - selectedSize,new OnResultCallbackListener() {
@Override
public void onSuccess(@NotNull ArrayList<ImageItem> images) {
if (images.isEmpty()) {
public void onResult(List<LocalMedia> list) {
if (list.isEmpty()) {
return;
}
for (int i = 0; i < images.size(); i++) {
AddImag(images.get(i).uri.toString());
for (int i = 0; i < list.size(); i++) {
AddImag(list.get(i).getPath());
}
}
@Override
public void onFail() {
public void onCancel() {
}
});
......
......@@ -6,8 +6,6 @@ import android.support.v4.app.DialogFragment
import android.support.v7.app.AppCompatActivity
import com.ydl.confide.api.IConfideService
import com.ydl.course.api.ICourseService
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback
import com.ydl.ydlcommon.actions.imagepicker.YdlImagePicker
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.consultant.api.IConsultantService
......@@ -168,10 +166,6 @@ object DynamicIn {
getImService().showSelector(activity, requestCode)
}
fun startPicker(activity: AppCompatActivity, openCamera: Boolean, callback: PickerCallback) {
YdlImagePicker.startPicker(activity, openCamera, callback)
}
/**
* 课程播放页
*/
......
......@@ -4,20 +4,16 @@ import android.Manifest;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.lzy.imagepicker.bean.ImageItem;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.miracle.view.imageeditor.utils.FileUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback;
import com.ydl.ydlcommon.actions.imagepicker.YdlImagePicker;
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.nimbase.business.session.actions.BaseAction;
import com.yidianling.nimbase.common.ToastHelper;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhoujianghua on 2015/7/31.
......@@ -58,19 +54,23 @@ public abstract class PickImageAction extends BaseAction {
}
private void selectImage(){
YdlImagePicker.INSTANCE.startPicker((AppCompatActivity) getActivity(), false, new PickerCallback() {
YDLImagePicker.INSTANCE.startPicker((AppCompatActivity) getActivity(),9, new OnResultCallbackListener() {
@Override
public void onSuccess(@NotNull ArrayList<ImageItem> images) {
for (int i = 0; i < images.size(); i++) {
onPicked(FileUtils.INSTANCE.getFileByUri(getActivity(),images.get(i).uri.toString()));
public void onResult(List<LocalMedia> list) {
if (list.isEmpty()) {
return;
}
for (int i = 0; i < list.size(); i++) {
onPicked(FileUtils.INSTANCE.getFileByUri(getActivity(),list.get(i).getPath()));
}
}
@Override
public void onFail() {
ToastHelper.showToast(getActivity(), R.string.im_picker_image_error);
public void onCancel() {
}
});
}
}
......@@ -18,6 +18,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.luck.picture.lib.photoview.PhotoView;
import com.netease.nimlib.sdk.AbortableFuture;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer;
......@@ -48,8 +49,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import uk.co.senab.photoview.PhotoView;
/**
* 查看聊天消息原图
* Created by huangjun on 2015/3/6.
......
......@@ -6,7 +6,7 @@
android:gravity="center"
android:orientation="vertical" >
<uk.co.senab.photoview.PhotoView
<com.luck.picture.lib.photoview.PhotoView
android:id="@+id/watch_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......
package com.yidianling.user;
import android.app.Activity;
import android.net.Uri;
import android.widget.ImageView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.lzy.imagepicker.loader.ImageLoader;
import com.ydl.ydl_image.config.ISimpleImageOpConfig;
import com.ydl.ydl_image.config.SimpleImageOpConfiger;
import com.ydl.ydl_image.manager.YDLImageCacheManager;
import com.ydl.ydl_image.module.GlideApp;
/**
* Created by xiongyu on 2017/4/7.
*/
public class GlideImageLoader implements ImageLoader {
@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
}
@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
}
@Override
public void displayImage(Activity activity, Uri uri, ImageView imageView, int i, int i1) {
GlideApp.with(activity) //配置上下文
.load(uri) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(com.ydl.ydlcommon.R.drawable.platform_default_img) //设置错误图片
.placeholder(com.ydl.ydlcommon.R.drawable.platform_default_img) //设置占位图片
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
}
private void showImage(Activity activity, String path, ImageView imageView, int width, int height){
SimpleImageOpConfiger sp = new SimpleImageOpConfiger();
sp.loadingPic = R.drawable.platform_default_img;
sp.errorPic = R.drawable.platform_default_img;
sp.scaleType = ISimpleImageOpConfig.CENTER_CROP;
sp.isCacheOnDisk = false;
YDLImageCacheManager.showImage(activity,path,imageView,width, height,sp);
}
@Override
public void clearMemoryCache() {
}
}
......@@ -14,10 +14,9 @@ import android.text.TextWatcher
import android.view.View
import android.widget.Toast
import com.alibaba.android.arouter.facade.annotation.Route
import com.lzy.imagepicker.ImagePicker
import com.lzy.imagepicker.bean.ImageItem
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback
import com.ydl.ydlcommon.actions.imagepicker.YdlImagePicker
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.listener.OnResultCallbackListener
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker
import com.ydl.ydlcommon.adapter.custom.PublishImageAdapter
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.PlatformDataManager
......@@ -25,7 +24,6 @@ import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.ui.ParcelableImage
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.ydl.ydlcommon.view.banner.GlideImageDisplayLoader
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
......@@ -207,25 +205,22 @@ class FeedBackActivity : BaseActivity(), View.OnClickListener {
}
private fun showSelector() {
ImagePicker.getInstance().selectLimit = 1
val imagePicker = ImagePicker.getInstance()
imagePicker.imageLoader = GlideImageDisplayLoader()
imagePicker.selectLimit = 1 //选中数量限制
YdlImagePicker.startPicker(this as BaseActivity, false, object : PickerCallback {
override fun onFail() {
}
override fun onSuccess(images: ArrayList<ImageItem>) {
if (images.isEmpty()) {
YDLImagePicker.startPicker(this as BaseActivity, object : OnResultCallbackListener {
override fun onResult(list: List<LocalMedia>) {
if (list.isEmpty()) {
return
}
for (i in images.indices) {
addImag(images[i].path)
for (i in list.indices) {
addImag(list[i].path)
}
}
override fun onCancel() {
}
})
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
......
package com.yidianling.user.ui;
import android.Manifest;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
......@@ -15,13 +14,13 @@ import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.ui.ImageGridActivity;
import com.lzy.imagepicker.view.CropImageView;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.miracle.view.imageeditor.utils.FileUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.webview.RefreshWebEvent;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.data.http.RxUtils;
......@@ -34,11 +33,8 @@ import com.ydl.ydlcommon.view.ListNoCancelDialog;
import com.ydl.ydlcommon.view.RoundCornerButton;
import com.ydl.ydlcommon.view.TitleBar;
import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.ydl.ydlcommon.view.dialog.ThreeLinesDialog;
import com.yidianling.common.tools.RxFileTool;
import com.yidianling.common.tools.RxImageTool;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.user.GlideImageLoader;
import com.yidianling.user.LoginHelper;
import com.yidianling.user.R;
import com.yidianling.user.UserConstants;
......@@ -133,18 +129,6 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
void init() {
rxPermissions = new RxPermissions(this);
head_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/yidianling/img/head_img/";
ImagePicker imagePicker = ImagePicker.getInstance();
imagePicker.setImageLoader(new GlideImageLoader()); //设置图片加载器
imagePicker.setShowCamera(true); //显示拍照按钮
imagePicker.setCrop(true); //允许裁剪(单选才有效)
imagePicker.setMultiMode(false);
imagePicker.setSaveRectangle(true); //是否按矩形区域保存
imagePicker.setSelectLimit(1); //选中数量限制
imagePicker.setStyle(CropImageView.Style.RECTANGLE); //裁剪框的形状
imagePicker.setFocusWidth(800); //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.setFocusHeight(800); //裁剪框的高度。单位像素(圆形自动取宽高最小值)
imagePicker.setOutPutX(300);//保存文件的宽度。单位像素
imagePicker.setOutPutY(300);//保存文件的高度。单位像素
if (!TextUtils.isEmpty(icon)) {
GlideApp.with(FillInfoActivity.this)
.load(icon)
......@@ -214,29 +198,23 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
public void onClick(View v) {
int id = v.getId();
if (id == R.id.sdv_head) {
rxPermissions.request(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(granted -> {
if (granted) {
ThreeLinesDialog.Builder builder1 = new ThreeLinesDialog.Builder(FillInfoActivity.this);
builder1.setTitle("相机");
builder1.setMessage("相册中选择");
builder1.setbottom("取消");
builder1.setFirstButton("相机", (dialog, which) -> {
head_path = head_dir + System.currentTimeMillis() + "hand_carmer.jpg";
showCameraAction(REQUEST_CODE_FILL_CAMER_HEAD, head_path);
dialog.dismiss();
});
builder1.setSecondButton("相册中选择", (dialog, which) -> {
Intent intent = new Intent(FillInfoActivity.this, ImageGridActivity.class);
startActivityForResult(intent, IMAGE_PICKER);
dialog.dismiss();
});
builder1.setThridButton("取消", (dialog, which) -> dialog.dismiss());
builder1.create().show();
} else {
ToastHelper.Companion.show("缺少使用相机和读取存储权限,无法获取图片");
}
});
YDLImagePicker.INSTANCE.startPicker(FillInfoActivity.this, new OnResultCallbackListener() {
@Override
public void onResult(List<LocalMedia> list) {
if (list.isEmpty()) {
return;
}
for (int i = 0; i < list.size(); i++) {
uploadImage(list.get(0).getPath(), 1002);
}
}
@Override
public void onCancel() {
}
});
} else if (id == R.id.tv_sex) {
List<String> name = new ArrayList<String>();
name.add("男");
......@@ -436,19 +414,6 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
}
break;
}
} else if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
switch (requestCode) {
case IMAGE_PICKER:
if (data != null) {
ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
uploadImage(images.get(0).path, 1002);
} else {
ToastUtil.toastShort(this, "没有数据");
}
break;
}
}
}
......@@ -498,7 +463,8 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
*/
void uploadImage(final String path, final int requestCode) {
UserHttp userHttp = UserHttpImpl.Companion.getInstance();
userHttp.uploadHead(new HeadParam(new File(path)))
File outputFile = FileUtils.INSTANCE.getFileByUri(FillInfoActivity.this,path);
userHttp.uploadHead(new HeadParam(outputFile))
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(disposable -> {
......
......@@ -82,13 +82,13 @@ class SecretActivity : BaseActivity() {
agreeAction()
}
user_use_btn.setOnClickListener {
H5Activity.start(this@SecretActivity, false)
}
user_secret_protect_btn.setOnClickListener {
H5Activity.start(this@SecretActivity, true)
}
// user_use_btn.setOnClickListener {
// H5Activity.start(this@SecretActivity, false)
// }
//
// user_secret_protect_btn.setOnClickListener {
// H5Activity.start(this@SecretActivity, true)
// }
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
......
package com.yidianling.user.widget
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import android.text.Html
import android.text.SpannableString
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.text.style.ForegroundColorSpan
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.Utils
import com.yidianling.user.R
import com.yidianling.user.ui.login.H5Activity
import kotlinx.android.synthetic.main.user_activity_secret.*
class SecretDescriptionDialog(
var mContext: Context,
var mSecretProtocolString: String,
private val listener: OnSecretDescriptionDialogListener?
) : Dialog(mContext, R.style.platform_dialog_default_style) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.user_activity_secret)
val params = window.attributes
params.width = WindowManager.LayoutParams.MATCH_PARENT
params.height = WindowManager.LayoutParams.WRAP_CONTENT
window.setGravity(Gravity.CENTER)
window.attributes = params
user_secret_desc.text = Html.fromHtml(mSecretProtocolString)
user_secret_no_agree.setOnClickListener {
listener?.onCancel()
}
user_secret_agree.setOnClickListener {
agreeAction()
}
val str = "阅读完整版《用户使用协议》、《隐私保护政策》"
val spannableString = SpannableString(str)
// spannableString.setSpan(
// ForegroundColorSpan(Color.parseColor("#159CEF")),
// 5,
// 13,
// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
// )
// spannableString.setSpan(
// ForegroundColorSpan(Color.parseColor("#159CEF")),
// str.length - 8,
// str.length,
// Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
// )
spannableString.setSpan(
object : ClickableSpan() {
override fun onClick(widget: View?) {
if (Utils.isFastClick()){
return
}
H5Activity.start(mContext, false)
}
override fun updateDrawState(ds: TextPaint?) {
ds?.color=Color.parseColor("#159CEF")
}
}, 5,
13, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
spannableString.setSpan(
object : ClickableSpan() {
override fun onClick(widget: View?) {
if (Utils.isFastClick()){
return
}
H5Activity.start(mContext, true)
}
override fun updateDrawState(ds: TextPaint?) {
ds?.color=Color.parseColor("#159CEF")
}
}, str.length - 8,
str.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
tv_content.movementMethod = LinkMovementMethod.getInstance()
tv_content.highlightColor = Color.TRANSPARENT
tv_content.text = spannableString
}
private fun agreeAction() {
SharedPreferencesEditor.putString("hasAgreeSecret", "true")
listener?.onSure()
}
interface OnSecretDescriptionDialogListener {
fun onCancel()
fun onSure()
}
}
\ No newline at end of file
......@@ -5,10 +5,12 @@ import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.yidianling.user.R
import kotlinx.android.synthetic.main.user_secret_dialog_layout.*
class SecretDialog(context: Context, private val listener: OnSecretDialogListener?): Dialog(context, R.style.platform_dialog_default_style) {
class SecretDialog(context: Context, private val listener: OnSecretDialogListener?) :
Dialog(context, R.style.platform_dialog_default_style) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -22,14 +24,12 @@ class SecretDialog(context: Context, private val listener: OnSecretDialogListene
window.attributes = params
user_secret_dialog_agree.setOnClickListener {
listener?.onSure()
agreeAction()
}
user_secret_dialog_no_agree.setOnClickListener {
listener?.onCancel()
}
}
interface OnSecretDialogListener {
......@@ -37,5 +37,9 @@ class SecretDialog(context: Context, private val listener: OnSecretDialogListene
fun onSure()
}
private fun agreeAction() {
SharedPreferencesEditor.putString("hasAgreeSecret", "true")
listener?.onSure()
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#E6FFFFFF" android:endColor="#00FFFFFF"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#ffffff">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/user_secret_top_bg" />
<RelativeLayout
android:id="@+id/user_top_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/secrey_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="40dp"
android:text="壹点灵"
android:textColor="#242424"
android:textSize="28dp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/secrey_title"
android:layout_marginLeft="25dp"
android:text="隐私政策概要"
android:textColor="#242424"
android:textSize="28dp"
android:textStyle="bold" />
</RelativeLayout>
<ScrollView
android:layout_below="@+id/user_top_rl"
android:layout_alignBottom="@+id/secret_bottom_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="42dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="vertical">
<TextView
android:id="@+id/user_secret_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:lineHeight="20dp"
tools:text="感谢您信任并使用壹点灵APP,\n
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:myapp="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="34dp"
android:layout_marginRight="34dp"
android:background="@drawable/user_secret_dialog_bg">
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<com.ydl.ydlcommon.view.widgets.RoundImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
myapp:pa_borderRadius="12dp"
myapp:pa_type="pa_round"
android:adjustViewBounds="true"
android:src="@drawable/user_secret_top_bg"/>
<RelativeLayout
android:id="@+id/user_top_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/secrey_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="40dp"
android:text="隐私政策"
android:textColor="#242424"
android:textSize="28dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/secrey_title"
android:layout_marginLeft="25dp"
android:text="及使用协议说明"
android:textColor="#242424"
android:textSize="28dp"
android:textStyle="bold"/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout android:layout_width="match_parent" android:layout_height="194dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="194dp"
android:scrollbars="none"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
>
<TextView
android:id="@+id/user_secret_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:lineHeight="20dp"
tools:text="感谢您信任并使用壹点灵APP,\n
我们深知个人隐私的重要性,为了您更好的使用本APP,希望您着重关注:\n\n1. 为向您提供交易相关基本功能,我们会收集、使用必要的信息;\n
2. 基于您的明示授权,我们可能会获取您的位置(为您提供附近的咨询师等)、设备号信息(以保障您账号与交易安全)等信息,您有权拒绝或取消授权;\n
3. 我们会采业界先进的安全措施保护您的信息安全;\n
4. 未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;\n
5. 您可以查询、更正、删除您的个人信息。"
android:textColor="#444444"
android:textSize="14dp" />
android:textColor="#444444"
android:textSize="14dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</ScrollView>
<View
android:background="@drawable/user_secret_dectription_bg"
android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_height="30dp"/>
<LinearLayout
android:id="@+id/secret_bottom_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_marginBottom="185dp"
android:layout_marginLeft="@dimen/platform_dp_25">
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="阅读完整版"
android:textColor="#444444"
android:textSize="14dp" />
<TextView
android:id="@+id/user_use_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《用户使用协议》"
android:textColor="#159CEF"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="、"
android:textColor="#444444"
android:textSize="14dp" />
android:id="@+id/tv_content"
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:text="阅读完整版《用户使用协议》、《隐私保护政策》"
android:textColor="#444444"
android:textSize="14dp"/>
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="阅读完整版"-->
<!--android:textColor="#444444"-->
<!--android:textSize="14dp"/>-->
<!--<TextView-->
<!--android:id="@+id/user_use_btn"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="《用户使用协议》"-->
<!--android:textColor="#159CEF"-->
<!--android:textSize="14dp"/>-->
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="、"-->
<!--android:textColor="#444444"-->
<!--android:textSize="14dp"/>-->
<!--<TextView-->
<!--android:id="@+id/user_secret_protect_btn"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="《隐私保护政策》"-->
<!--android:textColor="#159CEF"-->
<!--android:textSize="14dp"/>-->
<TextView
android:id="@+id/user_secret_protect_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《隐私保护政策》"
android:textColor="#159CEF"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="24dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:orientation="vertical"
android:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginBottom="40dp"
android:orientation="horizontal"
android:background="#ffffff">
<TextView
android:id="@+id/user_secret_agree"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_weight="1"
android:background="@drawable/user_secret_right_btn_bg"
android:gravity="center"
android:text="同意并继续"
android:textColor="#FFFFFF"
android:textSize="16dp"/>
<TextView
android:id="@+id/user_secret_no_agree"
android:layout_width="0dp"
android:layout_height="44dp"
android:layout_marginRight="5.5dp"
android:layout_weight="1"
android:background="@drawable/user_secret_left_btn_bg"
android:gravity="center"
android:text="不同意并退出"
android:textColor="#999999"
android:textSize="16dp" />
<TextView
android:id="@+id/user_secret_no_agree"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="仍不同意并退出"
android:textColor="#999999"
android:textSize="16dp"/>
<TextView
android:id="@+id/user_secret_agree"
android:layout_width="0dp"
android:layout_height="44dp"
android:layout_marginLeft="5.5dp"
android:layout_weight="1"
android:background="@drawable/user_secret_right_btn_bg"
android:gravity="center"
android:text="同意并继续"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
......@@ -9,8 +9,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginLeft="34dp"
android:layout_marginRight="34dp"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/user_secret_dialog_bg">
......
......@@ -81,7 +81,7 @@ dependencies {
exclude group: 'com.squareup.okhttp3', module: 'logging-interceptor'
}
api(rootProject.ext.dependencies["imagepicker"]) {
api(rootProject.ext.dependencies["pictureselector"]) {
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
......
package com.ydl.ydlcommon.actions.imagepicker;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.ImageViewTarget;
import com.luck.picture.lib.engine.ImageEngine;
import com.luck.picture.lib.listener.ImageCompleteCallback;
import com.luck.picture.lib.tools.MediaUtils;
import com.luck.picture.lib.widget.longimage.ImageSource;
import com.luck.picture.lib.widget.longimage.ImageViewState;
import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.R;
/**
* @author:luck
* @date:2019-11-13 17:02
* @describe:Glide加载引擎
*/
public class GlideEngine implements ImageEngine {
/**
* 加载图片
*
* @param context
* @param url
* @param imageView
*/
@Override
public void loadImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
GlideApp.with(context)
.load(url)
.into(imageView);
}
/**
* 加载网络图片适配长图方案
* # 注意:此方法只有加载网络图片才会回调
*
* @param context
* @param url
* @param imageView
* @param longImageView
* @param callback 网络图片加载回调监听
*/
@Override
public void loadImage(@NonNull Context context, @NonNull String url,
@NonNull ImageView imageView,
SubsamplingScaleImageView longImageView, ImageCompleteCallback callback) {
GlideApp.with(context)
.asBitmap()
.load(url)
.into(new ImageViewTarget<Bitmap>(imageView) {
@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
super.onLoadStarted(placeholder);
if (callback != null) {
callback.onShowLoading();
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
if (callback != null) {
callback.onHideLoading();
}
}
@Override
protected void setResource(@Nullable Bitmap resource) {
if (callback != null) {
callback.onHideLoading();
}
if (resource != null) {
boolean eqLongImage = MediaUtils.isLongImg(resource.getWidth(),
resource.getHeight());
longImageView.setVisibility(eqLongImage ? View.VISIBLE : View.GONE);
imageView.setVisibility(eqLongImage ? View.GONE : View.VISIBLE);
if (eqLongImage) {
// 加载长图
longImageView.setQuickScaleEnabled(true);
longImageView.setZoomEnabled(true);
longImageView.setPanEnabled(true);
longImageView.setDoubleTapZoomDuration(100);
longImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
longImageView.setDoubleTapZoomDpi(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER);
longImageView.setImage(ImageSource.bitmap(resource),
new ImageViewState(0, new PointF(0, 0), 0));
} else {
// 普通图片
imageView.setImageBitmap(resource);
}
}
}
});
}
/**
* 加载网络图片适配长图方案
* # 注意:此方法只有加载网络图片才会回调
*
* @param context
* @param url
* @param imageView
* @param longImageView
* @ 已废弃
*/
@Override
public void loadImage(@NonNull Context context, @NonNull String url,
@NonNull ImageView imageView,
SubsamplingScaleImageView longImageView) {
GlideApp.with(context)
.asBitmap()
.load(url)
.into(new ImageViewTarget<Bitmap>(imageView) {
@Override
protected void setResource(@Nullable Bitmap resource) {
if (resource != null) {
boolean eqLongImage = MediaUtils.isLongImg(resource.getWidth(),
resource.getHeight());
longImageView.setVisibility(eqLongImage ? View.VISIBLE : View.GONE);
imageView.setVisibility(eqLongImage ? View.GONE : View.VISIBLE);
if (eqLongImage) {
// 加载长图
longImageView.setQuickScaleEnabled(true);
longImageView.setZoomEnabled(true);
longImageView.setPanEnabled(true);
longImageView.setDoubleTapZoomDuration(100);
longImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
longImageView.setDoubleTapZoomDpi(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER);
longImageView.setImage(ImageSource.bitmap(resource),
new ImageViewState(0, new PointF(0, 0), 0));
} else {
// 普通图片
imageView.setImageBitmap(resource);
}
}
}
});
}
/**
* 加载相册目录
*
* @param context 上下文
* @param url 图片路径
* @param imageView 承载图片ImageView
*/
@Override
public void loadFolderImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
GlideApp.with(context)
.asBitmap()
.load(url)
.override(180, 180)
.centerCrop()
.sizeMultiplier(0.5f)
.apply(new RequestOptions().placeholder(R.drawable.picture_image_placeholder))
.into(new BitmapImageViewTarget(imageView) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.
create(context.getResources(), resource);
circularBitmapDrawable.setCornerRadius(8);
imageView.setImageDrawable(circularBitmapDrawable);
}
});
}
/**
* 加载gif
*
* @param context 上下文
* @param url 图片路径
* @param imageView 承载图片ImageView
*/
@Override
public void loadAsGifImage(@NonNull Context context, @NonNull String url,
@NonNull ImageView imageView) {
GlideApp.with(context)
.asGif()
.load(url)
.into(imageView);
}
/**
* 加载图片列表图片
*
* @param context 上下文
* @param url 图片路径
* @param imageView 承载图片ImageView
*/
@Override
public void loadGridImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) {
GlideApp.with(context)
.load(url)
.override(200, 200)
.centerCrop()
.apply(new RequestOptions().placeholder(R.drawable.picture_image_placeholder))
.into(imageView);
}
private GlideEngine() {
}
private static GlideEngine instance;
public static GlideEngine createGlideEngine() {
if (null == instance) {
synchronized (GlideEngine.class) {
if (null == instance) {
instance = new GlideEngine();
}
}
}
return instance;
}
}
package com.ydl.ydlcommon.actions.imagepicker
import android.app.Activity
import android.content.Intent
import com.lzy.imagepicker.ImagePicker
import com.lzy.imagepicker.bean.ImageItem
import com.lzy.imagepicker.ui.ImageGridActivity
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.remind.ToastHelper
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/05/07
*/
internal class ImagePickerActivity: BaseActivity() {
companion object {
private const val REQUEST_CODE = 0X00
private var callback: PickerCallback? = null
private const val OPEN_CAMERA = "open_camera"
fun start(activity: Activity, openCamera: Boolean, callback: PickerCallback) {
val intent = Intent(activity, ImagePickerActivity::class.java)
intent.putExtra(OPEN_CAMERA, openCamera)
activity.startActivityForResult(intent,
REQUEST_CODE
)
Companion.callback = callback
}
}
private var openCamera = false // 是否是直接打开相机
override fun layoutResId(): Int {
return 0
}
override fun initDataAndEvent() {
openCamera = intent.getBooleanExtra(OPEN_CAMERA, false)
val intent = Intent(this, ImageGridActivity::class.java)
intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, openCamera)
startActivityForResult(intent,
REQUEST_CODE
)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
if (data != null && requestCode == REQUEST_CODE) {
val images = data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS) as ArrayList<ImageItem>
callback?.onSuccess(images)
} else {
callback?.onFail()
ToastHelper.show("没有数据")
}
finish()
}
}
override fun onRestart() {
super.onRestart()
finish()
}
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.imagepicker
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.lzy.imagepicker.ImagePicker
import com.lzy.imagepicker.bean.ImageItem
import com.lzy.imagepicker.ui.ImageGridActivity
import com.ydl.ydlcommon.base.BaseFragment
import com.ydl.ydlcommon.utils.remind.ToastHelper
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/05/07
*/
internal class ImagePickerFragment: BaseFragment() {
companion object {
private const val REQUEST_CODE = 0X00
private const val OPEN_CAMERA = "open_camera"
private const val PICKER: String = "picker"
fun start(activity: AppCompatActivity, openCamera: Boolean, callback: PickerCallback) {
val fragment = ImagePickerFragment()
fragment.pickerCallback = callback
val args = Bundle()
args.putBoolean(OPEN_CAMERA, openCamera)
fragment.arguments = args
activity.supportFragmentManager.beginTransaction()
.add(fragment, PICKER)
.commitAllowingStateLoss()
}
}
private var pickerCallback: PickerCallback? = null
private var openCamera = false // 是否是直接打开相机
override fun layoutResId(): Int {
return 0
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
openCamera = arguments.getBoolean(OPEN_CAMERA, false)
val intent = Intent(activity, ImageGridActivity::class.java)
startActivityForResult(intent,
REQUEST_CODE
)
}
override fun initDataAndEvent() {
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
if (data != null && requestCode == REQUEST_CODE) {
val images = data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS) as ArrayList<ImageItem>
pickerCallback?.onSuccess(images)
} else {
pickerCallback?.onFail()
ToastHelper.show("没有数据")
}
}
}
override fun initDataAndEventLazy() {
}
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.imagepicker
import com.lzy.imagepicker.bean.ImageItem
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/05/07
*/
interface PickerCallback {
fun onSuccess(images: ArrayList<ImageItem>)
fun onFail()
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.imagepicker
import android.support.v7.app.AppCompatActivity
import com.luck.picture.lib.PictureSelector
import com.luck.picture.lib.config.PictureMimeType
import com.luck.picture.lib.listener.OnResultCallbackListener
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/05/07
*/
object YDLImagePicker {
fun startPicker(activity: AppCompatActivity, callback: OnResultCallbackListener) {
startPicker(activity,1,callback)
}
fun startPicker(activity: AppCompatActivity, maxSelectNum :Int,callback: OnResultCallbackListener) {
PictureSelector.create(activity)
.openGallery(PictureMimeType.ofImage())
.maxSelectNum(maxSelectNum)
.compress(true)
.minimumCompressSize(100)
.isWeChatStyle(true)
.loadImageEngine(GlideEngine.createGlideEngine())
.forResult(callback)
}
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.imagepicker;
import android.app.Activity;
import android.net.Uri;
import android.widget.ImageView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.lzy.imagepicker.loader.ImageLoader;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.R;
import java.io.File;
/**
* Created by haorui on 2019/6/28.
* Des:
*/
public class YdlImageLoader implements ImageLoader {
@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
}
@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
}
@Override
public void displayImage(Activity activity, Uri uri, ImageView imageView, int i, int i1) {
GlideApp.with(activity) //配置上下文
.load(uri) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(R.drawable.platform_default_img) //设置错误图片
.placeholder(R.drawable.platform_default_img) //设置占位图片
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
}
private void showImage(Activity activity, String path, ImageView imageView, int width, int height){
GlideApp.with(activity) //配置上下文
.load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(R.drawable.platform_default_img) //设置错误图片
.placeholder(R.drawable.platform_default_img) //设置占位图片
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
}
@Override
public void clearMemoryCache() {
}
}
package com.ydl.ydlcommon.actions.imagepicker
import android.support.v7.app.AppCompatActivity
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/05/07
*/
object YdlImagePicker {
fun startPicker(activity: AppCompatActivity, openCamera: Boolean, callback: PickerCallback) {
ImagePickerFragment.start(activity, openCamera, callback)
}
}
\ No newline at end of file
......@@ -3,10 +3,7 @@ package com.ydl.ydlcommon.app
import android.annotation.SuppressLint
import android.app.Application
import com.alibaba.android.arouter.launcher.ARouter
import com.lzy.imagepicker.ImagePicker
import com.lzy.imagepicker.view.CropImageView
import com.ydl.devicesidlib.DeviceIDHelper
import com.ydl.ydlcommon.actions.imagepicker.YdlImageLoader
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.UpLoadLogUtils
import com.ydl.ydlcommon.utils.AppProgressUtils
......@@ -38,7 +35,6 @@ object YdlRepository {
//初始化工具类
RxTool.init(app)
BuryPointUtils.init()
initImagePicker()
// if (LeakCanary.isInAnalyzerProcess(app)) {
// // This process is dedicated to LeakCanary for heap analysis.
......@@ -75,20 +71,4 @@ object YdlRepository {
}
ARouter.init(app)
}
private fun initImagePicker() {
val imagePicker = ImagePicker.getInstance()
imagePicker.imageLoader = YdlImageLoader() //设置图片加载器
imagePicker.isEdit = true //设置图片是否可编辑
imagePicker.isShowCamera = true //显示拍照按钮
imagePicker.isCrop = true //允许裁剪(单选才有效)
imagePicker.isSaveRectangle = true //是否按矩形区域保存
imagePicker.selectLimit = 9 //选中数量限制
imagePicker.style = CropImageView.Style.RECTANGLE //裁剪框的形状
imagePicker.focusWidth = 800 //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.focusHeight = 800 //裁剪框的高度。单位像素(圆形自动取宽高最小值)
imagePicker.outPutX = 1000//保存文件的宽度。单位像素
imagePicker.outPutY = 1000//保存文件的高度。单位像素
}
}
\ No newline at end of file
package com.ydl.ydlcommon.utils.log
import android.annotation.SuppressLint
import android.content.Context
import android.util.Log
import com.ydl.ydlcommon.base.BaseApp
......@@ -45,7 +46,7 @@ class LogHelper private constructor() {
/**
* 删除过期日志
*/
fun deleteExpireLog() {
private fun deleteExpireLog() {
val files = getLogFolder().listFiles()
val calendar = Calendar.getInstance()
calendar.add(Calendar.WEEK_OF_YEAR, -1)
......@@ -58,7 +59,9 @@ class LogHelper private constructor() {
}
}
@SuppressLint("SimpleDateFormat")
private val dateFormat = SimpleDateFormat("yyyyMMdd")
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeLogSync(content: String) {
......@@ -107,6 +110,7 @@ class LogHelper private constructor() {
}
@SuppressLint("CheckResult")
fun uploadLog(showToast: Boolean) {
Observable.create<File> {
it.onNext(zip())
......
package com.ydl.ydlcommon.view.banner;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.lzy.imagepicker.loader.ImageLoader;
import com.ydl.ydl_image.config.ISimpleImageOpConfig;
import com.ydl.ydl_image.config.SimpleImageOpConfiger;
import com.ydl.ydl_image.manager.YDLImageCacheManager;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.R;
import com.ydl.ydlcommon.view.banner.loader.ImageLoader;
/**
* Created by xiongyu on 2017/4/7.
*/
public class GlideImageDisplayLoader implements ImageLoader {
@Override
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
}
public class GlideImageDisplayLoader extends ImageLoader {
private int placeholderImage;//加载过程中的中间页面
private int radius = 0;
@Override
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
public GlideImageDisplayLoader() {
}
@Override
public void displayImage(Activity activity, Uri uri, ImageView imageView, int width, int i1) {
GlideApp.with(activity) //配置上下文
.load(uri) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
.error(com.ydl.ydlcommon.R.drawable.platform_default_img) //设置错误图片
.placeholder(com.ydl.ydlcommon.R.drawable.platform_default_img) //设置占位图片
.diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
.into(imageView);
public GlideImageDisplayLoader(int placeholderImage) {
this.placeholderImage = placeholderImage;
}
private void showImage(Activity activity, String path, ImageView imageView, int width, int height){
SimpleImageOpConfiger sp = new SimpleImageOpConfiger();
sp.loadingPic = R.drawable.platform_default_img;
sp.errorPic = R.drawable.platform_default_img;
sp.scaleType = ISimpleImageOpConfig.CENTER_CROP;
sp.isCacheOnDisk = false;
YDLImageCacheManager.showImage(activity,path,imageView,width, height,sp);
public GlideImageDisplayLoader(int placeholderImage, int radius) {
this.placeholderImage = placeholderImage;
this.radius = radius;
}
@Override
public void clearMemoryCache() {
public void displayImage(Context context, Object path, ImageView imageView) {
if (placeholderImage > 0) {
if (path instanceof String) {
SimpleImageOpConfiger sp = new SimpleImageOpConfiger();
sp.loadingPic = placeholderImage;
sp.scaleType = ISimpleImageOpConfig.CENTER_CROP;
sp.transform = ISimpleImageOpConfig.TRANSFORM_ROUND;
sp.radius = radius;
sp.transition = false;
YDLImageCacheManager.showImage(context, (String) path, imageView, imageView.getWidth(), imageView.getHeight(), sp);
}
} else {
if (path instanceof String) {
if (imageView != null) {
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
YDLImageCacheManager.showImage(context, (String) path, imageView, imageView.getWidth());
}
}
}
}
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