Skip to content

Instantly share code, notes, and snippets.

@bmc08gt
bmc08gt / SwipeToDelete.kt
Last active December 15, 2023 03:40
Jetpack Compose Modifier extension to implement swipe-to-delete via Modifier.draggable
import androidx.animation.IntToVectorConverter
import androidx.animation.tween
import androidx.compose.Composable
import androidx.compose.mutableStateOf
import androidx.compose.remember
import androidx.ui.animation.animatedFloat
import androidx.ui.animation.animatedValue
import androidx.ui.core.*
import androidx.ui.core.gesture.scrollorientationlocking.Orientation
import androidx.ui.foundation.animation.FlingConfig
val selectedSubcategories = selectedCategories.asSequence().map { it?.subCategories }.fold(mutableSetOf<SubCategoryModel>()) { acc, list ->
list?.asSequence()?.filter { it.checked }?.map { acc.add(it) }?.toList()
acc
}
val subcategoriesJoined = selectedSubcategories.asSequence().map { it.name }.joinToString(separator = " • ")
editTextProfessionalRegisterCategories.setText(subcategoriesJoined)
@arkilis
arkilis / get_google_map.kt
Created November 30, 2017 06:25
Get location from google map on kotlin
// 1.
class LocationActivity : AppCompatActivity(), OnMapReadyCallback {
// 2.
private var mLocationRequest: LocationRequest? = null
private val UPDATE_INTERVAL = (10 * 1000).toLong() /* 10 secs */
private val FASTEST_INTERVAL: Long = 2000 /* 2 sec */
private var latitude = 0.0
private var longitude = 0.0
@joielechong
joielechong / BadgeTabLayout.java
Created January 24, 2017 11:37 — forked from eneim/BadgeTabLayout.java
A custom TabLayout with badge support for Tabs
package im.ene.lab.android.widgets;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.util.AttributeSet;
@lopspower
lopspower / README.md
Last active April 22, 2024 07:02
Android studio format code auto break line

Android studio format code auto break line

Twitter

To do this in Android Studio go to Preferences > Editor > Code Style

and set Right margin (columns) to 150 (or the line width you want)

Now go to File -> Settings > Editor > Code Style > Java > Wrapping and Braces

@passsy
passsy / material text sizes.md
Last active May 25, 2023 04:24
Material font sizes
@artem-zinnatullin
artem-zinnatullin / MyApp.java
Last active January 15, 2023 13:04
If you need to set one font for all TextViews in android application you can use this solution. It will override ALL TextView's typefaces, includes action bar and other standard components, but EditText's password font won't be overriden.
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}