Compare commits
37 Commits
master
...
update_swi
| Author | SHA1 | Date |
|---|---|---|
|
|
200da70e1e | |
|
|
53adefddbb | |
|
|
194f1862c6 | |
|
|
0c8b444f20 | |
|
|
4ab4161610 | |
|
|
47b1c76fdf | |
|
|
4bf9d0991b | |
|
|
58c9f12d3c | |
|
|
6cc66fd242 | |
|
|
501fddd72d | |
|
|
3a6afded87 | |
|
|
9c67b0fa18 | |
|
|
19044fefa8 | |
|
|
fd51f7f67b | |
|
|
89271b79b8 | |
|
|
e65752731f | |
|
|
949b53f79d | |
|
|
231356bb82 | |
|
|
14d099806f | |
|
|
39289f61f4 | |
|
|
a616a39f27 | |
|
|
2ddc08c22b | |
|
|
adc53e6a7b | |
|
|
2bc496562e | |
|
|
79c9336c33 | |
|
|
527df2be1c | |
|
|
b54daede13 | |
|
|
0889ed2e9b | |
|
|
a615d54f3e | |
|
|
060aa5bb6a | |
|
|
8b0d17d5cc | |
|
|
8d4c5244a4 | |
|
|
f5f8183924 | |
|
|
a710d30b67 | |
|
|
c7e24038dd | |
|
|
184140b967 | |
|
|
5edc752686 |
|
|
@ -10,4 +10,13 @@ sealed class ContentEvent<out T>(open val data: T?) {
|
|||
|
||||
data class Complete<out T>(override val data: T? = null) : ContentEvent<T>(data)
|
||||
|
||||
fun <P> transform(transformation: (T?) -> P): ContentEvent<P> {
|
||||
return when(this) {
|
||||
is Loading -> Loading(transformation(data))
|
||||
is Success -> Success(transformation(data))
|
||||
is Complete -> Complete(transformation(data))
|
||||
is Error -> Error(throwable, transformation(data))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ dependencies {
|
|||
|
||||
implementation "com.google.android.gms:play-services-location"
|
||||
|
||||
implementation "com.huawei.hms:location:$versions.hmsLocation"
|
||||
|
||||
constraints {
|
||||
implementation("com.google.android.gms:play-services-location") {
|
||||
version {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package ru.touchin.livedata.location
|
||||
|
||||
import android.Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
import android.Manifest.permission.ACCESS_FINE_LOCATION
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import androidx.annotation.RequiresPermission
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import com.huawei.hms.location.FusedLocationProviderClient
|
||||
import com.huawei.hms.location.LocationAvailability
|
||||
import com.huawei.hms.location.LocationCallback
|
||||
import com.huawei.hms.location.LocationRequest
|
||||
import com.huawei.hms.location.LocationResult
|
||||
import com.huawei.hms.location.LocationServices
|
||||
|
||||
class HuaweiLocationLiveData(
|
||||
context: Context,
|
||||
private val request: LocationRequest
|
||||
) : LiveData<Location>() {
|
||||
|
||||
private val fusedLocationClient: FusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context)
|
||||
private val locationCallback = object : LocationCallback() {
|
||||
override fun onLocationResult(result: LocationResult) {
|
||||
postValue(result.lastLocation)
|
||||
}
|
||||
|
||||
override fun onLocationAvailability(availability: LocationAvailability) {
|
||||
if (!availability.isLocationAvailable) postValue(null)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermission(anyOf = [ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION])
|
||||
override fun observe(owner: LifecycleOwner, observer: Observer<in Location>) {
|
||||
super.observe(owner, observer)
|
||||
}
|
||||
|
||||
@RequiresPermission(anyOf = [ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION])
|
||||
override fun onActive() {
|
||||
startListening()
|
||||
}
|
||||
|
||||
override fun onInactive() {
|
||||
stopListening()
|
||||
}
|
||||
|
||||
private fun stopListening() {
|
||||
fusedLocationClient.removeLocationUpdates(locationCallback)
|
||||
}
|
||||
|
||||
@RequiresPermission(anyOf = [ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION])
|
||||
private fun startListening() {
|
||||
fusedLocationClient.requestLocationUpdates(
|
||||
request,
|
||||
locationCallback,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
|||
|
||||
import net.danlew.android.joda.JodaTimeAndroid;
|
||||
|
||||
import ru.touchin.hardware.ProcessKt;
|
||||
import ru.touchin.roboswag.core.log.ConsoleLogProcessor;
|
||||
import ru.touchin.roboswag.core.log.Lc;
|
||||
import ru.touchin.roboswag.core.log.LcGroup;
|
||||
|
|
@ -46,7 +47,7 @@ public abstract class TouchinApp extends Application {
|
|||
enableStrictMode();
|
||||
Lc.initialize(new ConsoleLogProcessor(LcLevel.VERBOSE), true);
|
||||
LcGroup.UI_LIFECYCLE.disable();
|
||||
} else {
|
||||
} else if (ProcessKt.isOnMainProcess(this)) {
|
||||
try {
|
||||
final FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
||||
crashlytics.setCrashlyticsCollectionEnabled(true);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ open class ViewControllerNavigation<TActivity : FragmentActivity>(
|
|||
*/
|
||||
fun <TState : Parcelable> setViewControllerAsTop(
|
||||
viewControllerClass: Class<out ViewController<out TActivity, TState>>,
|
||||
state: TState,
|
||||
state: TState?,
|
||||
addToStack: Boolean = true,
|
||||
tag: String? = null,
|
||||
transactionSetup: ((FragmentTransaction) -> Unit)? = null
|
||||
|
|
@ -149,7 +149,7 @@ open class ViewControllerNavigation<TActivity : FragmentActivity>(
|
|||
*/
|
||||
fun <TState : Parcelable> setInitialViewController(
|
||||
viewControllerClass: Class<out ViewController<out TActivity, TState>>,
|
||||
state: TState,
|
||||
state: TState?,
|
||||
tag: String? = null,
|
||||
transactionSetup: ((FragmentTransaction) -> Unit)? = null
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ dependencies {
|
|||
constraints {
|
||||
implementation("androidx.recyclerview:recyclerview") {
|
||||
version {
|
||||
require '1.0.0'
|
||||
require '1.1.0'
|
||||
}
|
||||
}
|
||||
implementation("androidx.core:core-ktx") {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,28 @@ open class DelegationListAdapter<TItem>(config: AsyncDifferConfig<TItem>) : Recy
|
|||
*
|
||||
* @param list The new list to be displayed.
|
||||
*/
|
||||
fun submitList(list: List<TItem>) = differ.submitList(list)
|
||||
fun submitList(list: List<TItem>?) = differ.submitList(list)
|
||||
|
||||
/**
|
||||
* Submits a new list to be diffed, and displayed.
|
||||
*
|
||||
* The commit callback can be used to know when the List is committed, but note that it
|
||||
* may not be executed. If List B is submitted immediately after List A, and is
|
||||
* committed directly, the callback associated with List A will not be run.
|
||||
*
|
||||
* @param newList The new List.
|
||||
* @param commitCallback Optional runnable that is executed when the List is committed, if
|
||||
* it is committed.
|
||||
*/
|
||||
fun submitList(list: List<TItem>?, commitCallback: (() -> Unit)?) = differ.submitList(list, commitCallback)
|
||||
|
||||
/**
|
||||
* Same as [submitList] with fast simple remove all items of a previous list
|
||||
*/
|
||||
fun replaceList(list: List<TItem>) {
|
||||
submitList(null)
|
||||
submitList(list)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current List - any diffing to present this list has already been computed and
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public final class CalendarUtils {
|
|||
final int firstDayInNextMonth = nextMonthFirstDay.getDayOfWeek() - 1;
|
||||
|
||||
if (daysLeftInWeek != 0) {
|
||||
calendarItems.add(new CalendarEmptyItem(shift, shift + daysLeftInWeek));
|
||||
calendarItems.add(new CalendarEmptyItem(shift, shift + daysLeftInWeek - 1));
|
||||
shift += daysLeftInWeek;
|
||||
}
|
||||
calendarItems.add(new CalendarHeaderItem(nextMonthFirstDay.getYear(), nextMonthFirstDay.getMonthOfYear() - 1, shift, shift));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ open class DefaultActivityLifecycleCallbacks : Application.ActivityLifecycleCall
|
|||
|
||||
override fun onActivityDestroyed(activity: Activity) = Unit
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle?) = Unit
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) = Unit
|
||||
|
||||
override fun onActivityStopped(activity: Activity) = Unit
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package ru.touchin.hardware
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
|
||||
fun Context.isOnMainProcess(): Boolean {
|
||||
val applicationContext = this.applicationContext
|
||||
val runningAppProcesses = (applicationContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager)
|
||||
.runningAppProcesses
|
||||
if (runningAppProcesses != null && runningAppProcesses.size != 0) {
|
||||
for (runningProcessInfo in runningAppProcesses) {
|
||||
val isCurrentProcess = runningProcessInfo.pid == Process.myPid()
|
||||
val isMainProcessName = this.packageName == runningProcessInfo.processName
|
||||
if (isCurrentProcess && isMainProcessName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class AmountWithDecimalDecorator(
|
|||
fun getTextWithoutFormatting(decimalSeparatorToReplace: String = decimalSeparator): String =
|
||||
previousInputtedText.withoutFormatting(decimalSeparatorToReplace)
|
||||
|
||||
@Suppress("detekt.TooGenericExceptionCaught")
|
||||
@Suppress("detekt.TooGenericExceptionCaught", "detekt.LongMethod", "detekt.ComplexMethod")
|
||||
private fun doOnTextChanged(text: String) {
|
||||
if (isTextWasArtificiallyChanged) {
|
||||
isTextWasArtificiallyChanged = false
|
||||
|
|
|
|||
|
|
@ -67,6 +67,13 @@ public class Switcher extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
public void hideAllChildren() {
|
||||
for (int index = 0; index < getChildCount(); index++) {
|
||||
final View child = getChildAt(index);
|
||||
setVisibilityWithAnimation(child, View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setVisibilityWithAnimation(@NonNull final View view, final int targetVisibility) {
|
||||
final Animation animation = targetVisibility == View.VISIBLE ? inAnimation : outAnimation;
|
||||
if (view.getVisibility() != targetVisibility) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue