-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
144 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout 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:id="@+id/frg_background" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="#80000000" | ||
android:elevation="1dp"> | ||
|
||
<LinearLayout | ||
android:id="@+id/frg_body" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginBottom="20dp" | ||
android:background="@drawable/rounded_rect" | ||
android:backgroundTint="#1E1E2E" | ||
android:divider="@drawable/divider" | ||
android:gravity="center" | ||
android:minWidth="200dp" | ||
android:orientation="vertical" | ||
android:showDividers="middle"> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
style="@style/settings_tab_divider" | ||
android:paddingVertical="12dp" | ||
android:text="Title" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:orientation="horizontal" | ||
android:padding="12dp"> | ||
|
||
<com.google.android.material.progressindicator.CircularProgressIndicator | ||
android:id="@+id/progress" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:indeterminate="true" | ||
android:padding="10dp" | ||
app:indicatorColor="@color/colorAccent" | ||
app:indicatorDirectionCircular="counterclockwise" | ||
app:trackCornerRadius="12dp" | ||
tools:indeterminate="false" | ||
tools:progress="50" /> | ||
|
||
<TextView | ||
android:id="@+id/message" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="12dp" | ||
android:maxWidth="400dp" | ||
android:textColor="#FFF" | ||
tools:text="Message" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> |
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,80 @@ | ||
package com.reco1l.osu.ui | ||
|
||
import com.google.android.material.progressindicator.CircularProgressIndicator | ||
import ru.nsu.ccfit.zuev.osuplus.R | ||
|
||
|
||
class ProgressDialog : MessageDialog() { | ||
|
||
|
||
override val layoutID = R.layout.dialog_progress | ||
|
||
|
||
/** | ||
* The progress of the dialog. | ||
*/ | ||
var progress: Int = 0 | ||
set(value) { | ||
field = value | ||
if (isCreated) { | ||
findViewById<CircularProgressIndicator>(R.id.progress)!!.progress = value | ||
} | ||
} | ||
|
||
/** | ||
* Whether the progress is indeterminate or not. | ||
*/ | ||
var indeterminate: Boolean = false | ||
set(value) { | ||
field = value | ||
if (isCreated) { | ||
findViewById<CircularProgressIndicator>(R.id.progress)!!.isIndeterminate = value | ||
} | ||
} | ||
|
||
/** | ||
* The maximum value of the progress. | ||
*/ | ||
var max: Int = 0 | ||
set(value) { | ||
field = value | ||
if (isCreated) { | ||
findViewById<CircularProgressIndicator>(R.id.progress)!!.max = value | ||
} | ||
} | ||
|
||
|
||
override fun onLoadView() { | ||
super.onLoadView() | ||
|
||
max = max | ||
progress = progress | ||
indeterminate = indeterminate | ||
} | ||
|
||
|
||
/** | ||
* Sets the progress of the dialog. | ||
*/ | ||
fun setProgress(value: Int): ProgressDialog { | ||
progress = value | ||
return this | ||
} | ||
|
||
/** | ||
* Sets whether the progress is indeterminate or not. | ||
*/ | ||
fun setIndeterminate(value: Boolean): ProgressDialog { | ||
indeterminate = value | ||
return this | ||
} | ||
|
||
/** | ||
* Sets the maximum value of the progress. | ||
*/ | ||
fun setMax(value: Int): ProgressDialog { | ||
max = value | ||
return this | ||
} | ||
|
||
} |