예제 #1
0
  public void setupStreamList(final List<VideoStream> videoStreams) {
    if (activity != null) {
      selectedVideoStream = 0;

      // this array will be shown in the dropdown menu for selecting the stream/resolution.
      String[] itemArray = new String[videoStreams.size()];
      for (int i = 0; i < videoStreams.size(); i++) {
        VideoStream item = videoStreams.get(i);
        itemArray[i] = MediaFormat.getNameById(item.format) + " " + item.resolution;
      }
      int defaultResolution = getDefaultResolution(videoStreams);

      ArrayAdapter<String> itemAdapter =
          new ArrayAdapter<>(
              activity.getBaseContext(), android.R.layout.simple_spinner_dropdown_item, itemArray);

      ActionBar ab = activity.getSupportActionBar();
      // todo: make this throwsable
      assert ab != null : "Could not get actionbar";
      ab.setListNavigationCallbacks(
          itemAdapter,
          new ActionBar.OnNavigationListener() {
            @Override
            public boolean onNavigationItemSelected(int itemPosition, long itemId) {
              selectedVideoStream = (int) itemId;
              return true;
            }
          });

      ab.setSelectedNavigationItem(defaultResolution);
    }
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mDatabaseHelper = new DatabaseHelper(getActivity().getApplicationContext());

    checkIfDatabaseExist();

    setHasOptionsMenu(true);

    ActionBar actionBar = ((ActionBarActivity) this.getActivity()).getSupportActionBar();

    if (actionBar != null) {
      SpinnerAdapter mSpinnerAdapter =
          ArrayAdapter.createFromResource(
              this.getActivity().getApplicationContext(),
              R.array.event_types_items,
              android.R.layout.simple_spinner_dropdown_item);

      actionBar.setListNavigationCallbacks(
          mSpinnerAdapter,
          new ActionBar.OnNavigationListener() {
            @Override
            public boolean onNavigationItemSelected(int position, long itemId) {

              ProgressDialog progressDialog = new ProgressDialog(getActivity());
              progressDialog.setMessage(getString(R.string.update));
              progressDialog.show();

              FragmentTransaction ft = getFragmentManager().beginTransaction();

              Bundle bundle = new Bundle();
              bundle.putInt(Constant.EXPLORER_SESSION_TYPE, position);

              ExplorerViewPagerFragment explorerViewPagerFragment = new ExplorerViewPagerFragment();
              explorerViewPagerFragment.setArguments(bundle);

              ft.replace(R.id.explorer_content, explorerViewPagerFragment);

              ft.commit();

              if (progressDialog.isShowing()) {
                progressDialog.dismiss();
              }

              return true;
            }
          });

      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setTitle("");
    }

    // generateFakes();
  }
  private void showFullUI(boolean fullUI) {
    mFullUI = fullUI;
    final ActionBar actionBar = getSupportActionBar();
    final FragmentManager fm = getSupportFragmentManager();

    if (fullUI) {
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setListNavigationCallbacks(mActionBarSpinnerAdapter, this);
      fm.beginTransaction().show(fm.findFragmentById(R.id.fragment_tracks_dropdown)).commit();
    } else {
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
      actionBar.setDisplayShowTitleEnabled(true);

      fm.beginTransaction().hide(fm.findFragmentById(R.id.fragment_tracks_dropdown)).commit();
    }
  }
예제 #4
0
  private void setActionBarNavigationList() {
    String[] array = getResources().getStringArray(R.array.manille_array);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    array[1] =
        String.format(
            array[1],
            Integer.parseInt(preferences.getString("score", getString(R.string.default_score))));
    array[2] =
        String.format(
            array[2],
            Integer.parseInt(preferences.getString("turns", getString(R.string.default_turns))));

    SpinnerAdapter mSpinnerAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, array);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    actionBar.setListNavigationCallbacks(mSpinnerAdapter, this);
  }
