Comments (9)
Hello.
Looks like it is the bug on your side. The method getItemModel() definitely exists in the library that I use for RecyclerView adapters.
Try to redownload the dependency and see if that helps.
from persistent-search-view.
It looks like the dependencies got mixed up for some odd reason. Nevertheless, I've fixed them and released a new version called v1.1.1. Please take a look at it.
from persistent-search-view.
Having the same issue even after updating dependency from v1.0.0 to v1.1.1 the method getItemModel doesn't exist still..... the only available method for 'getter' was geTrackeyKey() or getLayout() which obfiusly not for picking up the suggestion text
from persistent-search-view.
/*
- Copyright 2017
- Paul Rybitskyi, [email protected]
- Arthur Ivanets, [email protected]
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
*/
package com.paulrybitskyi.persistentsearchview.adapters.model;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.arthurivanets.adapster.Adapter;
import com.arthurivanets.adapster.listeners.ItemClickListener;
import com.arthurivanets.adapster.listeners.OnItemClickListener;
import com.arthurivanets.adapster.model.BaseItem;
import com.arthurivanets.adapster.model.markers.Trackable;
import com.paulrybitskyi.persistentsearchview.R;
import com.paulrybitskyi.persistentsearchview.adapters.resources.SuggestionItemResources;
import com.paulrybitskyi.persistentsearchview.model.Suggestion;
import com.paulrybitskyi.persistentsearchview.utils.Preconditions;
import com.paulrybitskyi.persistentsearchview.utils.Utils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import static com.paulrybitskyi.persistentsearchview.utils.ViewUtils.makeGone;
import static com.paulrybitskyi.persistentsearchview.utils.ViewUtils.makeVisible;
/**
-
A recycler view item for a suggestion.
*/
public class SuggestionItem extends BaseItem<Suggestion, SuggestionItem.ViewHolder, SuggestionItemResources> implements Trackable {/**
- A constant holding a layout resource ID for the suggestion item.
*/
public static final int MAIN_LAYOUT_ID = R.layout.persistent_search_view_suggestion_item_layout;
/**
- Creates a suggestion item with the specified text.
- @param suggestionText The suggestion's text
- @return An instance of a suggestion item
*/
public static SuggestionItem of(@nonnull String suggestionText) {
return of(-1L, suggestionText);
}
/**
-
Creates a suggestion item with the specified id and text.
-
@param id The suggestion's id
-
@param suggestionText The suggestion's text
-
@return An instance of a suggestion item
*/
public static SuggestionItem of(long id, @nonnull String suggestionText) {
Preconditions.nonEmpty(suggestionText);return new SuggestionItem(
new Suggestion()
.setId(id)
.setText(suggestionText)
);
}
public SuggestionItem(Suggestion itemModel) {
super(itemModel);
}@OverRide
public ViewHolder init(Adapter adapter,
ViewGroup parent,
LayoutInflater inflater,
SuggestionItemResources resources) {
final View view = inflater.inflate(MAIN_LAYOUT_ID, parent, false);
return new ViewHolder(view);
}@OverRide
public void bind(@nullable Adapter adapter,
@nonnull ViewHolder viewHolder,
@nullable SuggestionItemResources resources) {
super.bind(adapter, viewHolder, resources);final Suggestion suggestion = getItemModel(); final boolean isRecentSearchSuggestion = Suggestion.TYPE_RECENT_SEARCH_SUGGESTION.equals(suggestion.getType()); // text related viewHolder.mTextTv.setTextColor(resources.getTextColor()); handleText(viewHolder, resources); // icon related viewHolder.mIconIv.setImageDrawable(Utils.getColoredDrawable( viewHolder.mIconIv.getContext(), (isRecentSearchSuggestion ? R.drawable.ic_history_black_24dp : R.drawable.ic_magnify_black_24dp), (isRecentSearchSuggestion ? resources.getRecentSearchIconColor() : resources.getSearchSuggestionIconColor()) )); // remove button related if(isRecentSearchSuggestion) { viewHolder.mRemoveBtnIv.setImageDrawable(Utils.getColoredDrawable( viewHolder.mRemoveBtnIv.getContext(), R.drawable.ic_close_black_24dp, resources.getIconColor() )); makeVisible(viewHolder.mRemoveBtnIv); } else { makeGone(viewHolder.mRemoveBtnIv); }
}
private void handleText(ViewHolder viewHolder, SuggestionItemResources resources) {
final Suggestion suggestion = getItemModel();
final String text = suggestion.getText();
final int startIndex = suggestion.getText().toLowerCase().indexOf(resources.getCurrentQuery().toLowerCase());
final int endIndex = Math.min(resources.getCurrentQuery().length(), text.length());if(!TextUtils.isEmpty(resources.getCurrentQuery()) && (startIndex != -1) && (startIndex <= endIndex)) { final SpannableString spannableString = new SpannableString(text); spannableString.setSpan( new ForegroundColorSpan(resources.getSelectedTextColor()), startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ); viewHolder.mTextTv.setText(spannableString); } else { viewHolder.mTextTv.setText(text); }
}
/**
- Sets a listener to invoke when the item is clicked.
- @param viewHolder The view holder
- @param onItemClickListener The listener to set
*/
public void setOnItemClickListener(ViewHolder viewHolder, OnItemClickListener onItemClickListener) {
viewHolder.itemView.setOnClickListener(new ItemClickListener<>(
this,
viewHolder.getAdapterPosition(),
onItemClickListener
));
}
/**
- Sets a listener to invoke when the remove button is clicked.
- @param viewHolder The view holder
- @param onItemRemoveButtonClickListener The listener to set
*/
public void setOnItemRemoveButtonClickListener(ViewHolder viewHolder, OnItemClickListener onItemRemoveButtonClickListener) {
viewHolder.mRemoveBtnIv.setOnClickListener(new ItemClickListener<>(
this,
viewHolder.getAdapterPosition(),
onItemRemoveButtonClickListener
));
}
@OverRide
public int getLayout() {
return MAIN_LAYOUT_ID;
}@OverRide
public Long getTrackKey() {
final Suggestion suggestion = getItemModel();
return (suggestion.hasValidId() ? suggestion.getId() : ((long) suggestion.getText().hashCode()));
}/**
-
A view holder containing suggestion item related views.
*/
public static class ViewHolder extends BaseItem.ViewHolder {private TextView mTextTv;
private ImageView mIconIv;
private ImageView mRemoveBtnIv;public ViewHolder(View itemView) {
super(itemView);mTextTv = itemView.findViewById(R.id.textTv); mIconIv = itemView.findViewById(R.id.iconIv); mRemoveBtnIv = itemView.findViewById(R.id.removeBtnIv);
}
}
- A constant holding a layout resource ID for the suggestion item.
}
from persistent-search-view.
Hello.
Looks like it is the bug on your side. The method getItemModel() definitely exists in the library that I use for RecyclerView adapters.
Try to redownload the dependency and see if that helps.
tried redownloading dependencies too no luck with v1.1.1 still getItemModel() doesn't exist :-(
from persistent-search-view.
from persistent-search-view.
I got the exact same error, there is no itemModel
or getItemModel()
.
from persistent-search-view.
I have same error on v1.1.2
from persistent-search-view.
Hello,
Still the same issue, after a year. FYI, this is definitely not a "bug on your side".
from persistent-search-view.
Related Issues (20)
- Change textappearances HOT 1
- How to remove default padding, or maybe set custom padding HOT 4
- suggestion itemModel not resolved HOT 9
- Strange background image HOT 4
- Binary XML file line #29: Binary XML file line #29: Error inflating class com.paulrybitskyi.persistentsearchview.PersistentSearchView HOT 2
- Button to set suggestion text as query HOT 2
- jcenter deprecation HOT 4
- Dealing with Multiple Fragments in a ViewPager HOT 7
- how to add message item when item not found? HOT 1
- Gradle build error while removing jcenter HOT 3
- Change voice recognition language
- Trigger onSearchConfirmed when pressing the "ENTER" key (tablets with external keyboard)
- unable to scrool suggestion only in fragment HOT 4
- Sample application in Java for the usage in Fragment. HOT 2
- Class not found Exception in XML HOT 2
- Your own given sample has missing classes. HOT 2
- Unable to add library to app. HOT 2
- Unable to extract title of SuggestionItem from SuggestionItem object. HOT 2
- RecyclerView.addOnScrollListener is called automatically called whenever i click on persistentSearchView in my ui HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from persistent-search-view.