android.widget.Filter Java Examples

The following examples show how to use android.widget.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilterableRecyclerView.java    From chips-input-layout with MIT License 6 votes vote down vote up
/**
 * Applies the given filter pattern to the filter. If the filter yields no results,
 * then we hide this filterable recycler, or show it otherwise.
 *
 * @param filter Filter pattern
 */
void filterChips(CharSequence filter) {
    if (filter != null) {
        mFilter.filter(filter, new Filter.FilterListener() {
            @Override
            public void onFilterComplete(int count) {
                // Show if, and only if, there are results
                if (count > 0) {
                    fadeIn();
                } else {
                    fadeOut();
                }
            }
        });
    }
}
 
Example #2
Source File: AutoRunCommandListEditText.java    From revolution-irc with GNU General Public License v3.0 6 votes vote down vote up
private void performFiltering(boolean completeIfSingle) {
    final CharSequence text = getCurrentLineToken();
    if (text == null)
        return;
    Filter filter = mCommandAdapter.getFilter();
    filter.filter(text, (int i) -> {
        if (i == 0) {
            dismissDropDown();
            return;
        }
        if (!text.equals(getCurrentLineToken()) && !enoughToFilter())
            return;
        if (completeIfSingle && i == 1) {
            onItemClick(mCommandAdapter.getItem(0));
            return;
        }
        if (i > 0)
            showDropDown();
    });
}
 
Example #3
Source File: MusicFilter.java    From PlayWidget with MIT License 6 votes vote down vote up
@NonNull
@Override
protected Filter.FilterResults performFilteringImpl(CharSequence constraint) {
    Filter.FilterResults results = new Filter.FilterResults();
    if (TextUtils.isEmpty(constraint) || TextUtils.isEmpty(constraint.toString().trim())) {
        results.count = -1;
        return results;
    }
    String str = constraint.toString().trim();
    List<MusicItem> result = new ArrayList<>();
    int size = getNonFilteredCount();
    for (int i = 0; i < size; i++) {
        MusicItem item = getNonFilteredItem(i);
        if (
                check(str, item.title())
                        || check(str, item.album())
                        || check(str, item.artist())
                ) {
            result.add(item);
        }
    }
    results.count = result.size();
    results.values = result;
    return results;
}
 
Example #4
Source File: AutoCompleteAdapter.java    From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ArrayFilter();
    }
    return mFilter;
}
 
Example #5
Source File: FilterableChipsAdapter.java    From chips-input-layout with MIT License 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ChipFilter();
    }
    return mFilter;
}
 
Example #6
Source File: CustomArrayAdapter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Filter getFilter(){
    if(filter == null){
        filter = new ClassNameFilter();
    }
    return filter;
}
 
Example #7
Source File: EditText.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the Filter obtained from {@link Filterable#getFilter},
 * or <code>null</code> if {@link #setAdapter} was not called with
 * a Filterable.
 */
protected Filter getFilter() {
    switch (mAutoCompleteMode){
        case AUTOCOMPLETE_MODE_SINGLE:
            return ((InternalAutoCompleteTextView)mInputView).superGetFilter();
        case AUTOCOMPLETE_MODE_MULTI:
            return ((InternalMultiAutoCompleteTextView)mInputView).superGetFilter();
        default:
            return null;
    }
}
 
Example #8
Source File: AllTasksListFragment.java    From ActivityLauncher with ISC License 5 votes vote down vote up
@Override
public Filter getFilter() {
    AllTasksListAdapter adapter = (AllTasksListAdapter) this.list.getExpandableListAdapter();
    if (adapter != null) {
        return adapter.getFilter();
    } else {
        return null;
    }
}
 
Example #9
Source File: ContactAdapter.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (myFilter == null) {
        myFilter = new MyFilter(userList);
    }
    return myFilter;
}
 
Example #10
Source File: SocialArrayAdapter.java    From socialview with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Filter getFilter() {
    if (filter == null) {
        filter = new SocialFilter();
    }
    return filter;
}
 
Example #11
Source File: HeaderGridView.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (mIsFilterable) {
        return ((Filterable) mAdapter).getFilter();
    }
    return null;
}
 
