forked from starfish23/mangafeed
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorder downloads + Fixes to extensions autochecker
- Loading branch information
1 parent
65ca7ab
commit 53f7b3a
Showing
9 changed files
with
180 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 10 additions & 58 deletions
68
app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,24 @@ | ||
package eu.kanade.tachiyomi.ui.download | ||
|
||
import androidx.recyclerview.widget.RecyclerView | ||
import android.view.ViewGroup | ||
import eu.kanade.tachiyomi.R | ||
import eu.kanade.tachiyomi.data.download.model.Download | ||
import eu.kanade.tachiyomi.util.inflate | ||
import eu.davidea.flexibleadapter.FlexibleAdapter | ||
|
||
/** | ||
* Adapter storing a list of downloads. | ||
* | ||
* @param context the context of the fragment containing this adapter. | ||
*/ | ||
class DownloadAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<DownloadHolder>() { | ||
|
||
private var items = emptyList<Download>() | ||
|
||
init { | ||
setHasStableIds(true) | ||
} | ||
|
||
/** | ||
* Sets a list of downloads in the adapter. | ||
* | ||
* @param downloads the list to set. | ||
*/ | ||
fun setItems(downloads: List<Download>) { | ||
items = downloads | ||
notifyDataSetChanged() | ||
} | ||
class DownloadAdapter(controller: DownloadController) : FlexibleAdapter<DownloadItem>(null, controller, | ||
true) { | ||
|
||
/** | ||
* Returns the number of downloads in the adapter | ||
* Listener called when an item of the list is released. | ||
*/ | ||
override fun getItemCount(): Int { | ||
return items.size | ||
} | ||
val onItemReleaseListener: OnItemReleaseListener = controller | ||
|
||
/** | ||
* Returns the identifier for a download. | ||
* | ||
* @param position the position in the adapter. | ||
* @return an identifier for the item. | ||
*/ | ||
override fun getItemId(position: Int): Long { | ||
return items[position].chapter.id!! | ||
interface OnItemReleaseListener { | ||
/** | ||
* Called when an item of the list is released. | ||
*/ | ||
fun onItemReleased(position: Int) | ||
} | ||
|
||
/** | ||
* Creates a new view holder. | ||
* | ||
* @param parent the parent view. | ||
* @param viewType the type of the holder. | ||
* @return a new view holder for a manga. | ||
*/ | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DownloadHolder { | ||
val view = parent.inflate(R.layout.download_item) | ||
return DownloadHolder(view) | ||
} | ||
|
||
/** | ||
* Binds a holder with a new position. | ||
* | ||
* @param holder the holder to bind. | ||
* @param position the position to bind. | ||
*/ | ||
override fun onBindViewHolder(holder: DownloadHolder, position: Int) { | ||
val download = items[position] | ||
holder.onSetValues(download) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.