Skip to content

Instantly share code, notes, and snippets.

View webserveis's full-sized avatar

Webserveis webserveis

View GitHub Profile
@jong9000
jong9000 / mac-shortcuts.md
Last active December 15, 2021 12:13
macOS collection of shortcuts and commands

Mac Keyboard Symbols

symbol name
command
option
control
shift
tab
↩︎ return
@oohyugi
oohyugi / RecycleviewAdapter
Last active August 29, 2020 07:24
Live template recycerview adapter , Type cmd + shift + A to find action , enter Add Template and press Enter button. Preferences window with File and Code Templates tab will be opened. Press ctrl + N to add a new template. Name it ,, RecyclerView Adapter “ and add the following code:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
#parse("File Header.java")
@DenysZP
DenysZP / UseCase.kt
Created March 28, 2019 12:06
The implementation of the base UseCase with kotlin coroutines.
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
abstract class UseCase<T, Params : Any> {
private lateinit var parentJob: Job
private lateinit var params: Params
private var isAttachedToLifecycle = false
private val backgroundContext: CoroutineContext = Dispatchers.IO
private val foregroundContext: CoroutineContext = Dispatchers.Main
@yuntan
yuntan / FloatSeekBarPreference.kt
Last active May 3, 2023 08:06
SeekBarPreference for Float with value formatter
package com.example.app
import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.widget.SeekBar
import android.widget.TextView
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import android.app.Application
import android.arch.lifecycle.LiveData
import android.content.Context
import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkInfo
import android.net.NetworkRequest
import android.os.Build
import android.support.annotation.RequiresPermission
import android.support.annotation.VisibleForTesting
@vedant1811
vedant1811 / KotlinExtensions.kt
Created June 6, 2018 07:15
Useful android kotlin extensions
/**
* Use as `"#fff".parseColor()`
*/
fun String.parseColor() = Color.parseColor(this)
/**
* Use as `16.spToPx(context)` or `16.5.spToPx(context)`
*/
fun Number.spToPx(context: Context) = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, this.toFloat(), context.resources.displayMetrics).toInt()
@ThanosFisherman
ThanosFisherman / CheckableImageButton.java
Last active February 4, 2023 19:18
It's a checkable ImageButton that respects xml selector state changes
/**
* Created by thanos on 12/8/17.
* It's a checkable ImageButton that respects xml selector state changes
*/
public final class CheckableImageButton extends AppCompatImageButton implements Checkable
{
private static final int[] DRAWABLE_STATE_CHECKED = new int[]{android.R.attr.state_checked};
private boolean mChecked;
@liangzai-cool
liangzai-cool / HttpUtils.java
Last active February 26, 2019 18:35
convert relative url to absolute url and beautify the result in java.
```
import java.net.MalformedURLException;
import java.net.URL;
public class HttpUtils {
public static void main(String[] args) throws MalformedURLException {
String urlString = "https://www.google.com///images//branding/1234567890/..\\googlelogo/abcdefg/../1x/googlelogo_color_272x92dp.png";
System.out.println(absUrl(urlString));
@passsy
passsy / KIntent.kt
Last active March 28, 2023 06:51
Kotlin extension functions to start a generic Activity
package com.pascalwelsch.extensions
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
/**
* Extensions for simpler launching of Activities
package com.example.sampleapp;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;
public class MoreScreen extends ListActivity {