-
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.
Refactor plan to follow clean architecture
- Loading branch information
1 parent
08032fa
commit 5ced33b
Showing
32 changed files
with
206 additions
and
169 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
6 changes: 3 additions & 3 deletions
6
app/src/main/java/com/modarb/android/ui/home/helpers/WorkoutData.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
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
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/modarb/android/ui/home/ui/home/domain/models/MyWorkout.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
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
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/modarb/android/ui/home/ui/plan/data/PlanRepositoryImp.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,38 @@ | ||
package com.modarb.android.ui.home.ui.plan.data | ||
|
||
import android.content.Context | ||
import com.modarb.android.network.ApiService | ||
import com.modarb.android.network.Result | ||
import com.modarb.android.ui.home.ui.plan.domain.MyPlanRepository | ||
import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse | ||
import com.modarb.android.ui.onboarding.utils.UserPref.UserPrefUtil | ||
import retrofit2.Response | ||
|
||
class PlanRepositoryImp(private val apiService: ApiService) : MyPlanRepository { | ||
|
||
|
||
// TODO handle get custom workouts | ||
suspend fun getCustomWorkouts(context: Context): Response<PlanPageResponse> { | ||
return apiService.getCustomWorkouts( | ||
"Bearer " + UserPrefUtil.getUserData(context)!!.token | ||
) | ||
} | ||
|
||
override suspend fun getMyPlanPage(workoutId: String, token: String): Result<PlanPageResponse> { | ||
|
||
return try { | ||
val response = apiService.getPlanPage(workoutId, token) | ||
if (response.isSuccessful) { | ||
response.body()?.let { | ||
Result.Success(it) | ||
} ?: Result.Failure(Throwable("Response body is null")) | ||
} else { | ||
Result.Failure(Throwable(response.errorBody()?.string() ?: "Unknown error")) | ||
} | ||
} catch (e: Exception) { | ||
Result.Failure(e) | ||
} | ||
} | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/MyPlanRepository.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,9 @@ | ||
package com.modarb.android.ui.home.ui.plan.domain | ||
|
||
import com.modarb.android.network.Result | ||
import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse | ||
|
||
interface MyPlanRepository { | ||
|
||
suspend fun getMyPlanPage(workoutId: String, token: String): Result<PlanPageResponse> | ||
} |
2 changes: 1 addition & 1 deletion
2
...rb/android/ui/home/ui/plan/models/Data.kt → ...oid/ui/home/ui/plan/domain/models/Data.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
2 changes: 1 addition & 1 deletion
2
...arb/android/ui/home/ui/plan/models/Day.kt → ...roid/ui/home/ui/plan/domain/models/Day.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
2 changes: 1 addition & 1 deletion
2
...droid/ui/home/ui/plan/models/Equipment.kt → ...i/home/ui/plan/domain/models/Equipment.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
2 changes: 1 addition & 1 deletion
2
...ndroid/ui/home/ui/plan/models/Exercise.kt → ...ui/home/ui/plan/domain/models/Exercise.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
2 changes: 1 addition & 1 deletion
2
...e/ui/plan/models/ExpectedDurationRange.kt → ...an/domain/models/ExpectedDurationRange.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
2 changes: 1 addition & 1 deletion
2
...b/android/ui/home/ui/plan/models/Media.kt → ...id/ui/home/ui/plan/domain/models/Media.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
2 changes: 1 addition & 1 deletion
2
...i/home/ui/plan/models/PlanPageResponse.kt → ...ui/plan/domain/models/PlanPageResponse.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
2 changes: 1 addition & 1 deletion
2
...android/ui/home/ui/plan/models/Primary.kt → .../ui/home/ui/plan/domain/models/Primary.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
2 changes: 1 addition & 1 deletion
2
...droid/ui/home/ui/plan/models/Secondary.kt → ...i/home/ui/plan/domain/models/Secondary.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
2 changes: 1 addition & 1 deletion
2
...d/ui/home/ui/plan/models/TargetMuscles.kt → ...me/ui/plan/domain/models/TargetMuscles.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
2 changes: 1 addition & 1 deletion
2
...rb/android/ui/home/ui/plan/models/Week.kt → ...oid/ui/home/ui/plan/domain/models/Week.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
2 changes: 1 addition & 1 deletion
2
...android/ui/home/ui/plan/models/Workout.kt → .../ui/home/ui/plan/domain/models/Workout.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
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/PlanPageUseCase.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,11 @@ | ||
package com.modarb.android.ui.home.ui.plan.domain.usecase | ||
|
||
import com.modarb.android.network.Result | ||
import com.modarb.android.ui.home.ui.plan.domain.MyPlanRepository | ||
import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse | ||
|
||
class PlanPageUseCase(private val planRepository: MyPlanRepository) { | ||
suspend fun invoke(workoutId: String, token: String): Result<PlanPageResponse> { | ||
return planRepository.getMyPlanPage(workoutId, token) | ||
} | ||
} |
Oops, something went wrong.