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-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4' implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.recyclerview:recyclerview:1.1.0' 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.afollestad.material-dialogs:input:3.3.0'
implementation 'com.airbnb.android:lottie:3.4.2' implementation 'com.airbnb.android:lottie:3.4.2'
implementation 'com.amitshekhar.android:android-networking:1.0.2' implementation 'com.amitshekhar.android:android-networking:1.0.2'

@ -1,7 +1,6 @@
package com.cyb3rko.techniklogger.fragments package com.cyb3rko.techniklogger.fragments
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
@ -89,6 +88,15 @@ class ListingFragment : Fragment() {
loadEntries(adapter) 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 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") val query = ParseQuery.getQuery<ParseObject>("Einsatz")
query.getInBackground(childKey) { einsatz, e -> query.getInBackground(childKey) { einsatz, e ->
if (e == null) { if (e == null) {
@ -239,46 +293,8 @@ class ProjectFragment : Fragment() {
Toasty.error(myContext, "Fehler bei Einsatz-Suche").show() Toasty.error(myContext, "Fehler bei Einsatz-Suche").show()
Log.e("TechnikLogger.EinsSuche", e.message.toString()) 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 { private fun technikerExists(name: String): Boolean {

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

@ -1,193 +1,202 @@
<?xml version="1.0" encoding="utf-8"?> <?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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:ignore="HardcodedText"> android:id="@+id/swipe_refresh_layout">
<androidx.cardview.widget.CardView <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginStart="35dp"
android:layout_marginEnd="35dp">
<TextView
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-black"
android:gravity="center_horizontal"
android:textSize="20sp"
tools:text="Beispiel-Einsatz" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginStart="25dp" android:orientation="vertical"
android:layout_marginTop="20dp" tools:ignore="HardcodedText">
android:layout_marginEnd="25dp">
<LinearLayout <androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:layout_gravity="center_horizontal"
android:orientation="horizontal" android:layout_marginTop="20dp"
android:paddingVertical="4dp" android:layout_marginStart="35dp"
tools:ignore="UseCompoundDrawables"> android:layout_marginEnd="35dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="Date Icon"
android:padding="6dp"
android:src="@drawable/_icon_date" />
<TextView <TextView
android:id="@+id/date_view" android:id="@+id/title_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-black" android:fontFamily="sans-serif-black"
android:paddingHorizontal="12dp" android:gravity="center_horizontal"
android:paddingVertical="16dp" android:textSize="20sp"
android:textSize="16sp" tools:text="Beispiel-Einsatz" />
tools:text="01.01.1900, 1 Stunde" />
</LinearLayout> </androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:layout_marginStart="25dp"
android:orientation="horizontal" android:layout_marginTop="20dp"
android:paddingVertical="4dp" android:layout_marginEnd="25dp">
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="Location Icon"
android:padding="6dp"
android:src="@drawable/_icon_location" />
<TextView
android:id="@+id/location_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-black"
android:paddingHorizontal="12dp"
android:paddingVertical="16dp"
android:textSize="16sp"
tools:text="Forum Daun" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="20dp">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingVertical="4dp"
tools:ignore="UseCompoundDrawables">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical"> android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingVertical="4dp"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="Date Icon"
android:padding="6dp"
android:src="@drawable/_icon_date" />
<TextView
android:id="@+id/date_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-black"
android:paddingHorizontal="12dp"
android:paddingVertical="16dp"
android:textSize="16sp"
tools:text="01.01.1900, 1 Stunde" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingVertical="4dp"
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:contentDescription="Location Icon" android:contentDescription="Location Icon"
android:padding="6dp" android:padding="6dp"
android:src="@drawable/_icon_techniker" /> android:src="@drawable/_icon_location" />
<TextView <TextView
android:id="@+id/techniker_view" android:id="@+id/location_view"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="sans-serif-black" android:fontFamily="sans-serif-black"
android:paddingHorizontal="12dp" android:paddingHorizontal="12dp"
android:paddingVertical="16dp" android:paddingVertical="16dp"
android:text="Techniker: 0" android:textSize="16sp"
android:textSize="16sp" /> tools:text="Forum Daun" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="20dp">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingVertical="4dp"
tools:ignore="UseCompoundDrawables">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:gravity="center_vertical">
android:gravity="end">
<ImageButton <ImageView
android:id="@+id/reset_button" android:layout_width="40dp"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="45dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_gravity="end" android:contentDescription="Location Icon"
android:contentDescription="Add Icon" android:padding="6dp"
android:scaleType="fitEnd" android:src="@drawable/_icon_techniker" />
android:visibility="gone"
android:src="@drawable/_icon_delete"
tools:visibility="visible"/>
<ImageButton <TextView
android:id="@+id/add_button" android:id="@+id/techniker_view"
style="@style/Widget.AppCompat.Button.Borderless" android:layout_width="wrap_content"
android:layout_width="45dp" android:layout_height="wrap_content"
android:layout_height="40dp" android:fontFamily="sans-serif-black"
android:layout_gravity="end" android:paddingHorizontal="12dp"
android:contentDescription="Add Icon" android:paddingVertical="16dp"
android:scaleType="fitEnd" android:text="Techniker: 0"
android:src="@drawable/_icon_add" /> android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="end">
<ImageButton
android:id="@+id/reset_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="45dp"
android:layout_height="40dp"
android:layout_gravity="end"
android:contentDescription="Add Icon"
android:scaleType="fitEnd"
android:visibility="gone"
android:src="@drawable/_icon_delete"
tools:visibility="visible"/>
<ImageButton
android:id="@+id/add_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="45dp"
android:layout_height="40dp"
android:layout_gravity="end"
android:contentDescription="Add Icon"
android:scaleType="fitEnd"
android:src="@drawable/_icon_add" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#808080" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layoutAnimation="@anim/recycler_animation" />
</LinearLayout> </LinearLayout>
<View </androidx.cardview.widget.CardView>
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#808080" />
<androidx.recyclerview.widget.RecyclerView </LinearLayout>
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layoutAnimation="@anim/recycler_animation" />
</LinearLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Loading…
Cancel
Save