示例#1
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu
    getMenuInflater().inflate(R.menu.main, menu);

    mSearchMenuItem = menu.findItem(R.id.menu_act_filter);
    MenuItemCompat.setOnActionExpandListener(
        mSearchMenuItem,
        new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionExpand(MenuItem menuItem) {
            return true;
          }

          @Override
          public boolean onMenuItemActionCollapse(MenuItem menuItem) {
            notifyQueryChange("");
            return true;
          }
        });

    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(mSearchMenuItem);
    searchView.setOnQueryTextListener(this);
    searchView.setSubmitButtonEnabled(true);
    searchView.setQueryHint(getString(R.string.search));

    mRefreshAnim.setMenuItem(menu.findItem(R.id.menu_act_refresh));
    return super.onCreateOptionsMenu(menu);
  }
示例#2
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (GcmTaskService.SERVICE_ACTION_EXECUTE_TASK.equals(action)
       || SyncAdapter.SYNC_PROGRESS.equals(action)) {
     mRefreshAnim.start();
     notifySyncStart();
   } else if (SyncAdapter.SYNC_STOP.equals(action)) {
     int updatesCount = intent.getIntExtra(SyncAdapter.EXTRA_UPDATES_COUNT, 0);
     mRefreshAnim.stop();
     notifySyncStop();
     if (updatesCount == 0) {
       Toast.makeText(AppWatcherActivity.this, R.string.no_updates_found, Toast.LENGTH_SHORT)
           .show();
     }
   }
 }