Prevent NPE
This commit is contained in:
parent
b1df272797
commit
4366e134cf
|
@ -139,7 +139,9 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe
|
|||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
drawerToggle.onConfigurationChanged(newConfig);
|
||||
if(drawerToggle != null) {
|
||||
drawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLastFragment() {
|
||||
|
@ -283,7 +285,10 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe
|
|||
}
|
||||
|
||||
public void notifyMediaPositionChanged() {
|
||||
ChaptersFragment chaptersFragment = mPagerAdapter.getChaptersFragment();
|
||||
if(pagerAdapter == null) {
|
||||
return;
|
||||
}
|
||||
ChaptersFragment chaptersFragment = pagerAdapter.getChaptersFragment();
|
||||
if(chaptersFragment != null) {
|
||||
ChaptersListAdapter adapter = (ChaptersListAdapter) chaptersFragment.getListAdapter();
|
||||
if (adapter != null) {
|
||||
|
|
|
@ -206,8 +206,10 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
controller.reinitServiceIfPaused();
|
||||
controller.pause();
|
||||
if(controller != null) {
|
||||
controller.reinitServiceIfPaused();
|
||||
controller.pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -582,7 +584,9 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
super.onResume();
|
||||
Log.d(TAG, "onResume()");
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
controller.init();
|
||||
if(controller != null) {
|
||||
controller.init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -618,6 +622,9 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O
|
|||
|
||||
private void updateProgressbarPosition(int position, int duration) {
|
||||
Log.d(TAG, "updateProgressbarPosition(" + position + ", " + duration + ")");
|
||||
if(sbPosition == null) {
|
||||
return;
|
||||
}
|
||||
float progress = ((float) position) / duration;
|
||||
sbPosition.setProgress((int) (progress * sbPosition.getMax()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue