Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing on testing on android. and Koin at present.

eoin_a eoinahern

🎯
Focusing on testing on android. and Koin at present.
Block or report user

Report or block eoinahern

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View myTest.kt
@Test
fun testGetCurrency() {
val item: Pair<DomainCurrency, List<DomainCurrency>> = Pair(
DomainCurrency("USD", "1.00", 2, "US DOLLAR"),
listOf(DomainCurrency("EUR", "12.00", 1, "EURO"))
)
@eoinahern
eoinahern / FormatRealTime.kt
Created Apr 9, 2019
trying to format text in edittext using the Locale to add decimal places and comma seperators after user has typed
View FormatRealTime.kt
val df = DecimalFormat("#,###", DecimalFormatSymbols(Locale.getDefault()))
var textChanged = false
df.minimumFractionDigits = 0
df.maximumFractionDigits = asset.investmentDecimalPlaces
layout.txt_amount.textChanges()
.debounce(400, TimeUnit.MILLISECONDS)
.map { layout.txt_amount.text.toString() }
.subscribeOn(AndroidSchedulers.mainThread())
View CustomShrinkLayoutBehavior.kt
class CustomShrinkLayoutBehavior(context: Context, attrs: AttributeSet) :
CoordinatorLayout.Behavior<NestedScrollView>(context, attrs) {
private var screenHeight: Int = context.resources.displayMetrics.heightPixels
override fun layoutDependsOn(parent: CoordinatorLayout, child: NestedScrollView, dependency: View): Boolean {
return dependency is AppBarLayout
}
override fun onDependentViewChanged(parent: CoordinatorLayout, child: NestedScrollView, dependency: View): Boolean {
View ViewModel.kt
val whatsappRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
val telegramRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
val checkTextValid: BehaviorRelay<Boolean> = BehaviorRelay.create()
val openAppIntentRelay: BehaviorRelay<Intent> = BehaviorRelay.create()
val checkShowTextUnderSend: BehaviorRelay<Boolean> = BehaviorRelay.create()
val messageSent: BehaviorRelay<Boolean> = BehaviorRelay.create()
fun checkAppsInstalled() {
View loadFavourites.kt
override fun loadFavourites() {
compositeDisposable.add(viewModel.getFavouritesFromBackend()
.subscribe {
if (it.isEmpty()) {
showFavouritesEmpty()
} else {
updateFavouritesListener?.updateFavourites(it)
loadData(it)
@eoinahern
eoinahern / KeyStoreHelper.java
Created Dec 20, 2018
android keystore encryption class
View KeyStoreHelper.java
public class KeyStoreHelper {
private static final String ALIAS = "mikey";
private static final String ANDROID_KEYSTORE = "AndroidKeyStore";
private final Context context;
private Calendar start;
private Calendar end;
private KeyStore keyStore;
@eoinahern
eoinahern / CallToApi.java
Created Jun 22, 2018
rx problem a guy was having on slack. put into a gist because the code was formatted badly. An attempt to make the code more readable.
View CallToApi.java
Interceptor addHeadersInterceptor = chain -> {
if (tokenInvalid){
String token = getToken()); //If multiple call stays here blocked.
}
};
public String getToken() {
View backNavigation.kt
//back navigation in android
//initate toolbar
val detailsToolbar: Toolbar by lazy { findViewById<Toolbar>(R.id.toolbar) }
//in onCreate
this.setSupportActionBar(detailsToolbar)
actionBar = supportActionBar
actionBar?.apply {
this.setDisplayHomeAsUpEnabled(true)
View download_from_bitchute.go
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
View client.go
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
"os"
)
You can’t perform that action at this time.