-
Notifications
You must be signed in to change notification settings - Fork 0
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
Phong Truong Ho Phong
committed
Oct 16, 2019
1 parent
0b8bc14
commit bd101ec
Showing
9 changed files
with
244 additions
and
17 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
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
28 changes: 28 additions & 0 deletions
28
SOURCE/app/src/main/java/com/example/measurehearthrate/Helper/DialogHelper.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,28 @@ | ||
package com.example.measurehearthrate.Helper | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
|
||
class DialogHelper { | ||
|
||
|
||
companion object { | ||
|
||
private var mDialogState: MutableLiveData<DialogWrapper> = MutableLiveData() | ||
|
||
val dialogState: LiveData<DialogWrapper> | ||
get() = mDialogState | ||
|
||
fun emitDialogState( | ||
isshowingDialog: Boolean? = null | ||
) { | ||
val dialogModel = DialogWrapper(isshowingDialog) | ||
mDialogState.postValue(dialogModel) | ||
|
||
} | ||
|
||
data class DialogWrapper( | ||
var isshowingDialog: Boolean? | ||
) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
SOURCE/app/src/main/java/com/example/measurehearthrate/View/DialogLoadingFragment.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,60 @@ | ||
package com.example.measurehearthrate.View | ||
|
||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import android.text.TextUtils | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.fragment.app.DialogFragment | ||
import com.example.measurehearthrate.R | ||
|
||
class DialogLoadingFragment : DialogFragment() { | ||
|
||
private var title = "" | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
Log.d(TAG,"onCreate") | ||
arguments?.let { | ||
title = it.getString(DIALOG_TITLE) ?: "" | ||
} | ||
|
||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_dialog_loading,container,false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
val textView = view.findViewById<TextView>(R.id.tv_title) | ||
|
||
if(TextUtils.isEmpty(title)) { | ||
textView.visibility = View.GONE | ||
} else { | ||
textView.visibility = View.VISIBLE | ||
textView.text = title | ||
} | ||
|
||
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | ||
|
||
} | ||
|
||
companion object { | ||
const val TAG = "DialogLoadingFragment" | ||
const val DIALOG_TITLE = "DIALOG TITLE" | ||
|
||
fun newInstance(title: String =""): DialogLoadingFragment { | ||
val fragment = DialogLoadingFragment() | ||
val args = Bundle() | ||
args.putString(DIALOG_TITLE,title) | ||
fragment.arguments = args | ||
return fragment | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:duration="500" | ||
android:pivotX="50%" | ||
android:pivotY="50%"> | ||
|
||
<bitmap | ||
android:src="@drawable/ic_dialog_loading" | ||
android:tint="@color/primaryColor" /> | ||
|
||
</animated-rotate> |
40 changes: 40 additions & 0 deletions
40
SOURCE/app/src/main/res/layout/fragment_dialog_loading.xml
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,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="wrap_content" | ||
android:layout_height="@dimen/dp152" | ||
app:cardCornerRadius="@dimen/dp10"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ProgressBar | ||
android:id="@+id/progress_bar" | ||
android:layout_width="@dimen/dp30" | ||
android:layout_height="@dimen/dp30" | ||
android:layout_margin="@dimen/dp30" | ||
android:indeterminate="true" | ||
android:indeterminateDrawable="@drawable/loading_progress" | ||
app:layout_constraintBottom_toTopOf="@id/tv_title" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/dp50" | ||
android:layout_marginEnd="@dimen/dp50" | ||
android:layout_marginBottom="@dimen/dp30" | ||
android:gravity="center_horizontal" | ||
android:textColor="@color/primaryColor" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/progress_bar" | ||
app:layout_constraintVertical_chainStyle="packed" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</androidx.cardview.widget.CardView> |