예제 #1
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.global, menu);

    MenuItem menuRestart = menu.findItem(R.id.menuRestart);

    menuRestart.setOnMenuItemClickListener(
        new OnMenuItemClickListener() {
          public boolean onMenuItemClick(MenuItem item) {
            BrandManager.restart();
            return false;
          }
        });

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    menuGuessed = menu.findItem(R.id.menuGuessed);
    menuScore = menu.findItem(R.id.menuScore);
    updateScore();

    int total = BrandManager.size();
    int totalGuessed = BrandManager.sizeGuessed();

    menuGuessed.setTitle("Guessed: " + String.valueOf(totalGuessed) + "/" + String.valueOf(total));
    return true;
  }
예제 #2
0
  public boolean performItemAction(MenuItem item, int flags) {
    MenuItemImpl itemImpl = (MenuItemImpl) item;

    if (itemImpl == null || !itemImpl.isEnabled()) {
      return false;
    }

    boolean invoked = itemImpl.invoke();

    if (itemImpl.hasCollapsibleActionView()) {
      invoked |= itemImpl.expandActionView();
      if (invoked) close(true);
    } else if (item.hasSubMenu()) {
      close(false);

      final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
      final ActionProvider provider = item.getActionProvider();
      if (provider != null && provider.hasSubMenu()) {
        provider.onPrepareSubMenu(subMenu);
      }
      invoked |= dispatchSubMenuSelected(subMenu);
      if (!invoked) close(true);
    } else {
      if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) {
        close(true);
      }
    }

    return invoked;
  }
예제 #3
0
 @Override
 public boolean onMenuItemSelected(int featureId, MenuItem item) {
   if (optionsMenu.containsKey(item.getItemId())) {
     optionsMenu.get(item.getItemId()).activity(this).item(item).run();
   }
   return super.onMenuItemSelected(featureId, item);
 }
예제 #4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        finish();
        return true;
    }
    if (item.getTitle().equals("가입")) {
      if (member_name_edit_text.getText().length() < 2) {
        Toast.makeText(getApplicationContext(), "이름은 2자 이상!", Toast.LENGTH_LONG).show();
        return true;
      } else if (member_phone_num_edit_text.getText().length() < 11) {
        Toast.makeText(getApplicationContext(), "전화번호가 올바르지 않습니다!", Toast.LENGTH_LONG).show();
        return true;
      } else {
        showDialog(0);
        name = member_name_edit_text.getText().toString();
        phone = member_phone_num_edit_text.getText().toString();
        if (resized != null) {
          bm = resized;
        }
        new Usercreate().execute();

        return true;
      }
    }
    return true;
  }
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   MenuItem menuProgress = menu.findItem(R.id.menu_progress);
   MenuItem menuRefresh = menu.findItem(R.id.menu_refresh);
   menuProgress.setVisible(mProgressIndicator);
   menuRefresh.setVisible(!mProgressIndicator);
 }
예제 #6
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.repo_menu, menu);

    if (Gh4Application.THEME != R.style.LightTheme) {
      menu.getItem(0).setIcon(R.drawable.navigation_refresh_dark);
    }

    MenuItem watchAction = menu.getItem(1);
    if (isAuthorized()) {
      if (!isFinishLoadingWatching) {
        watchAction.setActionView(R.layout.ab_loading);
        watchAction.expandActionView();
      } else {
        if (isWatching) {
          watchAction.setTitle(R.string.repo_unwatch_action);
        } else {
          watchAction.setTitle(R.string.repo_watch_action);
        }
      }
    } else {
      menu.removeItem(R.id.watch);
    }

    return super.onPrepareOptionsMenu(menu);
  }
