Skip to content

Rx search view #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: rx-search-view
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cf45a01
Add ViewPager page scroll state change binding
kunny Jul 12, 2016
76aee5f
Added currentItem action to RxViewPager
pawel-schmidt Aug 14, 2016
bd269d8
Fix order of modifiers in ViewEvent
vanniktech Sep 8, 2016
cb0a6b8
Merge pull request #285 from vanniktech/order_modifier
JakeWharton Sep 8, 2016
10d1da5
Add new SlidingPaneLayout bindings
alex-townsend Sep 8, 2016
80d356e
Guard against null in ViewEvent
vanniktech Sep 8, 2016
ce9f935
Merge pull request #286 from vanniktech/master_guard_null
JakeWharton Sep 9, 2016
11af21c
change swipe speed to FAST to fix flaky test
alex-townsend Sep 9, 2016
affa7a4
Merge pull request #287 from alex-townsend/swipe-dismiss-flaky
JakeWharton Sep 11, 2016
18b18a8
Add support for View key event binding
unclesatrio Oct 10, 2016
1f1b346
Remove explicit 'public' modifier from Kotlin code.
JakeWharton Oct 10, 2016
4617805
Switch TargetApi for more correct RequiresApi annotation.
JakeWharton Oct 10, 2016
1f23195
Merge pull request #292 from JakeWharton/jw/public
JakeWharton Oct 10, 2016
3759aaa
Add listeners after setting the unsubscribe action.
JakeWharton Oct 10, 2016
85ef15a
Depend only on the Core UI artifact from support-v4.
JakeWharton Oct 10, 2016
6fa7a43
Merge pull request #293 from JakeWharton/jw/requires
JakeWharton Oct 10, 2016
3ccbd00
Merge pull request #294 from JakeWharton/jw/add-after
JakeWharton Oct 10, 2016
3630e44
Merge pull request #295 from JakeWharton/jw/support-breakage
JakeWharton Oct 10, 2016
1384644
Add BottomNavigationView binding
alex-townsend Oct 20, 2016
cdd9388
Merge branch 'master' of github.com:JakeWharton/RxBinding into rx-sea…
danielgomezrico Oct 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.github.javaparser.ast.PackageDeclaration
import com.github.javaparser.ast.TypeParameter
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
import com.github.javaparser.ast.body.MethodDeclaration
import com.github.javaparser.ast.body.ModifierSet
import com.github.javaparser.ast.type.ClassOrInterfaceType
import com.github.javaparser.ast.type.PrimitiveType
import com.github.javaparser.ast.type.ReferenceType
Expand Down Expand Up @@ -36,9 +35,9 @@ open class KotlinGenTask : SourceTask() {
*/
private val IGNORED_IMPORTS = listOf(
"java.util.List",
"android.annotation.TargetApi",
"android.support.annotation.CheckResult",
"android.support.annotation.NonNull"
"android.support.annotation.NonNull",
"android.support.annotation.RequiresApi"
)

fun resolveKotlinTypeByName(input: String): String {
Expand Down Expand Up @@ -187,7 +186,6 @@ open class KotlinGenTask : SourceTask() {
class KMethod(val n: MethodDeclaration) {
private val name = n.name
private val comment = if (n.comment != null) cleanUpDoc(n.comment.toString()) else null
private val accessModifier = ModifierSet.getAccessSpecifier(n.modifiers).codeRepresenation
private val extendedClass = n.parameters[0].type.toString()
private val parameters = n.parameters.subList(1, n.parameters.size)
private val returnType = n.type
Expand Down Expand Up @@ -276,8 +274,8 @@ open class KotlinGenTask : SourceTask() {
// doc
builder.append("${comment ?: ""}\n")

// access modifier and other signature boilerplate
builder.append("$accessModifier inline fun ")
// signature boilerplate
builder.append("inline fun ")

// type params
builder.append(if (typeParameters != null) typeParameters + " " else "")
Expand Down
25 changes: 19 additions & 6 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ ext {
kotlinPlugin = 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.3'
kotlinStdlib = 'org.jetbrains.kotlin:kotlin-stdlib:1.0.3'

supportAnnotations = 'com.android.support:support-annotations:24.0.0'
supportV4 = 'com.android.support:support-v4:24.0.0'
supportRecyclerView = 'com.android.support:recyclerview-v7:24.0.0'
supportAppCompat = 'com.android.support:appcompat-v7:24.0.0'
supportDesign = 'com.android.support:design:24.0.0'
supportLeanback = 'com.android.support:leanback-v17:24.0.0'
supportVersion = '25.0.0'
supportAnnotations = "com.android.support:support-annotations:$supportVersion"
supportV4CoreUi = "com.android.support:support-core-ui:$supportVersion"
supportRecyclerView = "com.android.support:recyclerview-v7:$supportVersion"
supportAppCompat = "com.android.support:appcompat-v7:$supportVersion"
supportDesign = "com.android.support:design:$supportVersion"
supportLeanback = "com.android.support:leanback-v17:$supportVersion"

supportTestRunner = 'com.android.support.test:runner:0.5'
supportTestRules = 'com.android.support.test:rules:0.5'
Expand All @@ -27,3 +28,15 @@ ext {

javaParser = 'com.github.javaparser:javaparser-core:2.1.0'
}

subprojects { project ->
project.configurations.all {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.android.support') {
details.useVersion(rootProject.ext.supportVersion)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import rx.Observable
* *Warning:* The created observable keeps a strong reference to `view`.
* Unsubscribe to free this reference.
*/
public inline fun ActionMenuView.itemClicks(): Observable<MenuItem> = RxActionMenuView.itemClicks(this)
inline fun ActionMenuView.itemClicks(): Observable<MenuItem> = RxActionMenuView.itemClicks(this)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import rx.Observable
* *Warning:* The created observable uses [PopupMenu.setOnMenuItemClickListener]
* to observe dismiss change. Only one observable can be used for a view at a time.
*/
public inline fun PopupMenu.itemClicks(): Observable<MenuItem> = RxPopupMenu.itemClicks(this)
inline fun PopupMenu.itemClicks(): Observable<MenuItem> = RxPopupMenu.itemClicks(this)

/**
* Create an observable which emits on `view` dismiss events. The emitted value is
Expand All @@ -25,4 +25,4 @@ public inline fun PopupMenu.itemClicks(): Observable<MenuItem> = RxPopupMenu.ite
* *Warning:* The created observable uses [PopupMenu.setOnDismissListener] to
* observe dismiss change. Only one observable can be used for a view at a time.
*/
public inline fun PopupMenu.dismisses(): Observable<Unit> = RxPopupMenu.dismisses(this).map { Unit }
inline fun PopupMenu.dismisses(): Observable<Unit> = RxPopupMenu.dismisses(this).map { Unit }
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jakewharton.rxbinding.support.v7.widget

import android.support.v7.widget.SearchView
import com.jakewharton.rxbinding.internal.Functions
import rx.Observable
import rx.functions.Action1
import rx.functions.Func1
Expand All @@ -15,7 +14,7 @@ import rx.functions.Func1
*
* *Note:* A value will be emitted immediately on subscribe.
*/
public inline fun SearchView.queryTextChangeEvents(): Observable<SearchViewQueryTextEvent> = RxSearchView.queryTextChangeEvents(this)
inline fun SearchView.queryTextChangeEvents(): Observable<SearchViewQueryTextEvent> = RxSearchView.queryTextChangeEvents(this)

/**
* Create an observable of character sequences for query text changes on `view`.
Expand All @@ -25,7 +24,7 @@ public inline fun SearchView.queryTextChangeEvents(): Observable<SearchViewQuery
*
* *Note:* A value will be emitted immediately on subscribe.
*/
public inline fun SearchView.queryTextChanges(): Observable<CharSequence> = RxSearchView.queryTextChanges(this)
inline fun SearchView.queryTextChanges(): Observable<CharSequence> = RxSearchView.queryTextChanges(this)

/**
* An action which sets the query property of `view` with character sequences.
Expand All @@ -35,38 +34,38 @@ public inline fun SearchView.queryTextChanges(): Observable<CharSequence> = RxSe
*
* @param submit weather to submit query right after updating query text
*/
public inline fun SearchView.query(submit: Boolean): Action1<in CharSequence> = RxSearchView.query(this, submit)
inline fun SearchView.query(submit: Boolean): Action1<in CharSequence> = RxSearchView.query(this, submit)

/**
* Create an observable of booleans representing the focus of the query text field.
*
*
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*
*
*/
public inline fun SearchView.queryTextFocusChange(): Observable<Boolean> = RxSearchView.queryTextFocusChange(this)
inline fun SearchView.queryTextFocusChange(): Observable<Boolean> = RxSearchView.queryTextFocusChange(this)

/**
* Create an observable of the absolute position of the clicked item in the list of suggestions
*
*
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*
*
* *Warning:* The created observable uses [SearchView.setOnSuggestionListener] to
* observe search view events. Only one observable can be used for a search view at a time.
*/
public inline fun SearchView.suggestionClick(): Observable<Int> = RxSearchView.suggestionClick(this)
inline fun SearchView.suggestionClick(): Observable<Int> = RxSearchView.suggestionClick(this)

/**
* Create an observable of the absolute position of the clicked item in the list of suggestions
*
*
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*
*
* *Warning:* The created observable uses [SearchView.setOnSuggestionListener] to
* observe search view events. Only one observable can be used for a search view at a time.
*
* @param handled Function invoked with each value to determine the return value of the
* underlying [SearchView.OnSuggestionListener].
*/
public inline fun SearchView.suggestionClick(handled: Func1<in Int, Boolean>): Observable<Int> = RxSearchView.suggestionClick(this, handled)
inline fun SearchView.suggestionClick(handled: Func1<in Int, Boolean>): Observable<Int> = RxSearchView.suggestionClick(this, handled)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import rx.Observable
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*/
public inline fun Toolbar.itemClicks(): Observable<MenuItem> = RxToolbar.itemClicks(this)
inline fun Toolbar.itemClicks(): Observable<MenuItem> = RxToolbar.itemClicks(this)

/**
* Create an observable which emits on `view` navigation click events. The emitted value is
Expand All @@ -22,4 +22,4 @@ public inline fun Toolbar.itemClicks(): Observable<MenuItem> = RxToolbar.itemCli
* *Warning:* The created observable uses [Toolbar.setNavigationOnClickListener]
* to observe clicks. Only one observable can be used for a view at a time.
*/
public inline fun Toolbar.navigationClicks(): Observable<Unit> = RxToolbar.navigationClicks(this).map { Unit }
inline fun Toolbar.navigationClicks(): Observable<Unit> = RxToolbar.navigationClicks(this).map { Unit }
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ final class ActionMenuViewItemClickOnSubscribe implements Observable.OnSubscribe
return true;
}
};
view.setOnMenuItemClickListener(listener);

subscriber.add(new MainThreadSubscription() {
@Override
protected void onUnsubscribe() {
view.setOnMenuItemClickListener(null);
}
});

view.setOnMenuItemClickListener(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public PopupMenuDismissOnSubscribe(PopupMenu view) {
}
};

view.setOnDismissListener(listener);

subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.setOnDismissListener(null);
}
});

view.setOnDismissListener(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public PopupMenuItemClickOnSubscribe(PopupMenu view) {
}
};

view.setOnMenuItemClickListener(listener);

subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.setOnMenuItemClickListener(null);
}
});

