Exemple #1
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);
  }
  public void restoreActionViewStates(Bundle states) {
    if (states == null) {
      return;
    }

    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());

    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
      final MenuItem item = getItem(i);
      final View v = item.getActionView();
      if (v != null && v.getId() != View.NO_ID) {
        v.restoreHierarchyState(viewStates);
      }
      if (item.hasSubMenu()) {
        final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
        subMenu.restoreActionViewStates(states);
      }
    }

    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
      MenuItem itemToExpand = findItem(expandedId);
      if (itemToExpand != null) {
        itemToExpand.expandActionView();
      }
    }
  }
Exemple #3
0
 @Override
 public boolean setMenuOptionItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       getApplicationContext()
           .openUserInfoActivity(this, mRepoOwner, null, Intent.FLAG_ACTIVITY_CLEAR_TOP);
       return true;
     case R.id.watch:
       item.setActionView(R.layout.ab_loading);
       item.expandActionView();
       getSupportLoaderManager().restartLoader(4, null, this);
       getSupportLoaderManager().getLoader(4).forceLoad();
       return true;
     case R.id.branches:
       if (mBranches == null) {
         mProgressDialog = showProgressDialog(getString(R.string.loading_msg), true);
         getSupportLoaderManager().getLoader(1).forceLoad();
       } else {
         showBranchesDialog();
       }
       return true;
     case R.id.tags:
       if (mTags == null) {
         mProgressDialog = showProgressDialog(getString(R.string.loading_msg), true);
         getSupportLoaderManager().getLoader(2).forceLoad();
       } else {
         showTagsDialog();
       }
       return true;
     case R.id.refresh:
       item.setActionView(R.layout.ab_loading);
       item.expandActionView();
       refreshFragment();
       return true;
     case R.id.share:
       Intent shareIntent = new Intent(Intent.ACTION_SEND);
       shareIntent.setType("text/plain");
       shareIntent.putExtra(Intent.EXTRA_SUBJECT, mRepoOwner + "/" + mRepoName);
       shareIntent.putExtra(
           Intent.EXTRA_TEXT, mRepoOwner + "/" + mRepoName + " " + mRepository.getHtmlUrl());
       shareIntent = Intent.createChooser(shareIntent, "Share");
       startActivity(shareIntent);
       return true;
     default:
       return true;
   }
 }
Exemple #4
0
        public void handleMessage(android.os.Message msg) {
          if (msg.what == 0) {
            mSMenuItem.expandActionView();
            ViewUtils.showKeybord(mSEditText, false);
            clearSearchFocus();
            getSherlockActivity().getSupportActionBar().setIcon(R.drawable.ic_logo);

            mSearchView.setOnSuggestionListener(
                new OnSuggestionListener() {

                  @Override
                  public boolean onSuggestionSelect(int position) {
                    // TODO Auto-generated method stub
                    return false;
                  }

                  @Override
                  public boolean onSuggestionClick(int position) {
                    if (mHistoryAdapter != null) {
                      Cursor s = (Cursor) mHistoryAdapter.getItem(position);
                      if (s.getString(1).equals(HistoryTask.SpecialRow)) {
                        clearHistory();
                      } else {
                        String jjdm = s.getString(2);
                        FundUtils.launchFundDetails(getSherlockActivity(), jjdm, 0, 0);
                        Analytics.onEvent(
                            getActivity(), Analytics.VIEW_FUND_DETAIL, Analytics.KEY_FROM, "历史记录");
                      }
                    }
                    return true;
                  }
                });

            mSMenuItem.setOnActionExpandListener(
                new OnActionExpandListener() {

                  @Override
                  public boolean onMenuItemActionExpand(MenuItem item) {
                    // TODO Auto-generated method stub
                    return false;
                  }

                  @Override
                  public boolean onMenuItemActionCollapse(MenuItem item) {
                    // TODO Auto-generated method stub
                    getActivity().finish();
                    return false;
                  }
                });
          }
        };
Exemple #5
0
 @Override
 public boolean setMenuOptionItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       getApplicationContext()
           .openUserInfoActivity(this, mRepoOwner, null, Intent.FLAG_ACTIVITY_CLEAR_TOP);
       return true;
     case R.id.watch:
       item.setActionView(R.layout.ab_loading);
       item.expandActionView();
       getSupportLoaderManager().restartLoader(4, null, this);
       getSupportLoaderManager().getLoader(4).forceLoad();
       return true;
     case R.id.branches:
       if (mBranches == null) {
         mProgressDialog = showProgressDialog(getString(R.string.loading_msg), true);
         getSupportLoaderManager().getLoader(1).forceLoad();
       } else {
         showBranchesDialog();
       }
       return true;
     case R.id.tags:
       if (mTags == null) {
         mProgressDialog = showProgressDialog(getString(R.string.loading_msg), true);
         getSupportLoaderManager().getLoader(2).forceLoad();
       } else {
         showTagsDialog();
       }
       return true;
     case R.id.refresh:
       item.setActionView(R.layout.ab_loading);
       item.expandActionView();
       refreshFragment();
       return true;
     default:
       return true;
   }
 }
  @Override
  public void onRestoreInstanceState(Parcelable p) {
    SavedState state = (SavedState) p;

    super.onRestoreInstanceState(state.getSuperState());

    if (state.expandedMenuItemId != 0 && mExpandedMenuPresenter != null && mOptionsMenu != null) {
      final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId);
      if (item != null) {
        item.expandActionView();
      }
    }

    if (state.isOverflowOpen) {
      postShowOverflowMenu();
    }
  }
 public static void setActionBarLoading(MenuItem refreshButton) {
   if (refreshButton != null) {
     refreshButton.setActionView(R.layout.actionbar_progressbar_circle);
     refreshButton.expandActionView();
   }
 }