예제 #7
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate your menu.
    getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    actionProvider.setShareIntent(createShareIntent());

    // XXX: For now, ShareActionProviders must be displayed on the action bar
    // Set file with share history to the provider and set the share intent.
    // MenuItem overflowItem = menu.findItem(R.id.menu_item_share_action_provider_overflow);
    // ShareActionProvider overflowProvider =
    //    (ShareActionProvider) overflowItem.getActionProvider();
    // overflowProvider.setShareHistoryFileName(
    //    ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    // overflowProvider.setShareIntent(createShareIntent());

    return true;
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == R.id.menu_new_playlist) {
     if (!RdioComm.getComm().isAuthorized()) {
       Toast.makeText(getActivity(), R.string.not_authorized, Toast.LENGTH_SHORT).show();
       return true;
     }
     if (isAnyTaskRunning()) {
       Toast.makeText(
               getActivity().getApplicationContext(),
               R.string.operation_in_progress,
               Toast.LENGTH_SHORT)
           .show();
       return true;
     }
     InputDialogFragment dialog =
         InputDialogFragment.newInstance(R.string.playlist_name, "playlistName");
     dialog.showDialog(getActivity());
     return true;
   } else if (item.getItemId() == R.id.menu_login) {
     if (isAnyTaskRunning()) {
       Toast.makeText(getActivity(), R.string.operation_in_progress, Toast.LENGTH_SHORT).show();
       return true;
     }
     RdioComm.getComm().cleanAuthTokens(getActivity());
     login();
     return true;
   } else {
     return super.onOptionsItemSelected(item);
   }
 }
예제 #9
0
  private void setReloadingState(boolean reloading) {
    LinearLayout llContent = (LinearLayout) getActivity().findViewById(R.id.llContent);
    RelativeLayout rlSplashScreen =
        (RelativeLayout) getActivity().findViewById(R.id.rlSplashScreen);
    ImageButton btnRefresh = (ImageButton) getActivity().findViewById(R.id.btnRefresh);
    ProgressBar pbRefreshing = (ProgressBar) getActivity().findViewById(R.id.pbRefreshing);

    _menuReload.setVisible(!reloading);
    _menuReloading.setVisible(reloading);

    if (reloading) {
      btnRefresh.setVisibility(View.INVISIBLE);
      llContent.setVisibility(View.INVISIBLE);

      pbRefreshing.setVisibility(View.VISIBLE);
      rlSplashScreen.setVisibility(View.VISIBLE);

      _menuReloading.setActionView(R.layout.menu_progress);
    } else {
      pbRefreshing.setVisibility(View.INVISIBLE);
      rlSplashScreen.setVisibility(View.GONE);

      btnRefresh.setVisibility(View.VISIBLE);
      llContent.setVisibility(View.VISIBLE);

      _menuReload.setIcon(R.drawable.ic_action_refresh);
      _menuReloading.setActionView(null);

      View control = null;
      for (int i = 0; i < llContent.getChildCount(); i++) {
        control = llContent.getChildAt(i);
        control.setVisibility(View.VISIBLE);
      }
    }
  }
예제 #10
0
 // Cuando se pulsa un elemento del menú.
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // Dependiendo del item pulsado se realiza la acción deseada.
   switch (item.getItemId()) {
     case android.R.id.home:
       mostrarTostada(getString(R.string.ir_a_la_actividad_superior));
       break;
     case R.id.mnuAgregar:
       mostrarTostada(getString(R.string.agregar));
       break;
     case R.id.mnuCargar:
       mostrarTostada(getString(R.string.cargar));
       break;
     case R.id.mnuEditar:
       mostrarTostada(item.getTitle().toString());
       break;
     case R.id.mnuEliminar:
       mostrarTostada(getString(R.string.eliminar));
       break;
     case R.id.mnuBuscar:
       mostrarTostada(getString(R.string.buscar));
       break;
     case R.id.mnuCompartir:
       mostrarTostada(getString(R.string.compartir));
       break;
     default:
       return super.onOptionsItemSelected(item);
   }
   // Retorna que ya ha sido gestionado.
   return true;
 }
 public void stopAnimatingRefreshButton(MenuItem refreshItem) {
   isAnimatingRefreshButton = false;
   if (refreshItem != null && refreshItem.getActionView() != null) {
     refreshItem.getActionView().clearAnimation();
     refreshItem.setActionView(null);
   }
 }
예제 #12
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuItem refresh = menu.add(0, 1, 1, "Joomla");
   refresh.setIcon(R.drawable.ic_action_overflow);
   refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
   refresh.setOnMenuItemClickListener(this);
   return true;
 }
예제 #13
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem create = menu.add("Create");
    create.setIcon(R.drawable.ic_menu_add2);
    create.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem saveItem = menu.add(0, 10001, 0, "确定");
    saveItem.setIcon(android.R.drawable.ic_menu_save);
    saveItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_IF_ROOM);

    return true;
  }
예제 #15
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.tropes_fragment_menu, menu);
    inflater.inflate(R.menu.index_fragment_menu, menu);

    MenuItem shareItem = menu.findItem(R.id.share_article);
    shareProvider = (ShareActionProvider) shareItem.getActionProvider();
  }
