캐싱관련해서 Glide3 -> Glide4로 마이그를 하던 중
아주 개빡치는일이.....
glide4 하고 kotlin, annotation끼리 충돌이 일어난다
kotlin 클래스에서 GlideApp을 불러오면 계속 can't resolved가 뜨고...
이걸 해결할려고 kapt를 사용하면 이번엔 annotation쪽에서 말썽이다.
문제는 나와 같은 문제로 질문(이라고 하고 하소연)하는 사람들이 넘치지만
각 라이브러리 담당자들은 자기 scope가 아니라면서 다 close시키네......
GlideApp이 자바에서는 문제가 없어서 일단 코틀린으로 짠걸 다시 자바로....ㅁㄴㅇㄹㅁㄴ럼내ㅑ러내러ㅑㅇㅁ내ㅑㅇ러ㅐㅁㄴ러
class TeamView(internal val context: Context) : LinearLayout(context) {
private var teamId: Long? = 0
private var isApplyingPerformance: Boolean = false
private var team: BPTeam? = null
private var realmListener: RealmChangeListener<BPTeam>? = null
private var clickListener: OnTeamListClickListener? = null
init {
View.inflate(context, R.layout.item_team, this)
}
fun bind(long: Long?, isApplyingPerformance: Boolean): Unit {
teamId = long
this.isApplyingPerformance = isApplyingPerformance
realmListener?.let {
team?.removeChangeListener(realmListener)
realmListener = null
}
team = teamId?.let { BPTeam.findTeamWhereTeamId(it) }
team?.let {
realmListener = RealmChangeListener { _: BPTeam -> updateUI() }
team?.addChangeListener(realmListener)
}
updateUI()
}
fun updateUI() {
val mainHandler = Handler(context.mainLooper)
val mainRunnable = Runnable {
val bpTeam = teamId?.let { BPTeam.findTeamWhereTeamId(it) }
bpTeam?.let {
if (isApplyingPerformance) {
editImageView.visibility = View.INVISIBLE
}
if (bpTeam.pictures != null && bpTeam.pictures.size > 0) {
// GlideApp.with(context.applicationContext)
// .load(bpTeam.pictures[0].thumb)
// .placeholder(bpTeam.pictures[0].backgroundColorDrawable)
// .into(teamImageView)
// .bitmapTransform(CropCircleTransformation(context.applicationContext)).into(teamImageView)
/** isActive 가 false 면 아직 팀 정보를 다 입력하지 않음 -> blur 처리 */
if (!bpTeam.isActive) {
// GlideApp.with(context.applicationContext)
// .load(bpTeam.pictures[0].thumb)
// .placeholder(bpTeam.pictures[0].backgroundColorDrawable)
// .into(teamImageView)
// .bitmapTransform(BlurTransformation(context.applicationContext, 10),
// CropCircleTransformation(context.applicationContext)).into(teamImageView)
teamNameTextView.setTextColor(ContextCompat.getColor(context.applicationContext, R.color.edit_hint))
}
} else {
// GlideApp.with(context.applicationContext)
// .load("")
// .placeholder(R.drawable.no_image_team)
// .into(teamImageView)
// .bitmapTransform(CropCircleTransformation(context.applicationContext)).into(teamImageView)
}
teamNameTextView.text = bpTeam.name
editImageView.setOnClickListener({
teamId?.let { it1 -> clickListener?.onEditClick(it1) }
})
item.setOnClickListener({
teamId?.let { it1 -> clickListener?.onClick(it1) }
})
item.setOnLongClickListener({
teamId?.let { it1 -> clickListener?.onLongClick(it1) }
true
})
}
}
mainHandler.post(mainRunnable)
}
interface OnTeamListClickListener {
fun onClick(teamId: Long)
fun onEditClick(teamId: Long)
fun onLongClick(teamId: Long)
}
fun setClickListener(clickListener: OnTeamListClickListener?): Unit {
this.clickListener = clickListener
}
}
class PerformanceZoneView(internal val context: Context) : LinearLayout(context) {
private var zoneId: Long? = 0
private var zone: BPZone? = null
private var realmListener: RealmChangeListener<BPPerformance>? = null
private var clickListener: OnPerformanceZoneListClickListener? = null
init {
View.inflate(context, R.layout.item_performance_zone, this)
}
fun bind(long: Long?): Unit {
zoneId = long
realmListener?.let {
zone?.removeChangeListener(realmListener)
realmListener = null
}
zone = Realm.getDefaultInstance().where(BPZone::class.java).equalTo("id", zoneId).findFirst()
zone?.let {
realmListener = RealmChangeListener { _: BPPerformance -> updateUI() }
zone?.addChangeListener(realmListener)
}
updateUI()
}
fun updateUI() {
// val mainHandler = Handler(context.mainLooper)
// val mainRunnable = Runnable {
// val bpZone = Realm.getDefaultInstance().where(BPZone::class.java).equalTo("id", zoneId).findFirst()
// bpZone.let {
// if (bpZone.pictures != null && bpZone.pictures.size > 0) {
// Glide.with(context.applicationContext)
// .load(bpZone.pictures[0].thumb)
// .placeholder(bpZone.pictures[0].backgroundColorDrawable)
// .bitmapTransform(CropCircleTransformation(context.applicationContext)).into(zoneImageView)
// }
// /** isActive 가 false 면 아직 존 정보를 를 다 입력하지 않음 -> blur 처리 */
// if (!bpZone.isActive) {
// Glide.with(context.applicationContext)
// .load(bpZone.pictures[0].thumb)
// .placeholder(bpZone.pictures[0].backgroundColorDrawable)
// .bitmapTransform(BlurTransformation(context.applicationContext, 10),
// CropCircleTransformation(context.applicationContext)).into(zoneImageView)
//
// zoneNameTextView.setTextColor(ContextCompat.getColor(context.applicationContext, R.color.edit_hint))
// managerNameTextView.setTextColor(ContextCompat.getColor(context.applicationContext, R.color.edit_hint))
// addressTextView.setTextColor(ContextCompat.getColor(context.applicationContext, R.color.edit_hint))
// }
// zoneNameTextView.text = bpZone.name
// managerNameTextView.text = bpZone.tel
// addressTextView.text = bpZone?.location?.address + bpZone.addressDetail
// item.setOnClickListener({
// zoneId?.let { it1 -> clickListener?.onClick(it1) }
// })
// }
// }
// mainHandler.post(mainRunnable)
}
interface OnPerformanceZoneListClickListener {
fun onClick(zoneId: Long)
}
fun setClickListener(clickListener: OnPerformanceZoneListClickListener?): Unit {
this.clickListener = clickListener
}
}
'Programming > Android' 카테고리의 다른 글
Anko (0) | 2017.11.27 |
---|---|
Glide 관련 이슈(이미지 로딩 실패) (0) | 2017.11.27 |
Flavor로 앱 이름 다르게 배포시 참고사항 (0) | 2017.08.15 |
안드로이드 Flavor 적용 (0) | 2017.08.02 |
Glide 관련 이슈(centerCrop, context) (1) | 2017.06.15 |