This file contains 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.hilllander.naunginlecalendar.view.fragment; | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.Fragment; | |
import android.support.v7.widget.GridLayoutManager; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; |
This file contains 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.hilllander.naunginlecalendar.util.adapter; | |
import android.content.Context; | |
import android.support.v7.widget.GridLayoutManager; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.Log; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; |
This file contains 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.hilllander.naunginlecalendar.util.adapter; | |
import android.content.Context; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.TextView; | |
import com.hilllander.naunginlecalendar.R; |
This file contains 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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' |
This file contains 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_kotlin_extensions) | |
welcomeMessage.text = "Hello Kotlin!" | |
helloButton.setOnClickListener { toast.("Hello Kotlin") } | |
} | |
fun setMessaeg(message: String) { | |
welcomeMessage.text = message // this wont call findViewById again |
This file contains 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 class DigitMapper { | |
public DigitMapper() { | |
} | |
public String mapToWord(int digit) throws DigitRangeException { | |
if (digit < 0 || digit > 9) throw new DigitRangeException(); | |
switch (digit) { |
This file contains 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 class Utils { | |
public static String mapDigitToWord(int digit) throws DigitRangeException { | |
if(digit < 0 || digit > 9) | |
throw new DigitRangeException(); | |
switch (digit) { | |
case 0: return "Zero"; | |
case 1: return "One"; | |
// case 2,3,...9 | |
default: return ""; |
This file contains 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
fun Int.mapToWord(): String { | |
val word: String | |
when (this) { // this refers to Int with its scope limited to the method level | |
0 -> word = "Zero" | |
1 -> word = "One" | |
2 -> word = "Two" | |
// 3,4,5,6,7,8,9 | |
else -> word = "Invalid Digit Range" | |
} | |
return word |
This file contains 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
override fun onCreate(savedInstanceState : Bundle?) { | |
setContentView(R.layout.activity_upload) | |
val digit = 2 | |
val wordTwo: String = digit.mapToWord() // return "Two" | |
} |
This file contains 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 final class User { | |
public final String id; | |
public final String name; | |
public final Throwable error; // the reason for failing to fetch will be stored here | |
public final State state; //either of SUCCESS,PROGRESS,ERROR enum | |
public User(Throwable error, State state, String id, String name) { | |
this.error = error; | |
this.state = state; | |
this.id = id; |
OlderNewer