Skip to content

Commit

Permalink
session-changes - tweaks to adapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
masterwok committed Aug 10, 2018
1 parent 57a6cd8 commit 8adce50
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@ class TorrentPieceAdapter : RecyclerView.Adapter<TorrentPieceAdapter.PieceViewHo
, position: Int
): Int {
val isDownloaded = torrentSessionBuffer.isPieceDownloaded(position)
val isHeadIndex = torrentSessionBuffer.bufferHeadIndex == position

if (isDownloaded) {
if (isHeadIndex) {
return ContextCompat.getColor(context, R.color.blue)
}

return ContextCompat.getColor(context, R.color.green)
}

if (torrentSessionBuffer.bufferSize == 0) {
return ContextCompat.getColor(context, R.color.purple)
}

if (torrentSessionBuffer.bufferHeadIndex == position) {
if (isDownloaded) {
return ContextCompat.getColor(context, R.color.blue)
}

if (isHeadIndex) {
return ContextCompat.getColor(context, R.color.red)
}

Expand Down

0 comments on commit 8adce50

Please sign in to comment.