Skip to content

Commit

Permalink
housekeeping: reorganize 2 classes into different java packages
Browse files Browse the repository at this point in the history
keep all exoplayer2 customizations together for better reusability
  • Loading branch information
warren-bank committed Mar 30, 2020
1 parent 827d102 commit 620c432
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.github.warren_bank.exoplayer_airplay_receiver.service;
package com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2;

import com.github.warren_bank.exoplayer_airplay_receiver.R;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.PlayerManager;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.VideoSource;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.SetPlayer;
import com.github.warren_bank.exoplayer_airplay_receiver.ui.VideoPlayerActivity;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.customizations.MyPlayerNotificationManager;
import com.github.warren_bank.exoplayer_airplay_receiver.utils.ResourceUtils;

import com.google.android.exoplayer2.Player;
Expand All @@ -30,17 +27,19 @@

import java.net.URI;

public class MyPlayerNotificationManagerContainer implements SetPlayer {
public class PlayerNotificationManagerContainer implements SetPlayer {
private Context context;
private PlayerManager playerManager;
private Class<?> pendingIntentActivityClass;

private MyPlayerNotificationManager playerNotificationManager;
private MediaSessionCompat mediaSession;
private MediaSessionConnector mediaSessionConnector;

public MyPlayerNotificationManagerContainer(Context context, PlayerManager playerManager) {
this.context = context;
this.playerManager = playerManager;
public PlayerNotificationManagerContainer(Context context, PlayerManager playerManager, @Nullable Class<?> pendingIntentActivityClass) {
this.context = context;
this.playerManager = playerManager;
this.pendingIntentActivityClass = pendingIntentActivityClass;

playerNotificationManager = MyPlayerNotificationManager.createWithNotificationChannel(
playerManager,
Expand All @@ -54,7 +53,9 @@ public MyPlayerNotificationManagerContainer(Context context, PlayerManager playe
@Nullable
@Override
public PendingIntent createCurrentContentIntent(Player player){
Intent intent = new Intent(context, VideoPlayerActivity.class);
if (pendingIntentActivityClass == null) return null;

Intent intent = new Intent(context, pendingIntentActivityClass);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.warren_bank.exoplayer_airplay_receiver.service;
package com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.customizations;

import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.PlayerManager;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.VideoSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.github.warren_bank.exoplayer_airplay_receiver.R;
import com.github.warren_bank.exoplayer_airplay_receiver.MainApp;
import com.github.warren_bank.exoplayer_airplay_receiver.constant.Constant;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.PlayerNotificationManagerContainer;
import com.github.warren_bank.exoplayer_airplay_receiver.exoplayer2.PlayerManager;
import com.github.warren_bank.exoplayer_airplay_receiver.httpcore.RequestListenerThread;
import com.github.warren_bank.exoplayer_airplay_receiver.ui.VideoPlayerActivity;
import com.github.warren_bank.exoplayer_airplay_receiver.utils.NetworkUtils;
import com.github.warren_bank.exoplayer_airplay_receiver.utils.ResourceUtils;
import com.github.warren_bank.exoplayer_airplay_receiver.utils.WakeLockMgr;
Expand Down Expand Up @@ -39,7 +41,7 @@ public class NetworkingService extends Service {

private static PlayerManager playerManager = null;

private MyPlayerNotificationManagerContainer playerNotificationManager;
private PlayerNotificationManagerContainer playerNotificationManager;
private MyPlaybackStatusMonitor playbackStatusMonitor;
private String airplayName;
private MyMessageHandler handler;
Expand All @@ -57,8 +59,8 @@ public void onCreate() {
super.onCreate();
Log.d(tag, "onCreate");

playerManager = PlayerManager.createPlayerManager( /* context= */ NetworkingService.this);
playerNotificationManager = new MyPlayerNotificationManagerContainer(/* context= */ NetworkingService.this, playerManager);
playerManager = PlayerManager.createPlayerManager( /* context= */ NetworkingService.this);
playerNotificationManager = new PlayerNotificationManagerContainer(/* context= */ NetworkingService.this, playerManager, /* pendingIntentActivityClass= */ VideoPlayerActivity.class);
playbackStatusMonitor = new MyPlaybackStatusMonitor();
airplayName = Build.MODEL + "@" + getString(R.string.app_name);

Expand Down
4 changes: 2 additions & 2 deletions android-studio-project/constants.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext {
releaseVersionCode = Integer.parseInt("002000616", 10)
releaseVersion = '002.00.06-16API'
releaseVersionCode = Integer.parseInt("002000716", 10)
releaseVersion = '002.00.07-16API'
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
Expand Down

0 comments on commit 620c432

Please sign in to comment.