Skip to content

Instantly share code, notes, and snippets.

View cnevinc's full-sized avatar

Nevin cnevinc

View GitHub Profile
package com.example.nevin.myapplication
import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.jakewharton.threetenabp.AndroidThreeTen
import org.jetbrains.anko.button
import org.jetbrains.anko.centerInParent
import org.jetbrains.anko.onClick
import org.jetbrains.anko.relativeLayout
@cnevinc
cnevinc / DesignSupport.kt
Last active May 26, 2017 17:11 — forked from mgranberry/DesignSupport.kt
A set of Anko-compatible extensions for Google's Material Design Support Library
package com.biideal.biibonus.util
/**
* https://gist.github.com/sargunster/418c0fd98eb765fa9aca
*/
import android.app.Activity
import android.support.design.widget.*
import android.support.v4.app.Fragment
import android.support.v4.view.PagerTabStrip
import android.support.v4.view.PagerTitleStrip
@cnevinc
cnevinc / ConfigTest.kt
Created November 1, 2015 12:09
Config test using Kotlin
package com.biideal.biibonus.ui
import com.biideal.biibonus.util.Config
import junit.framework.Assert
import org.junit.Test
/**
* Test the util implementation
*/
// ============== Quick sort start 20151015==============
fun quickSort(a: IntArray, lowOffset: Int, highOffset: Int) {
if (lowOffset > highOffset ) return;
// find pivot
var pivot: Int = a[highOffset]
var nextSmallTail = lowOffset;
@cnevinc
cnevinc / MergeSort.kt
Created October 8, 2015 01:13
merge sort
// ============== merge sort start ==============
var numbers: IntArray = intArrayOf()
var temp: IntArray = intArrayOf()
fun merge(low: Int, middle: Int, high: Int) {
for (i in low..high) {
temp[i] = numbers[i];
fun selectionSort(a: IntArray) {
if (a.size() < 1) {
return
}
for( j in 0..a.size() - 1){
var minp = j
for (i in j..a.size() - 1) {
@cnevinc
cnevinc / CustomView.java
Last active September 23, 2015 12:44
code snippet for custom view
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
setupBackPressed();
}
public static void addMe(Activity host) {
NotificationView v = (NotificationView) host.getLayoutInflater().inflate(R.layout.notification_list, null);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
host.addContentView(v, p);
@cnevinc
cnevinc / insertionSort.kt
Created September 21, 2015 15:28
insertion sort using Kotlin
package com.example
fun insertionSort(array: IntArray) {
for ((index, value) in array.withIndex()) {
// println("the element at $index is $value")
var j = index
while (j > 0 ) {
// swap if smaller than sorted[j]
if (array[j] < array[j - 1]) {
@cnevinc
cnevinc / HomeActivityTest.java
Created September 16, 2015 02:14
My first unit test
import com.biideal.biibonus.util.Config;
import junit.framework.TestCase;
import java.util.HashMap;
/**
* Testing my home activity
*/
@cnevinc
cnevinc / RxJavaFunActivity.java
Last active August 29, 2015 14:25
Just 9 lines of code to get the first 5 items from api server. There's no ways of going back to life without rxJava and retrolambda.
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;