-
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.
Merge pull request #16 from icanerdogan/appdevelopment
1.2.1
- Loading branch information
Showing
51 changed files
with
762 additions
and
80 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
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/ibrahimcanerdogan/valorantguideapp/data/database/other/ArmorDao.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,18 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.database.other | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData | ||
|
||
@Dao | ||
interface ArmorDao { | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun saveArmorDatabase(listMapData: List<ArmorData>) | ||
|
||
@Query("SELECT * FROM armor_data") | ||
fun getArmorListDatabase(): List<ArmorData> | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/ibrahimcanerdogan/valorantguideapp/data/model/other/armor/Armor.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,10 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Armor( | ||
@SerializedName("status") | ||
val status: Int, | ||
@SerializedName("data") | ||
val armors: List<ArmorData> | ||
) |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/ibrahimcanerdogan/valorantguideapp/data/model/other/armor/ArmorData.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,22 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import com.google.gson.annotations.SerializedName | ||
|
||
@Entity( | ||
tableName = "armor_data" | ||
) | ||
data class ArmorData( | ||
@PrimaryKey | ||
@SerializedName("uuid") | ||
val uuid: String, | ||
@SerializedName("displayName") | ||
val armorDisplayName: String, | ||
@SerializedName("description") | ||
val armorDescription: String, | ||
@SerializedName("displayIcon") | ||
val armorDisplayIcon: String, | ||
@SerializedName("shopData") | ||
val armorShopData: ArmorShopData? | ||
) |
15 changes: 15 additions & 0 deletions
15
.../main/java/com/ibrahimcanerdogan/valorantguideapp/data/model/other/armor/ArmorShopData.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,15 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor | ||
|
||
import androidx.room.PrimaryKey | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ArmorShopData( | ||
@PrimaryKey(autoGenerate = true) | ||
val armorShopId : Int, | ||
@SerializedName("cost") | ||
val armorShopCost: Int, | ||
@SerializedName("category") | ||
val armorShopCategory: String, | ||
@SerializedName("categoryText") | ||
val armorShopCategoryText: 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
53 changes: 53 additions & 0 deletions
53
...com/ibrahimcanerdogan/valorantguideapp/data/repository/other/armor/ArmorRepositoryImpl.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,53 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor | ||
|
||
import android.util.Log | ||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.Armor | ||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData | ||
import com.ibrahimcanerdogan.valorantguideapp.data.repository.map.MapRepositoryImpl | ||
import com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasource.ArmorLocalDataSource | ||
import com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasource.ArmorRemoteDataSource | ||
import com.ibrahimcanerdogan.valorantguideapp.domain.repository.other.armor.ArmorRepository | ||
import com.ibrahimcanerdogan.valorantguideapp.util.Resource | ||
import retrofit2.Response | ||
import javax.inject.Inject | ||
|
||
class ArmorRepositoryImpl @Inject constructor( | ||
private val armorRemoteDataSource: ArmorRemoteDataSource, | ||
private val armorLocalDataSource: ArmorLocalDataSource | ||
) : ArmorRepository { | ||
|
||
override suspend fun getAllArmorsFromRepository(): Resource<List<ArmorData>> { | ||
return getArmorDataFromDatabase() | ||
} | ||
|
||
private suspend fun getArmorDataFromDatabase() : Resource<List<ArmorData>> { | ||
lateinit var listArmorData: Resource<List<ArmorData>> | ||
try { | ||
listArmorData = armorLocalDataSource.getArmorDataFromLocal() | ||
} catch (e : Exception) { | ||
Log.e(TAG, e.message.toString()) | ||
} | ||
|
||
if (listArmorData.data!!.isNotEmpty()) { | ||
return listArmorData | ||
} else { | ||
listArmorData = responseToResource(armorRemoteDataSource.getArmorFromRemote()) | ||
armorLocalDataSource.saveArmorDataToLocal(listArmorData.data!!) | ||
} | ||
|
||
return listArmorData | ||
} | ||
|
||
private fun responseToResource(response: Response<Armor>):Resource<List<ArmorData>>{ | ||
if(response.isSuccessful){ | ||
response.body()?.let {result-> | ||
return Resource.Success(result.armors) | ||
} | ||
} | ||
return Resource.Error(response.message()) | ||
} | ||
|
||
companion object { | ||
private val TAG = MapRepositoryImpl::class.java.toString() | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...anerdogan/valorantguideapp/data/repository/other/armor/datasource/ArmorLocalDataSource.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.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasource | ||
|
||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData | ||
import com.ibrahimcanerdogan.valorantguideapp.util.Resource | ||
|
||
interface ArmorLocalDataSource { | ||
|
||
suspend fun saveArmorDataToLocal(listArmorData: List<ArmorData>) | ||
|
||
suspend fun getArmorDataFromLocal() : Resource<List<ArmorData>> | ||
} |
10 changes: 10 additions & 0 deletions
10
...nerdogan/valorantguideapp/data/repository/other/armor/datasource/ArmorRemoteDataSource.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,10 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasource | ||
|
||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.Armor | ||
import retrofit2.Response | ||
|
||
interface ArmorRemoteDataSource { | ||
|
||
suspend fun getArmorFromRemote() : Response<Armor> | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...n/valorantguideapp/data/repository/other/armor/datasourceImpl/ArmorLocalDataSourceImpl.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.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasourceImpl | ||
|
||
import com.ibrahimcanerdogan.valorantguideapp.data.database.other.ArmorDao | ||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData | ||
import com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasource.ArmorLocalDataSource | ||
import com.ibrahimcanerdogan.valorantguideapp.util.Resource | ||
import javax.inject.Inject | ||
|
||
class ArmorLocalDataSourceImpl @Inject constructor( | ||
private val armorDao: ArmorDao | ||
) : ArmorLocalDataSource { | ||
|
||
override suspend fun saveArmorDataToLocal(listArmorData: List<ArmorData>) { | ||
return armorDao.saveArmorDatabase(listArmorData) | ||
} | ||
|
||
override suspend fun getArmorDataFromLocal(): Resource<List<ArmorData>> { | ||
return Resource.Success(armorDao.getArmorListDatabase()) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../valorantguideapp/data/repository/other/armor/datasourceImpl/ArmorRemoteDataSourceImpl.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,16 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasourceImpl | ||
|
||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.Armor | ||
import com.ibrahimcanerdogan.valorantguideapp.data.remote.APIService | ||
import com.ibrahimcanerdogan.valorantguideapp.data.repository.other.armor.datasource.ArmorRemoteDataSource | ||
import retrofit2.Response | ||
import javax.inject.Inject | ||
|
||
class ArmorRemoteDataSourceImpl @Inject constructor( | ||
private val apiService: APIService | ||
) : ArmorRemoteDataSource { | ||
|
||
override suspend fun getArmorFromRemote(): Response<Armor> { | ||
return apiService.getArmorRemote() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...a/com/ibrahimcanerdogan/valorantguideapp/domain/repository/other/armor/ArmorRepository.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,10 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.domain.repository.other.armor | ||
|
||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData | ||
import com.ibrahimcanerdogan.valorantguideapp.util.Resource | ||
|
||
interface ArmorRepository { | ||
|
||
suspend fun getAllArmorsFromRepository() : Resource<List<ArmorData>> | ||
|
||
} |
1 change: 0 additions & 1 deletion
1
app/src/main/java/com/ibrahimcanerdogan/valorantguideapp/domain/usecase/map/GetMapUseCase.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
15 changes: 15 additions & 0 deletions
15
...java/com/ibrahimcanerdogan/valorantguideapp/domain/usecase/other/armor/GetArmorUseCase.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,15 @@ | ||
package com.ibrahimcanerdogan.valorantguideapp.domain.usecase.other.armor | ||
|
||
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData | ||
import com.ibrahimcanerdogan.valorantguideapp.domain.repository.other.armor.ArmorRepository | ||
import com.ibrahimcanerdogan.valorantguideapp.util.Resource | ||
import javax.inject.Inject | ||
|
||
class GetArmorUseCase @Inject constructor( | ||
private val armorRepository: ArmorRepository | ||
) { | ||
|
||
suspend fun execute() : Resource<List<ArmorData>> { | ||
return armorRepository.getAllArmorsFromRepository() | ||
} | ||
} |
Oops, something went wrong.