Ejemplo n.º 1
0
 // TODO
 public void setNavigationButton(boolean isArrow) {
   if (isArrow) {
     mActivity.getSupportActionBar().setDisplayShowHomeEnabled(false);
     mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back);
   } else {
     mActivity.getSupportActionBar().setDisplayShowHomeEnabled(true); // SHOW LOGO ICON
     mToolbar.setNavigationIcon(R.mipmap.ic_launcher);
   }
 }
Ejemplo n.º 2
0
  private void invalidateSubtitle(MediaEntry[] entries) {
    AppCompatActivity act = (AppCompatActivity) getActivity();
    if (act != null) {
      final boolean toolbarStats =
          PreferenceManager.getDefaultSharedPreferences(act)
              .getBoolean("toolbar_album_stats", true);
      if (toolbarStats) {
        if (entries == null || entries.length == 0) {
          act.getSupportActionBar().setSubtitle(getString(R.string.empty));
          return;
        }

        int folderCount = 0;
        int albumCount = 0;
        int videoCount = 0;
        int photoCount = 0;
        for (MediaEntry e : entries) {
          if (e.isFolder()) folderCount++;
          else if (e.isAlbum()) albumCount++;
          else if (e.isVideo()) videoCount++;
          else photoCount++;
        }
        final StringBuilder sb = new StringBuilder();
        if (albumCount > 1) {
          sb.append(getString(R.string.x_albums, albumCount));
        } else if (albumCount == 1) {
          sb.append(getString(R.string.one_album));
        }
        if (folderCount > 1) {
          if (sb.length() > 0) sb.append(", ");
          sb.append(getString(R.string.x_folders, folderCount));
        } else if (folderCount == 1) {
          if (sb.length() > 0) sb.append(", ");
          sb.append(getString(R.string.one_folder));
        }
        if (photoCount > 1) {
          if (sb.length() > 0) sb.append(", ");
          sb.append(getString(R.string.x_photos, photoCount));
        } else if (photoCount == 1) {
          if (sb.length() > 0) sb.append(", ");
          sb.append(getString(R.string.one_photo));
        }
        if (videoCount > 1) {
          if (sb.length() > 0) sb.append(", ");
          sb.append(getString(R.string.x_videos, videoCount));
        } else if (videoCount == 1) {
          if (sb.length() > 0) sb.append(", ");
          sb.append(getString(R.string.one_video));
        }
        act.getSupportActionBar().setSubtitle(sb.toString());
      } else {
        act.getSupportActionBar().setSubtitle(null);
      }
    }
  }
Ejemplo n.º 3
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);
    }
  }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   mMenu = menu;
   if (!appState.getTwoPane()) {
     Utility.makeMenuItemInvisible(mMenu, R.id.action_settings);
     // for crate home button
     AppCompatActivity activity = (AppCompatActivity) getActivity();
     activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
     activity.getSupportActionBar().setTitle("MovieDetail");
   } else {
     AppCompatActivity activity = (AppCompatActivity) getActivity();
     activity.getSupportActionBar().setTitle("Pop Movies");
   }
   shareMenuItem = menu.findItem(R.id.action_share);
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);
 }
  // ****************************************************************
  // * Constructors
  // ****************************************************************
  public GroupCreateActivityViewHolder(
      Context context, IFragmentController fragmentController, View view) {
    super(context, fragmentController, view);
    try {
      AppCompatActivity activity = (AppCompatActivity) context;

      Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
      activity.setSupportActionBar(toolbar);
      final ActionBar actionBar = activity.getSupportActionBar();
      actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      fragmentManager = activity.getSupportFragmentManager();
      groupCreateFragment =
          (GroupCreateFragment) fragmentManager.findFragmentById(R.id.groupCreateFragment);
      groupCreateChoosePrivacyFragment =
          (GroupCreateChoosePrivacyFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChoosePrivacyFragment);
      groupCreateChooseIconFragment =
          (GroupCreateChooseIconFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChooseIconFragment);
      progressBar = (RelativeLayout) view.findViewById(R.id.progressBar);

      title = (TextView) view.findViewById(R.id.toolbarTitle);
      initialize(context);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 6
0
 public CustomViewPagerAdapter(AppCompatActivity activity, ViewPager pager) {
   super(activity.getFragmentManager());
   mContext = activity;
   mActionBar = activity.getSupportActionBar();
   mViewPager = pager;
   mViewPager.setAdapter(this);
   mViewPager.setOnPageChangeListener(this);
 }
Ejemplo n.º 7
0
 @SuppressWarnings({"deprecation", "ConstantConditions"})
 public void setupNavMenu(AppCompatActivity activity) {
   this.activity = activity;
   try {
     activity.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
   } catch (NullPointerException e) {
     e.printStackTrace();
   }
 }
  /** Set the subtitle of the toolbar. */
  private void updateSubtitle() {
    CrimeLab crimeLab = CrimeLab.getInstance(getActivity());
    int crimeCount = crimeLab.getCrimes().size();
    String subtitle = getString(R.string.subtitle_format, crimeCount);

    if (!mSubtitleVisible) {
      subtitle = null;
    }

    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.getSupportActionBar().setSubtitle(subtitle);
  }
  /** update the subtitle of the crime when called from onOptionsItemSelected() */
  private void updateSubtitle() {
    CrimeLab crimeLab = CrimeLab.get(getActivity());
    int crimeCount = crimeLab.getCrimes().size();
    String subtitle =
        getResources().getQuantityString(R.plurals.subtitle_plural, crimeCount, crimeCount);

    // when subtitle is set to invisible clear the subtitle
    if (!mSubtitleVisible) subtitle = null;

    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.getSupportActionBar().setSubtitle(subtitle);
  }
Ejemplo n.º 10
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);

    if (mToolbar != null) {

      AppCompatActivity activity = ((AppCompatActivity) getActivity());
      activity.setSupportActionBar(mToolbar);
      activity.getSupportActionBar().setHomeButtonEnabled(true);
      activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
  }
Ejemplo n.º 11
0
  private void updateTitle(@NonNull final String title) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();

    if (activity != null) {
      final ActionBar actionBar = activity.getSupportActionBar();

      if (actionBar == null) {
        return;
      }

      actionBar.setTitle(title);
    }
  }
 private void initViewToolbar(View rootView) {
   mToolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
   AppCompatActivity activity = ((AppCompatActivity) getActivity());
   if (activity != null) {
     activity.setSupportActionBar(mToolbar);
     ActionBar actionBar = activity.getSupportActionBar();
     if (actionBar != null) {
       actionBar.setDisplayHomeAsUpEnabled(true);
       actionBar.setDisplayShowHomeEnabled(true);
       actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
       actionBar.setTitle(R.string.title_add_new_condition);
     }
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false);
    mPhotoView = (ImageView) mRootView.findViewById(R.id.photo);

    Toolbar toolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    bindViews();

    return mRootView;
  }
