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
import com.google.gson.Gson | |
import com.google.gson.GsonBuilder | |
import com.google.gson.reflect.TypeToken | |
val gson: Gson = GsonBuilder().create() | |
val gsonPretty: Gson = GsonBuilder().setPrettyPrinting().create() | |
inline fun <reified T> T.toJson(prettyPrint : Boolean = false) :String{ | |
return if(prettyPrint){ | |
gsonPretty |
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
@Parcelize | |
data class User(val name:String, val age:Int) : Parcelable | |
//now you will use putParcelable to add it to the bundle | |
val b3 = Bundle().apply { | |
putParcelable("user",User(name, age)) | |
} |
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
data class User(val name:String, val age:Int) : Serializable | |
... | |
//Now you can add it as a single line into the bundle. | |
val b2 = Bundle().apply{ | |
putSerializable("user",User(name, age)) | |
} |
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
val name = "Leo Dog" | |
val age = 6 | |
val b = Bundle().apply{ | |
putString("name",name) | |
putInt("age",age) | |
} |
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
import android.annotation.TargetApi; | |
import android.app.Service; | |
import android.content.Intent; | |
import android.os.Build; | |
import android.os.IBinder; | |
import android.speech.tts.TextToSpeech; | |
import android.speech.tts.UtteranceProgressListener; | |
import android.util.Log; | |
import java.util.HashMap; |
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 your.package.path.fragments; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.support.annotation.Nullable; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; |