-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update hint * Update title color * Update layout * Orders * Update sticky header * Order detail * Update share * Update ripple theme * Update layout * Update share scheme * Update * Update type string * Update font weight * Amounts to include "+" and "-" signs, update title * Update detail * Price item * Add index * Update index * Update order * Update USD collection * Update share market url * Update style * fix typo * Build message from token * Fix warnings * fix typo --------- Co-authored-by: Crossle Song <[email protected]>
- Loading branch information
1 parent
bdbce08
commit 61e3b9b
Showing
41 changed files
with
4,938 additions
and
178 deletions.
There are no files selected for viewing
3,536 changes: 3,536 additions & 0 deletions
3,536
app/schemas/one.mixin.android.db.MixinDatabase/64.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,55 @@ | ||
package one.mixin.android.db | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.paging.PagingSource | ||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import kotlinx.coroutines.flow.Flow | ||
import one.mixin.android.ui.home.web3.components.InscriptionState | ||
import one.mixin.android.vo.UtxoItem | ||
import one.mixin.android.vo.route.SwapOrder | ||
import one.mixin.android.vo.route.SwapOrderItem | ||
import one.mixin.android.vo.safe.Output | ||
import one.mixin.android.vo.safe.SafeCollectible | ||
import one.mixin.android.vo.safe.SafeCollection | ||
import timber.log.Timber | ||
|
||
@Dao | ||
interface OrderDao : BaseDao<SwapOrder> { | ||
|
||
@Query( | ||
""" | ||
SELECT o.*, t.icon_url as asset_icon_url, rt.icon_url as receive_asset_icon_url, rt.symbol as receive_asset_symbol, t.symbol as asset_symbol, pc.name AS pay_chain_name, rc.name AS receive_chain_name FROM swap_orders o | ||
LEFT JOIN tokens t ON o.pay_asset_id = t.asset_id | ||
LEFT JOIN tokens rt ON o.receive_asset_id = rt.asset_id | ||
LEFT JOIN chains pc ON t.chain_id = pc.chain_id | ||
LEFT JOIN chains rc ON rt.chain_id = rc.chain_id | ||
ORDER BY o.created_at DESC | ||
""" | ||
) | ||
fun orders(): Flow<List<SwapOrderItem>> | ||
|
||
@Query( | ||
""" | ||
SELECT o.*, t.icon_url as asset_icon_url, rt.icon_url as receive_asset_icon_url, rt.symbol as receive_asset_symbol, t.symbol as asset_symbol, rt.chain_id as receive_chain_id, t.chain_id as pay_chain_id, pc.name AS pay_chain_name, rc.name AS receive_chain_name | ||
FROM swap_orders o | ||
LEFT JOIN tokens t ON o.pay_asset_id = t.asset_id | ||
LEFT JOIN tokens rt ON o.receive_asset_id = rt.asset_id | ||
LEFT JOIN chains pc ON t.chain_id = pc.chain_id | ||
LEFT JOIN chains rc ON rt.chain_id = rc.chain_id | ||
WHERE o.order_id = :orderId | ||
""" | ||
) | ||
fun getOrderById(orderId: String): Flow<SwapOrderItem?> | ||
|
||
@Query("SELECT * FROM swap_orders WHERE state = 'pending'") | ||
suspend fun getPendingOrders(): List<SwapOrder> | ||
|
||
@Query( | ||
""" | ||
SELECT created_at FROM swap_orders ORDER BY created_at DESC LIMIT 1 | ||
""" | ||
) | ||
suspend fun lastOrderCreatedAt(): String? | ||
} |
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
29 changes: 29 additions & 0 deletions
29
app/src/main/java/one/mixin/android/job/RefreshOrdersJob.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,29 @@ | ||
package one.mixin.android.job | ||
|
||
import com.birbit.android.jobqueue.Params | ||
import kotlinx.coroutines.runBlocking | ||
|
||
class RefreshOrdersJob : BaseJob(Params(PRIORITY_BACKGROUND).singleInstanceBy(GROUP).requireNetwork().persist()) { | ||
companion object { | ||
private const val serialVersionUID = 2L | ||
const val GROUP = "RefreshOrdersJob" | ||
const val LIMIT = 20 | ||
} | ||
|
||
override fun onRun(): Unit = | ||
runBlocking { | ||
val lastCreate = orderDao.lastOrderCreatedAt() | ||
refreshOrders(lastCreate) | ||
} | ||
|
||
private suspend fun refreshOrders(offset: String?) { | ||
val response = routeService.orders(limit = LIMIT, offset = offset) | ||
if (response.isSuccess && response.data != null) { | ||
orderDao.insertListSuspend(response.data!!) | ||
if (response.data!!.size >= LIMIT) { | ||
val lastCreate = response.data?.last()?.createdAt ?: return | ||
refreshOrders(lastCreate) | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/one/mixin/android/job/RefreshPendingOrdersJob.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 one.mixin.android.job | ||
|
||
import com.birbit.android.jobqueue.Params | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.runBlocking | ||
|
||
class RefreshPendingOrdersJob : BaseJob(Params(PRIORITY_BACKGROUND).singleInstanceBy(GROUP).requireNetwork().persist()) { | ||
companion object { | ||
private const val serialVersionUID = 2L | ||
const val GROUP = "RefreshOrdersJob" | ||
} | ||
|
||
override fun onRun(): Unit = | ||
runBlocking { | ||
val pendingOrders = orderDao.getPendingOrders() | ||
if (pendingOrders.isNotEmpty()) { | ||
pendingOrders.forEach { | ||
launch { | ||
refreshPendingOrders(it.createdAt) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private suspend fun refreshPendingOrders(offset: String) { | ||
val response = routeService.orders(limit = 1, offset = offset) | ||
if (response.isSuccess && response.data != null) { | ||
orderDao.insertListSuspend(response.data!!) | ||
} | ||
} | ||
} |
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: 13 additions & 6 deletions
19
app/src/main/java/one/mixin/android/ui/home/web3/swap/KeyboardAwareBox.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
Oops, something went wrong.