Füge SwipeRefreshLayouts für Listing und Project hinzu

master
Niko Diamadis 5 years ago
parent f50476af93
commit e6e4160aac

@ -68,6 +68,7 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'com.afollestad.material-dialogs:input:3.3.0'
implementation 'com.airbnb.android:lottie:3.4.2'
implementation 'com.amitshekhar.android:android-networking:1.0.2'

@ -1,7 +1,6 @@
package com.cyb3rko.techniklogger.fragments
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Log
@ -89,6 +88,15 @@ class ListingFragment : Fragment() {
loadEntries(adapter)
binding.swipeRefreshLayout.setOnRefreshListener {
binding.swipeRefreshLayout.isRefreshing = false
binding.loadingAnimation.visibility = View.VISIBLE
binding.loadingAnimation.resumeAnimation()
data.clear()
adapter.notifyDataSetChanged()
loadEntries(adapter)
}
return root
}

@ -190,6 +190,60 @@ class ProjectFragment : Fragment() {
)
}
loadData()
adapter.submitList(techniker as List<ProjectTechnikerViewState>?)
binding.recyclerView.layoutManager = LinearLayoutManager(myContext)
binding.recyclerView.adapter = adapter
binding.addButton.setOnClickListener {
val name = sharedPref.getString("name", "invalid")!!
if (!adminMode) selfAdd(name) else bothAdd(name)
}
emptyCheck()
if (adminMode) {
binding.resetButton.visibility = View.VISIBLE
binding.resetButton.setOnClickListener {
MaterialDialog(myContext).show {
message(text = "Möchtest du alle eingetragenen Techniker entfernen?")
positiveButton(text = "Ja") {
val query = ParseQuery<ParseObject>("Teilnahme")
query.whereEqualTo("an", ParseObject.createWithoutData("Einsatz", childKey))
query.findInBackground { objects, e ->
if (e == null) {
ParseObject.deleteAllInBackground(objects)
techniker.clear()
adapter.notifyDataSetChanged()
showDivider(false)
binding.technikerView.text = "Techniker: 0"
} else {
Toasty.error(myContext, "Fehler bei Techniker-Abfrage", Toasty.LENGTH_SHORT).show()
Log.e("TechnikLogger.TechSuche", e.message.toString())
}
}
}
negativeButton(text = "Abbrechen")
}
}
}
binding.swipeRefreshLayout.setOnRefreshListener {
binding.titleView.text = ""
binding.dateView.text = ""
binding.locationView.text = ""
techniker.clear()
adapter.notifyDataSetChanged()
showDivider(false)
binding.technikerView.text = "Techniker: 0"
loadData()
}
return root
}
private fun loadData() {
val query = ParseQuery.getQuery<ParseObject>("Einsatz")
query.getInBackground(childKey) { einsatz, e ->
if (e == null) {
@ -239,46 +293,8 @@ class ProjectFragment : Fragment() {
Toasty.error(myContext, "Fehler bei Einsatz-Suche").show()
Log.e("TechnikLogger.EinsSuche", e.message.toString())
}
binding.swipeRefreshLayout.isRefreshing = false
}
adapter.submitList(techniker as List<ProjectTechnikerViewState>?)
binding.recyclerView.layoutManager = LinearLayoutManager(myContext)
binding.recyclerView.adapter = adapter
binding.addButton.setOnClickListener {
val name = sharedPref.getString("name", "invalid")!!
if (!adminMode) selfAdd(name) else bothAdd(name)
}
emptyCheck()
if (adminMode) {
binding.resetButton.visibility = View.VISIBLE
binding.resetButton.setOnClickListener {
MaterialDialog(myContext).show {
message(text = "Möchtest du alle eingetragenen Techniker entfernen?")
positiveButton(text = "Ja") {
val query = ParseQuery<ParseObject>("Teilnahme")
query.whereEqualTo("an", ParseObject.createWithoutData("Einsatz", childKey))
query.findInBackground { objects, e ->
if (e == null) {
ParseObject.deleteAllInBackground(objects)
techniker.clear()
adapter.notifyDataSetChanged()
showDivider(false)
binding.technikerView.text = "Techniker: 0"
} else {
Toasty.error(myContext, "Fehler bei Techniker-Abfrage", Toasty.LENGTH_SHORT).show()
Log.e("TechnikLogger.TechSuche", e.message.toString())
}
}
}
negativeButton(text = "Abbrechen")
}
}
}
return root
}
private fun technikerExists(name: String): Boolean {

@ -28,22 +28,27 @@
android:layout_height="150dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/recycler_view"
app:layout_constraintTop_toTopOf="@id/swipe_refresh_layout"
android:layout_marginTop="30dp"
app:lottie_fileName="loading.json"
app:lottie_loop="true"
app:lottie_speed="1.5"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="12dp"
android:layoutAnimation="@anim/recycler_animation"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />
android:id="@+id/swipe_refresh_layout">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutAnimation="@anim/recycler_animation" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatingActionButton"

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/swipe_refresh_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@ -191,3 +198,5 @@
</androidx.cardview.widget.CardView>
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
Loading…
Cancel
Save