This file contains hidden or 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
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Zego Express Video Call</title> | |
<style type="text/css"> | |
* { | |
font-family: sans-serif; | |
} | |
h1, |
This file contains hidden or 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
package com.asissuthar.validation | |
import android.os.Bundle | |
import android.util.Patterns | |
import android.widget.Toast | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.lifecycle.lifecycleScope | |
import com.asissuthar.validation.databinding.ActivityMainBinding | |
import com.asissuthar.validation.formfields.FormFieldText | |
import com.asissuthar.validation.formfields.disable |
This file contains hidden or 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
// ... | |
fun Collection<FormField<*>>.clearError() { | |
forEach { formField -> formField.clearError() } | |
} | |
fun Collection<FormField<*>>.clearFocus() { | |
forEach { formField -> formField.clearFocus() } | |
} |
This file contains hidden or 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
// ... | |
// Validate extention function for collection of FormFields. It will execute validate method of each field and return boolean result. | |
suspend fun Collection<FormField<*>>.validate(validateAll: Boolean = false) = coroutineScope { | |
if (validateAll) { | |
map { formField -> async { formField.validate(focusIfError = false) } }.awaitAll().all { result -> result } | |
} else { | |
all { formField -> formField.validate() } | |
} | |
} |
This file contains hidden or 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
<?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=".MainActivity"> | |
<androidx.appcompat.widget.LinearLayoutCompat | |
android:id="@+id/llForm" |
This file contains hidden or 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
package com.asissuthar.validation | |
import android.os.Bundle | |
import android.widget.Toast | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.lifecycle.lifecycleScope | |
import com.asissuthar.validation.databinding.ActivityMainBinding | |
import com.asissuthar.validation.formfields.FormFieldText | |
import kotlinx.coroutines.flow.launchIn | |
import kotlinx.coroutines.flow.onEach |
This file contains hidden or 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
package com.asissuthar.validation.formfields | |
import androidx.core.view.isVisible | |
import com.google.android.material.textfield.TextInputEditText | |
import com.google.android.material.textfield.TextInputLayout | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.flow.launchIn | |
import kotlinx.coroutines.flow.onEach | |
import kotlinx.coroutines.flow.update | |
import reactivecircus.flowbinding.android.widget.textChanges |
This file contains hidden or 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
package com.asissuthar.validation.formfields | |
import kotlinx.coroutines.flow.MutableStateFlow | |
import kotlinx.coroutines.flow.asStateFlow | |
abstract class FormField<T> { | |
protected val stateInternal = MutableStateFlow<T?>(null) | |
// state is StateFlow. It will be helpful for collecting any change in current value. | |
val state = stateInternal.asStateFlow() |
This file contains hidden or 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
android { | |
// ... | |
buildFeatures { | |
viewBinding true | |
} | |
} | |
dependencies { | |
// Use latest version of all dependencies | |
implementation 'androidx.core:core-ktx:1.9.0' | |
implementation 'androidx.appcompat:appcompat:1.5.1' |
This file contains hidden or 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
package com.asissuthar.experiments.service | |
import android.app.Service | |
import android.content.Intent | |
import android.os.IBinder | |
import com.asissuthar.experiments.common.AppEvent | |
import com.asissuthar.experiments.common.AppEventBus | |
import kotlinx.coroutines.* | |
import org.koin.android.ext.android.inject |
NewerOlder