Skip to content

Instantly share code, notes, and snippets.

Avatar

Jayjay jayjaykim

View GitHub Profile
View AbstractClass.java
/**
* Created by jayjay on 2016. 11. 27..
*/
public class AbstractClass {
public static void main(String[] args) {
NormalClass obj1 = new NormalClass();
// SomeInterface obj2 = new SomeInterface();
// SomeAbstractClass obj3 = new A;bstractClass()
SomeInterface obj2 = new SomeInterface() {
View AnonymousClassComparison.java
/**
* Created by jayjay on 2016. 9. 11..
*/
public class TestInterface {
String msg;
int number;
float floatNumber;
public interface ClickListener {
void onClick();
@jayjaykim
jayjaykim / TestSingleton.java
Created Sep 6, 2016
TestSingleton.java which is imperfect in multi-threading environment
View TestSingleton.java
public class Communication {
static Communication instance;
private Communication() {
}
public static Communication getInstance() {
if(instance == null)
instance = new Communication();
View TestForEach.java
public class TestForeach {
public static void main(String[] args) {
String[] msgs = {"aa", "bb", "cc", "dd"};
String[] msg1 = new String[]{"aa", "bb", "cc", "dd"};
final int size = msg1.length;
for(int i = 0; i < size; i++) {
System.out.println(msgs[i]);
}
@jayjaykim
jayjaykim / RemoveEntryForLoop.java
Created Aug 27, 2016
remove an entry in for-loop statement
View RemoveEntryForLoop.java
public class TestList {
public static void main(String[] args) {
String[] strings = {"hi", "hello", "mine", "you"};
List<String> list = Lists.newArrayList(strings);
// item or entry == 항목
System.out.println("list : " + list);
final int size = list.size();
for(int i = size - 1; i >= 0; i--) {
@jayjaykim
jayjaykim / MVvsMVP.java
Last active Aug 26, 2016
Legacy MV vs MVP
View MVvsMVP.java
/**
* Legacy
*/
public class ActivityA {
public void onCreate(A state) {
Volley.getList(new Callback() {
public void onSuccess(List<Image> list) {
showImageList(List<Image> list);
}
@jayjaykim
jayjaykim / TestStatic.java
Created Aug 21, 2016
java static keyword usage
View TestStatic.java
public class TestStatic {
public static void main(String[] args) {
Sample sample1 = new Sample();
Sample sample2 = new Sample();
Sample sample3 = new Sample();
Sample.number1 = 2;
Sample.method1();
sample1.setNumber2(1);
@jayjaykim
jayjaykim / FoldUnfold.java
Last active Aug 26, 2016
RecyclerView Fold/Unfold implementations
View FoldUnfold.java
public class FileWrapper {
int type; // 0 : File, 1 : Directory
int depth; // 0~n
File file;
// contructor for injecting depedency, e.g. File object, type, depth
// setters and getters
}
public class Adapter extends RecyclerView.Adapter<RecyclerView.Holder> {
@jayjaykim
jayjaykim / TestLruCache
Last active Aug 6, 2016
LruCache Sample code
View TestLruCache
package com.jayjaylab.android.test.plainjava;
import android.support.v4.util.LruCache;
import android.util.Log;
/**
* Created by jayjay on 2016. 8. 6..
*/
public class TestLruCache {
static final String TAG = TestLruCache.class.getSimpleName();
@jayjaykim
jayjaykim / gist:2ff5e1b4458f3b2e49e4
Last active Mar 23, 2016
Endless Scrolling with AdapterViews and RecyclerViews
View gist:2ff5e1b4458f3b2e49e4
// Instead of using [Endless Scrolling with AdapterViews and RecyclerViews]
// (https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView/_edit)
// introduced in codepath.
// There's more simple and less computational way to implement endless scrolling. You can replace 1 in if-statement
// if(position == getItemCount() - 1) for fine tuning.
// Make use of the following code snippet in your project.
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
EndlessScrollListener endlessScrollListener