Skip to content

Instantly share code, notes, and snippets.

View chetdeva's full-sized avatar

Chetan Sachdeva chetdeva

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="model"
type="com.fueled.loginbindings.LoginModel"/>
<variable
public class LoginModel extends BaseObservable {
private String email;
private String password;
private boolean loginEnabled;
@Bindable
public String getEmail() {
return email;
}
@Reusable
class CollapsingNotificationManager @Inject
constructor(private val collapsingNotificationStore: CollapsingNotificationStore) {
private val collapsingNotifications = getCollapsingNotifications()
/**
* get notifications to collapse
*/
fun getNotificationsToCollapse(data: Map<String, String>): List<Int>? {
package com.fueled.collapsingnotifications.util
/**
* Copyright (c) 2017 Fueled. All rights reserved.
*
* @author chetansachdeva on 22/09/17
*/
class MultiValuedMap<K, V> {
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srl"
android:layout_width="match_parent"
android:layout_height="match_parent"
bind:onPulledToRefresh="@{() -> presenter.initialize()}">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
/**
* @param swipeRefreshLayout Bind swipeRefreshLayout with OnRefreshListener
* @param onRefresh Listener for onRefresh when swiped
*/
@BindingAdapter("onPulledToRefresh")
fun setOnSwipeRefreshListener(swipeRefreshLayout: SwipeRefreshLayout, onPulledToRefresh: Runnable) {
swipeRefreshLayout.setOnRefreshListener { onPulledToRefresh.run() }
}
/**
* @param recyclerView RecyclerView to bind to RecyclerViewScrollCallback
* @param visibleThreshold The minimum number of items to have below your current scroll position before loading more.
* @param resetLoadingState Reset endless scroll listener when performing a new search
* @param onScrolledListener OnScrolledListener for RecyclerView scrolled
*/
@BindingAdapter(value = *arrayOf("visibleThreshold", "resetLoadingState", "onScrolledToBottom"), requireAll = false)
fun setRecyclerViewScrollCallback(recyclerView: RecyclerView, visibleThreshold: Int, resetLoadingState: Boolean,
onScrolledListener: RecyclerViewScrollCallback.OnScrolledListener) {
/**
* initialize all resources
* set current page to 1
* create paginator and subscribe to events
*/
override fun initialize() {
currentPage = 1 // set page = 1
paginator = PublishProcessor.create() // create PublishProcessor
val d = paginator.onBackpressureDrop()
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(new Truss()
.append("Click Me!", new Snippety.OnClickListener() {
@Override
public void onClick() {
Toast.makeText(getContext(), "Oooh it tickles!", Toast.LENGTH_SHORT).show();
}
})
.build());
textView.setText(new Truss()
.append(new Snippety().backgroundColor(Color.RED).textColor(Color.WHITE))
.build());