Skip to content

Instantly share code, notes, and snippets.

View yayaa's full-sized avatar

Yahya Bayramoğlu yayaa

View GitHub Profile
@yayaa
yayaa / StrokedFab.java
Last active May 6, 2016 07:35
FloatActionButton with stroke
/**
* Copyright 2016 yayandroid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yayaa
yayaa / PickedImageLoader.java
Last active June 3, 2016 08:07
There is an issue while getting image from camera. In some devices, it will not be loading on the first time you try to decodeFile from path you receive from camera (More info: http://stackoverflow.com/q/35103658/1171484) So this task will be trying recursively to get the bitmap eventually.
/**
* Copyright 2016 yayandroid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yayaa
yayaa / ImageLoader.java
Last active June 3, 2016 08:02
Loading a large image from file with required dimensions, based on Google Developer websites training samples.
/**
* Copyright 2016 yayandroid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yayaa
yayaa / ModifiedToString Template
Created December 28, 2016 09:47
Aligned toString method
public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
return "$classname{"
#foreach( $member in $members )
#if ( $i == 0 )
"##
#else
", ##
#end
public class SimpleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
DisplayImageOptions options = new DisplayImageOptions.Builder()
.resetViewBeforeLoading(true)
.showImageOnFail(android.R.drawable.ic_menu_report_image)
.showImageForEmptyUri(android.R.drawable.ic_menu_report_image)
public class SimpleApplication extends Application {
@Inject CoolAnalyticsTool coolAnalyticsTool;
@Inject ImageLoaderConfiguration imageLoaderConfiguration;
@Inject ImageLoader imageLoader;
@Override
public void onCreate() {
super.onCreate();
ApplicationComponent.create(this).inject(this);
@Module
@ApplicationScope
public class ApplicationPluginModule {
@Provides
@IntoSet static ApplicationPlugin provideCalligraphyPlugin() {
return new CalligraphyPlugin();
}
@Provides
public class SimpleApplication extends Application {
@Inject Set<ApplicationPlugin> plugins;
@Override
public void onCreate() {
super.onCreate();
ApplicationComponent.create(this).inject(this);
for (ApplicationPlugin plugin: plugins) {
@yayaa
yayaa / AnswerWithPair.kt
Last active October 28, 2017 18:06
How to Test Builder - 1
class AnswerWithPair<T : Any>(private val clazz: Class<*>, private val pair: Pair<Class<T>, T>) : Answer<Any> {
private val delegate = ReturnsEmptyValues()
@Throws(Throwable::class)
override fun answer(invocation: InvocationOnMock): Any = invocation.apply {
val returnType = method.returnType
return when (returnType) {
clazz -> mock
pair.first -> pair.second
else -> delegate.answer(this)
@yayaa
yayaa / MockBuilder.kt
Last active October 28, 2017 21:26
How to Test Builder - 2
inline fun <reified T: Any, reified R: Any> mockBuilder(mockResult: R)
= mock<T>(defaultAnswer = AnswerWithPair(T::class.java, R::class.java to mockResult))