예제 #16
0
  /** Updates the 'muted' and 'deafened' action bar icons to reflect the audio status. */
  private void updateMuteDeafenMenuItems(boolean muted, boolean deafened) {
    if (mutedButton == null || deafenedButton == null) return;

    mutedButton.setIcon(
        !muted ? R.drawable.ic_action_microphone : R.drawable.ic_microphone_muted_strike);
    deafenedButton.setIcon(
        !deafened ? R.drawable.ic_action_audio_on : R.drawable.ic_action_audio_muted);
  }
예제 #17
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   // TODO Auto-generated method stub
   MenuItem changeBtn = menu.add(5, 6, 7, "帐号管理");
   changeBtn
       .setIcon(R.drawable.home_action_icon_person)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
   return super.onCreateOptionsMenu(menu);
 }
예제 #18
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    final MainActivity that = this;

    SearchView searchView = new SearchView(this);
    searchView.setQueryHint("Search");
    searchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            mBus.post(new SearchEvent(query));
            return true;
          }

          @Override
          public boolean onQueryTextChange(String newText) {
            if ("".equals(newText)) mBus.post(new SearchEvent(true));
            return true; // To change body of implemented methods use File | Settings | File
                         // Templates.
          }
        });

    // Used to put dark icons on light action bar
    mMenueSearch = menu.add("Search");
    mMenueSearch
        .setIcon(R.drawable.ic_search)
        .setActionView(searchView)
        .setShowAsAction(
            MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    mMenueRefresh = menu.add("refresh");
    mMenueRefresh
        .setIcon(R.drawable.ic_refresh)
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem item) {
                mBus.post(new RefreshEvent());
                return true;
              }
            })
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    menu.add("Settings")
        .setOnMenuItemClickListener(
            new MenuItem.OnMenuItemClickListener() {
              @Override
              public boolean onMenuItemClick(MenuItem item) {
                Intent settingsIntent = new Intent(that, SettingsActivity.class);
                that.startActivity(settingsIntent);
                return true;
              }
            })
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    return true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.id.map_view) {
      category =
          (getArguments() != null) ? getArguments().getString(SearchFragment.ARG_CATEGORY) : null;
      if (category != null) {
        MapManager.switchToMapView(category, HomeFragment.ARG_POI_CATEGORY, this);
      } else {
        ArrayList<BaseDTObject> target = new ArrayList<BaseDTObject>();
        for (int i = 0; i < list.getAdapter().getCount(); i++) {
          BaseDTObject o = (BaseDTObject) list.getAdapter().getItem(i);
          target.add(o);
        }
        MapManager.switchToMapView(target, this);
      }
      return true;
    } else if (item.getItemId() == R.id.menu_item_addpoi) {
      {
        FragmentTransaction fragmentTransaction =
            getSherlockActivity().getSupportFragmentManager().beginTransaction();
        Fragment fragment = new CreatePoiFragment();
        Bundle args = new Bundle();
        args.putString(SearchFragment.ARG_CATEGORY, category);
        fragment.setArguments(args);
        fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        // fragmentTransaction.detach(this);
        fragmentTransaction.replace(R.id.fragment_container, fragment, "pois");
        fragmentTransaction.addToBackStack(fragment.getTag());
        fragmentTransaction.commit();
        reload = true;
        return true;
      }
    } else if (item.getItemId() == R.id.submenu_search) {
      FragmentTransaction fragmentTransaction;
      Fragment fragment;
      fragmentTransaction = getSherlockActivity().getSupportFragmentManager().beginTransaction();
      fragment = new SearchFragment();
      Bundle args = new Bundle();
      args.putString(SearchFragment.ARG_CATEGORY, category);
      args.putString(CategoryHelper.CATEGORY_TYPE_POIS, CategoryHelper.CATEGORY_TYPE_POIS);
      if (getArguments() != null
          && getArguments().containsKey(SearchFragment.ARG_MY)
          && getArguments().getBoolean(SearchFragment.ARG_MY))
        args.putBoolean(SearchFragment.ARG_MY, getArguments().getBoolean(SearchFragment.ARG_MY));
      fragment.setArguments(args);
      fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
      fragmentTransaction.replace(R.id.fragment_container, fragment, "pois");
      fragmentTransaction.addToBackStack(fragment.getTag());
      fragmentTransaction.commit();
      /* add category to bundle */
      return true;

    } else {
      return super.onOptionsItemSelected(item);
    }
  }
