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 { ...@@ -205,6 +205,7 @@ dependencies {
implementation project(':m-muse') implementation project(':m-muse')
implementation project(':m-im') implementation project(':m-im')
implementation project(':m-dynamic') implementation project(':m-dynamic')
implementation project(':m-audioim')
// api rootProject.ext.dependencies["ydl-m-fm-module-ydl"] // api rootProject.ext.dependencies["ydl-m-fm-module-ydl"]
......
...@@ -30,6 +30,8 @@ import com.yidianling.common.tools.ToastUtil ...@@ -30,6 +30,8 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.api.IConsultantService import com.yidianling.consultant.api.IConsultantService
import com.yidianling.fm.api.service.IFMService import com.yidianling.fm.api.service.IFMService
import com.yidianling.tests.home.NewTestHomeActivity 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.* import kotlinx.android.synthetic.main.activity_main.*
/** /**
...@@ -85,7 +87,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -85,7 +87,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
.navigation() .navigation()
} }
bt_to_consultant.setOnClickListener { bt_to_consultant.setOnClickListener {
// ARouter.getInstance() // ARouter.getInstance()
// .build("/consult/hot_search") // .build("/consult/hot_search")
// .withString( // .withString(
// HOT_SEARCH_DOCTOR_NAME, // HOT_SEARCH_DOCTOR_NAME,
...@@ -156,6 +158,36 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -156,6 +158,36 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
bt_to_home.setOnClickListener { bt_to_home.setOnClickListener {
FragmentContainerActivity.start(this, "MineFragment") FragmentContainerActivity.start(this, "MineFragment")
// startActivity(Intent(this, TestAppActivity::class.java)) // 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 @@ ...@@ -185,6 +185,23 @@
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:text="动态" /> android:text="动态" />
</LinearLayout> </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> </LinearLayout>
<com.ydl.ydlcommon.mvp.lce.view.YDLStateView <com.ydl.ydlcommon.mvp.lce.view.YDLStateView
......
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = true dev_mode = false
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
...@@ -42,13 +42,13 @@ ext { ...@@ -42,13 +42,13 @@ ext {
ydlPublishVersion = [ ydlPublishVersion = [
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.47.1", "m-confide" : "0.0.47.7",
"m-consultant" : "0.0.57", "m-consultant" : "0.0.57.4",
"m-fm" : "0.0.28", "m-fm" : "0.0.28",
"m-user" : "0.0.56", "m-user" : "0.0.58.2",
"m-home" : "0.0.19.1", "m-home" : "0.0.19.1",
"m-im" : "0.0.11", "m-im" : "0.0.14.1",
"m-dynamic" : "0.0.5.1", "m-dynamic" : "0.0.6.1",
"m-muse" : "0.0.27", "m-muse" : "0.0.27",
"m-tests" : "0.0.21", "m-tests" : "0.0.21",
...@@ -69,13 +69,13 @@ ext { ...@@ -69,13 +69,13 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.37.1", "ydl-platform" : "0.0.38.2",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.37.1", "ydl-webview" : "0.0.37.1",
"ydl-media" : "0.0.20", "ydl-media" : "0.0.20",
"ydl-pay" : "0.0.17", "ydl-pay" : "0.0.17",
"m-audioim" : "0.0.46", "m-audioim" : "0.0.46.5",
"ydl-flutter-base": "0.0.10", "ydl-flutter-base": "0.0.10",
//以下 几乎不会动 //以下 几乎不会动
...@@ -115,13 +115,13 @@ ext { ...@@ -115,13 +115,13 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.37", "ydl-platform" : "0.0.38.2",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.37.1", "ydl-webview" : "0.0.37.1",
"ydl-media" : "0.0.20", "ydl-media" : "0.0.20",
"ydl-pay" : "0.0.17", "ydl-pay" : "0.0.17",
"m-audioim" : "0.0.46", "m-audioim" : "0.0.46.5",
"ydl-flutter-base": "0.0.10", "ydl-flutter-base": "0.0.10",
//以下 几乎不会动 //以下 几乎不会动
...@@ -260,6 +260,7 @@ ext { ...@@ -260,6 +260,7 @@ ext {
"exoplayer" : "com.google.android.exoplayer:exoplayer:2.9.0", "exoplayer" : "com.google.android.exoplayer:exoplayer:2.9.0",
"free_reflection" : "me.weishu:free_reflection:2.0.0", "free_reflection" : "me.weishu:free_reflection:2.0.0",
"imagepicker" : "com.ydl:imagepicker:1.0.8.2", "imagepicker" : "com.ydl:imagepicker:1.0.8.2",
"pictureselector" : "com.ydl:pictureselector:1.2.0",
"protector" : "com.ydl:protector:1.0.1-SNAPSHOT@aar", "protector" : "com.ydl:protector:1.0.1-SNAPSHOT@aar",
"ydl-hnet" : "com.ydl:h-net:0.0.8", "ydl-hnet" : "com.ydl:h-net:0.0.8",
"ydl-user-router" : "com.ydl:router:1.0.0-SNAPSHOT@aar", "ydl-user-router" : "com.ydl:router:1.0.0-SNAPSHOT@aar",
......
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 ...@@ -8,7 +8,7 @@ import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
* 导医跳转私聊的中间页面,用于统一路由 * 导医跳转私聊的中间页面,用于统一路由
*/ */
@Route( path = "/chat/ChatService") @Route( path = "/consult/ChatService")
class ConsultAssistantCenterActivity : BaseActivity() { class ConsultAssistantCenterActivity : BaseActivity() {
override fun initDataAndEvent() { override fun initDataAndEvent() {
supportActionBar?.hide() supportActionBar?.hide()
......
...@@ -77,7 +77,6 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch ...@@ -77,7 +77,6 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
// holder.tvDesc.text = itemBean.famousRemark // holder.tvDesc.text = itemBean.famousRemark
// } // }
//服务中 //服务中
if (itemBean.inConsult || itemBean.isListening) { if (itemBean.inConsult || itemBean.isListening) {
holder.imgHead_online_server.visibility = View.VISIBLE holder.imgHead_online_server.visibility = View.VISIBLE
...@@ -110,59 +109,82 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch ...@@ -110,59 +109,82 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
}else{ }else{
holder.tvCity.text = "" holder.tvCity.text = ""
} }
//能力等级标签
if (1 == itemBean.abilityLevel){ //公益图标,不与其他图标冲突
//实习 if (1 == itemBean.hasServiceFree) {
holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_shixi) if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.serviceFreeIcon)) {
holder.imgAbilityLevel.visibility = View.VISIBLE expertSearchView.showImage(
}else if (2 == itemBean.abilityLevel){ itemBean.tagsIcon.serviceFreeIcon,
//新手 holder.imgServiceFree
holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_xinshou) )
holder.imgAbilityLevel.visibility = View.VISIBLE } else {
}
// 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{
val sp = SimpleImageOpConfiger() val sp = SimpleImageOpConfiger()
sp.loadingPic = R.drawable.consultant_service_free sp.loadingPic = R.drawable.consultant_service_free
sp.errorPic = 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 holder.imgServiceFree.visibility = View.VISIBLE
}else{ } else {
holder.imgServiceFree.visibility = View.GONE holder.imgServiceFree.visibility = View.GONE
} }
//新驻图标 // 展示了抗疫,就不展示其他标签
if (itemBean.isNewEnter){ if (itemBean.fightEpidemicIconShow) {
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.newEnterIcon)){ itemBean.tagsIcon?.fightEpidemicIcon?.let {
expertSearchView.showImage(itemBean.tagsIcon.newEnterIcon,holder.imgNewEnter) GlideApp.with(context).load(itemBean.tagsIcon?.fightEpidemicIcon)
}else{ .into(holder.imgFightEpidemicIcon)
val sp = SimpleImageOpConfiger() holder.imgFightEpidemicIcon.visibility = View.VISIBLE
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.imgAbilityLevel.visibility = View.GONE
holder.imgActivity.visibility = View.GONE
holder.imgNewEnter.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() holder.ll_feedbackRate.removeAllViews()
for (num in 1..5){ for (num in 1..5){
...@@ -330,6 +352,8 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch ...@@ -330,6 +352,8 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
val imgHead_online_server = itemView.imgHead_online_server!! val imgHead_online_server = itemView.imgHead_online_server!!
//多少人在问询 //多少人在问询
val chat_people_in_question = itemView.people_in_question!! val chat_people_in_question = itemView.people_in_question!!
// 抗疫先锋图标
val imgFightEpidemicIcon = itemView.img_fightEpidemicIcon
init { init {
itemView.setOnClickListener { itemView.setOnClickListener {
......
...@@ -19,4 +19,8 @@ data class ExpertSearchTagsIconBean( ...@@ -19,4 +19,8 @@ data class ExpertSearchTagsIconBean(
/** /**
* 新入驻图标 * 新入驻图标
*/ */
val newEnterIcon : String?) val newEnterIcon : String?,
\ No newline at end of file /**
* 抗疫先锋图标地址
*/
var fightEpidemicIcon: String? = null)
\ No newline at end of file
...@@ -60,6 +60,10 @@ data class DoctorServiceItem( ...@@ -60,6 +60,10 @@ data class DoctorServiceItem(
*/ */
var feedbackRate: Float = 0f, var feedbackRate: Float = 0f,
/** /**
* 是否抗疫先锋图标
*/
var fightEpidemicIconShow: Boolean = false,
/**
* 评价数(咨询订单数) * 评价数(咨询订单数)
*/ */
var zixunOrderNum: Int = 0, var zixunOrderNum: Int = 0,
......
...@@ -75,18 +75,24 @@ ...@@ -75,18 +75,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="10dp" android:paddingLeft="8dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_alignTop="@+id/tvName" android:layout_alignTop="@+id/tvName"
android:layout_alignBottom="@+id/tvName" android:layout_alignBottom="@+id/tvName"
android:layout_toEndOf="@+id/tvName" android:layout_toEndOf="@+id/tvName"
android:layout_marginStart="@dimen/platform_dp_2"> 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 <ImageView
android:id="@+id/img_activity" android:id="@+id/img_activity"
android:layout_width="42dp" android:layout_width="42dp"
android:layout_height="12dp" android:layout_height="12dp"
android:layout_marginStart="@dimen/platform_dp_4"
android:layout_marginRight="4dp" android:layout_marginRight="4dp"
android:visibility="gone"/> android:visibility="gone"/>
<!--公益图标--> <!--公益图标-->
......
...@@ -20,6 +20,7 @@ import android.view.WindowManager; ...@@ -20,6 +20,7 @@ import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.luck.picture.lib.photoview.PhotoView;
import com.miracle.view.imageeditor.utils.FileUtils; import com.miracle.view.imageeditor.utils.FileUtils;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
...@@ -39,8 +40,6 @@ import java.util.List; ...@@ -39,8 +40,6 @@ import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers; 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 ...@@ -324,12 +323,7 @@ public class BrowsePicturesActivity extends BaseActivity implements ViewPager.On
.load(uri) .load(uri)
.error(R.drawable.dynamic_default_img) .error(R.drawable.dynamic_default_img)
.into(mDatas.get(position)); .into(mDatas.get(position));
mDatas.get(position).setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { mDatas.get(position).setOnPhotoTapListener((imageView, v, v1) -> finish());
@Override
public void onPhotoTap(View view, float x, float y) {
finish();
}
});
((ViewPager) container).addView(mDatas.get(position), 0); ((ViewPager) container).addView(mDatas.get(position), 0);
// if (lodingDialog != null) { // if (lodingDialog != null) {
// lodingDialog.dismiss(); // lodingDialog.dismiss();
......
...@@ -17,6 +17,7 @@ import android.view.WindowManager; ...@@ -17,6 +17,7 @@ import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.luck.picture.lib.photoview.PhotoView;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
import com.yidianling.common.tools.ToastUtil; import com.yidianling.common.tools.ToastUtil;
...@@ -28,11 +29,6 @@ import com.yidianling.dynamic.common.tool.ImageDownLoadCallBack; ...@@ -28,11 +29,6 @@ import com.yidianling.dynamic.common.tool.ImageDownLoadCallBack;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;
/** /**
* 预览大图 2 集合范型为String * 预览大图 2 集合范型为String
*/ */
...@@ -257,12 +253,7 @@ public class BrowsePicturesActivity2 extends BaseActivity implements ViewPager.O ...@@ -257,12 +253,7 @@ public class BrowsePicturesActivity2 extends BaseActivity implements ViewPager.O
.load(mImages.get(position)) .load(mImages.get(position))
.error(R.drawable.dynamic_default_img) .error(R.drawable.dynamic_default_img)
.into(mDatas.get(position)); .into(mDatas.get(position));
mDatas.get(position).setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { mDatas.get(position).setOnPhotoTapListener((imageView, v, v1) -> finish());
@Override
public void onPhotoTap(View view, float x, float y) {
finish();
}
});
((ViewPager)container).addView(mDatas.get(position), 0); ((ViewPager)container).addView(mDatas.get(position), 0);
// if (lodingDialog != null) { // if (lodingDialog != null) {
// lodingDialog.dismiss(); // lodingDialog.dismiss();
......
...@@ -32,15 +32,14 @@ import android.widget.LinearLayout; ...@@ -32,15 +32,14 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.lzy.imagepicker.ImagePicker; import com.luck.picture.lib.entity.LocalMedia;
import com.lzy.imagepicker.bean.ImageItem; import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.lzy.imagepicker.view.CropImageView;
import com.tbruyelle.rxpermissions2.RxPermissions; import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.webview.H5Params; import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity; import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_image.module.GlideApp; 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.adapter.custom.PublishImageAdapter;
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.base.BaseApp; import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.BaseFragment; import com.ydl.ydlcommon.base.BaseFragment;
...@@ -69,8 +68,6 @@ import com.yidianling.dynamic.publishTrend.PublishTrendActivity; ...@@ -69,8 +68,6 @@ import com.yidianling.dynamic.publishTrend.PublishTrendActivity;
import com.yidianling.dynamic.publishTrend.SelecTopicActivity; import com.yidianling.dynamic.publishTrend.SelecTopicActivity;
import com.yidianling.dynamic.router.DynamicIn; import com.yidianling.dynamic.router.DynamicIn;
import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -197,17 +194,6 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -197,17 +194,6 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
@Override @Override
public void initDataAndEventLazy() { public void initDataAndEventLazy() {
rxPermissions = new RxPermissions(getActivity()); 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>(); imgFiles = new ArrayList<File>();
initView(); initView();
uiHandler = new Handler(); uiHandler = new Handler();
...@@ -770,25 +756,22 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -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() { private void showSelector() {
ImagePicker.getInstance().setEdit(true); int selectedSize = publishTrendImgs.size()!=0?publishTrendImgs.size()-1:0;
DynamicIn.INSTANCE.startPicker((BaseActivity) activity, false, new PickerCallback() {
YDLImagePicker.INSTANCE.startPicker((BaseActivity) activity, 9 - selectedSize,new OnResultCallbackListener() {
@Override @Override
public void onSuccess(@NotNull ArrayList<ImageItem> images) { public void onResult(List<LocalMedia> list) {
if (images.isEmpty()) { if (list.isEmpty()) {
return; return;
} }
for (int i = 0; i < images.size(); i++) { for (int i = 0; i < list.size(); i++) {
AddImag(images.get(i).uri.toString()); AddImag(list.get(i).getPath());
} }
} }
@Override @Override
public void onFail() { public void onCancel() {
} }
}); });
......
...@@ -6,8 +6,6 @@ import android.support.v4.app.DialogFragment ...@@ -6,8 +6,6 @@ import android.support.v4.app.DialogFragment
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import com.ydl.confide.api.IConfideService import com.ydl.confide.api.IConfideService
import com.ydl.course.api.ICourseService 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.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.consultant.api.IConsultantService import com.yidianling.consultant.api.IConsultantService
...@@ -168,10 +166,6 @@ object DynamicIn { ...@@ -168,10 +166,6 @@ object DynamicIn {
getImService().showSelector(activity, requestCode) getImService().showSelector(activity, requestCode)
} }
fun startPicker(activity: AppCompatActivity, openCamera: Boolean, callback: PickerCallback) {
YdlImagePicker.startPicker(activity, openCamera, callback)
}
/** /**
* 课程播放页 * 课程播放页
*/ */
......
...@@ -4,20 +4,16 @@ import android.Manifest; ...@@ -4,20 +4,16 @@ import android.Manifest;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; 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.miracle.view.imageeditor.utils.FileUtils;
import com.tbruyelle.rxpermissions2.RxPermissions; 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.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.nimbase.business.session.actions.BaseAction; 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.io.File;
import java.util.ArrayList; import java.util.List;
/** /**
* Created by zhoujianghua on 2015/7/31. * Created by zhoujianghua on 2015/7/31.
...@@ -58,19 +54,23 @@ public abstract class PickImageAction extends BaseAction { ...@@ -58,19 +54,23 @@ public abstract class PickImageAction extends BaseAction {
} }
private void selectImage(){ private void selectImage(){
YdlImagePicker.INSTANCE.startPicker((AppCompatActivity) getActivity(), false, new PickerCallback() { YDLImagePicker.INSTANCE.startPicker((AppCompatActivity) getActivity(),9, new OnResultCallbackListener() {
@Override @Override
public void onSuccess(@NotNull ArrayList<ImageItem> images) { public void onResult(List<LocalMedia> list) {
for (int i = 0; i < images.size(); i++) { if (list.isEmpty()) {
onPicked(FileUtils.INSTANCE.getFileByUri(getActivity(),images.get(i).uri.toString())); return;
}
for (int i = 0; i < list.size(); i++) {
onPicked(FileUtils.INSTANCE.getFileByUri(getActivity(),list.get(i).getPath()));
} }
} }
@Override @Override
public void onFail() { public void onCancel() {
ToastHelper.showToast(getActivity(), R.string.im_picker_image_error);
} }
}); });
} }
} }
...@@ -18,6 +18,7 @@ import android.view.ViewGroup; ...@@ -18,6 +18,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.luck.picture.lib.photoview.PhotoView;
import com.netease.nimlib.sdk.AbortableFuture; import com.netease.nimlib.sdk.AbortableFuture;
import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer; import com.netease.nimlib.sdk.Observer;
...@@ -48,8 +49,6 @@ import java.util.ArrayList; ...@@ -48,8 +49,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import uk.co.senab.photoview.PhotoView;
/** /**
* 查看聊天消息原图 * 查看聊天消息原图
* Created by huangjun on 2015/3/6. * Created by huangjun on 2015/3/6.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
android:gravity="center" android:gravity="center"
android:orientation="vertical" > android:orientation="vertical" >
<uk.co.senab.photoview.PhotoView <com.luck.picture.lib.photoview.PhotoView
android:id="@+id/watch_image_view" android:id="@+id/watch_image_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="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 ...@@ -14,10 +14,9 @@ import android.text.TextWatcher
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.lzy.imagepicker.ImagePicker import com.luck.picture.lib.entity.LocalMedia
import com.lzy.imagepicker.bean.ImageItem import com.luck.picture.lib.listener.OnResultCallbackListener
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker
import com.ydl.ydlcommon.actions.imagepicker.YdlImagePicker
import com.ydl.ydlcommon.adapter.custom.PublishImageAdapter import com.ydl.ydlcommon.adapter.custom.PublishImageAdapter
import com.ydl.ydlcommon.base.BaseActivity import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.PlatformDataManager import com.ydl.ydlcommon.data.PlatformDataManager
...@@ -25,7 +24,6 @@ import com.ydl.ydlcommon.modular.ModularServiceManager ...@@ -25,7 +24,6 @@ import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.ui.ParcelableImage import com.ydl.ydlcommon.ui.ParcelableImage
import com.ydl.ydlcommon.utils.Utils import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.ydl.ydlcommon.view.banner.GlideImageDisplayLoader
import com.ydl.ydlcommon.view.dialog.CommonDialog import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.LogUtil import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
...@@ -207,25 +205,22 @@ class FeedBackActivity : BaseActivity(), View.OnClickListener { ...@@ -207,25 +205,22 @@ class FeedBackActivity : BaseActivity(), View.OnClickListener {
} }
private fun showSelector() { private fun showSelector() {
ImagePicker.getInstance().selectLimit = 1 YDLImagePicker.startPicker(this as BaseActivity, object : OnResultCallbackListener {
val imagePicker = ImagePicker.getInstance() override fun onResult(list: List<LocalMedia>) {
imagePicker.imageLoader = GlideImageDisplayLoader() if (list.isEmpty()) {
imagePicker.selectLimit = 1 //选中数量限制
YdlImagePicker.startPicker(this as BaseActivity, false, object : PickerCallback {
override fun onFail() {
}
override fun onSuccess(images: ArrayList<ImageItem>) {
if (images.isEmpty()) {
return return
} }
for (i in images.indices) { for (i in list.indices) {
addImag(images[i].path) addImag(list[i].path)
} }
} }
override fun onCancel() {
}
}) })
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
......
package com.yidianling.user.ui; package com.yidianling.user.ui;
import android.Manifest;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -15,13 +14,13 @@ import android.view.View; ...@@ -15,13 +14,13 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import com.lzy.imagepicker.ImagePicker; import com.luck.picture.lib.entity.LocalMedia;
import com.lzy.imagepicker.bean.ImageItem; import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.lzy.imagepicker.ui.ImageGridActivity; import com.miracle.view.imageeditor.utils.FileUtils;
import com.lzy.imagepicker.view.CropImageView;
import com.tbruyelle.rxpermissions2.RxPermissions; import com.tbruyelle.rxpermissions2.RxPermissions;
import com.ydl.webview.RefreshWebEvent; import com.ydl.webview.RefreshWebEvent;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.actions.imagepicker.YDLImagePicker;
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.RxUtils; import com.ydl.ydlcommon.data.http.RxUtils;
...@@ -34,11 +33,8 @@ import com.ydl.ydlcommon.view.ListNoCancelDialog; ...@@ -34,11 +33,8 @@ import com.ydl.ydlcommon.view.ListNoCancelDialog;
import com.ydl.ydlcommon.view.RoundCornerButton; import com.ydl.ydlcommon.view.RoundCornerButton;
import com.ydl.ydlcommon.view.TitleBar; import com.ydl.ydlcommon.view.TitleBar;
import com.ydl.ydlcommon.view.dialog.CommonDialog; 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.RxFileTool;
import com.yidianling.common.tools.RxImageTool; 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.LoginHelper;
import com.yidianling.user.R; import com.yidianling.user.R;
import com.yidianling.user.UserConstants; import com.yidianling.user.UserConstants;
...@@ -133,18 +129,6 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen ...@@ -133,18 +129,6 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
void init() { void init() {
rxPermissions = new RxPermissions(this); rxPermissions = new RxPermissions(this);
head_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/yidianling/img/head_img/"; 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)) { if (!TextUtils.isEmpty(icon)) {
GlideApp.with(FillInfoActivity.this) GlideApp.with(FillInfoActivity.this)
.load(icon) .load(icon)
...@@ -214,29 +198,23 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen ...@@ -214,29 +198,23 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if (id == R.id.sdv_head) { if (id == R.id.sdv_head) {
rxPermissions.request(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE) YDLImagePicker.INSTANCE.startPicker(FillInfoActivity.this, new OnResultCallbackListener() {
.subscribe(granted -> { @Override
if (granted) { public void onResult(List<LocalMedia> list) {
ThreeLinesDialog.Builder builder1 = new ThreeLinesDialog.Builder(FillInfoActivity.this); if (list.isEmpty()) {
builder1.setTitle("相机"); return;
builder1.setMessage("相册中选择"); }
builder1.setbottom("取消"); for (int i = 0; i < list.size(); i++) {
builder1.setFirstButton("相机", (dialog, which) -> { uploadImage(list.get(0).getPath(), 1002);
head_path = head_dir + System.currentTimeMillis() + "hand_carmer.jpg"; }
showCameraAction(REQUEST_CODE_FILL_CAMER_HEAD, head_path);
dialog.dismiss(); }
});
builder1.setSecondButton("相册中选择", (dialog, which) -> { @Override
Intent intent = new Intent(FillInfoActivity.this, ImageGridActivity.class); public void onCancel() {
startActivityForResult(intent, IMAGE_PICKER);
dialog.dismiss(); }
}); });
builder1.setThridButton("取消", (dialog, which) -> dialog.dismiss());
builder1.create().show();
} else {
ToastHelper.Companion.show("缺少使用相机和读取存储权限,无法获取图片");
}
});
} else if (id == R.id.tv_sex) { } else if (id == R.id.tv_sex) {
List<String> name = new ArrayList<String>(); List<String> name = new ArrayList<String>();
name.add("男"); name.add("男");
...@@ -436,19 +414,6 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen ...@@ -436,19 +414,6 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
} }
break; 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 ...@@ -498,7 +463,8 @@ public class FillInfoActivity extends BaseActivity implements View.OnClickListen
*/ */
void uploadImage(final String path, final int requestCode) { void uploadImage(final String path, final int requestCode) {
UserHttp userHttp = UserHttpImpl.Companion.getInstance(); 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()) .compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(disposable -> { .doOnSubscribe(disposable -> {
......
...@@ -82,13 +82,13 @@ class SecretActivity : BaseActivity() { ...@@ -82,13 +82,13 @@ class SecretActivity : BaseActivity() {
agreeAction() agreeAction()
} }
user_use_btn.setOnClickListener { // user_use_btn.setOnClickListener {
H5Activity.start(this@SecretActivity, false) // H5Activity.start(this@SecretActivity, false)
} // }
//
user_secret_protect_btn.setOnClickListener { // user_secret_protect_btn.setOnClickListener {
H5Activity.start(this@SecretActivity, true) // H5Activity.start(this@SecretActivity, true)
} // }
} }
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { 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 ...@@ -5,10 +5,12 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
import android.view.WindowManager import android.view.WindowManager
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.yidianling.user.R import com.yidianling.user.R
import kotlinx.android.synthetic.main.user_secret_dialog_layout.* 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?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -22,14 +24,12 @@ class SecretDialog(context: Context, private val listener: OnSecretDialogListene ...@@ -22,14 +24,12 @@ class SecretDialog(context: Context, private val listener: OnSecretDialogListene
window.attributes = params window.attributes = params
user_secret_dialog_agree.setOnClickListener { user_secret_dialog_agree.setOnClickListener {
listener?.onSure() agreeAction()
} }
user_secret_dialog_no_agree.setOnClickListener { user_secret_dialog_no_agree.setOnClickListener {
listener?.onCancel() listener?.onCancel()
} }
} }
interface OnSecretDialogListener { interface OnSecretDialogListener {
...@@ -37,5 +37,9 @@ class SecretDialog(context: Context, private val listener: OnSecretDialogListene ...@@ -37,5 +37,9 @@ class SecretDialog(context: Context, private val listener: OnSecretDialogListene
fun onSure() 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
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="40dp" android:layout_marginLeft="34dp"
android:layout_marginRight="40dp" android:layout_marginRight="34dp"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:background="@drawable/user_secret_dialog_bg"> android:background="@drawable/user_secret_dialog_bg">
......
...@@ -81,7 +81,7 @@ dependencies { ...@@ -81,7 +81,7 @@ dependencies {
exclude group: 'com.squareup.okhttp3', module: 'logging-interceptor' 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: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' 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 ...@@ -3,10 +3,7 @@ package com.ydl.ydlcommon.app
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Application import android.app.Application
import com.alibaba.android.arouter.launcher.ARouter 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.devicesidlib.DeviceIDHelper
import com.ydl.ydlcommon.actions.imagepicker.YdlImageLoader
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.UpLoadLogUtils import com.ydl.ydlcommon.data.http.UpLoadLogUtils
import com.ydl.ydlcommon.utils.AppProgressUtils import com.ydl.ydlcommon.utils.AppProgressUtils
...@@ -38,7 +35,6 @@ object YdlRepository { ...@@ -38,7 +35,6 @@ object YdlRepository {
//初始化工具类 //初始化工具类
RxTool.init(app) RxTool.init(app)
BuryPointUtils.init() BuryPointUtils.init()
initImagePicker()
// if (LeakCanary.isInAnalyzerProcess(app)) { // if (LeakCanary.isInAnalyzerProcess(app)) {
// // This process is dedicated to LeakCanary for heap analysis. // // This process is dedicated to LeakCanary for heap analysis.
...@@ -75,20 +71,4 @@ object YdlRepository { ...@@ -75,20 +71,4 @@ object YdlRepository {
} }
ARouter.init(app) 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 package com.ydl.ydlcommon.utils.log
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.util.Log import android.util.Log
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
...@@ -45,7 +46,7 @@ class LogHelper private constructor() { ...@@ -45,7 +46,7 @@ class LogHelper private constructor() {
/** /**
* 删除过期日志 * 删除过期日志
*/ */
fun deleteExpireLog() { private fun deleteExpireLog() {
val files = getLogFolder().listFiles() val files = getLogFolder().listFiles()
val calendar = Calendar.getInstance() val calendar = Calendar.getInstance()
calendar.add(Calendar.WEEK_OF_YEAR, -1) calendar.add(Calendar.WEEK_OF_YEAR, -1)
...@@ -58,7 +59,9 @@ class LogHelper private constructor() { ...@@ -58,7 +59,9 @@ class LogHelper private constructor() {
} }
} }
@SuppressLint("SimpleDateFormat")
private val dateFormat = SimpleDateFormat("yyyyMMdd") private val dateFormat = SimpleDateFormat("yyyyMMdd")
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeLogSync(content: String) { fun writeLogSync(content: String) {
...@@ -107,6 +110,7 @@ class LogHelper private constructor() { ...@@ -107,6 +110,7 @@ class LogHelper private constructor() {
} }
@SuppressLint("CheckResult")
fun uploadLog(showToast: Boolean) { fun uploadLog(showToast: Boolean) {
Observable.create<File> { Observable.create<File> {
it.onNext(zip()) it.onNext(zip())
......
package com.ydl.ydlcommon.view.banner; package com.ydl.ydlcommon.view.banner;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.widget.ImageView; import android.widget.ImageView;
import com.bumptech.glide.load.engine.DiskCacheStrategy; 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.ISimpleImageOpConfig;
import com.ydl.ydl_image.config.SimpleImageOpConfiger; import com.ydl.ydl_image.config.SimpleImageOpConfiger;
import com.ydl.ydl_image.manager.YDLImageCacheManager; import com.ydl.ydl_image.manager.YDLImageCacheManager;
import com.ydl.ydl_image.module.GlideApp; import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.R; import com.ydl.ydlcommon.R;
import com.ydl.ydlcommon.view.banner.loader.ImageLoader;
/** /**
* Created by xiongyu on 2017/4/7. * Created by xiongyu on 2017/4/7.
*/ */
public class GlideImageDisplayLoader implements ImageLoader { public class GlideImageDisplayLoader extends ImageLoader {
@Override private int placeholderImage;//加载过程中的中间页面
public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { private int radius = 0;
showImage(activity,path,imageView,width,height);
}
@Override public GlideImageDisplayLoader() {
public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
showImage(activity,path,imageView,width,height);
} }
@Override public GlideImageDisplayLoader(int placeholderImage) {
public void displayImage(Activity activity, Uri uri, ImageView imageView, int width, int i1) { this.placeholderImage = placeholderImage;
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){ public GlideImageDisplayLoader(int placeholderImage, int radius) {
SimpleImageOpConfiger sp = new SimpleImageOpConfiger(); this.placeholderImage = placeholderImage;
sp.loadingPic = R.drawable.platform_default_img; this.radius = radius;
sp.errorPic = R.drawable.platform_default_img;
sp.scaleType = ISimpleImageOpConfig.CENTER_CROP;
sp.isCacheOnDisk = false;
YDLImageCacheManager.showImage(activity,path,imageView,width, height,sp);
} }
@Override @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