1 package com.moiseum.wolnelektury.view.player;
3 import android.content.Context;
4 import android.os.Bundle;
6 import com.moiseum.wolnelektury.R;
7 import com.moiseum.wolnelektury.base.AbstractActivity;
8 import com.moiseum.wolnelektury.base.AbstractIntent;
9 import com.moiseum.wolnelektury.connection.models.BookDetailsModel;
11 import org.parceler.Parcels;
13 import static com.moiseum.wolnelektury.view.player.PlayerActivity.PlayerIntent.BOOK_KEY;
14 import static com.moiseum.wolnelektury.view.player.PlayerActivity.PlayerIntent.BOOK_SLUG_KEY;
17 * Created by Piotr Ostrowski on 22.05.2018.
19 public class PlayerActivity extends AbstractActivity {
21 private static final String PLAYER_FRAGMENT_TAG = "PlayerFragmentTag";
23 public static class PlayerIntent extends AbstractIntent {
25 static final String BOOK_KEY = "BookKey";
26 static final String BOOK_SLUG_KEY = "BookSlugKey";
28 public PlayerIntent(BookDetailsModel book, String slug, Context context) {
29 super(context, PlayerActivity.class);
30 putExtra(BOOK_KEY, Parcels.wrap(book));
31 putExtra(BOOK_SLUG_KEY, slug);
36 public int getLayoutResourceId() {
37 return R.layout.activity_blank;
41 public void prepareView(Bundle savedInstanceState) {
42 PlayerFragment playerFragment = (PlayerFragment) getSupportFragmentManager().findFragmentByTag(PLAYER_FRAGMENT_TAG);
43 if (playerFragment == null) {
44 playerFragment = PlayerFragment.newInstance(Parcels.unwrap(getIntent().getParcelableExtra(BOOK_KEY)), getIntent().getStringExtra(BOOK_SLUG_KEY));
45 getSupportFragmentManager().beginTransaction().add(R.id.flContainer, playerFragment, PLAYER_FRAGMENT_TAG).commit();