-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add loading indicator fragment
- Loading branch information
Showing
5 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/de/szalkowski/activitylauncher/ui/LoadingFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package de.szalkowski.activitylauncher.ui | ||
|
||
import android.annotation.SuppressLint | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.fragment.findNavController | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import de.szalkowski.activitylauncher.R | ||
import de.szalkowski.activitylauncher.services.PackageListService | ||
import javax.inject.Inject | ||
import javax.inject.Provider | ||
import kotlin.concurrent.thread | ||
|
||
@AndroidEntryPoint | ||
class LoadingFragment : Fragment() { | ||
@Inject | ||
internal lateinit var packageListService: Provider<PackageListService> | ||
|
||
@SuppressLint("RestrictedApi") | ||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? | ||
): View? { | ||
val context = this.requireActivity() | ||
|
||
thread { | ||
// preload package list | ||
packageListService.get() | ||
|
||
context.runOnUiThread { | ||
val action = LoadingFragmentDirections.actionLoadingFinished() | ||
findNavController().navigate(action) | ||
} | ||
} | ||
|
||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_loading, container, false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".ui.LoadingFragment" > | ||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="24dp" | ||
android:text="@string/dialog_progress_loading" | ||
android:textSize="24sp" | ||
app:layout_constraintBottom_toTopOf="@+id/progressBar" | ||
app:layout_constraintEnd_toEndOf="@+id/progressBar" | ||
app:layout_constraintStart_toStartOf="@+id/progressBar" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/progressBar" | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters