Skip to content

Instantly share code, notes, and snippets.

View johnkil's full-sized avatar

Evgenii Shishkin johnkil

View GitHub Profile
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
abstract class BindableFragment<VB : ViewBinding>(
private val viewBindingFactory: (LayoutInflater, ViewGroup?, Boolean) -> VB
) : Fragment() {
/**
* Copyright 2019 Coinbase, 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,
task deleteBuildDirs(type: Delete) {
doLast {
def buildDirs = []
file(".").eachFileRecurse(groovy.io.FileType.DIRECTORIES) { File file ->
if (file.name == "build") {
buildDirs << file
}
}
buildDirs.reverseEach {
@johnkil
johnkil / CustomSnackbar.java
Created November 12, 2017 21:05 — forked from raphaelbussa/CustomSnackbar.java
Helper for inflate custom layout in google support design snackbar
/*
* The MIT License (MIT)
*
* Copyright (c) 2016 Raphaël Bussa
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@johnkil
johnkil / ItemClickSupport.java
Last active March 28, 2017 11:22
Getting your clicks on RecyclerView.
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import static android.support.v7.widget.RecyclerView.ViewHolder;
import static android.view.View.OnClickListener;
import static android.view.View.OnLongClickListener;
/**
ImageView imageView = (ImageView) findViewById(R.id.card_thumbnail_image);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rose);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
//Default
imageView.setBackgroundResource(R.drawable.rose);
} else {
//RoundCorners
RoundCornersDrawable round = new RoundCornersDrawable(mBitmap,
getResources().getDimension(R.dimen.cardview_default_radius), 0); //or your custom radius
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
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
/*
* Copyright 2014 Chris Banes
*
* 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