mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Renamed DownloaderTracker to DownloaderManager
This commit is contained in:
parent
134d4e33e5
commit
e4d09f3bc0
4 changed files with 14 additions and 13 deletions
|
|
@ -28,7 +28,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
public class DownloaderTracker {
|
public class DownloaderManager {
|
||||||
private static final String TAG = "DownloadTracker";
|
private static final String TAG = "DownloadTracker";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
@ -41,7 +41,7 @@ public class DownloaderTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
@SuppressLint("UnsafeOptInUsageError")
|
||||||
public DownloaderTracker(Context context, DownloadManager downloadManager) {
|
public DownloaderManager(Context context, DownloadManager downloadManager) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
|
|
||||||
listeners = new CopyOnWriteArraySet<>();
|
listeners = new CopyOnWriteArraySet<>();
|
||||||
|
|
@ -18,6 +18,7 @@ import androidx.media3.session.MediaSession;
|
||||||
|
|
||||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||||
import com.cappielloantonio.play.util.DownloadUtil;
|
import com.cappielloantonio.play.util.DownloadUtil;
|
||||||
|
import com.google.android.gms.cast.framework.CastContext;
|
||||||
|
|
||||||
public class MediaService extends MediaLibraryService {
|
public class MediaService extends MediaLibraryService {
|
||||||
private static final String TAG = "MediaService";
|
private static final String TAG = "MediaService";
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,16 @@ import androidx.media3.session.SessionToken;
|
||||||
|
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
import com.cappielloantonio.play.service.DownloaderService;
|
import com.cappielloantonio.play.service.DownloaderService;
|
||||||
import com.cappielloantonio.play.service.DownloaderTracker;
|
import com.cappielloantonio.play.service.DownloaderManager;
|
||||||
import com.cappielloantonio.play.service.MediaService;
|
import com.cappielloantonio.play.service.MediaService;
|
||||||
import com.cappielloantonio.play.util.DownloadUtil;
|
import com.cappielloantonio.play.util.DownloadUtil;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
public class BaseActivity extends AppCompatActivity implements DownloaderTracker.Listener {
|
public class BaseActivity extends AppCompatActivity implements DownloaderManager.Listener {
|
||||||
private static final String TAG = "BaseActivity";
|
private static final String TAG = "BaseActivity";
|
||||||
|
|
||||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||||
private DownloaderTracker downloaderTracker;
|
private DownloaderManager downloaderManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
|
@ -102,7 +102,7 @@ public class BaseActivity extends AppCompatActivity implements DownloaderTracker
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
@SuppressLint("UnsafeOptInUsageError")
|
||||||
private void initializeDownloader() {
|
private void initializeDownloader() {
|
||||||
downloaderTracker = DownloadUtil.getDownloadTracker(this);
|
downloaderManager = DownloadUtil.getDownloadTracker(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DownloadService.start(this, DownloaderService.class);
|
DownloadService.start(this, DownloaderService.class);
|
||||||
|
|
@ -112,10 +112,10 @@ public class BaseActivity extends AppCompatActivity implements DownloaderTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDownloadListener() {
|
private void addDownloadListener() {
|
||||||
downloaderTracker.addListener(this);
|
downloaderManager.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDownloadListener() {
|
private void removeDownloadListener() {
|
||||||
downloaderTracker.removeListener(this);
|
downloaderManager.removeListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import androidx.media3.exoplayer.offline.DefaultDownloadIndex;
|
||||||
import androidx.media3.exoplayer.offline.DownloadManager;
|
import androidx.media3.exoplayer.offline.DownloadManager;
|
||||||
import androidx.media3.exoplayer.offline.DownloadNotificationHelper;
|
import androidx.media3.exoplayer.offline.DownloadNotificationHelper;
|
||||||
|
|
||||||
import com.cappielloantonio.play.service.DownloaderTracker;
|
import com.cappielloantonio.play.service.DownloaderManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -43,7 +43,7 @@ public final class DownloadUtil {
|
||||||
private static File downloadDirectory;
|
private static File downloadDirectory;
|
||||||
private static Cache downloadCache;
|
private static Cache downloadCache;
|
||||||
private static DownloadManager downloadManager;
|
private static DownloadManager downloadManager;
|
||||||
private static DownloaderTracker downloaderTracker;
|
private static DownloaderManager downloaderManager;
|
||||||
private static DownloadNotificationHelper downloadNotificationHelper;
|
private static DownloadNotificationHelper downloadNotificationHelper;
|
||||||
|
|
||||||
public static synchronized HttpDataSource.Factory getHttpDataSourceFactory() {
|
public static synchronized HttpDataSource.Factory getHttpDataSourceFactory() {
|
||||||
|
|
@ -81,9 +81,9 @@ public final class DownloadUtil {
|
||||||
return downloadManager;
|
return downloadManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized DownloaderTracker getDownloadTracker(Context context) {
|
public static synchronized DownloaderManager getDownloadTracker(Context context) {
|
||||||
ensureDownloadManagerInitialized(context);
|
ensureDownloadManagerInitialized(context);
|
||||||
return downloaderTracker;
|
return downloaderManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
@SuppressLint("UnsafeOptInUsageError")
|
||||||
|
|
@ -103,7 +103,7 @@ public final class DownloadUtil {
|
||||||
upgradeActionFile(context, DOWNLOAD_ACTION_FILE, downloadIndex, false);
|
upgradeActionFile(context, DOWNLOAD_ACTION_FILE, downloadIndex, false);
|
||||||
upgradeActionFile(context, DOWNLOAD_TRACKER_ACTION_FILE, downloadIndex, true);
|
upgradeActionFile(context, DOWNLOAD_TRACKER_ACTION_FILE, downloadIndex, true);
|
||||||
downloadManager = new DownloadManager(context, getDatabaseProvider(context), getDownloadCache(context), getHttpDataSourceFactory(), Executors.newFixedThreadPool(6));
|
downloadManager = new DownloadManager(context, getDatabaseProvider(context), getDownloadCache(context), getHttpDataSourceFactory(), Executors.newFixedThreadPool(6));
|
||||||
downloaderTracker = new DownloaderTracker(context, downloadManager);
|
downloaderManager = new DownloaderManager(context, downloadManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue