Search in sources :

Example 1 with SearchHandler

use of ingage.ingage20.handlers.SearchHandler in project iNGAGE by davis123123.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
    searchView = (android.support.v7.widget.SearchView) myActionMenuItem.getActionView();
    final FragmentManager fragmentManager = this.getSupportFragmentManager();
    final Class fragmentClass = SearchResultFragment.class;
    searchView.setOnSearchClickListener(this);
    searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            Log.d("SEARCH", s);
            SearchHandler searchHandler = new SearchHandler();
            String result = "";
            session.updateSearch(s);
            final Fragment fragment = Fragment.instantiate(getApplicationContext(), fragmentClass.getName());
            fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment, fragmentClass.getSimpleName()).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            Log.d("SEARCH", "yes");
            return false;
        }
    });
    return true;
}
Also used : SearchHandler(ingage.ingage20.handlers.SearchHandler) SearchResultFragment(ingage.ingage20.fragments.SearchResultFragment) MenuItem(android.view.MenuItem) FrontPageFragment(ingage.ingage20.fragments.FrontPageFragment) Fragment(android.support.v4.app.Fragment) CategoriesPageFragment(ingage.ingage20.fragments.CategoriesPageFragment) SearchResultFragment(ingage.ingage20.fragments.SearchResultFragment) FragmentManager(android.support.v4.app.FragmentManager)

Example 2 with SearchHandler

use of ingage.ingage20.handlers.SearchHandler in project iNGAGE by davis123123.

the class SearchResultFragment method getThreadsJSON.

public void getThreadsJSON(int rowCount, String searchString) {
    searchHandler = new SearchHandler();
    Log.d("ROWCOUNT", " result : " + searchString);
    session = new SessionManager(getActivity().getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    String type = user.get(SessionManager.PAGE_TYPE);
    try {
        json_string = searchHandler.execute(String.valueOf(rowCount), searchString).get();
        Log.d("STATE", "query result : " + json_string);
        threadListAdapter.setLoaded(false);
        inflateThreads();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
Also used : SearchHandler(ingage.ingage20.handlers.SearchHandler) SessionManager(ingage.ingage20.managers.SessionManager) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with SearchHandler

use of ingage.ingage20.handlers.SearchHandler in project iNGAGE by davis123123.

the class MainActivity method onSearch.

private void onSearch() {
    final FragmentManager fragmentManager = this.getSupportFragmentManager();
    final Class fragmentClass = SearchResultFragment.class;
    searchView.setOnSearchClickListener(this);
    searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            Log.d("SEARCH", "submit");
            SearchHandler searchHandler = new SearchHandler();
            String result = "";
            try {
                result = searchHandler.execute("0", s).get();
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
            final Fragment fragment = Fragment.instantiate(getApplicationContext(), fragmentClass.getName());
            fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment, fragmentClass.getSimpleName()).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            Log.d("SEARCH", "yes");
            return false;
        }
    });
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) SearchHandler(ingage.ingage20.handlers.SearchHandler) SearchResultFragment(ingage.ingage20.fragments.SearchResultFragment) FrontPageFragment(ingage.ingage20.fragments.FrontPageFragment) Fragment(android.support.v4.app.Fragment) CategoriesPageFragment(ingage.ingage20.fragments.CategoriesPageFragment) SearchResultFragment(ingage.ingage20.fragments.SearchResultFragment)

Aggregations

SearchHandler (ingage.ingage20.handlers.SearchHandler)3 Fragment (android.support.v4.app.Fragment)2 FragmentManager (android.support.v4.app.FragmentManager)2 CategoriesPageFragment (ingage.ingage20.fragments.CategoriesPageFragment)2 FrontPageFragment (ingage.ingage20.fragments.FrontPageFragment)2 SearchResultFragment (ingage.ingage20.fragments.SearchResultFragment)2 MenuItem (android.view.MenuItem)1 SessionManager (ingage.ingage20.managers.SessionManager)1 ExecutionException (java.util.concurrent.ExecutionException)1