Skip to content

Commit

Permalink
ICS: Migrate SearchViewCompat to SearchView.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Oct 2, 2014
1 parent 3668ff2 commit a3de8ad
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions wallet/src/de/schildbach/wallet/ui/ExchangeRatesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.widget.SearchViewCompat;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.ResourceCursorAdapter;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.TextView;

import com.google.bitcoin.core.Wallet;
Expand Down Expand Up @@ -158,32 +159,29 @@ public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater)
{
inflater.inflate(R.menu.exchange_rates_fragment_options, menu);

final View searchView = menu.findItem(R.id.exchange_rates_options_search).getActionView();
if (searchView != null)
final SearchView searchView = (SearchView) menu.findItem(R.id.exchange_rates_options_search).getActionView();
searchView.setOnQueryTextListener(new OnQueryTextListener()
{
SearchViewCompat.setOnQueryTextListener(searchView, new SearchViewCompat.OnQueryTextListenerCompat()
@Override
public boolean onQueryTextChange(final String newText)
{
@Override
public boolean onQueryTextChange(final String newText)
{
query = newText.trim();
if (query.isEmpty())
query = null;
query = newText.trim();
if (query.isEmpty())
query = null;

getLoaderManager().restartLoader(ID_RATE_LOADER, null, rateLoaderCallbacks);
getLoaderManager().restartLoader(ID_RATE_LOADER, null, rateLoaderCallbacks);

return true;
}
return true;
}

@Override
public boolean onQueryTextSubmit(final String query)
{
searchView.clearFocus();
@Override
public boolean onQueryTextSubmit(final String query)
{
searchView.clearFocus();

return true;
}
});
}
return true;
}
});

super.onCreateOptionsMenu(menu, inflater);
}
Expand Down

0 comments on commit a3de8ad

Please sign in to comment.