Skip to content

Commit

Permalink
remove background thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
knzfujii committed Oct 21, 2021
1 parent 586775f commit b4a0886
Showing 1 changed file with 0 additions and 65 deletions.
65 changes: 0 additions & 65 deletions app/src/main/java/com/daigorian/epcltvapp/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ import retrofit2.Response
class MainFragment : BrowseSupportFragment() {

private val mHandler = Handler(Looper.getMainLooper())
private lateinit var mBackgroundManager: BackgroundManager
private var mDefaultBackground: Drawable? = null
private lateinit var mMetrics: DisplayMetrics
private var mBackgroundTimer: Timer? = null
private var mBackgroundUri: String? = null
private var mNeedsReloadAllOnResume = false
private var mNeedsReloadHistoryOnResume = false

Expand Down Expand Up @@ -102,8 +99,6 @@ class MainFragment : BrowseSupportFragment() {

override fun onDestroy() {
super.onDestroy()
Log.d(TAG, "onDestroy: " + mBackgroundTimer?.toString())
mBackgroundTimer?.cancel()
}

private fun initEPGStationApi(){
Expand Down Expand Up @@ -180,9 +175,6 @@ class MainFragment : BrowseSupportFragment() {
}

private fun prepareBackgroundManager() {

mBackgroundManager = BackgroundManager.getInstance(activity)
mBackgroundManager.attach(requireActivity().window)
mDefaultBackground = ContextCompat.getDrawable(requireContext(), R.drawable.default_background)
mMetrics = DisplayMetrics()
//from API LEVEL 30
Expand Down Expand Up @@ -475,20 +467,6 @@ class MainFragment : BrowseSupportFragment() {
rowViewHolder: RowPresenter.ViewHolder, row: Row
) {
when (item) {
is RecordedProgram -> {
// EPGStation Version 1.x.x
mBackgroundUri = EpgStation.getThumbnailURL(item.id.toString())
startBackgroundTimer()
}
is RecordedItem -> {
// EPGStation Version 2.x.x
mBackgroundUri = if(!item.thumbnails.isNullOrEmpty()) {
EpgStationV2.getThumbnailURL(item.thumbnails[0].toString())
} else {
EpgStationV2.getThumbnailURL("") // ありえないURLでエラーに落とす。
}
startBackgroundTimer()
}
is GetRecordedParam -> {
// EPGStation Version 1.x.x の続きを取得するアイテム
val adapter = ((row as ListRow).adapter as ArrayObjectAdapter)
Expand Down Expand Up @@ -580,49 +558,6 @@ class MainFragment : BrowseSupportFragment() {
}
}

private fun updateBackground(uri: String?) {
val width = mMetrics.widthPixels
val height = mMetrics.heightPixels

//Glideでイメージを取得する際にBasic認証が必要な場合はヘッダを付与してやる
val glideUrl = if(EpgStation.api!=null && EpgStation.authForGlide!=null){
GlideUrl( uri, EpgStation.authForGlide)
}else if(EpgStationV2.api!=null && EpgStationV2.authForGlide!=null){
GlideUrl( uri, EpgStationV2.authForGlide)
}else{
GlideUrl ( uri )
}

Glide.with(requireContext())
.load(glideUrl)
.centerCrop()
.error(mDefaultBackground)
.into<CustomTarget<Drawable>>(
object : CustomTarget<Drawable>(width, height) {
override fun onResourceReady(
drawable: Drawable,
transition: Transition<in Drawable>?
) {
mBackgroundManager.drawable = drawable
}
override fun onLoadCleared(placeholder: Drawable?) {}
})
mBackgroundTimer?.cancel()
}

private fun startBackgroundTimer() {
mBackgroundTimer?.cancel()
mBackgroundTimer = Timer()
mBackgroundTimer?.schedule(UpdateBackgroundTask(), BACKGROUND_UPDATE_DELAY.toLong())
}

private inner class UpdateBackgroundTask : TimerTask() {

override fun run() {
mHandler.post { updateBackground(mBackgroundUri) }
}
}

private inner class GridItemPresenter : Presenter() {
override fun onCreateViewHolder(parent: ViewGroup): ViewHolder {
val view = TextView(parent.context)
Expand Down

0 comments on commit b4a0886

Please sign in to comment.