Example #12
Source File: EaseContactAdapter.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if(myFilter==null){
        myFilter = new MyFilter(userList);
    }
    return myFilter;
}
 
Example #13
Source File: EaseConversationAdapater.java    From monolog-android with MIT License 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (conversationFilter == null) {
        conversationFilter = new ConversationFilter(conversationList);
    }
    return conversationFilter;
}
 
Example #14
Source File: UserQuickSelectorListAdapter.java    From YiBo with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
	if (filter == null) {
		filter = new UserFilter();
	}
	return filter;
}
 
Example #15
Source File: PostItemsAdapter.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (postFilter == null) {
        postFilter = new PostFilter(postList);
    }

    return postFilter;
}
 
Example #16
Source File: SimpleAdapterAssert.java    From assertj-android with Apache License 2.0 5 votes vote down vote up
public SimpleAdapterAssert hasFilter(Filter filter) {
  isNotNull();
  Filter actualFilter = actual.getFilter();
  assertThat(actualFilter) //
      .overridingErrorMessage("Expected filter <%s> but was <%s>.", filter, actualFilter) //
      .isSameAs(filter);
  return this;
}
 
Example #17
Source File: ArrayAdapterCompat2.java    From Android-Next with Apache License 2.0 5 votes vote down vote up
@Override
public @NonNull
Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ArrayFilter();
    }
    return mFilter;
}
 
Example #18
Source File: SearchAdapter.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
	if (mFilter == null) {
		mFilter = new SearchFilter();
	}
	return mFilter;
}
 
Example #19
Source File: ObservableGridView.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (mIsFilterable) {
        return ((Filterable) mAdapter).getFilter();
    }
    return null;
}
 
Example #20
Source File: GroupMemberListAdapter.java    From YiBo with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
	if (filter == null) {
		filter = new UserFilter();
	}
	return filter;
}
 
Example #21
Source File: FilterableListView.java    From MaterialChipsInput with Apache License 2.0 5 votes vote down vote up
public void filterList(CharSequence text) {
    mAdapter.getFilter().filter(text, new Filter.FilterListener() {
        @Override
        public void onFilterComplete(int count) {
            // show if there are results
            if(mAdapter.getItemCount() > 0)
                fadeIn();
            else
                fadeOut();
        }
    });
}
 
Example #22
Source File: CursorFilter.java    From AppCodeArchitecture with Apache License 2.0 5 votes vote down vote up
@Override
protected void publishResults(CharSequence constraint, Filter.FilterResults results) {
    Cursor oldCursor = mClient.getCursor();

    if (results.values != null && results.values != oldCursor) {
        mClient.changeCursor((Cursor) results.values);
    }
}
 
Example #23
Source File: TableOfContentRecyclerViewAdapter.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new TitlesFilter();
    }
    return mFilter;
}
 
Example #24
Source File: HeaderGridView.java    From HeartbeatFixerForGCM with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (mIsFilterable) {
        return ((Filterable) mAdapter).getFilter();
    }
    return null;
}
 
Example #25
Source File: LogLineAdapter.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ArrayFilter();
    }
    return mFilter;
}
 
Example #26
Source File: SortedFilterArrayAdapter.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ArrayFilter();
    }
    return mFilter;
}
 
Example #27
Source File: AdapterDialog.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (valueFilter == null) {
        valueFilter = new ValueFilter();
    }
    return valueFilter;
}
 
Example #28
Source File: HeaderViewListAdapterAssert.java    From assertj-android with Apache License 2.0 5 votes vote down vote up
public HeaderViewListAdapterAssert hasFilter(Filter filter) {
  isNotNull();
  Filter actualFilter = actual.getFilter();
  assertThat(actualFilter) //
      .overridingErrorMessage("Expected filter <%s> but was <%s>.", filter, actualFilter) //
      .isSameAs(filter);
  return this;
}
 
Example #29
Source File: SortedFilterArrayAdapter.java    From matlog with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Filter getFilter() {
    if (mFilter == null) {
        mFilter = new ArrayFilter();
    }
    return mFilter;
}
 
Example #30
Source File: MyEaseConversationAdapter.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
public Filter getFilter() {
    if (conversationFilter == null) {
        conversationFilter = new ConversationFilter(conversationList);
    }
    return conversationFilter;
}