예제 #20
0
 private void updateRefreshStatus(boolean refreshing) {
   if (mRefreshItem != null) {
     if (refreshing) {
       mRefreshItem.setActionView(R.layout.indeterminate_progress_action);
     } else {
       mRefreshItem.setActionView(null);
     }
   }
 }
 protected void setRefreshActionButtonState(boolean refreshing) {
   if (refreshItem != null) {
     if (refreshing) {
       refreshItem.setActionView(R.layout.actionbar_indeterminate_progress);
     } else {
       refreshItem.setActionView(null);
     }
   }
 }
예제 #22
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home || item.getItemId() == 0) {
     return false;
   }
   THEME = item.getItemId();
   Toast.makeText(this, "Theme changed to \"" + item.getTitle() + "\"", Toast.LENGTH_SHORT).show();
   return true;
 }
 private void setEvernoteMenuEnabled(MenuItem item) {
   if (item != null) {
     boolean loggedIn = false;
     if (session != null) {
       loggedIn = session.isLoggedIn();
     }
     item.setEnabled(loggedIn);
     item.setVisible(loggedIn);
   }
 }
예제 #24
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getSupportMenuInflater().inflate(R.menu.weibo, menu);
   loveItem = menu.findItem(R.id.menu_favorite);
   if (status.isFavorited()) {
     loveItem.setIcon(R.drawable.rating_favorite_r);
   }
   loveItem.setVisible(false);
   return super.onCreateOptionsMenu(menu);
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home || item.getItemId() == 0) {
     return false;
   }
   mSettings.edit().putInt(PREFS_SORT, item.getItemId()).commit();
   mFileMag.setSortType(item.getItemId());
   mHandler.updateDirectory(mFileMag.getNextDir(mFileMag.getCurrentDir(), true));
   return true;
 }
예제 #26
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.ui_connection_menu, menu);
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem helpMenu = menu.findItem(R.id.ui_menu_help);
    helpMenu.setOnMenuItemClickListener(new HelpMenuClickListener());

    MenuItem settingMenu = menu.findItem(R.id.ui_menu_setting);
    settingMenu.setOnMenuItemClickListener(new SettingMenuClickListener());

    MenuItem exitMenu = menu.findItem(R.id.ui_menu_exit);
    exitMenu.setOnMenuItemClickListener(new ExitMenuClickListener());

    // refresh button
    stopButton = (MenuItem) menu.findItem(R.id.ui_menu_stop);

    if (stopUpdate) stopButton.setIcon(R.drawable.ic_action_start);
    else stopButton.setIcon(R.drawable.ic_action_stop);

    stopButton.setOnMenuItemClickListener(
        new OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            stopUpdate = !stopUpdate;

            if (stopUpdate) stopButton.setIcon(R.drawable.ic_action_start);
            else stopButton.setIcon(R.drawable.ic_action_stop);
            return false;
          }
        });

    return;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_logout:
        logOut();
        item.setVisible(false);
        break;
    }

    return true;
  }
예제 #28
0
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   // If the nav drawer is open, hide action items related to the content view
   boolean isDrawerOpen = ((BaseNavDrawerActivity) getActivity()).isDrawerOpen();
   MenuItem filter = menu.findItem(R.id.menu_action_shows_filter);
   filter.setVisible(!isDrawerOpen);
   filter.setIcon(
       mIsFilterFavorites || mIsFilterUnwatched || mIsFilterUpcoming || mIsFilterHidden
           ? R.drawable.ic_action_filter_selected
           : R.drawable.ic_action_filter);
 }
예제 #29
0
 /** Toggles visibility of chart/data UI parts. */
 protected void toggleChartData(MenuItem item) {
   if (View.VISIBLE == chartframe.getVisibility()) {
     chartframe.setVisibility(View.GONE);
     dataframe.setVisibility(View.VISIBLE);
     item.setIcon(this.getResources().getDrawable(R.drawable.icon_graph));
   } else {
     chartframe.setVisibility(View.VISIBLE);
     dataframe.setVisibility(View.GONE);
     item.setIcon(this.getResources().getDrawable(R.drawable.icon_data));
   }
 }
 @Override
 public void onRestoreInstanceState(Parcelable state) {
   SavedState saved = (SavedState) state;
   if (saved.openSubMenuId > 0) {
     MenuItem item = mMenu.findItem(saved.openSubMenuId);
     if (item != null) {
       SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
       onSubMenuSelected(subMenu);
     }
   }
 }