Skip to content

Instantly share code, notes, and snippets.

@wertgit
wertgit / ReminderWorker
Created November 27, 2019 06:53
ReminderWorker
import android.R
import android.annotation.SuppressLint
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import androidx.core.app.NotificationCompat
import androidx.work.*
import org.koin.core.KoinComponent
import org.koin.core.inject
@wertgit
wertgit / CustomSwipeToRefresh.kt
Created November 22, 2019 03:27
A Customed SwipeRefreshLayout that handles swiping issues with a RecyclerView inside a SwipeRefreshLayout. It also works for HorizontalScrollView.
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.ViewConfiguration
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import kotlin.math.abs
/**
//
// ViewController.m
@implementation ViewController : UIViewController
-(void) shareMethod: (const char *) path Message : (const char *) shareMessage
{
NSString *imagePath = [NSString stringWithUTF8String:path];
@wertgit
wertgit / Diamond.QML
Created January 25, 2017 05:20
Diamond
// List of total cards to swipe for a diamond
// Minimum being 3 and Maximum being 13
var diamond_targets = [3,8,5,7,9,10,4,12,13,6];
// Sets the total ammount of cards to solve
function set_total_cards_to_solve_for_diamond() {
// a random number from the list
var random
@wertgit
wertgit / shake.qml
Created January 20, 2017 05:13 — forked from anonymous/shake.qml
Card Shake
ParallelAnimation {
id: shake_card
running: false
alwaysRunToEnd: true
ParallelAnimation {
ColorAnimation { target: thefirstword; property: "color" ; to: first_word_color;duration: brokecolors ? 1000 : 0 ; easing.type: Easing.Linear; }
ColorAnimation { target: thefirstword; property: "styleColor" ; to: "#00000000";duration: brokecolors ? 1000 : 0 ; easing.type: Easing.Linear; }
@wertgit
wertgit / correction.qml
Last active January 20, 2017 05:10
Card Correction
// Plays the correction animation when the user gets the answer wrong
ParallelAnimation {
id: correciton_animation
alwaysRunToEnd: true
ScaleAnimator { running: false ; target: thefirstword; from: 1; to: 1.3; duration: 600 ; easing.type: Easing.OutExpo; }
ScaleAnimator { running: false ; target: thesecondword; from: 1; to: 1.3; duration: 600 ; easing.type: Easing.OutExpo; }
ScaleAnimator { running: false ; target: answer_word; from: 1; to: 1.3; duration: 600 ; easing.type: Easing.OutExpo; }
ScaleAnimator { running: false ; target: is; from: 1; to: 1.1; duration: 400; easing.type: Easing.OutExpo; }
@wertgit
wertgit / Camera.java
Created March 22, 2016 10:53
EasyCamera
EasyCamera camera = DefaultEasyCamera.open();
CameraActions actions = camera.startPreview(surface);
PictureCallback callback = new PictureCallback() {
public void onPictureTaken(byte[] data, CameraActions actions) {
// store picture
}
};
actions.takePicture(Callbacks.create().withJpegCallback(callback));
@wertgit
wertgit / JsonConversionUtil.java
Last active March 22, 2016 11:07
JsonConversionUtil
if (matcher.matches()) {
// Handle as array
String fieldName = matcher.group(1);
int index = Integer.parseInt(matcher.group(2));
JSONArray newArrayStep;
if (root.has(fieldName)) {
newArrayStep = root.getJSONArray(fieldName);
} else {
newArrayStep = new JSONArray();
root.put(fieldName, newArrayStep);