Skip to content

Instantly share code, notes, and snippets.

View Papashkin's full-sized avatar
👻

Pavel Antoshkin Papashkin

👻
View GitHub Profile
@Papashkin
Papashkin / Json example
Last active July 30, 2019 10:01
POJO + Converters
{
"id": "string",
"notifications": [
{
"content": "string",
"contentDates": [
null
],
"id": "string",
"relatedEntity": {
class LogInRequest(
private val service: ApolloService
) : UseCase<LoginData, LoginResponse>() {
override fun buildObservable(criteria: LoginData): Observable<LoginResponse> =
service.logIn(criteria)
.doOnError {
if (it is HttpException) {
Throwable(getMessageByCode(it.code()))
} else {
Throwable(it.message)
@Papashkin
Papashkin / TestAdapter
Created June 27, 2019 05:25
Adapter realization with onItemClick function invokation.
class TestAdapter(
private val onItemClick: (id: Int) -> Unit
) : ApolloBaseAdapter<DrawerItemsAdapter.TestViewHolder>() {
private var items: ArrayList<String> = arrayListOf()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DrawerViewHolder {
val view = LayoutInflator.from(parent.context).inflate(R.layout.drawer_body_items_list, parent, false)
return DrawerViewHolder(view)
}
@Papashkin
Papashkin / ITestBaseAdapter
Last active June 28, 2019 15:27
Adapter realization based on RecyclerView.Adapter using DiffUtil callback
interface ITestBaseAdapter<T : Any> {
fun add(item: T)
fun addAll(items: List<T>)
fun addTo(position: Int = 0, item: T)
fun remove(position: Int)
fun getList(): List<T>
fun update(newList: List<T>, callback: ApolloBaseDiffUtilCallback<T>)
fun clear()
}