Skip to content

Instantly share code, notes, and snippets.

View Audhil's full-sized avatar
🎯
Focusing

Mohammed Audhil Audhil

🎯
Focusing
View GitHub Profile
@Audhil
Audhil / AlsoSample.kt
Created February 27, 2020 10:01
kotlin scope function
fun main() {
val valueIs = "Jack and jill went up the hill!"
val result = valueIs.also {
it.contains("jill")
}
println(valueIs) // o/p - Jack and jill went up the hill!
println(result) // o/p - Jack and jill went up the hill!
}
@Audhil
Audhil / WithSample.kt
Created February 27, 2020 09:55
kotlin scope function
fun main() {
val valueIs = "Jack and jill went up the hill!"
val result = with(valueIs) {
this.contains("yup")
}
println(valueIs) // o/p - Jack and jill went up the hill!
println(result) // o/p - false
}
@Audhil
Audhil / RunSample2.kt
Last active February 27, 2020 07:48
kotlin scope functions
fun main() {
val val1 = run {
"function"
// true
}
val val2 = run {
// "function"
true
}
println(val1) // function
@Audhil
Audhil / RunSample.kt
Created February 27, 2020 07:39
kotlin scope function
fun main() {
val valueIs = "Jack and jill went up the hill!"
val result = valueIs.run {
this.contains("help")
}
println(valueIs) // o/p - Jack and jill went up the hill!
println(result) // o/p - false
}
@Audhil
Audhil / LetSample.kt
Last active February 27, 2020 07:36
kotlin scope functions
fun main() {
val valueIs = "Jack and jill went up the hill!"
val result = valueIs.let {
it.contains("help")
}
println(valueIs) // o/p - Jack and jill went up the hill!
println(result) // o/p - false
}
@Audhil
Audhil / hitArea.java
Created November 24, 2019 10:42
to increase touch area of a view
@Bind(R.id.baseLayout)
RelativeLayout baseLayout;
@Bind(R.id.button)
Button delegate;
private void init() {
baseLayout.post(new Runnable() {
@Override
public void run() {
class MainActivity : AppCompatActivity() {
@Inject lateinit var info: Info
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
DaggerMagicBox.create().poke(this)
text_view.text = info.text
}
class AppRepositoryInjectTest {
@Inject
lateinit var appAPIs: AppAPIs
@Before
fun setUp() {
val component = DaggerTestAppComponent.builder()
.applicationModule(TestApplicationModule(GDelegate()))
.build()
@Singleton
@Component(
modules = [
(ApplicationModule::class)
]
)
interface TestAppComponent : ApplicationComponent {
fun into(appRepositoryTest: AppRepositoryInjectNamedTest)
fun into(appRepositoryTest: AppRepositoryInjectTest)
fun into(baseTest: BaseTest)
class TestApplicationModule(delegate: GDelegate) : ApplicationModule(delegate) {
override fun giveAppAPIs(): AppAPIs = mockk()
override fun giveRetrofitService(okHttpClient: OkHttpClient): AppAPIs = mockk()
override fun giveOkHttpClient(loggingInterceptor: HttpLoggingInterceptor): OkHttpClient = mockk()
override fun giveLoggingInterceptor(): HttpLoggingInterceptor = mockk()
}