Ejemplo n.º 14
0
 public static void onPanelMenuCreated(int featureId, Menu menu, AppCompatActivity activity) {
   if (featureId == Window.FEATURE_OPTIONS_PANEL) {
     Context context = activity.getSupportActionBar().getThemedContext();
     ColorStateList menuTintList =
         ViewUtils.getColorStateListFromAttrRes(R.attr.colorControlNormal, context);
     int popupThemeResId = ViewUtils.getResIdFromAttrRes(R.attr.popupTheme, 0, context);
     ColorStateList subMenuTintList;
     if (popupThemeResId != 0) {
       Context popupContext = new ContextThemeWrapper(context, popupThemeResId);
       subMenuTintList =
           ViewUtils.getColorStateListFromAttrRes(R.attr.colorControlNormal, popupContext);
     } else {
       subMenuTintList = menuTintList;
     }
     tintMenuItemIcon(menu, menuTintList, subMenuTintList);
   }
 }
Ejemplo n.º 15
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_view_photo, container, false);
    ButterKnife.bind(this, view);
    activity.setSupportActionBar(toolbarViewPicture);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toolbarViewPicture.setNavigationOnClickListener(
        view -> {
          FragmentManager fm = getActivity().getSupportFragmentManager();
          fm.popBackStack();
        });

    return view;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false);

    setHasOptionsMenu(true);

    Toolbar toolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);
    AppCompatActivity activity = ((AppCompatActivity) getActivity());
    activity.setSupportActionBar(toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowHomeEnabled(true);

    } else {
      Log.e(TAG, "Missing actionbar!");
    }

    mPhotoView = (ImageView) mRootView.findViewById(R.id.ivPhoto);

    mRootView
        .findViewById(R.id.share_fab)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                startActivity(
                    Intent.createChooser(
                        ShareCompat.IntentBuilder.from(getActivity())
                            .setType("text/plain")
                            .setText("Some sample text")
                            .getIntent(),
                        getString(R.string.action_share)));
              }
            });

    bindViews();
    return mRootView;
  }
Ejemplo n.º 17
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ActivitiesFragmentBinding binding =
        DataBindingUtil.inflate(inflater, R.layout.activities_fragment, container, false);
    binding.setCategory(category);

    Toolbar toolbar = binding.toolbar;
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    assert activity.getSupportActionBar() != null;
    final ActionBar ab = activity.getSupportActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setDisplayHomeAsUpEnabled(false);

    Spinner spinner = binding.spinner;
    spinner.setAdapter(
        new ArrayAdapter<>(
            ab.getThemedContext(), android.R.layout.simple_spinner_item, localizedCategory));
    spinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (currentCategory != position) {
              currentCategory = position;
              category.set(localizedCategory[currentCategory]);
              activities.clear();
              list.getAdapter().notifyDataSetChanged();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });

    slider = binding.slider;
    slider.setCustomIndicator(binding.customIndicator);
    slider.setDuration(3500);
    slider.setPresetTransformer(SliderLayout.Transformer.Fade);
    api.getActivities("recommendations", 0, 5)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(
            new Action1<List<Activity>>() {
              @Override
              public void call(List<Activity> activities) {
                slider.stopAutoCycle();
                slider.removeAllSliders();
                for (Activity activity : activities) {
                  ActivitySliderView view = new ActivitySliderView(getContext(), activity);
                  view.bundle(new Bundle());
                  view.getBundle().putLong("id", activity.getId());
                  view.setOnSliderClickListener(sliderClickListener);
                  slider.addSlider(view);
                }
                slider.startAutoCycle();
              }
            },
            new Action1<Throwable>() {
              @Override
              public void call(Throwable throwable) {
                Timber.e("failed to fetch recommended activities", throwable);
                throwable.printStackTrace();
              }
            });

    list = binding.list;
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    list.setLayoutManager(linearLayoutManager);
    list.addItemDecoration(new MarginDownDecoration(getContext()));
    list.setAdapter(new ActivitiesAdapter(activities));
    list.addOnScrollListener(
        new EndlessRecyclerOnScrollListener(linearLayoutManager) {
          @Override
          public void onLoadMore(int currentPage) {
            loadPage(currentPage);
          }
        });

    // loadPage(0);

    return binding.getRoot();
  }
Ejemplo n.º 18
0
 public void setToolbarTitle(String title) {
   mActivity.getSupportActionBar().setTitle("  " + String.valueOf(title));
   mToolbar.setTitleTextColor(mActivity.getResources().getColor(android.R.color.white));
 }