Exemplo n.º 1
0
  @Override
  public boolean onNavigationItemSelected(int itemPosition, long itemId) {
    spinnerSelectedValue = itemPosition;

    LoadingProgressBar.get().setProgressBar(progressBar);

    // set/change the video category
    videoGridAdapter.setVideoCategory(VideoCategory.getVideoCategory(itemPosition));

    return true; // true means event was handled
  }
Exemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_videos_grid, container, false);

    // set up the loading progress bar
    this.progressBar = view.findViewById(R.id.loading_progress_bar);

    // setup the video grid view
    this.gridView = (RecyclerView) view.findViewById(R.id.grid_view);
    if (this.videoGridAdapter == null) {
      this.videoGridAdapter = new VideoGridAdapter(getActivity());
    }
    videoGridAdapter.setListener((MainActivityListener) getActivity());
    this.gridView.setLayoutManager(
        new GridLayoutManager(
            getActivity(), getResources().getInteger(R.integer.video_grid_num_columns)));
    this.gridView.setAdapter(this.videoGridAdapter);

    // setup the toolbar / actionbar
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.activity_main_toolbar);
    setSupportActionBar(toolbar);

    // indicate that this fragment has an action bar menu
    setHasOptionsMenu(true);

    DrawerLayout subsDrawerLayout = (DrawerLayout) view.findViewById(R.id.subs_drawer_layout);
    subsDrawerToggle =
        new ActionBarDrawerToggle(
            getActivity(), subsDrawerLayout, R.string.app_name, R.string.app_name);
    subsDrawerToggle.setDrawerIndicatorEnabled(true);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setHomeButtonEnabled(true);
    }

    this.subsListView = (RecyclerView) view.findViewById(R.id.subs_drawer);
    if (subsAdapter == null) {
      this.subsAdapter =
          SubsAdapter.get(getActivity(), view.findViewById(R.id.subs_drawer_progress_bar));
    }
    subsAdapter.setListener((MainActivityListener) getActivity());

    this.subsListView.setLayoutManager(new LinearLayoutManager(getActivity()));
    this.subsListView.setAdapter(this.subsAdapter);
    return view;
  }