Skip to content

Commit 0612772

Browse files
committed
all: reformat
1 parent 94dbe74 commit 0612772

9 files changed

Lines changed: 53 additions & 55 deletions

File tree

app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ constructor(
400400
val query = Query(source = locations, exclude = emptyList())
401401
val storage = Storage(cache, covers, storedPlaylists, fileTreeCache)
402402
val interpretation = Interpretation(nameFactory, separators, withHidden)
403-
val result =
404-
Musikr.new(context, storage, interpretation).run(query, ::emitIndexingProgress)
403+
val result = Musikr.new(context, storage, interpretation).run(query, ::emitIndexingProgress)
405404
// Music loading completed, update the revision right now so we re-use this work
406405
// later.
407406
musicSettings.revision = newRevision

app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
8585
}
8686
set(value) {
8787
sharedPreferences.edit {
88-
putString(
89-
getString(R.string.set_key_music_locations), value.stringify())
88+
putString(getString(R.string.set_key_music_locations), value.stringify())
9089
commit()
9190
// Sometimes changing this setting just won't actually trigger the listener.
9291
// Only this one. No idea why.
@@ -139,7 +138,6 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
139138
}
140139
}
141140

142-
143141
private fun List<OpenedLocation>.stringify(): String =
144142
joinToString(separator = ";") { it.uri.toString().replace(";", "\\;") }
145143

app/src/main/java/org/oxycblt/auxio/music/locations/LocationAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import org.oxycblt.auxio.databinding.ItemMusicLocationBinding
2525
import org.oxycblt.auxio.list.recycler.DialogRecyclerView
2626
import org.oxycblt.auxio.util.context
2727
import org.oxycblt.auxio.util.inflater
28-
import org.oxycblt.musikr.fs.Location
2928
import org.oxycblt.musikr.fs.OpenedLocation
3029
import timber.log.Timber as L
3130

@@ -38,7 +37,8 @@ import timber.log.Timber as L
3837
class LocationAdapter(private val listener: Listener) : RecyclerView.Adapter<MusicDirViewHolder>() {
3938
private val _locations = mutableListOf<OpenedLocation>()
4039
/**
41-
* The current list of [OpenedLocation]s, may not line up with [OpenedLocation]s due to removals.
40+
* The current list of [OpenedLocation]s, may not line up with [OpenedLocation]s due to
41+
* removals.
4242
*/
4343
val locations: List<OpenedLocation> = _locations
4444

app/src/main/res/layout/dialog_music_locations.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
app:layout_constraintTop_toBottomOf="@+id/locations_list_header"
1717
tools:listitem="@layout/item_music_location" />
1818

19-
</FrameLayout>
19+
</FrameLayout>
20+

musikr/src/main/java/org/oxycblt/musikr/Config.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ import org.oxycblt.musikr.covers.Cover
2323
import org.oxycblt.musikr.covers.MutableCovers
2424
import org.oxycblt.musikr.fs.Location
2525
import org.oxycblt.musikr.fs.OpenedLocation
26-
import org.oxycblt.musikr.fs.Path
2726
import org.oxycblt.musikr.fs.device.FileTreeCache
2827
import org.oxycblt.musikr.playlist.db.StoredPlaylists
2928
import org.oxycblt.musikr.tag.interpret.Naming
3029
import org.oxycblt.musikr.tag.interpret.Separators
3130

32-
data class Query(
33-
val source: List<OpenedLocation>,
34-
val exclude: List<Location>
35-
)
31+
data class Query(val source: List<OpenedLocation>, val exclude: List<Location>)
3632

3733
/** Side-effect laden [Storage] for use during music loading and [MutableLibrary] operation. */
3834
data class Storage(

musikr/src/main/java/org/oxycblt/musikr/Musikr.kt

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,31 +117,29 @@ private class MusikrImpl(
117117
private val extractStep: ExtractStep,
118118
private val evaluateStep: EvaluateStep
119119
) : Musikr {
120-
override suspend fun run(
121-
query: Query,
122-
onProgress: suspend (IndexingProgress) -> Unit
123-
) = coroutineScope {
124-
val start = System.currentTimeMillis()
125-
var exploredCount = 0
126-
var extractedCount = 0
127-
val explored =
128-
exploreStep
129-
.explore(query)
130-
.buffer(Channel.UNLIMITED)
131-
.onStart { onProgress(IndexingProgress.Songs(0, 0)) }
132-
.onEach { onProgress(IndexingProgress.Songs(extractedCount, ++exploredCount)) }
133-
val extracted =
134-
extractStep
135-
.extract(explored)
136-
.buffer(Channel.UNLIMITED)
137-
.onEach { onProgress(IndexingProgress.Songs(++extractedCount, exploredCount)) }
138-
.onCompletion { onProgress(IndexingProgress.Indeterminate) }
139-
val library = evaluateStep.evaluate(extracted)
140-
Log.d(
141-
"Musikr",
142-
"Loaded ${library.songs.size} songs in ${System.currentTimeMillis() - start}ms")
143-
LibraryResultImpl(storage, library)
144-
}
120+
override suspend fun run(query: Query, onProgress: suspend (IndexingProgress) -> Unit) =
121+
coroutineScope {
122+
val start = System.currentTimeMillis()
123+
var exploredCount = 0
124+
var extractedCount = 0
125+
val explored =
126+
exploreStep
127+
.explore(query)
128+
.buffer(Channel.UNLIMITED)
129+
.onStart { onProgress(IndexingProgress.Songs(0, 0)) }
130+
.onEach { onProgress(IndexingProgress.Songs(extractedCount, ++exploredCount)) }
131+
val extracted =
132+
extractStep
133+
.extract(explored)
134+
.buffer(Channel.UNLIMITED)
135+
.onEach { onProgress(IndexingProgress.Songs(++extractedCount, exploredCount)) }
136+
.onCompletion { onProgress(IndexingProgress.Indeterminate) }
137+
val library = evaluateStep.evaluate(extracted)
138+
Log.d(
139+
"Musikr",
140+
"Loaded ${library.songs.size} songs in ${System.currentTimeMillis() - start}ms")
141+
LibraryResultImpl(storage, library)
142+
}
145143
}
146144

147145
private class LibraryResultImpl(

musikr/src/main/java/org/oxycblt/musikr/fs/Location.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class Location private constructor(val uri: Uri, val path: Path) {
3737
try {
3838
context.contentResolverSafe.takePersistableUriPermission(
3939
uri,
40-
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
41-
)
40+
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
4241
} catch (e: Exception) {
4342
// Not fully sure what happens if I'm disallowed to take the permission,
4443
// check for both circumstances (error or no-op)
@@ -68,7 +67,10 @@ class Location private constructor(val uri: Uri, val path: Path) {
6867
}
6968

7069
class OpenedLocation internal constructor(val uri: Uri, val path: Path) {
71-
override fun equals(other: Any?) = other is OpenedLocation && uri == other.uri && path == other.path
70+
override fun equals(other: Any?) =
71+
other is OpenedLocation && uri == other.uri && path == other.path
72+
7273
override fun hashCode() = 31 * uri.hashCode() + path.hashCode()
74+
7375
override fun toString(): String = uri.toString()
7476
}

musikr/src/main/java/org/oxycblt/musikr/fs/device/DeviceFS.kt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ internal interface DeviceFS {
5151
fun explore(query: Query, fileTree: FileTree): Flow<DeviceDirectory>
5252

5353
companion object {
54-
fun from(
55-
context: Context,
56-
withHidden: Boolean
57-
): DeviceFS = DeviceFSImpl(context.contentResolverSafe, withHidden)
54+
fun from(context: Context, withHidden: Boolean): DeviceFS =
55+
DeviceFSImpl(context.contentResolverSafe, withHidden)
5856
}
5957
}
6058

@@ -65,9 +63,15 @@ private class DeviceFSImpl(
6563
private val explorationScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
6664

6765
override fun explore(query: Query, fileTree: FileTree) =
68-
query.source.asFlow().mapNotNull { location -> queryRoot(location, fileTree, query.exclude) }
66+
query.source.asFlow().mapNotNull { location ->
67+
queryRoot(location, fileTree, query.exclude)
68+
}
6969

70-
private suspend fun queryRoot(location: OpenedLocation, fileTree: FileTree, exclude: List<Location>): DeviceDirectory? {
70+
private suspend fun queryRoot(
71+
location: OpenedLocation,
72+
fileTree: FileTree,
73+
exclude: List<Location>
74+
): DeviceDirectory? {
7175
val treeDocumentId = DocumentsContract.getTreeDocumentId(location.uri)
7276
val uri = DocumentsContract.buildDocumentUriUsingTree(location.uri, treeDocumentId)
7377
val modifiedMs =
@@ -82,7 +86,8 @@ private class DeviceFSImpl(
8286
if (modifiedMs == null) {
8387
return null
8488
}
85-
return query(location.uri, treeDocumentId, location.path, modifiedMs, null, fileTree, exclude)
89+
return query(
90+
location.uri, treeDocumentId, location.path, modifiedMs, null, fileTree, exclude)
8691
}
8792

8893
private suspend fun query(
@@ -159,7 +164,7 @@ private class DeviceFSImpl(
159164
// Check if the current path matches the excluded path
160165
// exactly
161166
excluded.path.volume == newPath.volume &&
162-
excluded.path.components == newPath.components
167+
excluded.path.components == newPath.components
163168
}
164169
if (shouldExclude) {
165170
continue
@@ -250,15 +255,17 @@ private class DeviceFSImpl(
250255
val shouldExclude =
251256
exclude.any { excluded ->
252257
excluded.path.volume == subdirPath.volume &&
253-
excluded.path.components ==
258+
excluded.path.components ==
254259
subdirPath.components
255260
}
256261

257262
if (shouldExclude) {
258263
return@transform
259264
}
260265

261-
emit(hydrateCached(cachedSubdir, dir, subdirPath, fileTree, exclude))
266+
emit(
267+
hydrateCached(
268+
cachedSubdir, dir, subdirPath, fileTree, exclude))
262269
}
263270
.filterNotNull(),
264271
cached.fileUris.asFlow().map {

musikr/src/main/java/org/oxycblt/musikr/pipeline/ExploreStep.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import org.oxycblt.musikr.cache.CachedSong
4242
import org.oxycblt.musikr.covers.Cover
4343
import org.oxycblt.musikr.covers.CoverResult
4444
import org.oxycblt.musikr.covers.Covers
45-
import org.oxycblt.musikr.fs.OpenedLocation
4645
import org.oxycblt.musikr.fs.device.DeviceFS
4746
import org.oxycblt.musikr.fs.device.FileTreeCache
4847
import org.oxycblt.musikr.fs.device.flatten
@@ -55,9 +54,7 @@ internal interface ExploreStep {
5554
companion object {
5655
fun from(context: Context, storage: Storage, interpretation: Interpretation): ExploreStep =
5756
ExploreStepImpl(
58-
DeviceFS.from(
59-
context = context,
60-
withHidden = interpretation.withHidden),
57+
DeviceFS.from(context = context, withHidden = interpretation.withHidden),
6158
storage.cache,
6259
storage.covers,
6360
storage.fileTreeCache,

0 commit comments

Comments
 (0)