-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
220 additions
and
29 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
29 changes: 29 additions & 0 deletions
29
app/src/main/java/io/github/a13e300/ro_tieba/history/HistoryManager.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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/io/github/a13e300/ro_tieba/serializer/SearchHistorySerializer.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,26 @@ | ||
package io.github.a13e300.ro_tieba.serializer | ||
|
||
import androidx.datastore.core.CorruptionException | ||
import androidx.datastore.core.Serializer | ||
import com.google.protobuf.InvalidProtocolBufferException | ||
import io.github.a13e300.ro_tieba.datastore.SearchHistory | ||
import java.io.InputStream | ||
import java.io.OutputStream | ||
|
||
object SearchHistorySerializer : | ||
Serializer<SearchHistory> { | ||
override val defaultValue: SearchHistory = SearchHistory.getDefaultInstance() | ||
|
||
override suspend fun readFrom(input: InputStream): SearchHistory { | ||
try { | ||
return SearchHistory.parseFrom(input) | ||
} catch (exception: InvalidProtocolBufferException) { | ||
throw CorruptionException("Cannot read proto.", exception) | ||
} | ||
} | ||
|
||
override suspend fun writeTo( | ||
t: SearchHistory, | ||
output: OutputStream | ||
) = t.writeTo(output) | ||
} |
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
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,11 @@ | ||
syntax = "proto3"; | ||
|
||
option java_package = "io.github.a13e300.ro_tieba.datastore"; | ||
option java_multiple_files = true; | ||
|
||
message SearchHistory { | ||
message Entry { | ||
string keyword = 1; | ||
} | ||
repeated Entry entries = 1; | ||
} |
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,11 @@ | ||
<vector android:autoMirrored="true" | ||
android:height="24dp" | ||
android:tint="#000000" | ||
android:viewportHeight="24" | ||
android:viewportWidth="24" | ||
android:width="24dp" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M21,3.01H3c-1.1,0 -2,0.9 -2,2V9h2V4.99h18v14.03H3V15H1v4.01c0,1.1 0.9,1.98 2,1.98h18c1.1,0 2,-0.88 2,-1.98v-14c0,-1.11 -0.9,-2 -2,-2zM11,16l4,-4 -4,-4v3H1v2h10v3z" /> | ||
</vector> |
Oops, something went wrong.