-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean greadle file & update decencies, update UI test by Hilt annotat…
…ions.
- Loading branch information
1 parent
5345513
commit 3c0711a
Showing
20 changed files
with
101 additions
and
179 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 was deleted.
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
19 changes: 10 additions & 9 deletions
19
app/src/main/java/com/task/data/error/mapper/ErrorMapper.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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
package com.task.data.error.mapper | ||
|
||
import com.task.App | ||
import android.content.Context | ||
import com.task.R | ||
import com.task.data.error.* | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
class ErrorMapper @Inject constructor() : ErrorMapperInterface { | ||
class ErrorMapper @Inject constructor(@ApplicationContext val context: Context) : ErrorMapperSource { | ||
|
||
override fun getErrorString(errorId: Int): String { | ||
return App.context.getString(errorId) | ||
return context.getString(errorId) | ||
} | ||
|
||
override val errorsMap: Map<Int, String> | ||
get() = mapOf( | ||
Pair(NO_INTERNET_CONNECTION, getErrorString(R.string.no_internet)), | ||
Pair(NETWORK_ERROR, getErrorString(R.string.network_error)), | ||
Pair(PASS_WORD_ERROR, getErrorString(R.string.invalid_password)), | ||
Pair(USER_NAME_ERROR, getErrorString(R.string.invalid_username)), | ||
Pair(CHECK_YOUR_FIELDS, getErrorString(R.string.invalid_username_and_password)), | ||
Pair(SEARCH_ERROR, getErrorString(R.string.search_error)) | ||
Pair(NO_INTERNET_CONNECTION, getErrorString(R.string.no_internet)), | ||
Pair(NETWORK_ERROR, getErrorString(R.string.network_error)), | ||
Pair(PASS_WORD_ERROR, getErrorString(R.string.invalid_password)), | ||
Pair(USER_NAME_ERROR, getErrorString(R.string.invalid_username)), | ||
Pair(CHECK_YOUR_FIELDS, getErrorString(R.string.invalid_username_and_password)), | ||
Pair(SEARCH_ERROR, getErrorString(R.string.search_error)) | ||
).withDefault { getErrorString(R.string.network_error) } | ||
} |
2 changes: 1 addition & 1 deletion
2
...data/error/mapper/ErrorMapperInterface.kt → ...sk/data/error/mapper/ErrorMapperSource.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.task.data.error.mapper | ||
|
||
interface ErrorMapperInterface { | ||
interface ErrorMapperSource { | ||
fun getErrorString(errorId: Int): String | ||
val errorsMap: Map<Int, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package com.task.data.local | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import com.task.App.Companion.context | ||
import com.task.FAVOURITES_KEY | ||
import com.task.SHARED_PREFERENCES_FILE_NAME | ||
import com.task.data.Resource | ||
import com.task.data.dto.login.LoginRequest | ||
import com.task.data.dto.login.LoginResponse | ||
import com.task.FAVOURITES_KEY | ||
import com.task.SHARED_PREFERENCES_FILE_NAME | ||
import com.task.data.error.PASS_WORD_ERROR | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by AhmedEltaher | ||
*/ | ||
|
||
class LocalData @Inject constructor() { | ||
class LocalData @Inject constructor(val context: Context) { | ||
|
||
fun doLogin(loginRequest: LoginRequest): Resource<LoginResponse> { | ||
if (loginRequest == LoginRequest("[email protected]", "ahmed")) { | ||
|
Oops, something went wrong.