Instead of the verbose setOnClickListener
:
RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));
Observable
.just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
<?xml version="1.0" encoding="utf-8"?> | |
<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
android:width="24dp" | |
android:height="24dp" | |
android:viewportHeight="24.0" | |
android:viewportWidth="24.0"> | |
<path | |
android:fillColor="#FF000000" | |
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zm0,-8c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z" /> | |
</vector> |
Copyright (c) 2016 Stephen D'Amico | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE |
public func delay(time: Double, completion: () -> Void) { | |
let ms = dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC))) | |
dispatch_after(ms, dispatch_get_main_queue()) { | |
() -> Void in | |
completion() | |
} | |
} | |
public func delay(time: Double) -> (()->Void) -> Void { | |
return { |
OkHttpClient okHttpClient = new OkHttpClient(); | |
try { | |
int cacheSize = 10 * 1024 * 1024 // 10 MiB | |
Cache cache = new Cache(getCacheDir(), cacheSize); | |
okHttpClient.setCache(cache); | |
} catch (IOException e) { | |
Log.e(TAG, "Could not set cache", e); | |
} | |
// Forces cache. Used for cache connection |
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
Copyright (C) 2015 The Android Open Source Project | |
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 |
public enum NotificationKey: String { | |
case UserSignedIn = "UserSignedInNotification" | |
case UserSignedOut = "UserSignedOutNotification" | |
case SomeOtherEvent = "SomeOtherEventNotification" | |
} | |
extension NSNotificationCenter { | |
func addObserver(observer: AnyObject, selector aSelector: Selector, key aKey: NotificationKey) { | |
self.addObserver(observer, selector: aSelector, name: aKey.rawValue, object: nil) |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; |
<!-- You can change the parent around to whatever you normally use --> | |
<style name="DebugColors" parent="Theme.AppCompat"> | |
<!-- System colors --> | |
<item name="android:windowBackground">@color/__debugWindowBackground</item> | |
<item name="android:colorPressedHighlight">#FF4400</item> | |
<item name="android:colorLongPressedHighlight">#FF0044</item> | |
<item name="android:colorFocusedHighlight">#44FF00</item> | |
<item name="android:colorActivatedHighlight">#00FF44</item> |
public class ScrollViewWithMaxHeight extends ScrollView { | |
public static int WITHOUT_MAX_HEIGHT_VALUE = -1; | |
private int maxHeight = WITHOUT_MAX_HEIGHT_VALUE; | |
public ScrollViewWithMaxHeight(Context context) { | |
super(context); | |
} |