view.setOnMenuItemClickListener(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ final class SearchViewQueryTextChangeEventsOnSubscribe
}
};

view.setOnQueryTextListener(watcher);

subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.setOnQueryTextListener(null);
}
});

view.setOnQueryTextListener(watcher);

// Emit initial value.
subscriber.onNext(SearchViewQueryTextEvent.create(view, view.getQuery(), false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ final class SearchViewQueryTextChangesOnSubscribe implements Observable.OnSubscr
}
};

view.setOnQueryTextListener(watcher);

subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.setOnQueryTextListener(null);
}
});

view.setOnQueryTextListener(watcher);

// Emit initial value.
subscriber.onNext(view.getQuery());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ final class ToolbarItemClickOnSubscribe implements Observable.OnSubscribe<MenuIt
return true;
}
};
view.setOnMenuItemClickListener(listener);

subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.setOnMenuItemClickListener(null);
}
});

view.setOnMenuItemClickListener(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ final class ToolbarNavigationClickOnSubscribe implements Observable.OnSubscribe<
}
}
};
view.setNavigationOnClickListener(listener);

subscriber.add(new MainThreadSubscription() {
@Override protected void onUnsubscribe() {
view.setNavigationOnClickListener(null);
}
});

view.setNavigationOnClickListener(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import rx.Observable
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*/
public inline fun AppBarLayout.offsetChanges(): Observable<Int> = RxAppBarLayout.offsetChanges(this)
inline fun AppBarLayout.offsetChanges(): Observable<Int> = RxAppBarLayout.offsetChanges(this)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jakewharton.rxbinding.support.design.widget

import android.support.design.widget.BottomNavigationView
import android.view.MenuItem
import rx.Observable

/**
* Create an observable which emits the selected item in `view`.
*
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*
* *Note:* If an item is already selected, it will be emitted immediately on subscribe.
*/
inline fun BottomNavigationView.itemSelections(): Observable<MenuItem> = RxBottomNavigationView.itemSelections(this)
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ import rx.Observable
* *Note:* If an item is already selected, it will be emitted immediately on subscribe.
* This behavior assumes but does not enforce that the items are exclusively checkable.
*/
public inline fun NavigationView.itemSelections(): Observable<MenuItem> = RxNavigationView.itemSelections(this)
inline fun NavigationView.itemSelections(): Observable<MenuItem> = RxNavigationView.itemSelections(this)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import rx.Observable
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*/
public inline fun Snackbar.dismisses(): Observable<Int> = RxSnackbar.dismisses(this)
inline fun Snackbar.dismisses(): Observable<Int> = RxSnackbar.dismisses(this)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ import rx.Observable
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*/
public inline fun View.dismisses(): Observable<View> = RxSwipeDismissBehavior.dismisses(this)
inline fun View.dismisses(): Observable<View> = RxSwipeDismissBehavior.dismisses(this)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import rx.functions.Action1
*
* *Note:* If a tab is already selected, it will be emitted immediately on subscribe.
*/
public inline fun TabLayout.selections(): Observable<Tab> = RxTabLayout.selections(this)
inline fun TabLayout.selections(): Observable<Tab> = RxTabLayout.selections(this)

/**
* Create an observable which emits selection, reselection, and unselection events for the tabs
Expand All @@ -24,12 +24,12 @@ public inline fun TabLayout.selections(): Observable<Tab> = RxTabLayout.selectio
*
* *Note:* If a tab is already selected, an event will be emitted immediately on subscribe.
*/
public inline fun TabLayout.selectionEvents(): Observable<TabLayoutSelectionEvent> = RxTabLayout.selectionEvents(this)
inline fun TabLayout.selectionEvents(): Observable<TabLayoutSelectionEvent> = RxTabLayout.selectionEvents(this)

/**
* An action which sets the selected tab of `view`.
*
* *Warning:* The created observable keeps a strong reference to `view`. Unsubscribe
* to free this reference.
*/
public inline fun TabLayout.select(): Action1<in Int> = RxTabLayout.select(this)
inline fun TabLayout.select(): Action1<in Int> = RxTabLayout.select(this)
Loading