-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from hieuwu/feature/order-history-usecase-dat…
…a-layer Feature/order history usecase data layer
- Loading branch information
Showing
24 changed files
with
438 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/GetOrderListUseCase.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,12 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases | ||
|
||
import com.hieuwu.groceriesstore.domain.models.OrderModel | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface GetOrderListUseCase : UseCase<GetOrderListUseCase.Input, GetOrderListUseCase.Output> { | ||
class Input | ||
sealed class Output { | ||
class Success(val data: List<OrderModel>) : Output() | ||
object Failure : 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
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/impl/GetOrderListUseCaseImpl.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,20 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases.impl | ||
|
||
import com.hieuwu.groceriesstore.data.repository.OrderRepository | ||
import com.hieuwu.groceriesstore.domain.usecases.GetOrderListUseCase | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.withContext | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
class GetOrderListUseCaseImpl @Inject constructor( | ||
private val orderRepository: OrderRepository | ||
) : GetOrderListUseCase { | ||
override suspend fun execute(input: GetOrderListUseCase.Input): GetOrderListUseCase.Output { | ||
return withContext(Dispatchers.IO) { | ||
val result = orderRepository.getOrders() | ||
GetOrderListUseCase.Output.Success(data = result) | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...src/main/java/com/hieuwu/groceriesstore/presentation/orderhistory/OrderHistoryFragment.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,25 @@ | ||
package com.hieuwu.groceriesstore.presentation.orderhistory | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.compose.ui.platform.ComposeView | ||
import androidx.fragment.app.Fragment | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class OrderHistoryFragment : Fragment() { | ||
|
||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
return ComposeView(requireContext()).apply { | ||
setContent { | ||
OrderHistoryScreen() | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.