Giter Site home page Giter Site logo

mars885 / persistent-search-view Goto Github PK

View Code? Open in Web Editor NEW
415.0 415.0 41.0 698 KB

An Android library designed to simplify the process of implementing search-related functionality.

License: Apache License 2.0

Java 91.18% Shell 0.31% Kotlin 8.51%
android android-library android-searchview search searchview

persistent-search-view's People

Contributors

mars885 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

persistent-search-view's Issues

Does this library run on API 19..

Hi,
Currently it run only on API 21, I used tools:overrideLibrary="com.paulrybitskyi.persistentsearchview"
to make it run on API 19.. Will it run smoothly on API 19 devices .. without error ?

Strange background image

Hello!
Thank you for the wonderful library!
When I use app:shouldDimBehind = "true", I get a strange image in center.
The same is observed in your example.
Thanks!

strange_image

Dealing with Multiple Fragments in a ViewPager

I have a couple of fragments in a viewPager2. Two of the fragments have persistent search views. When I toggle back & forth between the fragments, tapping to activate the search query does not work.

I was thinking it's related to the Lifecycle of the fragments which toggles between pause & resume depending on which fragment is active. Do we need to do anything special when multiple instances of the persistent search views are active at a time?

Unable to add library to app.

When I try to add this library to my app I'm greeted with the following error:

Failed to resolve: com.arthurivanets.adapster:adapster:1.0.13
Show in Project Structure dialog
Affected Modules: app

Use github releases

Please use github releases (by tagging your code) and add demo APK to it as well.

RecyclerView.addOnScrollListener is called automatically called whenever i click on persistentSearchView in my ui

public class MainActivity extends AppCompatActivity {

private int page = 1;




PersistentSearchView persistentSearchView;
RecyclerView recyclerView;

PhotosAdapter adapter;
PhotosAdapter.OnPhotoClickedListener photoClickListener;

UnsplashInterface dataService;
private Merlin merlin;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_img_picker);


    merlin = new Merlin.Builder().withConnectableCallbacks().build(getApplicationContext ());

    recyclerView = findViewById(R.id.recyclerView);

    persistentSearchView = findViewById (R.id.persistentSearchView);

    dataService = UnsplashClient.getUnsplashClient().create(UnsplashInterface.class);



    photoClickListener = new PhotosAdapter.OnPhotoClickedListener() {
        @Override
        public void photoClicked(Photo photo, ImageView imageView) {
            Intent intent = new Intent();
            intent.putExtra("image", photo);
            setResult(RESULT_OK, intent);
            finish();
        }
    };


    persistentSearchView.setOnLeftBtnClickListener(new View.OnClickListener () {

        @Override
        public void onClick(View view) {
            finish ();
        }

    });



    persistentSearchView.setVoiceRecognitionDelegate(new VoiceRecognitionDelegate (this));

    persistentSearchView.setOnSearchConfirmedListener(new OnSearchConfirmedListener () {

        @Override
        public void onSearchConfirmed(PersistentSearchView searchView, String query) {
            // Handle a search confirmation. This is the place where you'd
            // want to perform a search against your data provider.


            search (query);
            Toast.makeText (MainActivity.this, "search is confirmed", Toast.LENGTH_SHORT).show ();

        }

    });

    persistentSearchView.setOnSuggestionChangeListener(new OnSuggestionChangeListener () {

        @Override
        public void onSuggestionPicked(SuggestionItem suggestion) {
            // Handle a suggestion pick event. This is the place where you'd
            // want to perform a search against your data provider.


        }

        @Override
        public void onSuggestionRemoved(SuggestionItem suggestion) {
            // Handle a suggestion remove event. This is the place where
            // you'd want to remove the suggestion from your data provider.


        }

    });


    GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
    recyclerView.setLayoutManager(layoutManager);
    adapter = new PhotosAdapter(new ArrayList<Photo> (), this, photoClickListener);
    recyclerView.setAdapter(adapter);

    recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(layoutManager) {
        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {

                loadPhotos();

            Toast.makeText (MainActivity.this, "  endless scroll view is called  ", Toast.LENGTH_LONG).show ();

        }
    });



    loadPhotos();

    merlin.registerConnectable(new Connectable () {
        @Override
        public void onConnect() {
            

            Toast.makeText (MainActivity.this, "connected with internet", Toast.LENGTH_SHORT).show ();

        }



    });


}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult (requestCode, resultCode, data);

    VoiceRecognitionDelegate.handleResult(persistentSearchView, requestCode, resultCode, data);

}

private void loadPhotos() {


    dataService.getPhotos(page,null,"latest")
            .enqueue (new Callback<List<Photo>> () {
                @Override
                public void onResponse(Call<List<Photo>> call, Response<List<Photo>> response) {
                    List<Photo> photos = response.body();
                    Log.i("Photos", "Photos Fetched " + photos.size());
                    //add to adapter
                    page++;
                    adapter.addPhotos(photos);
                    recyclerView.setAdapter(adapter);

                  

                }

                @Override
                public void onFailure(Call<List<Photo>> call, Throwable t) {

                }
            });

}

