-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
okay so now it draws the first 5 items...success?
- Loading branch information
Showing
21 changed files
with
1,115 additions
and
464 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
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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/dev/jvmname/acquisitive/network/ItemIdArrayAdapterFactory.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,31 @@ | ||
package dev.jvmname.acquisitive.network | ||
|
||
import com.squareup.moshi.JsonAdapter | ||
import com.squareup.moshi.JsonReader | ||
import com.squareup.moshi.JsonWriter | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.adapter | ||
import dev.jvmname.acquisitive.util.ItemIdArray | ||
import java.lang.reflect.Type | ||
|
||
object ItemIdArrayAdapterFactory : JsonAdapter.Factory { | ||
override fun create( | ||
type: Type, | ||
annotations: MutableSet<out Annotation>, | ||
moshi: Moshi, | ||
): JsonAdapter<ItemIdArray>? { | ||
if (type != ItemIdArray::class.java) return null | ||
|
||
val delegate = moshi.adapter<IntArray>() | ||
return object : JsonAdapter<ItemIdArray>() { | ||
override fun fromJson(reader: JsonReader): ItemIdArray? { | ||
return delegate.fromJson(reader)?.let(::ItemIdArray) | ||
} | ||
|
||
override fun toJson(writer: JsonWriter, value: ItemIdArray?) { | ||
delegate.toJson(writer, value?.storage) | ||
} | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.