Skip to content

Commit

Permalink
* Correção de carregamento de dados podia gerar valor nulo
Browse files Browse the repository at this point in the history
* version update
  • Loading branch information
deyvidandrades committed Apr 20, 2024
1 parent 8fb35ac commit fcfba44
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId = "com.deyvidandrades.meusdias"
minSdk = 29
targetSdk = 34
versionCode = 16
versionName = "1.3.1"
versionCode = 17
versionName = "1.3.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Binary file modified debug/app-debug.aab
Binary file not shown.
Binary file modified release/app-release.aab
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.deyvidandrades.meusdias.assistentes

import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import com.deyvidandrades.meusdias.objetos.Objetivo
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
Expand Down Expand Up @@ -37,14 +36,16 @@ object Persistencia {
notificacoesDiarias = preferences!!.getBoolean(Paths.NOTIFICACOES_DIARIAS.name.lowercase(), true)
notificacoesRecorde = preferences!!.getBoolean(Paths.NOTIFICACOES_RECORDE.name.lowercase(), true)

val listaRawObjetivos = preferences!!.getString(Paths.OBJETIVOS.name.lowercase(), "")!!
val typeTokenObjetivos = object : TypeToken<ArrayList<Objetivo>>() {}.type
val listaRawObjetivos = preferences!!.getString(Paths.OBJETIVOS.name.lowercase(), "")

if (listaRawObjetivos != "") {
val typeTokenObjetivos = object : TypeToken<ArrayList<Objetivo>>() {}.type

try {
arrayObjetivos.clear()
arrayObjetivos.addAll(Gson().fromJson(listaRawObjetivos, typeTokenObjetivos))
} catch (e: NullPointerException) {
arrayObjetivos = ArrayList()
} else {
arrayObjetivos.add(Objetivo("sem um objetivo"))
salvarDados()
}
}
}
Expand Down Expand Up @@ -130,16 +131,7 @@ object Persistencia {

/*FLUXO OBJETIVOS*/

fun getObjetivoAtual(): Objetivo {
if (arrayObjetivos.isEmpty()) {
arrayObjetivos.add(Objetivo("sem um objetivo"))
salvarDados()
}

Log.d("DWS", arrayObjetivos.toString())

return arrayObjetivos.last()
}
fun getObjetivoAtual() = arrayObjetivos.last()

fun getObjetivos() = arrayObjetivos

Expand Down

0 comments on commit fcfba44

Please sign in to comment.