public void search(String query){
    if(query != null && !query.equals("")) {


        dataService.searchPhotos(query,1,null,null)
                .enqueue (new Callback<SearchResults> () {
                    @Override
                    public void onResponse(Call<SearchResults> call, Response<SearchResults> response) {
                        SearchResults results = response.body();
                        Log.d("Photos", "Total Results Found " + results.getTotal());
                        List<Photo> photos = results.getResults();
                        adapter = new PhotosAdapter(photos, MainActivity.this, photoClickListener);
                        recyclerView.setAdapter(adapter);

                     
                    }

                    @Override
                    public void onFailure(Call<SearchResults> call, Throwable t) {


                    }
                });

    }
    else {
        loadPhotos();
    }
}



@Override
protected void onResume() {
    super.onResume();
    merlin.bind();
}

@Override
protected void onPause() {
    merlin.unbind();
    super.onPause();
}

}

suggestion itemModel not resolved

I want to use OnSuggestionChangeListener, but itemModel not resolved. I'm getting following error.

Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.paulrybitskyi.persistentsearchview.adapters.model.SuggestionItem, unresolved supertypes: com.arthurivanets.adapster.model.BaseItem, com.arthurivanets.adapster.model.markers.Trackable

Class not found Exception in XML

Hi your library does not loading a class as shared below. Please resolve this asap.
The following classes could not be instantiated:
- com.paulrybitskyi.persistentsearchview.PersistentSearchView (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.ClassNotFoundException: com.arthurivanets.adapster.listeners.OnItemClickListener

java.lang.ClassNotFoundException: com.arthurivanets.adapster.listeners.OnItemClickListener
at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.findClass(DelegatingClassLoader.kt:81)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.loadClass(DelegatingClassLoader.kt:65)
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3137)
at java.base/java.lang.Class.getConstructor0(Class.java:3342)
at java.base/java.lang.Class.getConstructor(Class.java:2151)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:282)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

Target sdk 32
Min sdk 21
AndroidX
Java - Android Studio

While building a project it says,
*** What went wrong:
Execution failed for task ':app:dataBindingMergeDependencyArtifactsDebugAndroidTest'.

Could not resolve all files for configuration ':app:debugAndroidTestCompileClasspath'.
Could not find com.arthurivanets.adapster:adapster:1.0.13.
Required by:
project :app > com.paulrybitskyi.persistentsearchview:persistentsearchview:1.1.4**

problem on getting suggestion text

im trying to get text from suggestion, from sample the sample you provided, i think OnSuggestionChangeListener in java should be like this :

private final OnSuggestionChangeListener onSuggestionChangeListener = new OnSuggestionChangeListener() {
@OverRide
public void onSuggestionPicked(SuggestionItem suggestion) {
String query = suggestion.getItemModel().getText();

        startSearch(query);
    }
    @Override
    public void onSuggestionRemoved(SuggestionItem suggestion) {
    }
};

but when i try this code, getItemModel() either not available or missing,somehow the only available method for 'getter' was geTrackeyKey() or getLayout() which obfiusly not for picking up the suggestion text

Change voice recognition language

Hi. Thank you for your awesome library. Can you add a feature to force the Voice Recognition Language from Default Locale to a Specific language?

Button to set suggestion text as query

Hello author. I'm intergrating this search view to my app and it's an amazing search view.

I would like to suggest to have this button at the right of Regular Suggestion view. It will set the suggestion text as the query and also call the OnSearchQueryChangeListener.

Below is an image of Google app as example
image

Thank you.

Change textappearances

How to change query, hint and suggested text appearances? I don't see any textappearances attributes.

Unable to extract title of SuggestionItem from SuggestionItem object.

I am using mars885 Persistent Search View. I dont know how to extract the SuggestionItem title from its object. I want to extract the title in a string and use it to show some results. i encountered this problem while using setOnSuggestionChangeListener -> onSuggestionPicked().

I am a Java Programmer

unable to scrool suggestion only in fragment

hi, i'm facing weird issue when placing searchivew on fragment, suggestion work as i expected but unable to scroll. i've also confirmed with the same code, sugestion can be scrolled flawlesly

jcenter deprecation

Hello, since jcenter will be deprecated soon enough, any plans to release this via mavencentral?

Trigger onSearchConfirmed when pressing the "ENTER" key (tablets with external keyboard)

Hello,

I'm having difficulties using the fork through jitpack.io (1.1.4 does not build successfully). I'm getting this: "⚠️ ERROR: No build artifacts found". https://jitpack.io/com/github/svrzii/persistent-search-view/v1.1.4/build.log

Is it possible to add this statement to the project, so on pressing ENTER, the listener would trigger correctly?

private final TextView.OnEditorActionListener mInternalEditorActionListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if((actionId == EditorInfo.IME_ACTION_SEARCH) && (onSearchConfirmedListener != null)) {
                onSearchConfirmedListener.onSearchConfirmed(PersistentSearchView.this, getInputQuery());
            } else if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                onSearchConfirmedListener.onSearchConfirmed(PersistentSearchView.this, getInputQuery());
            }

            return true;
        }
  };

https://github.com/svrzii/persistent-search-view/commit/23cccd82d10ec9f2fee04884d9b455eeae8f5684

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.