コード例 #1
0
  @Override
  public void onItemSelected(MovieComplete movie) {
    this.movie = movie;

    // FRAGMENT 2
    detailFragment =
        (DetailFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame2);
    if (detailFragment == null) {
      detailFragment = DetailFragment.newInstance();
      ActivityUtils.addFragmentToActivity(
          getSupportFragmentManager(), detailFragment, R.id.contentFrame2);
    } else {
      detailFragment = DetailFragment.newInstance();
      ActivityUtils.replaceFragmentToActivity(
          getSupportFragmentManager(), detailFragment, R.id.contentFrame2);
    }
    detailPresenter = new DetailPresenter(detailFragment);
    detailPresenter.setCompleteMovie(movie);
    detailFragment.setPresenter(detailPresenter);
  }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setUpAnimation();
    setContentView(R.layout.activity_full_list);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.popular_title);

    ActionBarDrawerToggle mDrawerToggle =
        new ActionBarDrawerToggle(
            this,
            mDrawerLayout,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    mDrawerToggle.syncState();

    navigationView.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.accueil:
                Intent intentAcceuil = new Intent(getApplicationContext(), AccueilActivity.class);
                startActivity(intentAcceuil);
                break;
              case R.id.search:
                Intent intentSearch = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intentSearch);
                break;
              case R.id.favorite:
                Intent intentFavorite = new Intent(getApplicationContext(), FavoriteActivity.class);
                startActivity(intentFavorite);
                break;
              default:
                break;
            }
            item.setChecked(true);
            mDrawerLayout.closeDrawers();
            return true;
          }
        });

    // Test de la taille de l'écran
    if (is_720) {
      // FRAGMENT 1
      FullListFragment fragment =
          (FullListFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame1);
      if (fragment == null) {
        fragment = FullListFragment.newInstance();
        ActivityUtils.addFragmentToActivity(
            getSupportFragmentManager(), fragment, R.id.contentFrame1);
      }
      // Create the popularPresenter
      popularPresenter = new FullListPresenter(fragment);
      // attached the popularPresenter to the fragment
      fragment.setPresenter(popularPresenter);
    } else {
      FullListFragment fragment =
          (FullListFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
      if (fragment == null) {
        fragment = FullListFragment.newInstance();
        ActivityUtils.addFragmentToActivity(
            getSupportFragmentManager(), fragment, R.id.contentFrame);
      }
      // Create the popularPresenter
      popularPresenter = new FullListPresenter(fragment);
      // attached the popularPresenter to the fragment
      fragment.setPresenter(popularPresenter);
    }
  }
コード例 #3
0
 @Override
 protected void onPause() {
   super.onPause();
   if (is_720) ActivityUtils.removeFragment(getSupportFragmentManager(), detailFragment);
 }