protected void setRefreshActionButtonState(boolean refreshing) {
    if (mOptionsMenu == null) {
      //	mPendingMenuRefreshState=refreshing;
      return;
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);

    if (refreshItem != null) {
      if (refreshing) {
        View actionView = MenuItemCompat.getActionView(refreshItem);
        if (actionView == null || actionView.findViewById(R.id.progress_circular_ab) == null) {
          MenuItemCompat.setActionView(refreshItem, R.layout.actionbar_indeterminate_progress);
          actionView = MenuItemCompat.getActionView(refreshItem);
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            // Framework bug https://code.google.com/p/android/issues/detail?id=162416
            ProgressBar progressBar =
                (ProgressBar) actionView.findViewById(R.id.progress_circular_ab);
            progressBar.setIndeterminate(true);
            progressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
            progressBar.setIndeterminateTintList(
                getResources().getColorStateList(R.color.action_bar_title));
            // progressBar.setBackgroundTintList(getResources().getColorStateList(R.color.action_bar_title));
          }
        }
        refreshItem.setVisible(true);
      } else {
        MenuItemCompat.setActionView(refreshItem, null);
        if (mHasFeatureIndeterminateProgress) refreshItem.setVisible(false);
      }
    }
    mPendingMenuRefreshState = null;
    // if(mHasFeatureIndeterminateProgress)
    // setSupportProgressBarIndeterminateVisibility(refreshing);
  }
예제 #2
0
 @Override
 public void onPrepareOptionsMenu(Menu menu) {
   if (cargando) {
     MenuItemCompat.setActionView(mnuActualizar, R.layout.actionview_progreso);
   } else {
     MenuItemCompat.setActionView(mnuActualizar, null);
   }
   super.onPrepareOptionsMenu(menu);
 }
 public void setRefreshIndicationState(boolean refreshing) {
   if (optionsMenu == null) {
     return;
   }
   final MenuItem refreshItem = optionsMenu.findItem(R.id.menu_refresh);
   if (refreshItem != null) {
     if (refreshing) {
       MenuItemCompat.setActionView(refreshItem, R.layout.actionbar_indeterminate_progress);
     } else {
       MenuItemCompat.setActionView(refreshItem, null);
     }
   }
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_base, menu);
    setupWindowAnimations();

    MenuItem countItem = menu.findItem(R.id.pending_goals);
    MenuItemCompat.setActionView(countItem, R.layout.feed_update_count);
    if (mPendingCount > 0) {
      countItem.setVisible(true);
      buttonPending = (Button) MenuItemCompat.getActionView(countItem);
      buttonPending.setText(String.valueOf(mPendingCount));
      buttonPending.setOnClickListener(
          new View.OnClickListener() {
            public void onClick(View v) {
              Intent i = new Intent(getApplicationContext(), ReminderListActivity.class);
              startActivity(
                  i,
                  ActivityOptions.makeSceneTransitionAnimation(HistoryBaseActivity.this)
                      .toBundle());
            }
          });
    } else {
      countItem.setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
  }
  protected void updateUserHeader() {
    final MenuItem userHeaderMenu =
        (mOptionsMenu != null) ? mOptionsMenu.findItem(R.id.menu_user_header) : null;
    if (userHeaderMenu != null) {
      View userHeaderView = MenuItemCompat.getActionView(userHeaderMenu);
      if (userHeaderView == null) {
        userHeaderView = getLayoutInflater().inflate(R.layout.actionbar_user_header, null, false);
        userHeaderView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                onOptionsItemSelected(userHeaderMenu);
              }
            });
        MenuItemCompat.setShowAsAction(userHeaderMenu, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
        MenuItemCompat.setActionView(userHeaderMenu, userHeaderView);
      }
      UserHeader header = Session.getInstance().getCustomerHeader();
      if (header != null) {
        ((TextView) userHeaderView.findViewById(R.id.text1)).setText("hi");

        userHeaderMenu.setTitle(header.userName.getUserNameDisplay());
        userHeaderMenu.setVisible(true);
      } else {
        userHeaderMenu.setTitle("Login");
        userHeaderMenu.setVisible(false);
      }
    }
  }
예제 #6
0
  void initializeLoadingIndicator(Menu OptionsMenu) {
    // Add refresh in Action Bar
    mLoadingItem = OptionsMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, getString(R.string.loading));

    // Set up the view
    MenuItemCompat.setActionView(mLoadingItem, R.layout.loading);

    // Specify the show flags
    MenuItemCompat.setShowAsAction(mLoadingItem, MenuItem.SHOW_AS_ACTION_ALWAYS);

    // Hide by default
    mLoadingItem.setVisible(false);
  }
예제 #7
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_activity_orders, menu);

    // Search Icon referenzieren
    searchItem = menu.findItem(R.id.itm_action_search);

    MenuItemCompat.setActionView(searchItem, searchView);
    MenuItemCompat.setShowAsAction(
        searchItem,
        MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return super.onCreateOptionsMenu(menu);
  }
예제 #8
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.menu_main_search, menu); // removed to not double the menu items
    MenuItem item = menu.findItem(R.id.menu_search);
    SearchView sv =
        new SearchView(((MainActivity) getActivity()).getSupportActionBar().getThemedContext());
    MenuItemCompat.setShowAsAction(
        item,
        MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setActionView(item, sv);
    sv.setOnQueryTextListener(this);
    sv.setIconifiedByDefault(false);
    sv.setOnSearchClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {}
        });

    MenuItemCompat.setOnActionExpandListener(
        item,
        new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionCollapse(MenuItem item) {
            // Do something when collapsed
            return true; // Return true to collapse action view
          }

          @Override
          public boolean onMenuItemActionExpand(MenuItem item) {
            // Do something when expanded
            return true; // Return true to expand action view
          }
        });

    super.onCreateOptionsMenu(menu, inflater);
  }
예제 #9
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.script_menu, menu);
    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.script_add), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setActionProvider(
        menu.findItem(R.id.script_add), new AddActionProvider(this)); // 自定义子菜单

    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.script_view), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.script_setting), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItem item = menu.findItem(R.id.script_search);
    SearchView searchView = new SearchView(this.getSupportActionBar().getThemedContext());
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setActionView(item, searchView); // 设置搜索窗口
    searchView.setOnQueryTextListener(
        new OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            mInSearchResultMode = true;
            updateAndFilterScriptList(query);
            mAdapter.notifyDataSetChanged();
            return false;
          }

          @Override
          public boolean onQueryTextChange(String query) {
            mInSearchResultMode = true;
            updateAndFilterScriptList(query);
            mAdapter.notifyDataSetChanged();
            return false;
          }
        });
    return true;
  }