Skip to content

Instantly share code, notes, and snippets.

View HomeViewModel.kt
package lu.gian.uniwhere.features.home.ui
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.google.firebase.iid.FirebaseInstanceId
import com.uniwhere.kmp.elephas.localdatasource.LocalDataSource
import com.uniwhere.kmp.elephas.model.CredentialsManager
import com.uniwhere.kmp.elephas.model.ExamStatsAverageType
import com.uniwhere.kmp.elephas.model.UWErrorCodeClass
View HomeViewModel.kt
package lu.gian.uniwhere.features.home.ui
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.google.firebase.iid.FirebaseInstanceId
import com.uniwhere.kmp.elephas.localdatasource.LocalDataSource
import com.uniwhere.kmp.elephas.model.ExamStatsAverageType
import com.uniwhere.kmp.elephas.model.UWErrorCodeClass
import com.uniwhere.kmp.elephas.model.UniAccountWrapper
@mrsasha
mrsasha / page.html
Created May 17, 2022
Example of page with change password request
View page.html
<html id="top" lang="it"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cambio password, Università di UNICAL</title>
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="Servizi online dell'ateneo" name="description">
<meta content="noindex, nofollow" name="robots">
<base href="https://unical.esse3.cineca.it/">
<link href="img/layout/favicons/apple-touch-icon.png" sizes="120x120" rel="apple-touch-icon" class="favicon">
<link href="https://unical.esse3.cineca.it/img/layout/favicons/favicon-32x32.png" sizes="32x32" type="image/png" rel="icon" class="favicon">
View AndroidManifest.xml
<manifest>
<application>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
@mrsasha
mrsasha / GsonSetup.kt
Last active Feb 10, 2020
date & time formatting & de/serialization with Gson and ThreeTenABP
View GsonSetup.kt
private fun createGson(): Gson = GsonBuilder()
.registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeTypeAdapter())
.create()
class OffsetDateTimeTypeAdapter : JsonSerializer<OffsetDateTime>, JsonDeserializer<OffsetDateTime> {
override fun serialize(
src: OffsetDateTime,
typeOfSrc: Type,
context: JsonSerializationContext
@mrsasha
mrsasha / Activity.kt
Last active Feb 18, 2020
viewmodels with channels
View Activity.kt
private fun observeViewModel() {
mainViewModel.observe(lifecycleScope) {
when (it) {
MainScreenState.InProgress -> showProgress()
}
}
}
@mrsasha
mrsasha / Activity.kt
Created Feb 4, 2020
Permission management
View Activity.kt
override fun onStart() {
super.onStart()
permissionManager.requestLocationPermission(this, object : LocationPermissionListener {
override fun permissionGranted() {
Timber.v("location permission granted!")
}
override fun permissionError(error: DexterError) {
Timber.w("location permission error: $error!")
}
@mrsasha
mrsasha / detekt-config.yml
Created Dec 18, 2019
detekt setup for 1.2.2 version
View detekt-config.yml
build:
maxIssues: 0
comments:
active: true
excludes: "**/*Test.kt, **/*Spec.kt"
CommentOverPrivateFunction:
active: false
CommentOverPrivateProperty:
active: false
@mrsasha
mrsasha / build.gradle
Last active Apr 14, 2022
adding Sonarqube reporting for Lint and test coverage to Android Kotlin project (multi-module)
View build.gradle
apply plugin: "org.sonarqube"
buildscript {
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
//ADD ALL THE TASKS (coverage, lint) FOR ALL THE MODULES YOU WANT TO BE REPORTED
project.tasks["sonarqube"].dependsOn ':library-core:testDebugUnitTestCoverage'
@mrsasha
mrsasha / build.gradle
Last active May 23, 2020
adding Sonarqube reporting for Lint and test coverage to Android Kotlin project (single module)
View build.gradle
buildscript {
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}