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
/** | |
* 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 |
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
/** | |
* 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 |
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
/** | |
* 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 |
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 java.lang.String toString() { | |
#if ( $members.size() > 0 ) | |
#set ( $i = 0 ) | |
return "$classname{" | |
#foreach( $member in $members ) | |
#if ( $i == 0 ) | |
"## | |
#else | |
", ## | |
#end |
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 SimpleApplication extends Application { | |
@Inject CoolAnalyticsTool coolAnalyticsTool; | |
@Inject ImageLoaderConfiguration imageLoaderConfiguration; | |
@Inject ImageLoader imageLoader; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
ApplicationComponent.create(this).inject(this); |
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 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) |
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
@Module | |
@ApplicationScope | |
public class ApplicationPluginModule { | |
@Provides | |
@IntoSet static ApplicationPlugin provideCalligraphyPlugin() { | |
return new CalligraphyPlugin(); | |
} | |
@Provides |
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 SimpleApplication extends Application { | |
@Inject Set<ApplicationPlugin> plugins; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
ApplicationComponent.create(this).inject(this); | |
for (ApplicationPlugin plugin: plugins) { |
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
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) |
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
class AnswerWithPairList(private val clazz: Class<*>, private val pairs: List<Pair<Class<*>, *>>) : Answer<Any> { | |
private val delegate = ReturnsEmptyValues() | |
@Throws(Throwable::class) | |
override fun answer(invocation: InvocationOnMock): Any = invocation.apply { | |
val returnType = method.returnType | |
return if (returnType == clazz) mock | |
else pairs.find { returnType == it.first }?.second ?: delegate.answer(this) | |
} | |
} |
OlderNewer