Skip to content

Commit

Permalink
EPGStation V2.x.x を使用しているとき 録画ルールが 24個(=1ページ目)までしか表示されない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
daigorian committed Jul 7, 2021
1 parent b79f566 commit 355fe5e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/com/daigorian/epcltvapp/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class MainFragment : BrowseSupportFragment() {
Toast.makeText(context!!, R.string.connect_epgstation_failed, Toast.LENGTH_LONG).show()
}
})
EpgStationV2.api?.getRules()?.enqueue(object : Callback<Rules> {
EpgStationV2.api?.getRules(limit=Int.MAX_VALUE)?.enqueue(object : Callback<Rules> {
override fun onResponse(call: Call<Rules>, response: Response<Rules>) {
response.body()?.rules?.forEach { rule ->

Expand Down Expand Up @@ -515,20 +515,20 @@ class MainFragment : BrowseSupportFragment() {
hasOriginalFile = item.hasOriginalFile
)?.enqueue(object : Callback<Records> {
override fun onResponse(call: Call<Records>, response: Response<Records>) {
response.body()?.let { response ->
response.body()?.let { responseRoot ->

//APIのレスポンスをひとつづつアイテムとして加える。最初のアイテムだけ、Loadingアイテムを置き換える
//先にremoveしてaddすると高速でスクロールさせたときに描画とremoveがぶつかって落ちるのであえてreplaceに。
response.records.forEachIndexed { index, recordedProgram ->
responseRoot.records.forEachIndexed { index, recordedProgram ->
if(index == 0) {
adapter.replace(adapter.indexOf(item),recordedProgram)
}else{
adapter.add(recordedProgram)
}
}
//続きがあるなら"次を読み込む"を置く。
val numOfItem = response.records.count().toLong() + item.offset
if (numOfItem < response.total) {
val numOfItem = responseRoot.records.count().toLong() + item.offset
if (numOfItem < responseRoot.total) {
adapter.add(item.copy(offset = numOfItem))
}

Expand Down

0 comments on commit 355fe5e

Please sign in to comment.