This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass { | |
fun test() { | |
val str: String = "..." | |
val result = str.xxx { | |
print(this) // Receiver | |
print(it) // Argument | |
42 // Block return value | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
public class JavaGenericsTest { | |
public static void main(String[] args) { | |
List<? super B> l1 = new ArrayList<A>(); | |
// l1.add(new A()); // Nope! | |
l1.add(new B()); | |
l1.add(new C()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Bitmap getBitmapFromView(View view) { | |
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); | |
Canvas c = new Canvas(bitmap); | |
view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); | |
view.draw(c); | |
return bitamp; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2017 Subinkrishna Gopi | |
* | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SparseBooleanArray that is also Parcelable. Had to put this together so I could pass this to a | |
* {@code Fragment} bundle. | |
*/ | |
public class ParcelableSparseBooleanArray extends SparseBooleanArray implements Parcelable { | |
public ParcelableSparseBooleanArray(){ | |
super(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.ObjectAnimator; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Property; | |
import android.view.View; | |
import android.view.animation.DecelerateInterpolator; | |
import android.widget.FrameLayout; | |
public class MainActivity extends AppCompatActivity { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.subinkrishna.rx; | |
import rx.Observable; | |
import rx.Subscriber; | |
import rx.Subscription; | |
import rx.functions.Action0; | |
import rx.functions.Action1; | |
import rx.schedulers.Schedulers; | |
import rx.subscriptions.Subscriptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Property<TextView, Integer> textValueProperty = new Property<TextView, Integer>(Integer.class, "textValue") { | |
@Override public Integer get(TextView textView) { | |
return Integer.parseInt(textView.getText().toString()); | |
} | |
@Override public void set(TextView textView, Integer value) { | |
textView.setText(String.valueOf(value)); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Applies tint & bound to a drawable. | |
* | |
* @param context | |
* @param drawableRes | |
* @param colorRes | |
* @param sizeRes | |
* @return | |
*/ | |
public static Drawable applyTintAndBounds(Context context, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.res.AssetManager; | |
import android.databinding.BindingAdapter; | |
import android.graphics.Color; | |
import android.graphics.Typeface; | |
import android.graphics.drawable.Drawable; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v4.graphics.drawable.DrawableCompat; | |
import android.util.Log; | |
import android.widget.TextView; |
NewerOlder