Skip to content

Commit

Permalink
Merge pull request #16 from icanerdogan/appdevelopment
Browse files Browse the repository at this point in the history
1.2.1
  • Loading branch information
icanerdogan authored Oct 16, 2023
2 parents d0f4ef4 + 4654d36 commit 391a53a
Show file tree
Hide file tree
Showing 51 changed files with 762 additions and 80 deletions.
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins {
}

def versionMajor = 1
def versionMinor = 1
def versionPatch = 0
def versionMinor = 2
def versionPatch = 1

android {
namespace 'com.ibrahimcanerdogan.valorantguideapp'
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />

<application
android:name=".App"
android:allowBackup="true"
Expand All @@ -16,10 +17,15 @@
android:supportsRtl="true"
android:theme="@style/Theme.ValorantGuideApp.Splash"
tools:targetApi="31">
<activity
android:label="Armor"
android:name=".view.fragment.other.OtherArmorActivity"
android:exported="false"
android:theme="@style/Theme.ValorantGuideApp" />
<activity
android:name=".view.MainActivity"
android:theme="@style/Theme.ValorantGuideApp.Splash"
android:exported="true">
android:exported="true"
android:theme="@style/Theme.ValorantGuideApp.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.ibrahimcanerdogan.valorantguideapp.data.model.agent.AgentVoiceLine
import com.ibrahimcanerdogan.valorantguideapp.data.model.map.MapCallout
import com.ibrahimcanerdogan.valorantguideapp.data.model.map.MapData
import com.ibrahimcanerdogan.valorantguideapp.data.model.map.MapLocation
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorShopData
import com.ibrahimcanerdogan.valorantguideapp.data.model.weapon.WeaponData
import com.ibrahimcanerdogan.valorantguideapp.data.model.weapon.shop.WeaponShop
import com.ibrahimcanerdogan.valorantguideapp.data.model.weapon.skin.SkinChroma
Expand Down Expand Up @@ -251,4 +252,20 @@ class Converters {
fun toWeaponShop(json: String): WeaponShop? {
return gson.fromJson(json, WeaponShop::class.java)
}

// OTHER

// Armor

@TypeConverter
fun fromArmorShopData(armorShopData: ArmorShopData?): String {
return gson.toJson(armorShopData)
}

@TypeConverter
fun toArmorShopData(data: String): ArmorShopData? {
val listType = object : TypeToken<ArmorShopData>() {}.type
return gson.fromJson(data, listType)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.ibrahimcanerdogan.valorantguideapp.data.database.agent.AgentDao
import com.ibrahimcanerdogan.valorantguideapp.data.database.map.MapDao
import com.ibrahimcanerdogan.valorantguideapp.data.database.other.ArmorDao
import com.ibrahimcanerdogan.valorantguideapp.data.database.weapon.WeaponDao
import com.ibrahimcanerdogan.valorantguideapp.data.model.agent.AgentData
import com.ibrahimcanerdogan.valorantguideapp.data.model.map.MapData
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.ArmorData
import com.ibrahimcanerdogan.valorantguideapp.data.model.weapon.WeaponData

@Database(
entities = [AgentData::class, MapData::class, WeaponData::class],
version = 7,
entities = [AgentData::class, MapData::class, WeaponData::class, ArmorData::class],
version = 8,
exportSchema = false
)
@TypeConverters(Converters::class)
abstract class ValorantDatabase : RoomDatabase(){

abstract fun agentDao() : AgentDao

abstract fun mapDao() : MapDao

abstract fun weaponDao() : WeaponDao

abstract fun armorDao() : ArmorDao
}
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>

}
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>
)
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?
)
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
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ibrahimcanerdogan.valorantguideapp.data.remote

import com.ibrahimcanerdogan.valorantguideapp.data.model.agent.Agent
import com.ibrahimcanerdogan.valorantguideapp.data.model.map.Map
import com.ibrahimcanerdogan.valorantguideapp.data.model.other.armor.Armor
import com.ibrahimcanerdogan.valorantguideapp.data.model.weapon.Weapon
import retrofit2.Response
import retrofit2.http.GET
Expand All @@ -15,4 +16,7 @@ interface APIService {

@GET("v1/weapons")
suspend fun getWeaponRemote() : Response<Weapon>

@GET("v1/gear")
suspend fun getArmorRemote() : Response<Armor>
}
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()
}
}
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>>
}
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>

}
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())
}
}
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()
}
}
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>>

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ibrahimcanerdogan.valorantguideapp.domain.usecase.map

import com.ibrahimcanerdogan.valorantguideapp.data.model.agent.AgentData
import com.ibrahimcanerdogan.valorantguideapp.data.model.map.MapData
import com.ibrahimcanerdogan.valorantguideapp.domain.repository.map.MapRepository
import com.ibrahimcanerdogan.valorantguideapp.util.Resource
Expand Down
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()
}
}
Loading

0 comments on commit 391a53a

Please sign in to comment.