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
//This file represents several classes. It's just named *.java for syntax highlighting purposes! | |
//AIDL file: Defines interfaces for communicating between activities and your service. | |
//You can see these implemented in the service @ 'private static class ServiceStub extends IPlaybackService.Stub' | |
interface IPlaybackService { | |
void stop(); | |
void play(); |
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
import retrofit2.Call | |
import retrofit2.CallAdapter | |
import retrofit2.Response | |
import retrofit2.Retrofit | |
import java.lang.reflect.ParameterizedType | |
import java.lang.reflect.Type | |
import java.util.concurrent.Executor | |
class CallResultAdapterFactory(private val responseErrorMapper: ((Response<*>) -> Error?)? = null) : CallAdapter.Factory() { |
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
override fun onResponse(call: Call<T>, response: Response<T>) { | |
if (call.isCanceled) return | |
if (response.isSuccessful) { | |
callback(Result.Success(response.body())) | |
} else { | |
callback(Result.Failure(responseErrorMapper?.invoke(response) ?: RemoteServiceHttpError(response))) | |
} | |
} |
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
fun Error.userDescription(): String { | |
return when (this) { | |
is RemoteServiceHttpError -> | |
return when { | |
isServerError -> "A server error occurred. (${httpStatusCode.code})" | |
else -> "An error occurred. (${httpStatusCode.code})" | |
} | |
} | |
is OAuthError -> { | |
return "Authentication failed." |
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 | |
} | |
} |
OlderNewer