Skip to content

Instantly share code, notes, and snippets.

View electrolobzik's full-sized avatar

Roman Chernyak electrolobzik

  • Russia, Saint Petersburg
View GitHub Profile
@Mugurell
Mugurell / ExampleSpekTest
Last active March 27, 2019 11:30
Spek + JUnit5 config for Android project
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.junit.Assert
class ExampleSpekTest : Spek({
val x = 2
val y = 3
@aashreys
aashreys / ChromeTabUtils.java
Last active November 20, 2019 06:00
Simple helper to check if Chrome Tabs is supported on a device and open urls.
public class ChromeTabUtils {
public static void openUrl(Context context, String url) {
if (isChromeTabSupported(context)) {
// Build intent to open Chrome Tab
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(getColor(context, R.color.toolbarBackground));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
} else {
@marwinxxii
marwinxxii / SeparateBusSample.java
Created November 23, 2015 18:32
RxJava generic event bus sample
package com.github.marwinxxii.rxsamples;
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.Subject;
public class SeparateBusSample {
public static void test() {
EventBus<String> stringEventBus = new EventBus<>();
EventBus<Long> longEventBus = new EventBus<>();
@ArthurSav
ArthurSav / WrapGridLayoutManager.java
Created September 11, 2015 14:45
GridLayoutManager with working wrap_content.
package com.inperson.android.utils.leastview;
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
public class WrappableGridLayoutManager extends GridLayoutManager {
import android.app.Activity;
import android.app.Dialog;
import android.support.v4.app.DialogFragment;
/**
* Base dialog fragment.
* @param <Listener> listener type.
*/
public abstract class BaseDialogFragment<Listener> extends DialogFragment {
@ljubisa987
ljubisa987 / gist:e33cd5597da07172c55d
Last active July 26, 2021 18:02
TextInputLayout temporary workaround for hint not showing on initial load for SDK > 20
import android.content.Context;
import android.graphics.Canvas;
import android.support.design.widget.TextInputLayout;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
public class CustomTextInputLayout extends TextInputLayout {
@kaushikgopal
kaushikgopal / RoundedBitmapDrawableUsage.java
Last active March 25, 2024 13:55
RoundedImageView - drop dead easy way to do this with RoundedBitmapDrawable
Bitmap batmapBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.batman);
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), batmapBitmap);
// option 1 h/t [Chris Banes](https://chris.banes.me/)
circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth());
// option 2 h/t @csorgod in the comments
circularBitmapDrawable.setCircular(true);
@daniellevass
daniellevass / android_material_design_colours.xml
Last active May 16, 2024 02:09
Android Material Design Colours
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
@romannurik
romannurik / DrawInsetsFrameLayout.java
Created February 10, 2014 16:28
DrawInsetsFrameLayout — adding additional background protection for system UI chrome when using KitKat’s translucent decor flags.
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@klynch
klynch / android-configure.sh
Created December 31, 2013 04:42
This script runs a configure script with the Android NDK toolchain You may need to adjust the COMPILE_TARGET and ANDROID_API variables depending on your requirements.
#!/bin/sh
# This script runs a configure script with the Android NDK toolchain
# You may need to adjust the COMPILE_TARGET and ANDROID_API variables
# depending on your requirements.
#
# Call this script in a directory with a valid configure script.
# Example: PREFIX=${PWD}/bin android-configure.sh
# Set the ANDROID_NDK variable to the root