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
##BaseRecyclerAdapter## | |
package ${PACKAGE_NAME}; | |
import android.support.v7.widget.RecyclerView; | |
import java.util.ArrayList; | |
import java.util.List; | |
public abstract class BaseRecyclerAdapter<T, VH extends RecyclerView.ViewHolder, I extends BaseRecyclerAdapter.OnItemClickListener<T>> extends RecyclerView.Adapter<VH> { |
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
#!/usr/local/bin/ruby | |
## Created by Tim Malseed 16/07/2016 | |
## This script depends on `onesky-ruby` | |
## Run gem install onesky-ruby | |
require 'onesky' | |
API_PUBLIC_KEY = 'your_public_key' | |
API_SECRET_KEY = 'your_secret_key' |
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
#!/usr/local/bin/ruby | |
## Created by Tim Malseed 16/07/2016 | |
## This script depends on `onesky-ruby` | |
## Run gem install onesky-ruby | |
require 'onesky' | |
SOURCE_FILE_NAME = 'strings.xml' |
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
import Foundation | |
class HanekeImageLoader: ImageLoader { | |
/** | |
Haneke requires that we register our 'formats' before they can be used. | |
**/ | |
func setup() { |
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
call.enqueue { | |
override fun onResponse(response: Response) { | |
// Todo: Check if response is valid (>200 & < 300) or call | |
// Todo: Handle error if not valid | |
} | |
override fun onFailure() { | |
// Todo: Handle error | |
} | |
} |
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
call.enqueue { | |
override fun onSuccess(response: Response) { | |
// Todo: Check if response is valid (>200 & < 300) or call | |
} | |
override fun onError(error: Error) { | |
// Todo: Handle error | |
} | |
} |
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
sealed class Result<out T> { | |
data class Success<out T>(val data: T?) : Result<T>() | |
data class Failure(val error: Error) : Result<Nothing>() | |
} |
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
call.enqueue { | |
override fun onResult(result: Result) { | |
when(result){ | |
is Success -> { | |
// Handle Success | |
} | |
is Failure -> { | |
// Handle failure | |
result.error.doSomething() | |
} |
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
val responseErrorMapper: (Response<*>) -> Error? = { response -> | |
response.errorBody()?.string()?.let { errorBody -> | |
// Is this an OAuthError? | |
OAuthError.errorData(response, errorBody)?.let { errorData -> | |
OAuthError(response, errorData) | |
} | |
} | |
} |
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
val retrofit = Retrofit.Builder() | |
.addCallAdapterFactory(CallResultAdapterFactory(responseErrorMapper)) | |
.baseUrl(baseUrl) | |
.client(okHttpClient) | |
.addConverterFactory(converterFactory) | |
.build() |
OlderNewer