Commit 9e3f65bf authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

add AppGlideModule;

set cache directory for glide content (images by design) as cache/files/photos
parent 8f4943c3
...@@ -125,6 +125,7 @@ dependencies { ...@@ -125,6 +125,7 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.14.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2' implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.14.0' implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.14.0'
......
package com.biganto.visual.roompark.di.dagger
import android.content.Context
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory
import com.bumptech.glide.module.AppGlideModule
/**
* Created by Vladislav Bogdashkin on 19.03.2020.
*/
@GlideModule
class RoomParkGlideModule : AppGlideModule() {
// fun applyOptions(@NonNull context: Context?, @NonNull builder: GlideBuilder) {
// super.applyOptions(context, builder)
// builder.setDefaultRequestOptions(RequestOptions().format(DecodeFormat.PREFER_ARGB_8888))
// }
override fun applyOptions(context: Context, builder: GlideBuilder) {
val filderName = "../files/photos"
builder.setDiskCache(
InternalCacheDiskCacheFactory(
context,filderName,1024L*1024L*256L)
)
}
//
// fun registerComponents(
// @NonNull context: Context?, @NonNull glide: Glide?, @NonNull registry: Registry
// ) {
// registry.append(Photo::class.java, InputStream::class.java, Factory())
// }
// Disable manifest parsing to avoid adding similar modules twice.
override fun isManifestParsingEnabled(): Boolean {
return false
}
}
\ No newline at end of file
...@@ -9,6 +9,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel ...@@ -9,6 +9,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
/** /**
...@@ -40,6 +41,7 @@ class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewMode ...@@ -40,6 +41,7 @@ class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewMode
.load(model.previewUrl) .load(model.previewUrl)
.centerCrop() .centerCrop()
.fitCenter() .fitCenter()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(preview) .into(preview)
} }
} }
...@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc ...@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.detaches import com.jakewharton.rxbinding3.view.detaches
import com.jakewharton.rxrelay2.BehaviorRelay import com.jakewharton.rxrelay2.BehaviorRelay
...@@ -90,6 +91,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView) ...@@ -90,6 +91,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
.load(it.url) .load(it.url)
.centerCrop() .centerCrop()
.fitCenter() .fitCenter()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(photoPreview) .into(photoPreview)
}} }}
} }
......
...@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.article.util.HtmlPageAdap ...@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.article.util.HtmlPageAdap
import com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag import com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import com.biganto.visual.roompark.util.extensions.formatToSimple import com.biganto.visual.roompark.util.extensions.formatToSimple
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import jp.wasabeef.glide.transformations.BlurTransformation import jp.wasabeef.glide.transformations.BlurTransformation
import timber.log.Timber import timber.log.Timber
...@@ -123,10 +124,12 @@ class ArticleScreenController : ...@@ -123,10 +124,12 @@ class ArticleScreenController :
Glide.with(blurPreview) Glide.with(blurPreview)
.load(viewState.item.previewUrl) .load(viewState.item.previewUrl)
.transform(BlurTransformation(40,4)) .transform(BlurTransformation(40,4))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(blurPreview) .into(blurPreview)
Glide.with(articlePreview) Glide.with(articlePreview)
.load(viewState.item.previewUrl) .load(viewState.item.previewUrl)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(articlePreview) .into(articlePreview)
} }
......
...@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView ...@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
/** /**
...@@ -94,6 +95,7 @@ class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource ...@@ -94,6 +95,7 @@ class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource
Glide.with(itemView) Glide.with(itemView)
.load(url) .load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(itemView as ImageView) .into(itemView as ImageView)
} }
} }
......
...@@ -23,6 +23,7 @@ import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusPr ...@@ -23,6 +23,7 @@ import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusPr
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks import com.jakewharton.rxbinding3.view.clicks
import com.jakewharton.rxbinding3.view.scrollChangeEvents import com.jakewharton.rxbinding3.view.scrollChangeEvents
...@@ -212,6 +213,7 @@ class DealScreenController : ...@@ -212,6 +213,7 @@ class DealScreenController :
viewState.estate.estate.multitourPreview?.let { viewState.estate.estate.multitourPreview?.let {
Glide.with(tourScreen) Glide.with(tourScreen)
.load(it) .load(it)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(tourScreen) .into(tourScreen)
} }
......
...@@ -19,6 +19,7 @@ import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView ...@@ -19,6 +19,7 @@ import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks import com.jakewharton.rxbinding3.view.clicks
import io.reactivex.Observable import io.reactivex.Observable
...@@ -98,12 +99,10 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi ...@@ -98,12 +99,10 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
statusLayout.addView(currentStatusText,0) statusLayout.addView(currentStatusText,0)
statusLayout.invalidate() statusLayout.invalidate()
model.tourPreview?.let { model.tourPreview?.let {
Glide.with(tourScreen) Glide.with(tourScreen)
.load(it) .load(it)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(tourScreen) .into(tourScreen)
} }
} }
......
...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc ...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone import com.biganto.visual.roompark.util.extensions.setGone
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import timber.log.Timber import timber.log.Timber
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
...@@ -46,6 +47,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>( ...@@ -46,6 +47,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
Glide.with(preview) Glide.with(preview)
.load(model.previewUrl) .load(model.previewUrl)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(preview) .into(preview)
} }
......
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