Skip to content

Commit

Permalink
Corrigido erro ao exibir algumas disciplinas
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigmatrix committed Jun 14, 2019
1 parent 51bb6ea commit 8546bb6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.rodrigmatrix.sippa"
minSdkVersion 21
targetSdkVersion 28
versionCode 11
versionName "2.0.2"
versionCode 12
versionName "2.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class DisciplinasFragment : Fragment(), CoroutineScope {
swiperefresh?.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(view.context, R.color.colorSwipeRefresh))
swiperefresh?.setOnRefreshListener {
val jsession = database.studentDao().getStudent().jsession
launch(handler) {
launch(handler){
setClasses(jsession, database)
}
}
val jsession = database.studentDao().getStudent().jsession
swiperefresh.isRefreshing = true
launch(handler){
launch{
setClasses(jsession, database)
}
}
Expand All @@ -66,6 +66,12 @@ class DisciplinasFragment : Fragment(), CoroutineScope {
super.onDestroy()
}
private val handler = CoroutineExceptionHandler { _, throwable ->
runOnUiThread {
job.cancel()
swiperefresh?.isRefreshing = false
coroutineContext.cancel()
Snackbar.make(view!!, "Erro ao exibir disciplinas. Por favor, me envie um email(email na tela sobre)", Snackbar.LENGTH_LONG).show()
}
Log.e("Exception", ":$throwable")
}

Expand Down Expand Up @@ -112,6 +118,7 @@ class DisciplinasFragment : Fragment(), CoroutineScope {
if(parsed){
try {
if(classes.size != 0){
println(classes)
runOnUiThread {
recyclerView_disciplinas.layoutManager = LinearLayoutManager(context)
recyclerView_disciplinas.adapter = DisciplinasAdapter(classes)
Expand All @@ -129,7 +136,7 @@ class DisciplinasFragment : Fragment(), CoroutineScope {
swiperefresh.isRefreshing = false
Snackbar.make(view!!, "Erro ao exibir disciplinas. Tente novamente", Snackbar.LENGTH_LONG).show()
}
println(e)
println("exce $e")
}
}
}
Expand Down
21 changes: 12 additions & 9 deletions app/src/main/java/com/rodrigmatrix/sippa/Serializer/Serializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,24 @@ class Serializer {
}
2 -> {
var arr = it.text()
var date = arr.replaceRange(10, arr.length, "")
var content = arr.replaceRange(0,10, "")
classPlan.classDate = date
when (content) {
"" -> classPlan.classPlanned = "Plano não cadastrado"
else -> classPlan.classPlanned = content
var date = "Data não cadastrada"
var content = "Plano não cadastrado"
if(arr.isNotEmpty() && arr.length >= 10){
date = arr.replaceRange(10, arr.length, "")
content = arr.replaceRange(0,10, "")
}

classPlan.classDate = date
classPlan.classPlanned = content
}
3 -> {
var arr = it.text()
when {
arr != "" -> {
var content = arr.replaceRange(0,10, "")
when (content) {
var content = ""
if(arr.isNotEmpty() && arr.length >= 10){
content = arr.replaceRange(0,10, "")
}
when(content){
"" -> classPlan.classDiary = "Não cadastrado"
else -> classPlan.classDiary = content
}
Expand Down

0 comments on commit 8546bb6

Please sign in to comment.