public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {
private int mItemOffset;
public ItemOffsetDecoration(int itemOffset) {
mItemOffset = itemOffset;
}| let rx_request = Observable<Value>.create { (observer) -> Disposable in | |
| let requestReference = Alamofire.request(.POST, url, parameters: payload) | |
| .responseJSON(completionHandler: { (response) in | |
| if let value = response.result.value { | |
| observer.onNext(value) | |
| observer.onCompleted() | |
| }else if let error = response.result.error { | |
| observer.onError(error) | |
| } | |
| }) |
- Create a project in XCode with the default settings
- iOS > Application > Single View Application
- Language: Swift
- Under project General settings, add ReactKit to Linked Framework and Libraries
- + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
- Now ReactKit would have been imported. Link it by choosing it from the list.
- + > lib.ReactKit.a
- Under project Build Settings,
Alamofire is a great Swift library developed by the creator of AFNetworking @mattt. The purpose of this gist is to explain how to use the built-in power of Alamofire to serialize your JSON. In this example we will be serializing a simple blog API. First we will start with serializing a single JSON object and add complexity as we go along.
This is the first JSON object that we will be serializing.
You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.
The RecyclerView should use a LinearLayoutManager.
You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)
This is a porting of the class SimpleSectionedListAdapter provided by Google
Example:
| // LINKED LIST | |
| /** | |
| * NODE | |
| */ | |
| private class Node<T:protocol<Printable, Comparable>>: Printable, Comparable { | |
| /** | |
| * PROPERTIES | |
| */ | |
| var info:T |
| extension Array { | |
| func first() -> Element? { | |
| if isEmpty { | |
| return nil | |
| } | |
| return self[0] | |
| } | |
| func last() -> Element? { |
| /* | |
| * Copyright 2014 Julian Shen | |
| * | |
| * 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 |
| //Override UICollectionViewFlowLayout class | |
| @interface FixedHeaderLayout : UICollectionViewFlowLayout | |
| @end | |
| @implementation FixedHeaderLayout | |
| //Override shouldInvalidateLayoutForBoundsChange to require a layout update when we scroll | |
| - (BOOL) shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { | |
| return YES; | |
| } |
