Skip to content

Instantly share code, notes, and snippets.

View Swisyn's full-sized avatar

Dzhunet Hasan Swisyn

  • kleinanzeigen GmbH
  • Berlin, Germany
  • 05:34 (UTC +02:00)
View GitHub Profile
@Swisyn
Swisyn / string_encrypt_decrypt.md
Created April 23, 2016 20:10 — forked from aogilvie/string_encrypt_decrypt.md
Quick and sexy String encrypt / decrypt for Android

#Quick and sexy String encrypt / decrypt for Android

Sometimes you find yourself wanted to use SharedPrefs to hold something precious? Want to prevent those pesky rooted hackz0rs from looking in your SharedPreds? Here is a quick and sexy no-external-libs-required solution.

Notes;

  • I have declared everything static so you can create your own utility class and throw the following straight in.

  • 3rd party imports are not required. Use import android.util.Base64; for Base64, and import javax.crypto.*; for Cipher.

@Swisyn
Swisyn / EventsQueue.kt
Created May 13, 2020 11:45 — forked from osipxd/EventsQueue.kt
ViewModel and LiveData extensions
import androidx.annotation.MainThread
import androidx.lifecycle.MutableLiveData
import java.util.LinkedList
import java.util.Queue
/**
* Класс-очередь для обработки временных событий, не являющихся частью View
* Например, показ SnackBar с сообщением или ошибкой.
*/
class EventsQueue : MutableLiveData<Queue<Event>>() {
@Swisyn
Swisyn / gradle_tests_report.gradle.kts
Created September 24, 2021 07:12 — forked from ethanmdavidson/gradle_tests_report.gradle.kts
Fancy gradle test result logging, in kotlin
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import groovy.time.TimeCategory
import java.util.Date
/**
* based on the groovy code by lwasyl:
* https://gist.github.com/lwasyl/f5b2b4ebe9e348ebbd8ee4cb995f8362
*/
var testResults by extra(mutableListOf<TestOutcome>()) // Container for tests summaries
@Swisyn
Swisyn / gradle_tests_report.gradle
Created September 24, 2021 07:12 — forked from lwasyl/gradle_tests_report.gradle
Gradle tests logging #loggingpost
import groovy.time.TimeCategory
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
rootProject {
ext.testsResults = [] // Container for tests summaries
allprojects { project ->
tasks.withType(Test) { testTask ->
<style name="TopSheet_DialogAnimation">
  <item name="android:windowEnterAnimation">@anim/slide_out_from_top</item>
  <item name="android:windowExitAnimation">@anim/slide_back_to_top</item>
</style>

slide_out_from_top

@Swisyn
Swisyn / DetailsFragment.kt
Created May 13, 2020 11:46 — forked from osipxd/DetailsFragment.kt
Partial view state rendering with LiveData transformations
class DetailsFragment : BaseFragment(R.layout.fragment_details) {
lateinit val viewModel: DetailsViewModel
// ...
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onVewCreated(view, savedInstanceState)
// Assumed that viewModel initialized here
@Swisyn
Swisyn / setLocale.kt
Created May 13, 2020 11:45 — forked from osipxd/setLocale.kt
Set locale in Android application
import android.app.Activity
import android.app.Application
import android.content.ComponentCallbacks
import android.content.Context
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import java.util.Locale
private const val LANGUAGE_RU = "ru"
@Swisyn
Swisyn / ViewModelFactory.kt
Created May 13, 2020 11:44 — forked from osipxd/ViewModelFactory.kt
Dagger ViewModel Multibinding
class ViewModelFactory @Inject constructor(
private val providers: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
val provider = providers[modelClass]
?: providers.asIterable().find { modelClass.isAssignableFrom(it.key) }?.value
?: error("Unknown ViewModel class $modelClass")
return try {
@Swisyn
Swisyn / ViewBinding.kt
Created May 13, 2020 11:43 — forked from osipxd/ViewBinding.kt
View binding extensions + delegate
/**
* Инфлейт ViewBinding заданного типа [T].
*
* В качестве родителя используется [ViewGroup], по умолчанию view прикрепляется к корню родителя.
* **ВАЖНО!** Для инфлейта вьюх с `merge` в корне нужно использовать только этот метод.
*/
inline fun <reified T : ViewBinding> ViewGroup.inflateViewBinding(
context: Context = this.context,
attachToRoot: Boolean = true
): T {
@Swisyn
Swisyn / iOSActivityRingSwiftUI.swift
Created May 10, 2020 07:23 — forked from frankfka/iOSActivityRingSwiftUI.swift
iOS Activity Ring in SwiftUI
import SwiftUI
import PlaygroundSupport
extension Double {
func toRadians() -> Double {
return self * Double.pi / 180
}
func toCGFloat() -> CGFloat {
return CGFloat(self)