Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View adfleshner's full-sized avatar
💻
Code Go Burrrr

Aaron Fleshner adfleshner

💻
Code Go Burrrr
View GitHub Profile
@adfleshner
adfleshner / GsonExtensions.kt
Last active March 14, 2023 06:33
Gson Kotlin Extensions. I created a few simple extensions for gson to Simplfy any Gson needs.
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
@adfleshner
adfleshner / TheGoodWay.kt
Created April 9, 2022 04:40
The Good way to Pass data into a bundle
@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))
}
@adfleshner
adfleshner / TheEasyWay.kt
Last active April 9, 2022 04:20
The Easy way you can pass data into a bundle
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))
}
@adfleshner
adfleshner / theHardWay.kt
Last active April 9, 2022 04:13
Making a Bunde the hard way
val name = "Leo Dog"
val age = 6
val b = Bundle().apply{
putString("name",name)
putInt("age",age)
}
@adfleshner
adfleshner / SpeakingService.java
Last active August 27, 2016 00:56
Text To Speech on a Service. This service spins up a TTS and say what it needs to say and then spins down. Uses PugNotification (https://github.com/halysongoncalves/Pugnotification) for Notifcation Creation All you need to do is declare it in the manifest <service android:name=".SpeakingService"/>
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;
@adfleshner
adfleshner / MyRecyclerFragment
Last active August 29, 2015 14:15
This is a simple way to A Fragment with A RecyclerView kind of like how ListFragments and ListActivities work. As well as adding in an empty view that is as easy as adding a layout file to the code. To use just add The RecylcerFragment java file and recycler_layout xml file to the appropriate locations and then extend RecyclerFragment and add a …
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;