Skip to content

Instantly share code, notes, and snippets.

@hisetu
hisetu / SwipeToDelete.kt
Created June 19, 2022 08:02 — forked from bmc08gt/SwipeToDelete.kt
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
package com.theozgurr.apparchitecture.common
import android.graphics.Bitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.captureToImage
import androidx.test.platform.app.InstrumentationRegistry
import java.io.FileOutputStream
fun saveScreenshot(
@hisetu
hisetu / AllGattCharacteristics.java
Created March 4, 2022 16:10 — forked from sam016/AllGattCharacteristics.java
Bluetooth GATT Services & Characteristics
package com.sam016.vsflatomation.service.ble;
import java.util.HashMap;
import java.util.UUID;
public class AllGattCharacteristics {
private static HashMap<String, String> attributes = new HashMap();
static {
attributes.put("00002a00-0000-1000-8000-00805f9b34fb", "Device Name");
@hisetu
hisetu / ActivityIntentState.kt
Last active July 3, 2022 10:10
Kotlin Extensions
fun Activity.getStringFromIntentOrState(field: String, savedInstanceState: Bundle?): String? =
when {
intent.getStringExtra(field) != null -> intent.getStringExtra(field)
savedInstanceState?.getString(field) != null -> savedInstanceState.getString(field)
else -> null
}
@hisetu
hisetu / NoRipple.kt
Last active July 3, 2022 10:06
Jetpack Compose Modifier
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.selection.selectable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
inline fun Modifier.noRippleClickable(crossinline onClick: () -> Unit): Modifier = composed {
clickable(indication = null,
interactionSource = remember { MutableInteractionSource() }) {
@hisetu
hisetu / fluid-android-prepare.sh
Created June 1, 2021 11:46 — forked from santoxyz/fluid-android-prepare.sh
Shell file to set up various environment variables to allow cross compilation for Android
#!/bin/bash
# Android cross-compile environment setup script for Glib
# Author : Zengwen Yuan
# Date : 2016-07-16
# License : Creative Commons Attribution-ShareAlike 4.0
# http://zwyuan.github.io/2016/07/17/cross-compile-glib-for-android/
#
# Modified by Tom Moebert to provide an Android cross compilation toolchain for fluidsynth 2.0
# Date: 2018-09-06
@hisetu
hisetu / fluid-android-compile.sh
Created June 1, 2021 11:45 — forked from santoxyz/fluid-android-compile.sh
Script for cross compiling fluidsynth for Android
#!/bin/bash
# Android cross-compile environment setup script for Fluidsynth, Glib and dependencies
# Author : Tom Moebert
# Date : 2018-09-06
# License : CC0 1.0 Universal
# If you have questions or need support, contact our mailing list:
# https://lists.nongnu.org/mailman/listinfo/fluid-dev
set -ex
@hisetu
hisetu / GridSpacingItemDecoration.md
Created May 11, 2021 03:28 — forked from cxyxlxdm/GridSpacingItemDecoration.md
Add column spacing in RecyclerView with GridLayoutManager

Android Recyclerview GridLayoutManager column spacing Here is the question, the first answer does not work well in my project,and it makes the spacing bigger between item and item. the second answer is quite perfect.But if RecyclerView has headers,it does not work well. Then I fixed it.

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
@hisetu
hisetu / gist:1043b00d84bcfd7525e14cafe76e16bb
Created November 13, 2020 10:16 — forked from RikkaW/gist:0ae7f51117768a03c6581c956d75958c
insert general file with MediaStore
Context context = view.getContext();
ContentResolver cr = context.getContentResolver();
ContentValues values;
try {
// create a file for test
File file = new File(context.getFilesDir(), "1234568");
file.createNewFile();
try (OutputStream os = new FileOutputStream(file)) {
os.write("test".getBytes());
@hisetu
hisetu / Dockerfile
Created September 4, 2020 04:06 — forked from atsushieno/Dockerfile
fluidsynth for Android docker build
FROM bitriseio/android-ndk
WORKDIR /usr/local/src
ENV ANDROID_NDK_PATH /opt/android-ndk
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
RUN useradd -u $HOST_USER_ID -ms /bin/bash user