mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-02-09 08:11:19 -06:00
app: improve update checking
This commit is contained in:
Submodule MediaServiceCore updated: ca837d1ebf...0929b78952
@@ -113,6 +113,8 @@ public class BrowsePresenter extends BasePresenter<BrowseView> implements Sectio
|
||||
|
||||
@Override
|
||||
public void onViewInitialized() {
|
||||
super.onViewInitialized();
|
||||
|
||||
if (getView() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -123,8 +125,6 @@ public class BrowsePresenter extends BasePresenter<BrowseView> implements Sectio
|
||||
int selectedSectionIndex = findSectionIndex(mSelectedSectionId);
|
||||
mSelectedSectionId = -1;
|
||||
getView().selectSection(selectedSectionIndex != -1 ? selectedSectionIndex : mBootSectionIndex, true);
|
||||
showBootDialogs();
|
||||
Utils.updateRemoteControlService(getContext());
|
||||
}
|
||||
|
||||
private void initSections() {
|
||||
@@ -142,7 +142,7 @@ public class BrowsePresenter extends BasePresenter<BrowseView> implements Sectio
|
||||
|
||||
mSectionsMapping.put(MediaGroup.TYPE_HOME, new BrowseSection(MediaGroup.TYPE_HOME, getContext().getString(R.string.header_home), BrowseSection.TYPE_ROW, R.drawable.icon_home));
|
||||
mSectionsMapping.put(MediaGroup.TYPE_GAMING, new BrowseSection(MediaGroup.TYPE_GAMING, getContext().getString(R.string.header_gaming), BrowseSection.TYPE_ROW, R.drawable.icon_gaming));
|
||||
if (!Helpers.equalsAny(country, "RU")) {
|
||||
if (!Helpers.equalsAny(country, "RU", "BY")) {
|
||||
mSectionsMapping.put(MediaGroup.TYPE_NEWS, new BrowseSection(MediaGroup.TYPE_NEWS, getContext().getString(R.string.header_news), BrowseSection.TYPE_ROW, R.drawable.icon_news));
|
||||
}
|
||||
mSectionsMapping.put(MediaGroup.TYPE_MUSIC, new BrowseSection(MediaGroup.TYPE_MUSIC, getContext().getString(R.string.header_music), BrowseSection.TYPE_ROW, R.drawable.icon_music));
|
||||
@@ -478,12 +478,6 @@ public class BrowsePresenter extends BasePresenter<BrowseView> implements Sectio
|
||||
}
|
||||
}
|
||||
|
||||
private void showBootDialogs() {
|
||||
BootDialogPresenter updatePresenter = BootDialogPresenter.instance(getContext());
|
||||
updatePresenter.start();
|
||||
updatePresenter.unhold();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
if (mCurrentSection != null) {
|
||||
updateSection(mCurrentSection.getId());
|
||||
|
||||
@@ -6,6 +6,8 @@ import androidx.fragment.app.Fragment;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Playlist;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.data.VideoGroup;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.BrowsePresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.dialogs.BootDialogPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.interfaces.Presenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.views.BrowseView;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.views.ChannelUploadsView;
|
||||
@@ -24,6 +26,7 @@ public abstract class BasePresenter<T> implements Presenter<T> {
|
||||
private WeakReference<Context> mApplicationContext = new WeakReference<>(null);
|
||||
private Runnable mOnDone;
|
||||
private static boolean sRunOnce;
|
||||
private long mUpdateCheckMs;
|
||||
|
||||
public BasePresenter(Context context) {
|
||||
setContext(context);
|
||||
@@ -84,7 +87,7 @@ public abstract class BasePresenter<T> implements Presenter<T> {
|
||||
|
||||
@Override
|
||||
public void onViewInitialized() {
|
||||
// NOP
|
||||
showBootDialogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,6 +103,8 @@ public abstract class BasePresenter<T> implements Presenter<T> {
|
||||
// NOTE: don't place cleanup in the onViewResumed!!! This could cause errors when view is resumed.
|
||||
syncItem(Playlist.instance().getChangedItems());
|
||||
}
|
||||
|
||||
showBootDialogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,4 +189,16 @@ public abstract class BasePresenter<T> implements Presenter<T> {
|
||||
sSync = true;
|
||||
Playlist.instance().onNewSession();
|
||||
}
|
||||
|
||||
private void showBootDialogs() {
|
||||
long currentTimeMs = System.currentTimeMillis();
|
||||
|
||||
if (this instanceof BrowsePresenter && currentTimeMs - mUpdateCheckMs > 60 * 60 * 1_000) {
|
||||
BootDialogPresenter updatePresenter = BootDialogPresenter.instance(getContext());
|
||||
updatePresenter.start();
|
||||
updatePresenter.unhold();
|
||||
Utils.updateRemoteControlService(getContext());
|
||||
mUpdateCheckMs = currentTimeMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user