mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 03:12:15 +00:00
Improve: Android Studio's Reformat
This commit is contained in:
parent
e49b357173
commit
a321e9bfa5
@ -58,6 +58,7 @@ Run `./gradlew assembleRelease` to build the package, which can be installed usi
|
||||
package manager.
|
||||
|
||||
## :scroll: License
|
||||
|
||||
Licensed GPLv3+. \
|
||||
Direct Adaptation/Modification of [Foxy-Droid](https://github.com/kitsunyan/foxy-droid/) \
|
||||
Copyright © 2020–2021 Iamlooker and contributors.
|
||||
|
@ -53,7 +53,8 @@ class MainApplication : Application(), ImageLoaderFactory {
|
||||
if (packageName != null) {
|
||||
when (intent.action.orEmpty()) {
|
||||
Intent.ACTION_PACKAGE_ADDED,
|
||||
Intent.ACTION_PACKAGE_REMOVED -> {
|
||||
Intent.ACTION_PACKAGE_REMOVED,
|
||||
-> {
|
||||
val packageInfo = try {
|
||||
packageManager.getPackageInfo(
|
||||
packageName,
|
||||
|
@ -155,7 +155,7 @@ object Cache {
|
||||
|
||||
override fun query(
|
||||
uri: Uri, projection: Array<String>?,
|
||||
selection: String?, selectionArgs: Array<out String>?, sortOrder: String?
|
||||
selection: String?, selectionArgs: Array<out String>?, sortOrder: String?,
|
||||
): Cursor {
|
||||
val file = getFileAndTypeForUri(uri).first
|
||||
val columns = (projection ?: defaultColumns).mapNotNull {
|
||||
@ -179,7 +179,7 @@ object Cache {
|
||||
|
||||
override fun update(
|
||||
uri: Uri, contentValues: ContentValues?,
|
||||
selection: String?, selectionArgs: Array<out String>?
|
||||
selection: String?, selectionArgs: Array<out String>?,
|
||||
): Int = unsupported
|
||||
|
||||
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? {
|
||||
|
@ -13,7 +13,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
data class ProductsAvailable(
|
||||
val searchQuery: String, val section: ProductItem.Section,
|
||||
val order: ProductItem.Order
|
||||
val order: ProductItem.Order,
|
||||
) : Request() {
|
||||
override val id: Int
|
||||
get() = 1
|
||||
@ -21,7 +21,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
data class ProductsInstalled(
|
||||
val searchQuery: String, val section: ProductItem.Section,
|
||||
val order: ProductItem.Order
|
||||
val order: ProductItem.Order,
|
||||
) : Request() {
|
||||
override val id: Int
|
||||
get() = 2
|
||||
@ -29,7 +29,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
data class ProductsUpdates(
|
||||
val searchQuery: String, val section: ProductItem.Section,
|
||||
val order: ProductItem.Order
|
||||
val order: ProductItem.Order,
|
||||
) : Request() {
|
||||
override val id: Int
|
||||
get() = 3
|
||||
@ -48,7 +48,7 @@ class CursorOwner : Fragment(), LoaderManager.LoaderCallbacks<Cursor> {
|
||||
private data class ActiveRequest(
|
||||
val request: Request,
|
||||
val callback: Callback?,
|
||||
val cursor: Cursor?
|
||||
val cursor: Cursor?,
|
||||
)
|
||||
|
||||
init {
|
||||
|
@ -308,7 +308,7 @@ object Database {
|
||||
private fun SQLiteDatabase.insertOrReplace(
|
||||
replace: Boolean,
|
||||
table: String,
|
||||
contentValues: ContentValues
|
||||
contentValues: ContentValues,
|
||||
): Long {
|
||||
return if (replace) replace(table, null, contentValues) else insert(
|
||||
table,
|
||||
@ -320,7 +320,7 @@ object Database {
|
||||
private fun SQLiteDatabase.query(
|
||||
table: String, columns: Array<String>? = null,
|
||||
selection: Pair<String, Array<String>>? = null, orderBy: String? = null,
|
||||
signal: CancellationSignal? = null
|
||||
signal: CancellationSignal? = null,
|
||||
): Cursor {
|
||||
return query(
|
||||
false,
|
||||
@ -501,7 +501,7 @@ object Database {
|
||||
// Complex left to wiring phase
|
||||
fun query(
|
||||
installed: Boolean, updates: Boolean, searchQuery: String,
|
||||
section: ProductItem.Section, order: ProductItem.Order, signal: CancellationSignal?
|
||||
section: ProductItem.Section, order: ProductItem.Order, signal: CancellationSignal?,
|
||||
): Cursor {
|
||||
val builder = QueryBuilder()
|
||||
|
||||
|
@ -6,10 +6,11 @@ import android.database.Cursor
|
||||
import android.database.CursorWrapper
|
||||
|
||||
class ObservableCursor(
|
||||
cursor: Cursor, private val observable: (
|
||||
cursor: Cursor,
|
||||
private val observable: (
|
||||
register: Boolean,
|
||||
observer: () -> Unit
|
||||
) -> Unit
|
||||
observer: () -> Unit,
|
||||
) -> Unit,
|
||||
) : CursorWrapper(cursor) {
|
||||
private var registered = false
|
||||
private val contentObservable = ContentObservable()
|
||||
|
@ -5,5 +5,5 @@ class InstalledItem(
|
||||
val packageName: String,
|
||||
val version: String,
|
||||
val versionCode: Long,
|
||||
val signature: String
|
||||
val signature: String,
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ data class Product(
|
||||
val licenses: List<String>,
|
||||
val donates: List<Donate>,
|
||||
val screenshots: List<Screenshot>,
|
||||
val releases: List<Release>
|
||||
val releases: List<Release>,
|
||||
) {
|
||||
data class Author(val name: String, val email: String, val web: String)
|
||||
|
||||
@ -163,7 +163,7 @@ data class Product(
|
||||
fun <T> findSuggested(
|
||||
products: List<T>,
|
||||
installedItem: InstalledItem?,
|
||||
extract: (T) -> Product
|
||||
extract: (T) -> Product,
|
||||
): T? {
|
||||
return products.maxWithOrNull(compareBy({
|
||||
extract(it).compatible &&
|
||||
|
@ -10,7 +10,7 @@ import com.looker.droidify.utility.extension.json.forEachKey
|
||||
data class ProductItem(
|
||||
var repositoryId: Long, var packageName: String, var name: String, var summary: String,
|
||||
val icon: String, val metadataIcon: String, val version: String, var installedVersion: String,
|
||||
var compatible: Boolean, var canUpdate: Boolean, var matchRank: Int
|
||||
var compatible: Boolean, var canUpdate: Boolean, var matchRank: Int,
|
||||
) {
|
||||
sealed class Section : KParcelable {
|
||||
object All : Section() {
|
||||
|
@ -29,7 +29,7 @@ data class Release(
|
||||
val permissions: List<String>,
|
||||
val features: List<String>,
|
||||
val platforms: List<String>,
|
||||
val incompatibilities: List<Incompatibility>
|
||||
val incompatibilities: List<Incompatibility>,
|
||||
) {
|
||||
sealed class Incompatibility {
|
||||
object MinSdk : Incompatibility()
|
||||
|
@ -11,7 +11,7 @@ data class Repository(
|
||||
var id: Long, val address: String, val mirrors: List<String>,
|
||||
val name: String, val description: String, val version: Int, val enabled: Boolean,
|
||||
val fingerprint: String, val lastModified: String, val entityTag: String,
|
||||
val updated: Long, val timestamp: Long, val authentication: String
|
||||
val updated: Long, val timestamp: Long, val authentication: String,
|
||||
) {
|
||||
fun edit(address: String, fingerprint: String, authentication: String): Repository {
|
||||
val addressChanged = this.address != address
|
||||
@ -28,7 +28,7 @@ data class Repository(
|
||||
|
||||
fun update(
|
||||
mirrors: List<String>, name: String, description: String, version: Int,
|
||||
lastModified: String, entityTag: String, timestamp: Long
|
||||
lastModified: String, entityTag: String, timestamp: Long,
|
||||
): Repository {
|
||||
return copy(
|
||||
mirrors = mirrors, name = name, description = description,
|
||||
@ -100,7 +100,7 @@ data class Repository(
|
||||
fun newRepository(
|
||||
address: String,
|
||||
fingerprint: String,
|
||||
authentication: String
|
||||
authentication: String,
|
||||
): Repository {
|
||||
val name = try {
|
||||
URL(address).let { "${it.host}${it.path}" }
|
||||
@ -112,7 +112,7 @@ data class Repository(
|
||||
|
||||
private fun defaultRepository(
|
||||
address: String, name: String, description: String,
|
||||
version: Int, enabled: Boolean, fingerprint: String, authentication: String
|
||||
version: Int, enabled: Boolean, fingerprint: String, authentication: String,
|
||||
): Repository {
|
||||
return Repository(
|
||||
-1, address, emptyList(), name, description, version, enabled,
|
||||
|
@ -30,7 +30,7 @@ class IndexHandler(private val repositoryId: Long, private val callback: Callbac
|
||||
interface Callback {
|
||||
fun onRepository(
|
||||
mirrors: List<String>, name: String, description: String,
|
||||
certificate: String, version: Int, timestamp: Long
|
||||
certificate: String, version: Int, timestamp: Long,
|
||||
)
|
||||
|
||||
fun onProduct(product: Product)
|
||||
@ -181,7 +181,7 @@ class IndexHandler(private val repositoryId: Long, private val callback: Callbac
|
||||
uri: String,
|
||||
localName: String,
|
||||
qName: String,
|
||||
attributes: Attributes
|
||||
attributes: Attributes,
|
||||
) {
|
||||
super.startElement(uri, localName, qName, attributes)
|
||||
|
||||
|
@ -16,7 +16,7 @@ object IndexV1Parser {
|
||||
name: String,
|
||||
description: String,
|
||||
version: Int,
|
||||
timestamp: Long
|
||||
timestamp: Long,
|
||||
)
|
||||
|
||||
fun onProduct(product: Product)
|
||||
@ -26,17 +26,17 @@ object IndexV1Parser {
|
||||
private class Screenshots(
|
||||
val phone: List<String>,
|
||||
val smallTablet: List<String>,
|
||||
val largeTablet: List<String>
|
||||
val largeTablet: List<String>,
|
||||
)
|
||||
|
||||
private class Localized(
|
||||
val name: String, val summary: String, val description: String,
|
||||
val whatsNew: String, val metadataIcon: String, val screenshots: Screenshots?
|
||||
val whatsNew: String, val metadataIcon: String, val screenshots: Screenshots?,
|
||||
)
|
||||
|
||||
private fun <T> Map<String, Localized>.getAndCall(
|
||||
key: String,
|
||||
callback: (String, Localized) -> T?
|
||||
callback: (String, Localized) -> T?,
|
||||
): T? {
|
||||
return this[key]?.let { callback(key, it) }
|
||||
}
|
||||
@ -50,7 +50,7 @@ object IndexV1Parser {
|
||||
|
||||
private fun Map<String, Localized>.findString(
|
||||
fallback: String,
|
||||
callback: (Localized) -> String
|
||||
callback: (Localized) -> String,
|
||||
): String {
|
||||
return (find { _, localized -> callback(localized).nullIfEmpty() } ?: fallback).trim()
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ object RepositoryUpdater {
|
||||
private enum class IndexType(
|
||||
val jarName: String,
|
||||
val contentName: String,
|
||||
val certificateFromIndex: Boolean
|
||||
val certificateFromIndex: Boolean,
|
||||
) {
|
||||
INDEX("index.jar", "index.xml", true),
|
||||
INDEX_V1("index-v1.jar", "index-v1.json", false)
|
||||
@ -93,7 +93,7 @@ object RepositoryUpdater {
|
||||
fun update(
|
||||
context: Context,
|
||||
repository: Repository, unstable: Boolean,
|
||||
callback: (Stage, Long, Long?) -> Unit
|
||||
callback: (Stage, Long, Long?) -> Unit,
|
||||
): Single<Boolean> {
|
||||
return update(
|
||||
context,
|
||||
@ -107,7 +107,7 @@ object RepositoryUpdater {
|
||||
private fun update(
|
||||
context: Context,
|
||||
repository: Repository, indexTypes: List<IndexType>, unstable: Boolean,
|
||||
callback: (Stage, Long, Long?) -> Unit
|
||||
callback: (Stage, Long, Long?) -> Unit,
|
||||
): Single<Boolean> {
|
||||
val indexType = indexTypes[0]
|
||||
return downloadIndex(context, repository, indexType, callback)
|
||||
@ -152,7 +152,7 @@ object RepositoryUpdater {
|
||||
private fun downloadIndex(
|
||||
context: Context,
|
||||
repository: Repository, indexType: IndexType,
|
||||
callback: (Stage, Long, Long?) -> Unit
|
||||
callback: (Stage, Long, Long?) -> Unit,
|
||||
): Single<Pair<Downloader.Result, File>> {
|
||||
return Single.just(Unit)
|
||||
.map { Cache.getTemporaryFile(context) }
|
||||
@ -190,7 +190,7 @@ object RepositoryUpdater {
|
||||
private fun processFile(
|
||||
context: Context,
|
||||
repository: Repository, indexType: IndexType, unstable: Boolean,
|
||||
file: File, lastModified: String, entityTag: String, callback: (Stage, Long, Long?) -> Unit
|
||||
file: File, lastModified: String, entityTag: String, callback: (Stage, Long, Long?) -> Unit,
|
||||
): Boolean {
|
||||
var rollback = true
|
||||
return synchronized(updaterLock) {
|
||||
@ -216,7 +216,7 @@ object RepositoryUpdater {
|
||||
IndexHandler(repository.id, object : IndexHandler.Callback {
|
||||
override fun onRepository(
|
||||
mirrors: List<String>, name: String, description: String,
|
||||
certificate: String, version: Int, timestamp: Long
|
||||
certificate: String, version: Int, timestamp: Long,
|
||||
) {
|
||||
changedRepository = repository.update(
|
||||
mirrors, name, description, version,
|
||||
@ -278,7 +278,7 @@ object RepositoryUpdater {
|
||||
name: String,
|
||||
description: String,
|
||||
version: Int,
|
||||
timestamp: Long
|
||||
timestamp: Long,
|
||||
) {
|
||||
changedRepository = repository.update(
|
||||
mirrors, name, description, version,
|
||||
@ -299,7 +299,7 @@ object RepositoryUpdater {
|
||||
|
||||
override fun onReleases(
|
||||
packageName: String,
|
||||
releases: List<Release>
|
||||
releases: List<Release>,
|
||||
) {
|
||||
if (Thread.interrupted()) {
|
||||
throw InterruptedException()
|
||||
@ -432,7 +432,7 @@ object RepositoryUpdater {
|
||||
private fun transformProduct(
|
||||
product: Product,
|
||||
features: Set<String>,
|
||||
unstable: Boolean
|
||||
unstable: Boolean,
|
||||
): Product {
|
||||
val releasePairs =
|
||||
product.releases.distinctBy { it.identifier }.sortedByDescending { it.versionCode }
|
||||
|
@ -92,7 +92,7 @@ object CoilDownloader {
|
||||
fun createScreenshotUri(
|
||||
repository: Repository,
|
||||
packageName: String,
|
||||
screenshot: Product.Screenshot
|
||||
screenshot: Product.Screenshot,
|
||||
): Uri {
|
||||
return Uri.Builder().scheme("https").authority(HOST_SCREENSHOT)
|
||||
.appendQueryParameter(QUERY_ADDRESS, repository.address)
|
||||
@ -115,7 +115,7 @@ object CoilDownloader {
|
||||
packageName: String,
|
||||
icon: String,
|
||||
metadataIcon: String,
|
||||
repository: Repository
|
||||
repository: Repository,
|
||||
): Uri {
|
||||
val size = (view.layoutParams.let { min(it.width, it.height) } /
|
||||
view.resources.displayMetrics.density).roundToInt()
|
||||
@ -124,7 +124,7 @@ object CoilDownloader {
|
||||
|
||||
private fun createIconUri(
|
||||
context: Context, packageName: String, icon: String, metadataIcon: String,
|
||||
targetSizeDp: Int, repository: Repository
|
||||
targetSizeDp: Int, repository: Repository,
|
||||
): Uri {
|
||||
return Uri.Builder().scheme("https").authority(HOST_ICON)
|
||||
.appendQueryParameter(QUERY_ADDRESS, repository.address)
|
||||
|
@ -68,7 +68,7 @@ object Downloader {
|
||||
|
||||
fun download(
|
||||
url: String, target: File, lastModified: String, entityTag: String, authentication: String,
|
||||
callback: ((read: Long, total: Long?) -> Unit)?
|
||||
callback: ((read: Long, total: Long?) -> Unit)?,
|
||||
): Single<Result> {
|
||||
val start = if (target.exists()) target.length().let { if (it > 0L) it else null } else null
|
||||
val request = Request.Builder().url(url)
|
||||
|
@ -68,7 +68,7 @@ class MessageDialog() : DialogFragment() {
|
||||
|
||||
class ReleaseIncompatible(
|
||||
val incompatibilities: List<Release.Incompatibility>,
|
||||
val platforms: List<String>, val minSdkVersion: Int, val maxSdkVersion: Int
|
||||
val platforms: List<String>, val minSdkVersion: Int, val maxSdkVersion: Int,
|
||||
) : Message() {
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeInt(incompatibilities.size)
|
||||
|
@ -13,7 +13,7 @@ import com.looker.droidify.widget.CursorRecyclerAdapter
|
||||
|
||||
class RepositoriesAdapter(
|
||||
private val onClick: (Repository) -> Unit,
|
||||
private val onSwitch: (repository: Repository, isEnabled: Boolean) -> Boolean
|
||||
private val onSwitch: (repository: Repository, isEnabled: Boolean) -> Boolean,
|
||||
) :
|
||||
CursorRecyclerAdapter<RepositoriesAdapter.ViewType, RecyclerView.ViewHolder>() {
|
||||
enum class ViewType { REPOSITORY }
|
||||
@ -38,7 +38,7 @@ class RepositoriesAdapter(
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: ViewType
|
||||
viewType: ViewType,
|
||||
): RecyclerView.ViewHolder {
|
||||
return ViewHolder(parent.inflate(R.layout.repository_item)).apply {
|
||||
itemView.setOnClickListener { onClick(getRepository(adapterPosition)) }
|
||||
|
@ -22,7 +22,7 @@ class RepositoriesFragment : ScreenFragment(), CursorOwner.Callback {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
savedInstanceState: Bundle?,
|
||||
): View {
|
||||
val view = fragmentBinding.root.apply {
|
||||
val content = fragmentBinding.fragmentContent
|
||||
|
@ -32,7 +32,7 @@ abstract class ScreenActivity : AppCompatActivity() {
|
||||
|
||||
private class FragmentStackItem(
|
||||
val className: String, val arguments: Bundle?,
|
||||
val savedState: Fragment.SavedState?
|
||||
val savedState: Fragment.SavedState?,
|
||||
) : KParcelable {
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeString(className)
|
||||
|
@ -211,7 +211,7 @@ class ScreenshotsFragment() : DialogFragment() {
|
||||
fun update(
|
||||
viewPager: ViewPager2,
|
||||
repository: Repository?,
|
||||
screenshots: List<Product.Screenshot>
|
||||
screenshots: List<Product.Screenshot>,
|
||||
) {
|
||||
this.repository = repository
|
||||
this.screenshots = screenshots
|
||||
@ -239,7 +239,7 @@ class ScreenshotsFragment() : DialogFragment() {
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: ViewType
|
||||
viewType: ViewType,
|
||||
): RecyclerView.ViewHolder {
|
||||
return ViewHolder(parent.context).apply {
|
||||
itemView.setOnClickListener { onClick() }
|
||||
|
@ -402,7 +402,7 @@ class TabsFragment : ScreenFragment() {
|
||||
|
||||
private fun setSectionsAndUpdate(
|
||||
categories: List<ProductItem.Section.Category>?,
|
||||
repositories: List<ProductItem.Section.Repository>?
|
||||
repositories: List<ProductItem.Section.Repository>?,
|
||||
) {
|
||||
val oldCategories = collectOldSections(categories)
|
||||
val oldRepositories = collectOldSections(repositories)
|
||||
@ -468,7 +468,7 @@ class TabsFragment : ScreenFragment() {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
positionOffsetPixels: Int,
|
||||
) {
|
||||
val layout = layout!!
|
||||
val fromSections = AppListFragment.Source.values()[position].sections
|
||||
@ -520,7 +520,7 @@ class TabsFragment : ScreenFragment() {
|
||||
|
||||
private class SectionsAdapter(
|
||||
private val sections: () -> List<ProductItem.Section>,
|
||||
private val onClick: (ProductItem.Section) -> Unit
|
||||
private val onClick: (ProductItem.Section) -> Unit,
|
||||
) : StableRecyclerAdapter<SectionsAdapter.ViewType,
|
||||
RecyclerView.ViewHolder>() {
|
||||
enum class ViewType { SECTION }
|
||||
@ -546,7 +546,7 @@ class TabsFragment : ScreenFragment() {
|
||||
fun configureDivider(
|
||||
context: Context,
|
||||
position: Int,
|
||||
configuration: DividerItemDecoration.Configuration
|
||||
configuration: DividerItemDecoration.Configuration,
|
||||
) {
|
||||
val currentSection = sections()[position]
|
||||
val nextSection = sections().getOrNull(position + 1)
|
||||
@ -580,7 +580,7 @@ class TabsFragment : ScreenFragment() {
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: ViewType
|
||||
viewType: ViewType,
|
||||
): RecyclerView.ViewHolder {
|
||||
return SectionViewHolder(parent.context).apply {
|
||||
itemView.setOnClickListener { onClick(sections()[adapterPosition]) }
|
||||
|
@ -9,7 +9,7 @@ import android.os.IBinder
|
||||
class Connection<B : IBinder, S : ConnectionService<B>>(
|
||||
private val serviceClass: Class<S>,
|
||||
private val onBind: ((Connection<B, S>, B) -> Unit)? = null,
|
||||
private val onUnbind: ((Connection<B, S>, B) -> Unit)? = null
|
||||
private val onUnbind: ((Connection<B, S>, B) -> Unit)? = null,
|
||||
) : ServiceConnection {
|
||||
var binder: B? = null
|
||||
private set
|
||||
|
@ -78,7 +78,7 @@ class DownloadService : ConnectionService<DownloadService.Binder>() {
|
||||
|
||||
class Success(
|
||||
packageName: String, name: String, val release: Release,
|
||||
val consume: () -> Unit
|
||||
val consume: () -> Unit,
|
||||
) : State(packageName, name)
|
||||
|
||||
class Error(packageName: String, name: String) : State(packageName, name)
|
||||
@ -89,7 +89,7 @@ class DownloadService : ConnectionService<DownloadService.Binder>() {
|
||||
|
||||
private class Task(
|
||||
val packageName: String, val name: String, val release: Release,
|
||||
val url: String, val authentication: String
|
||||
val url: String, val authentication: String,
|
||||
) {
|
||||
val notificationTag: String
|
||||
get() = "download-$packageName"
|
||||
|
@ -49,7 +49,7 @@ class SyncService : ConnectionService<SyncService.Binder>() {
|
||||
data class Connecting(val name: String) : State()
|
||||
data class Syncing(
|
||||
val name: String, val stage: RepositoryUpdater.Stage,
|
||||
val read: Long, val total: Long?
|
||||
val read: Long, val total: Long?,
|
||||
) : State()
|
||||
|
||||
object Finishing : State()
|
||||
@ -58,7 +58,7 @@ class SyncService : ConnectionService<SyncService.Binder>() {
|
||||
private class Task(val repositoryId: Long, val manual: Boolean)
|
||||
private data class CurrentTask(
|
||||
val task: Task?, val disposable: Disposable,
|
||||
val hasUpdates: Boolean, val lastState: State
|
||||
val hasUpdates: Boolean, val lastState: State,
|
||||
)
|
||||
|
||||
private enum class Started { NO, AUTO, MANUAL }
|
||||
|
@ -118,7 +118,7 @@ class AppListAdapter(private val onClick: (ProductItem) -> Unit) :
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: ViewType
|
||||
viewType: ViewType,
|
||||
): RecyclerView.ViewHolder {
|
||||
return when (viewType) {
|
||||
ViewType.PRODUCT -> ProductViewHolder(parent.inflate(R.layout.product_item)).apply {
|
||||
|
@ -18,7 +18,7 @@ object PackageItemResolver {
|
||||
|
||||
private fun load(
|
||||
context: Context, localCache: LocalCache, packageName: String,
|
||||
nonLocalized: CharSequence?, resId: Int
|
||||
nonLocalized: CharSequence?, resId: Int,
|
||||
): CharSequence? {
|
||||
return when {
|
||||
nonLocalized != null -> {
|
||||
@ -63,7 +63,7 @@ object PackageItemResolver {
|
||||
fun loadLabel(
|
||||
context: Context,
|
||||
localCache: LocalCache,
|
||||
packageItemInfo: PackageItemInfo
|
||||
packageItemInfo: PackageItemInfo,
|
||||
): CharSequence? {
|
||||
return load(
|
||||
context, localCache, packageItemInfo.packageName,
|
||||
@ -74,7 +74,7 @@ object PackageItemResolver {
|
||||
fun loadDescription(
|
||||
context: Context,
|
||||
localCache: LocalCache,
|
||||
permissionInfo: PermissionInfo
|
||||
permissionInfo: PermissionInfo,
|
||||
): CharSequence? {
|
||||
return load(
|
||||
context, localCache, permissionInfo.packageName,
|
||||
@ -88,29 +88,35 @@ object PackageItemResolver {
|
||||
when (permissionInfo.name) {
|
||||
android.Manifest.permission.READ_CONTACTS,
|
||||
android.Manifest.permission.WRITE_CONTACTS,
|
||||
android.Manifest.permission.GET_ACCOUNTS ->
|
||||
android.Manifest.permission.GET_ACCOUNTS,
|
||||
->
|
||||
android.Manifest.permission_group.CONTACTS
|
||||
android.Manifest.permission.READ_CALENDAR,
|
||||
android.Manifest.permission.WRITE_CALENDAR ->
|
||||
android.Manifest.permission.WRITE_CALENDAR,
|
||||
->
|
||||
android.Manifest.permission_group.CALENDAR
|
||||
android.Manifest.permission.SEND_SMS,
|
||||
android.Manifest.permission.RECEIVE_SMS,
|
||||
android.Manifest.permission.READ_SMS,
|
||||
android.Manifest.permission.RECEIVE_MMS,
|
||||
android.Manifest.permission.RECEIVE_WAP_PUSH,
|
||||
"android.permission.READ_CELL_BROADCASTS" ->
|
||||
"android.permission.READ_CELL_BROADCASTS",
|
||||
->
|
||||
android.Manifest.permission_group.SMS
|
||||
android.Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
android.Manifest.permission.ACCESS_MEDIA_LOCATION ->
|
||||
android.Manifest.permission.ACCESS_MEDIA_LOCATION,
|
||||
->
|
||||
android.Manifest.permission_group.STORAGE
|
||||
android.Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
android.Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION ->
|
||||
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION,
|
||||
->
|
||||
android.Manifest.permission_group.LOCATION
|
||||
android.Manifest.permission.READ_CALL_LOG,
|
||||
android.Manifest.permission.WRITE_CALL_LOG,
|
||||
@Suppress("DEPRECATION") android.Manifest.permission.PROCESS_OUTGOING_CALLS ->
|
||||
@Suppress("DEPRECATION") android.Manifest.permission.PROCESS_OUTGOING_CALLS,
|
||||
->
|
||||
android.Manifest.permission_group.CALL_LOG
|
||||
android.Manifest.permission.READ_PHONE_STATE,
|
||||
android.Manifest.permission.READ_PHONE_NUMBERS,
|
||||
@ -118,7 +124,8 @@ object PackageItemResolver {
|
||||
android.Manifest.permission.ADD_VOICEMAIL,
|
||||
android.Manifest.permission.USE_SIP,
|
||||
android.Manifest.permission.ANSWER_PHONE_CALLS,
|
||||
android.Manifest.permission.ACCEPT_HANDOVER ->
|
||||
android.Manifest.permission.ACCEPT_HANDOVER,
|
||||
->
|
||||
android.Manifest.permission_group.PHONE
|
||||
android.Manifest.permission.RECORD_AUDIO ->
|
||||
android.Manifest.permission_group.MICROPHONE
|
||||
|
@ -4,7 +4,7 @@ import java.io.InputStream
|
||||
|
||||
class ProgressInputStream(
|
||||
private val inputStream: InputStream,
|
||||
private val callback: (Long) -> Unit
|
||||
private val callback: (Long) -> Unit,
|
||||
) : InputStream() {
|
||||
private var count = 0L
|
||||
|
||||
|
@ -25,7 +25,7 @@ object RxUtils {
|
||||
private fun <T, R> managedSingle(
|
||||
create: () -> T,
|
||||
cancel: (T) -> Unit,
|
||||
execute: (T) -> R
|
||||
execute: (T) -> R,
|
||||
): Single<R> {
|
||||
return Single.create {
|
||||
val task = create()
|
||||
|
@ -61,7 +61,7 @@ fun JsonParser.forEach(requiredToken: JsonToken, callback: JsonParser.() -> Unit
|
||||
|
||||
fun <T> JsonParser.collectNotNull(
|
||||
requiredToken: JsonToken,
|
||||
callback: JsonParser.() -> T?
|
||||
callback: JsonParser.() -> T?,
|
||||
): List<T> {
|
||||
val list = mutableListOf<T>()
|
||||
forEach(requiredToken) {
|
||||
|
@ -10,10 +10,11 @@ import com.looker.droidify.utility.extension.resources.getDrawableFromAttr
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class DividerItemDecoration(
|
||||
context: Context, private val configure: (
|
||||
context: Context,
|
||||
private val configure: (
|
||||
context: Context,
|
||||
position: Int, configuration: Configuration
|
||||
) -> Unit
|
||||
position: Int, configuration: Configuration,
|
||||
) -> Unit,
|
||||
) : RecyclerView.ItemDecoration() {
|
||||
interface Configuration {
|
||||
fun set(needDivider: Boolean, toTop: Boolean, paddingStart: Int, paddingEnd: Int)
|
||||
@ -49,7 +50,7 @@ class DividerItemDecoration(
|
||||
view: View,
|
||||
top: Int,
|
||||
width: Int,
|
||||
rtl: Boolean
|
||||
rtl: Boolean,
|
||||
) {
|
||||
val divider = divider
|
||||
val left = if (rtl) configuration.paddingEnd else configuration.paddingStart
|
||||
@ -105,7 +106,7 @@ class DividerItemDecoration(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
state: RecyclerView.State,
|
||||
) {
|
||||
val configuration = view.configuration
|
||||
val position = parent.getChildAdapterPosition(view)
|
||||
|
@ -33,7 +33,7 @@ class RecyclerFastScroller(private val recyclerView: RecyclerView) {
|
||||
private data class FastScrolling(
|
||||
val startAtThumbOffset: Float?,
|
||||
val startY: Float,
|
||||
val currentY: Float
|
||||
val currentY: Float,
|
||||
)
|
||||
|
||||
private var scrolling = false
|
||||
@ -130,7 +130,7 @@ class RecyclerFastScroller(private val recyclerView: RecyclerView) {
|
||||
itemHeight: Int,
|
||||
thumbHeight: Int,
|
||||
range: Int,
|
||||
fastScrolling: FastScrolling
|
||||
fastScrolling: FastScrolling,
|
||||
) {
|
||||
val offset = calculateOffset(thumbHeight, fastScrolling)
|
||||
val scrollPosition = ((range - recyclerView.height) * offset).roundToInt()
|
||||
|
Loading…
x
Reference in New Issue
Block a user