Skip to content

Instantly share code, notes, and snippets.

public class CanNotCompileThisGenerics {
static class AbsScrambleAdapter<A extends AbsScrambleAdapter<A, T>, T> {
}
static class IViewHolderFactory<A extends AbsScrambleAdapter<A, ?>> {
}
static class ScrambleAdapter<T> extends AbsScrambleAdapter<ScrambleAdapter<T>, T> {
}
public class LearnGenericsAssignment {
static class Func<T> {
T item;
public T getItem() {
return item;
}
public void setItem(T item) {
this.item = item;
public class LearnGenerics {
static abstract class AbsRecursive<A extends AbsRecursive<A, T>, T> {
RecursiveListener<A, ? super T> mListener;
T mItem;
public <XA extends AbsRecursive<XA, ? super T>>
void setListener(RecursiveListener<? super XA, ? super T> listener) {
// FIXME: I could not fix this.
@SuppressWarnings("unchecked")
RecursiveListener<A, ? super T> l = (RecursiveListener<A, ? super T>) listener;
@cattaka
cattaka / adb-screenshot.sh
Last active December 6, 2017 00:51 — forked from hkurokawa/adb-screenshot.sh
A shell script to take a screen shot of the android device, resize it and copy to clipboard
#! /bin/bash
## This script is for taking a screen shot of an Android device.
## If possible, it tries to resize the image file and then copy to the clipboard.
##
## The script passes unrecognized arguments to adb command, which means you can specify "-e" or "-d"
## to select which device to take a screenshot of.
if [ -z $(which adb) ]; then
echo "Error. adb must be installed and in PATH." 1>&2
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.view.NestedScrollingChildHelper;
import android.util.AttributeSet;
import android.view.View;
/**
* These codes are licensed under CC0.
*
* Created by cattaka on 2016/04/27.
@cattaka
cattaka / AdapterConverter.java
Last active November 6, 2018 16:39
Converter from RecyclerView.Adapter to BaseAdapter for ListVIew
import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* These codes are licensed under CC0.
import android.support.annotation.Keep;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
/**
* These codes are licensed under CC0.
* <p>
* Save all methods from proguard!!
* <p/>
@cattaka
cattaka / ConnectionStatus.java
Last active February 8, 2016 08:35
Example of enum that has methods.
public enum ConnectionStatus {
NOT_CONNECTED(false),
CONNECTING(false),
CONNECTED(true);
private final boolean established;
public ConnectionStatus(boolean established) {
this.established = established;
}
@cattaka
cattaka / collect_git_url.sh
Last active November 22, 2015 00:51
Collect git url under the directory
#!/bin/sh
echo "name url"
for i in * ; do
if [ -d $i -a -f $i/.git/config ] ; then
url=`grep url $i/.git/config | cut -d "=" -f 2`
splited=`echo $url|sed "s/[@:\/]/\t/g"`
echo $i $url $splited
fi
done
@cattaka
cattaka / RelativeLayoutAnimatorHelper.java
Last active April 15, 2016 06:00
RelativeLayoutAnimatorHelper
import android.view.View;
import android.widget.RelativeLayout;
/**
* Save all methods from proguard!!
* <p/>
* Created by cattaka on 2015/11/10.
*/
public class RelativeLayoutAnimatorHelper {
View mView;