Ergänze weitere Animationen

master
Niko Diamadis 5 years ago
parent c8523a9e9a
commit 9b9993f2ad

File diff suppressed because one or more lines are too long

@ -0,0 +1,48 @@
package com.cyb3rko.techniklogger.fragments
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import androidx.fragment.app.Fragment
class AboutAnimationsFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val myContext = requireContext()
val information = listOf(
Triple("Technical Assistance", "Jesús Suárez", "https://lottiefiles.com/29410-technical-assistance"),
Triple("No connection animation", "Lenny Miranda Jr.", "https://lottiefiles.com/9010-no-connection-animation")
)
val view = ScrollView(myContext)
val linearLayout = LinearLayout(myContext)
linearLayout.orientation = LinearLayout.VERTICAL
information.forEach {
val textView = TextView(myContext)
textView.textSize = 18f
textView.setPaddingRelative(40, 50, 40, 0)
val text = "${it.first}-Animation von ${it.second}"
val spannableString = SpannableString(text)
val clickableSpan = object: ClickableSpan() {
override fun onClick(widget: View) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(it.third)))
}
}
spannableString.setSpan(clickableSpan, 0, it.first.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
textView.text = spannableString
textView.movementMethod = LinkMovementMethod.getInstance()
linearLayout.addView(textView)
}
view.addView(linearLayout)
return view
}
}

@ -27,6 +27,9 @@ class AboutFragment : Fragment() {
.addItem(Element().setTitle("Benutzte Icons").setIconDrawable(R.drawable._icon_question).setOnClickListener {
findNavController().navigate(R.id.navigation_about_icons)
})
.addItem(Element().setTitle("Benutzte Animationen").setIconDrawable(R.drawable._icon_question).setOnClickListener {
findNavController().navigate(R.id.navigation_about_animations)
})
.create()
}