예제 #5
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      SpinnerAdapter spinnerAdapter =
          ArrayAdapter.createFromResource(
              actionBar.getThemedContext(),
              R.array.video_categories,
              android.R.layout.simple_spinner_dropdown_item);

      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setListNavigationCallbacks(spinnerAdapter, this);

      actionBar.setSelectedNavigationItem(spinnerSelectedValue);
    }

    subsDrawerToggle.syncState();
  }
  @TargetApi(11)
  private void setNavigation() {

    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    categoryAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strs);
    OnNavigationListener callback =
        new OnNavigationListener() {

          @Override
          public boolean onNavigationItemSelected(int itemPosition, long itemId) {
            TopiclistContainer f1 =
                (TopiclistContainer) getSupportFragmentManager().findFragmentById(R.id.item_list);
            if (f1 != null) {
              f1.onCategoryChanged(itemPosition);
            }
            return true;
          }
        };
    actionBar.setListNavigationCallbacks(categoryAdapter, callback);
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    detailsContainer = (FrameLayout) getActivity().findViewById(R.id.details_fragment_container);
    isDualPane = detailsContainer != null && detailsContainer.getVisibility() == View.VISIBLE;

    adapter = new AlarmAdapter(getActivity(), null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    getListView().setAdapter(adapter);

    TextView emptyText = (TextView) getActivity().findViewById(R.id.empty_list_text);
    emptyText.setText(getString(R.string.alarms_list_empty));

    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    SpinnerAdapter mSpinnerAdapter =
        ArrayAdapter.createFromResource(
            getActivity(),
            R.array.alarms_action_list,
            android.R.layout.simple_spinner_dropdown_item);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, this);
  }
예제 #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar to show a dropdown list.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(
        // Specify a SpinnerAdapter to populate the dropdown list.
        new ArrayAdapter<String>(
            actionBar.getThemedContext(),
            android.R.layout.simple_list_item_1,
            android.R.id.text1,
            new String[] {
              getString(R.string.title_section1),
              getString(R.string.title_section2),
              getString(R.string.title_section3),
            }),
        this);
  }
  /**
   * Manages the list of connected players in the action bar.
   *
   * @param players A list of players to show. May be empty (use {@code
   *     Collections.&lt;Player>emptyList()}) but not null.
   * @param activePlayer The currently active player. May be null.
   */
  @UiThread
  private void updatePlayerDropDown(
      @NonNull Collection<Player> players, @Nullable Player activePlayer) {
    if (!isAdded()) {
      return;
    }

    // Only include players that are connected to the server.
    ArrayList<Player> connectedPlayers = new ArrayList<Player>();
    for (Player player : players) {
      if (player.getConnected()) {
        connectedPlayers.add(player);
      }
    }

    ActionBar actionBar = mActivity.getSupportActionBar();

    // If there are multiple players connected then show a spinner allowing the user to
    // choose between them.
    if (connectedPlayers.size() > 1) {
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
      final ArrayAdapter<Player> playerAdapter =
          new ArrayAdapter<Player>(
              actionBar.getThemedContext(),
              android.R.layout.simple_spinner_dropdown_item,
              connectedPlayers) {
            @Override
            public View getDropDownView(int position, View convertView, ViewGroup parent) {
              return Util.getActionBarSpinnerItemView(
                  getContext(), convertView, parent, getItem(position).getName());
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
              return Util.getActionBarSpinnerItemView(
                  getContext(), convertView, parent, getItem(position).getName());
            }
          };
      actionBar.setListNavigationCallbacks(
          playerAdapter,
          new ActionBar.OnNavigationListener() {
            @Override
            public boolean onNavigationItemSelected(int position, long id) {
              if (!playerAdapter.getItem(position).equals(mService.getActivePlayer())) {
                Log.i(
                    TAG,
                    "onNavigationItemSelected.setActivePlayer("
                        + playerAdapter.getItem(position)
                        + ")");
                mService.setActivePlayer(playerAdapter.getItem(position));
                updateUiFromPlayerState(mService.getActivePlayerState());
              }
              return true;
            }
          });
      if (activePlayer != null) {
        actionBar.setSelectedNavigationItem(playerAdapter.getPosition(activePlayer));
      }
    } else {
      // 0 or 1 players, disable the spinner, and either show the sole player in the
      // action bar, or the app name if there are no players.
      actionBar.setDisplayShowTitleEnabled(true);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

      if (connectedPlayers.size() == 1) {
        actionBar.setTitle(connectedPlayers.get(0).getName());
      } else {
        // TODO: Alert the user if there are no connected players.
        actionBar.setTitle(R.string.app_name);
      }
    }
  }