Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Lifecycle.State.STARTED instead of Lifecycle.State.INITIALIZED #2157

Merged
merged 1 commit into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public void onResume() {
//Re-retrieve anything that needs it but delay slightly so we don't take away gui landing
if (mAdapter != null) {
mHandler.postDelayed(() -> {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

if (mAdapter != null && mAdapter.size() > 0) {
if (!mAdapter.ReRetrieveIfNeeded()) {
Expand Down Expand Up @@ -730,7 +730,7 @@ public void onResponse() {
if (mAdapter.getTotalItems() == 0) {
binding.toolBar.requestFocus();
mHandler.postDelayed(() -> {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

binding.title.setText(mFolder.getName());
}, 500);
Expand Down Expand Up @@ -980,7 +980,7 @@ public void onItemClicked(final Presenter.ViewHolder itemViewHolder, Object item
private final Runnable mDelayedSetItem = new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

backgroundService.getValue().setBackground(mCurrentItem.getBaseItem());
setItem(mCurrentItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void onResponse(TimerInfoDtoResult response) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

mRowsFragment.setSelectedPosition(0, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void onResume() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

for (int i = 0; i < mRowsAdapter.size(); i++) {
if (mRowsAdapter.get(i) instanceof ListRow) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void onResponse(org.jellyfin.apiclient.model.livetv.SeriesTimerInfoDto re
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

addAdditionalRows(mRowsAdapter);

Expand Down Expand Up @@ -253,7 +253,7 @@ public void onResume() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

long lastPlaybackTime = dataRefreshService.getValue().getLastPlayback();
Timber.d("current time %s last playback event time %s last refresh time %s", System.currentTimeMillis(), lastPlaybackTime, mLastUpdated.getTimeInMillis());
Expand Down Expand Up @@ -331,7 +331,7 @@ private void startClock() {
mClockLoop = new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

if (mBaseItem != null && ((mBaseItem.getRunTimeTicks() != null && mBaseItem.getRunTimeTicks() > 0) || mBaseItem.getOriginalRunTimeTicks() != null)) {
mDorPresenter.getViewHolder().setInfoValue3(getEndTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void onResume() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

mItemList.refresh();
lastUpdated = Calendar.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ protected Void doInBackground(Integer... params) {
requireActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

GuideChannelHeader header = getChannelHeader(requireContext(), channel);
mChannels.addView(header);
Expand Down Expand Up @@ -755,7 +755,7 @@ private void fillTimeLine(long start, int hours) {
private Runnable detailUpdateTask = new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

if (mSelectedProgram.getOverview() == null && mSelectedProgram.getId() != null) {
KoinJavaComponent.<ApiClient>get(ApiClient.class).GetItemAsync(mSelectedProgram.getId(), KoinJavaComponent.<UserRepository>get(UserRepository.class).getCurrentUser().getValue().getId().toString(), new Response<BaseItemDto>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private void loadItem() {
mLoopHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

updateSSInfo();
}
Expand All @@ -452,7 +452,7 @@ private void updateButtons(final boolean playing) {
requireActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

mPoster.setKeepScreenOn(playing);
if (!playing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ private void fillTimeLine(int hours) {
private Runnable detailUpdateTask = new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

if (mSelectedProgram.getOverview() == null && mSelectedProgram.getId() != null) {
apiClient.getValue().GetItemAsync(mSelectedProgram.getId(), KoinJavaComponent.<UserRepository>get(UserRepository.class).getCurrentUser().getValue().getId().toString(), new Response<BaseItemDto>() {
Expand Down Expand Up @@ -1122,7 +1122,7 @@ public void onAnimationRepeat(Animation animation) {
public void showQuickChannelChanger() {
showChapterPanel();
mHandler.postDelayed(() -> {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

int ndx = TvManager.getAllChannelsIndex(TvManager.getLastLiveTvChannel());
if (ndx > 0) {
Expand All @@ -1135,7 +1135,7 @@ public void showQuickChannelChanger() {
public void showChapterSelector() {
showChapterPanel();
mHandler.postDelayed(() -> {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

int ndx = getCurrentChapterIndex(mPlaybackController.getCurrentlyPlayingItem(), mPlaybackController.getCurrentPosition() * 10000);
if (ndx > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private void startReportLoop() {
mReportLoop = new Runnable() {
@Override
public void run() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) return;
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;

ReportingHelper.reportProgress(playbackController, mItemsToPlay.get(mCurrentNdx), mCurrentStreamInfo, mPosition * RUNTIME_TICKS_TO_MS, false);
mHandler.postDelayed(this, 15000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.jellyfin.apiclient.interaction.EmptyResponse
abstract class EmptyLifecycleAwareResponse(
private val lifecycle: Lifecycle,
) : EmptyResponse() {
val active get() = lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)
val active get() = lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)

override fun triggerInnerResponse() {
if (!active) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.jellyfin.apiclient.interaction.Response
abstract class LifecycleAwareResponse<T>(
private val lifecycle: Lifecycle,
) : Response<T>() {
val active get() = lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)
val active get() = lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)

override fun triggerInnerResponse() {
if (!active) return
Expand Down