@ -91,14 +91,17 @@ class ListingFragment : Fragment() {
loadEntries(adapter)
binding.swipeRefreshLayout.setOnRefreshListener {
binding.swipeRefreshLayout.isRefreshing = false
binding.loadingAnimation.visibility = View.VISIBLE
binding.loadingAnimation.resumeAnimation()
binding.swipeRefreshLayout.apply {
setProgressBackgroundColorSchemeResource(R.color.refreshLayoutBackground)
setColorSchemeResources(R.color.refreshLayoutArrow)
setOnRefreshListener {
isRefreshing = false
showAnimation(true)
data.clear()
adapter.notifyDataSetChanged()
loadEntries(adapter)
}
}
binding.fab.setOnClickListener {
if (!isFABOpen) showFABMenu() else closeFABMenu()
@ -153,22 +156,18 @@ class ListingFragment : Fragment() {
}
data.sortBy { it.date }
hideProgress()
showAnimation(false)
adapter.notifyDataSetChanged()
binding.recyclerView.scheduleLayoutAnimation()
binding.recyclerView.scrollBy(0, -10000)
} else {
showAnimation(true, false)
Toasty.error(myContext, "Abruf fehlgeschlagen", Toasty.LENGTH_SHORT).show()
Log.e("TechnikLogger.EinsSuche", e.message.toString())
}
}
}
private fun hideProgress() {
binding.loadingAnimation.visibility = View.GONE
binding.loadingAnimation.cancelAnimation()
}
private fun updateAdminStatus() {
val query = ParseQuery.getQuery<ParseObject>("Techniker")
query.whereEqualTo("name", sharedPref.getString("name", ""))
@ -194,6 +193,20 @@ class ListingFragment : Fragment() {
}
}
private fun showAnimation(show: Boolean, connected: Boolean = true) {
val viewVisibility = if (show) View.VISIBLE else View.INVISIBLE
val newSpeed = if (!connected) 1.2f else 1.5f
val animation = if (connected) "loading.json" else "no-connection.json"
binding.apply {
loadingAnimation.apply {
setAnimation(animation)
speed = newSpeed
visibility = viewVisibility
playAnimation()
}
}
}
private fun showFABMenu() {
isFABOpen = true
binding.fabLayout1.visibility = View.VISIBLE

@ -57,6 +57,7 @@ class ManageTechnikerFragment : Fragment() {
saveInBackground {
if (it == null) {
Toast.makeText(myContext, "Hinzugefügt", Toast.LENGTH_SHORT).show()
showAnimation(true)
fetchTechniker()
} else {
Toasty.error(myContext, "Fehler bei Speicherung").show()
@ -68,17 +69,28 @@ class ManageTechnikerFragment : Fragment() {
}
}
binding.swipeRefreshLayout.apply {
setProgressBackgroundColorSchemeResource(R.color.refreshLayoutBackground)
setColorSchemeResources(R.color.refreshLayoutArrow)
setOnRefreshListener {
isRefreshing = false
showAnimation(true)
fetchTechniker()
}
}
return root
}
private fun fetchTechniker() {
technikerNames.clear()
binding.list.adapter = ArrayAdapter(myContext, android.R.layout.simple_list_item_1, technikerNames)
query.findInBackground { objects, e ->
if (e == null) {
techniker = objects.sortedBy {
it.getString("name")!!
}.toMutableList()
technikerNames.clear()
objects.forEach {
technikerNames.add(it.getString("name")!!)
}
@ -86,6 +98,8 @@ class ManageTechnikerFragment : Fragment() {
val adapter = ArrayAdapter(myContext, android.R.layout.simple_list_item_1, technikerNames)
binding.list.adapter = adapter
showAnimation(false)
binding.list.setOnItemClickListener { _, _, index, _ ->
val dialogView = layoutInflater.inflate(R.layout.techniker_dialog, null)
dialogView.findViewById<TextInputEditText>(R.id.name).setText(technikerNames[index])
@ -105,6 +119,7 @@ class ManageTechnikerFragment : Fragment() {
saveInBackground {
if (it == null) {
Toast.makeText(myContext, "Gespeichert", Toast.LENGTH_SHORT).show()
showAnimation(true)
fetchTechniker()
} else {
Toasty.error(myContext, "Fehler bei Speicherung").show()
@ -125,6 +140,7 @@ class ManageTechnikerFragment : Fragment() {
saveInBackground {
if (it == null) {
Toast.makeText(myContext, "Gespeichert", Toast.LENGTH_SHORT).show()
showAnimation(true)
fetchTechniker()
} else {
Toasty.error(myContext, "Fehler bei Speicherung").show()
@ -138,6 +154,24 @@ class ManageTechnikerFragment : Fragment() {
}
}
}
} else {
showAnimation(true, false)
Toasty.error(myContext, "Abruf fehlgeschlagen", Toasty.LENGTH_SHORT).show()
Log.e("TechnikLogger.TechVerw", e.message.toString())
}
}
}
private fun showAnimation(show: Boolean, connected: Boolean = true) {
val viewVisibility = if (show) View.VISIBLE else View.INVISIBLE
val newSpeed = if (!connected) 1.2f else 1.5f
val animation = if (connected) "loading.json" else "no-connection.json"
binding.apply {
loadingAnimation.apply {
setAnimation(animation)
speed = newSpeed
visibility = viewVisibility
playAnimation()
}
}
}

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -8,6 +14,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/loading_animation"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
app:lottie_fileName="loading.json"
app:lottie_loop="true"
app:lottie_speed="1.5"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
@ -19,4 +37,6 @@
android:src="@drawable/_icon_add"
android:tint="@color/drawableTint" />
</RelativeLayout>
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

@ -81,4 +81,10 @@
android:id="@+id/navigation_about_icons"
android:name="com.cyb3rko.techniklogger.fragments.AboutIconsFragment"
android:label="Über" />
<fragment
android:id="@+id/navigation_about_animations"
android:name="com.cyb3rko.techniklogger.fragments.AboutAnimationsFragment"
android:label="Über" />
</navigation>

@ -5,4 +5,7 @@
<color name="colorAccent">#1596F8</color>
<color name="cardBackground">@color/cardview_dark_background</color>
<color name="blurBackground">#92000000</color>
<color name="refreshLayoutBackground">@color/cardview_dark_background</color>
<color name="refreshLayoutArrow">#FFFFFF</color>
</resources>

@ -6,4 +6,7 @@
<color name="cardBackground">#FFFFFF</color>
<color name="blurBackground">#92000000</color>
<color name="drawableTint">#FFFFFF</color>
<color name="refreshLayoutBackground">#FFFFFF</color>
<color name="refreshLayoutArrow">#393939</color>
</resources>
Loading…
Cancel
Save