-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature|optimize|build] Support searching for similar images; optimi…
…ze image listing page with Paging; use TOML to manage dependencies
- Loading branch information
Showing
40 changed files
with
1,105 additions
and
340 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.skyd.rays.di | ||
|
||
import androidx.paging.PagingConfig | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object PagingModule { | ||
@Provides | ||
@Singleton | ||
fun providePagingConfig(): PagingConfig = | ||
PagingConfig(pageSize = 20, enablePlaceholders = false) | ||
} |
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
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/skyd/rays/model/db/objectbox/ObjectBox.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.skyd.rays.model.db.objectbox | ||
|
||
import android.content.Context | ||
import com.skyd.rays.model.db.objectbox.entity.MyObjectBox | ||
import io.objectbox.BoxStore | ||
|
||
object ObjectBox { | ||
@Volatile | ||
private var instance: BoxStore? = null | ||
|
||
fun getInstance(context: Context): BoxStore { | ||
return instance ?: synchronized(this) { | ||
instance ?: MyObjectBox.builder() | ||
.androidContext(context) | ||
.build() | ||
.apply { instance = this } | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/skyd/rays/model/db/objectbox/entity/StickerEmbedding.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.skyd.rays.model.db.objectbox.entity | ||
|
||
import io.objectbox.annotation.Entity | ||
import io.objectbox.annotation.HnswIndex | ||
import io.objectbox.annotation.Id | ||
import io.objectbox.annotation.Index | ||
|
||
@Entity | ||
data class StickerEmbedding( | ||
@Id var id: Long = 0, | ||
@Index var uuid: String, | ||
@HnswIndex(dimensions = 1024) | ||
var embedding: FloatArray? = null, | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as StickerEmbedding | ||
|
||
if (uuid != other.uuid) return false | ||
if (embedding != null) { | ||
if (other.embedding == null) return false | ||
if (!embedding.contentEquals(other.embedding)) return false | ||
} else if (other.embedding != null) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = uuid.hashCode() | ||
result = 31 * result + (embedding?.contentHashCode() ?: 0) | ||
return result | ||
} | ||
} |
Oops, something went wrong.