Skip to content

Commit

Permalink
VideoThumbManager > ThumbManager, fix typos, minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sadr0b0t committed Feb 5, 2023
1 parent b302e96 commit c1f5f69
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ updt: должно стать намного лучше после вот эти

Гуглу не нравится большое количество запросов с одного адреса, поэтому он включает режим рекапчи. Можно переключиться на другую сеть (например, выключить подключение вайфай и перейти на мобильный интернет) или подождать до конца текущего часа (или подождите час), когда Гугл снимет бан для наказанного адреса.

- НЕ ДЕЛАЙТЕ ДУНГРЕЙД на версию 0.1.0 (или ниже) после того, как обновились на старшую версию (начиная с 0.2.0). Потеряете все данные - добавленные плейлисты, историю просмотров, закладки и т.п.!
- НЕ ДЕЛАЙТЕ ДАУНГРЕЙД на версию 0.1.0 (или ниже) после того, как обновились на старшую версию (начиная с 0.2.0). Потеряете все данные - добавленные плейлисты, историю просмотров, закладки и т.п.!

Начиная с версии 0.2.0 эта проблема исправлена (на 0.2.0 можно будет делать безопасный даунгрейд, но не на 0.1.0!). Кроме того, версия 0.1.0 все равно больше не работает и никогда не заработает, т.к. Гугл в очередной раз поломал задействованный в ней API.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import su.sadrobot.yashlang.controller.PlaylistInfoActions;
import su.sadrobot.yashlang.controller.TaskController;
import su.sadrobot.yashlang.controller.VideoItemActions;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.VideoItem;
import su.sadrobot.yashlang.util.PlaylistUrlUtil;
Expand Down Expand Up @@ -462,7 +462,7 @@ public void run() {
_plInfo = ContentLoader.getInstance().getPlaylistInfo(plUrl);

// иконка канала
_plThumb = VideoThumbManager.getInstance().loadPlaylistThumb(
_plThumb = ThumbManager.getInstance().loadPlaylistThumb(
AddPlaylistActivity.this, _plInfo);
} catch (final Exception e) {
playlistLoadError = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.controller.VideoItemActions;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.VideoDatabase;
import su.sadrobot.yashlang.model.VideoItem;
Expand Down Expand Up @@ -220,7 +220,7 @@ public void run() {

// иконка плейлиста - может грузиться подольше, без интернета вообще не загрузится
try {
final Bitmap plThumb = VideoThumbManager.getInstance().loadPlaylistThumb(
final Bitmap plThumb = ThumbManager.getInstance().loadPlaylistThumb(
ConfigurePlaylistFragment.this.getContext(), plInfo);
plInfo.setThumbBitmap(plThumb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import su.sadrobot.yashlang.controller.ContentLoader;
import su.sadrobot.yashlang.controller.TaskController;
import su.sadrobot.yashlang.controller.VideoItemActions;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.VideoDatabase;
import su.sadrobot.yashlang.model.VideoItem;
Expand Down Expand Up @@ -408,7 +408,7 @@ public void run() {

// иконка плейлиста - может грузиться подольше, без интернета вообще не загрузится
try {
final Bitmap plThumb = VideoThumbManager.getInstance().loadPlaylistThumb(
final Bitmap plThumb = ThumbManager.getInstance().loadPlaylistThumb(
ConfigurePlaylistNewItemsFragment.this.getContext(), plInfo);
plInfo.setThumbBitmap(plThumb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import su.sadrobot.yashlang.controller.ContentLoader;
import su.sadrobot.yashlang.controller.TaskController;
import su.sadrobot.yashlang.controller.VideoItemActions;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.VideoDatabase;
import su.sadrobot.yashlang.model.VideoItem;
Expand Down Expand Up @@ -600,7 +600,7 @@ public void run() {
try {
// иконка канала
if (plInfo.getThumbBitmap() == null) {
final Bitmap _plThumb = VideoThumbManager.getInstance().loadPlaylistThumb(
final Bitmap _plThumb = ThumbManager.getInstance().loadPlaylistThumb(
ConfigurePlaylistsNewItemsFragment.this.getContext(), plInfo);
plInfo.setThumbBitmap(_plThumb);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
selResPos = 0;
}
}

vidStreamCustomResSpinner.setSelection(selResPos);
vidStreamCustomResSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import su.sadrobot.yashlang.controller.DataIO;
import su.sadrobot.yashlang.controller.PlaylistInfoActions;
import su.sadrobot.yashlang.controller.TaskController;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.VideoDatabase;
import su.sadrobot.yashlang.util.PlaylistUrlUtil;
Expand Down Expand Up @@ -430,7 +430,7 @@ public void run() {
try {
// иконка канала
if (plInfo.getThumbBitmap() == null) {
final Bitmap _plThumb = VideoThumbManager.getInstance().loadPlaylistThumb(
final Bitmap _plThumb = ThumbManager.getInstance().loadPlaylistThumb(
ImportPlaylistsActivity.this, plInfo);
plInfo.setThumbBitmap(_plThumb);
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/su/sadrobot/yashlang/PlaylistActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

import su.sadrobot.yashlang.controller.PlaylistInfoActions;
import su.sadrobot.yashlang.controller.VideoItemActions;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.VideoDatabase;
import su.sadrobot.yashlang.model.VideoItem;
Expand Down Expand Up @@ -384,7 +384,7 @@ public void run() {

// иконка плейлиста - может грузиться подольше, без интернета вообще не загрузится
try {
final Bitmap plThumb = VideoThumbManager.getInstance().loadPlaylistThumb(
final Bitmap plThumb = ThumbManager.getInstance().loadPlaylistThumb(
PlaylistActivity.this, plInfo);
plInfo.setThumbBitmap(plThumb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
import su.sadrobot.yashlang.controller.ContentLoader;
import su.sadrobot.yashlang.controller.StreamHelper;
import su.sadrobot.yashlang.controller.VideoItemActions;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.StreamCache;
import su.sadrobot.yashlang.model.VideoDatabase;
Expand Down Expand Up @@ -1465,7 +1465,7 @@ public void run() {
@Override
public void run() {
final Bitmap thumb =
VideoThumbManager.getInstance().loadVideoThumb(WatchVideoActivity.this, videoItem);
ThumbManager.getInstance().loadVideoThumb(WatchVideoActivity.this, videoItem);
videoItem.setThumbBitmap(thumb);
handler.post(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by Anton Moiseev (sadr0b0t) in 2019.
*
* Copyright (C) Anton Moiseev 2019 <github.com/sadr0b0t>
* VideoThumbManager.java is part of YaShlang.
* ThumbManager.java is part of YaShlang.
*
* YaShlang is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,16 +38,16 @@
import su.sadrobot.yashlang.model.VideoItem;
import su.sadrobot.yashlang.util.PlaylistUrlUtil;

public class VideoThumbManager {
private static VideoThumbManager _instance;
public class ThumbManager {
private static ThumbManager _instance;
static {
_instance = new VideoThumbManager();
_instance = new ThumbManager();
}

public static VideoThumbManager getInstance() {
public static ThumbManager getInstance() {
return _instance;
}
private VideoThumbManager() {
private ThumbManager() {
}

private Bitmap defaultVideoItemThumb;
Expand Down Expand Up @@ -198,7 +198,7 @@ public Bitmap loadPlaylistThumb(final Context context, final PlaylistInfo plInfo
return thumb;
}

public void loadThumbs(final Context context, final List<VideoItem> videoItems) {
public void loadVideoThumbs(final Context context, final List<VideoItem> videoItems) {
for (VideoItem videoItem : videoItems) {
final Bitmap thumb = loadVideoThumb(context, videoItem);
videoItem.setThumbBitmap(thumb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static void downloadStream(final Context context, final StreamCache strea
if (conn.getErrorStream() != null) {
// Сюда попадаем, если connection.getInputStream() вылетает с эксепшеном
// (на сервере нет видео, которое пытаемся скачать)
// см. комент в VideoThumbManager.loadBitmap
// см. комент в ThumbManager.loadBitmap
try {
conn.getErrorStream().close();
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,9 @@
import androidx.annotation.NonNull;
import androidx.paging.ItemKeyedDataSource;

import org.schabi.newpipe.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;

import java.io.IOException;
import java.util.List;

import su.sadrobot.yashlang.controller.ContentLoader;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.model.VideoItem;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.concurrent.TimeUnit;

import su.sadrobot.yashlang.R;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;

public class PlaylistInfoArrayAdapter extends RecyclerView.Adapter<PlaylistInfoArrayAdapter.PlaylistInfoViewHolder> {
Expand Down Expand Up @@ -128,7 +128,7 @@ public void onBindViewHolder(@NonNull final PlaylistInfoViewHolder holder, final
@Override
public void run() {
final Bitmap thumb =
VideoThumbManager.getInstance().loadPlaylistThumb(context, item);
ThumbManager.getInstance().loadPlaylistThumb(context, item);
item.setThumbBitmap(thumb);
context.runOnUiThread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.util.concurrent.TimeUnit;

import su.sadrobot.yashlang.R;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;

public class PlaylistInfoPagedListAdapter extends PagedListAdapter<PlaylistInfo, PlaylistInfoPagedListAdapter.PlaylistInfoViewHolder> {
Expand Down Expand Up @@ -159,7 +159,7 @@ public void onBindViewHolder(@NonNull final PlaylistInfoViewHolder holder, final
@Override
public void run() {
final Bitmap thumb =
VideoThumbManager.getInstance().loadPlaylistThumb(context, item);
ThumbManager.getInstance().loadPlaylistThumb(context, item);
item.setThumbBitmap(thumb);
context.runOnUiThread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import su.sadrobot.yashlang.R;
import su.sadrobot.yashlang.controller.StreamCacheFsManager;
import su.sadrobot.yashlang.controller.TaskController;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.StreamCache;
import su.sadrobot.yashlang.model.VideoDatabase;
Expand Down Expand Up @@ -464,7 +464,7 @@ public void run() {
// (строго говоря, такой вариант невозможен, за это отвечает движок базы данных)
if (item.getVideoItem() != null) {
final Bitmap thumb =
VideoThumbManager.getInstance().loadVideoThumb(context, item.getVideoItem());
ThumbManager.getInstance().loadVideoThumb(context, item.getVideoItem());
item.getVideoItem().setThumbBitmap(thumb);

context.runOnUiThread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import su.sadrobot.yashlang.ConfigOptions;
import su.sadrobot.yashlang.R;
import su.sadrobot.yashlang.controller.StreamCacheFsManager;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.PlaylistInfo;
import su.sadrobot.yashlang.model.StreamCache;
import su.sadrobot.yashlang.model.VideoDatabase;
Expand Down Expand Up @@ -280,7 +280,7 @@ public void run() {
// (строго говоря, такой вариант невозможен, за это отвечает движок базы данных)
if (item.getVideoItem() != null) {
final Bitmap thumb =
VideoThumbManager.getInstance().loadVideoThumb(context, item.getVideoItem());
ThumbManager.getInstance().loadVideoThumb(context, item.getVideoItem());
item.getVideoItem().setThumbBitmap(thumb);
context.runOnUiThread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.util.concurrent.TimeUnit;

import su.sadrobot.yashlang.R;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.VideoItem;

public class VideoItemArrayAdapter extends RecyclerView.Adapter<VideoItemArrayAdapter.VideoItemViewHolder> {
Expand Down Expand Up @@ -184,7 +184,7 @@ public void onBindViewHolder(@NonNull final VideoItemViewHolder holder, final in
@Override
public void run() {
final Bitmap thumb =
VideoThumbManager.getInstance().loadVideoThumb(context, item);
ThumbManager.getInstance().loadVideoThumb(context, item);
item.setThumbBitmap(thumb);
context.runOnUiThread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import su.sadrobot.yashlang.ConfigOptions;
import su.sadrobot.yashlang.controller.ContentLoader;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.VideoDatabase;
import su.sadrobot.yashlang.model.VideoItem;

Expand Down Expand Up @@ -115,7 +115,7 @@ public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull Load
final List<VideoItem> videoItems = ContentLoader.getInstance().extractVideoItems(
pageNewItems, playlistId);
if (loadThumbs) {
VideoThumbManager.getInstance().loadThumbs(context, videoItems);
ThumbManager.getInstance().loadVideoThumbs(context, videoItems);
}
callback.onResult(videoItems);
} else {
Expand Down Expand Up @@ -218,7 +218,7 @@ public void loadAfter(@NonNull LoadParams<String> params, @NonNull LoadCallback<
final List<VideoItem> videoItems = ContentLoader.getInstance().extractVideoItems(
pageNewItems, playlistId);
if (loadThumbs) {
VideoThumbManager.getInstance().loadThumbs(context, videoItems);
ThumbManager.getInstance().loadVideoThumbs(context, videoItems);
}
callback.onResult(videoItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.List;

import su.sadrobot.yashlang.controller.ContentLoader;
import su.sadrobot.yashlang.controller.VideoThumbManager;
import su.sadrobot.yashlang.controller.ThumbManager;
import su.sadrobot.yashlang.model.VideoItem;

/**
Expand Down Expand Up @@ -71,7 +71,7 @@ public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull Load
// загрузили, можно обновлять список
final List<VideoItem> videoItems = ContentLoader.getInstance().extractVideoItems(loadedPage.getItems());
if(loadThumbs) {
VideoThumbManager.getInstance().loadThumbs(context, videoItems);
ThumbManager.getInstance().loadVideoThumbs(context, videoItems);
}
callback.onResult(videoItems);
} catch (ExtractionException | IOException e) {
Expand Down Expand Up @@ -103,7 +103,7 @@ public void loadAfter(@NonNull LoadParams<String> params, @NonNull LoadCallback<
// загрузили страницу, можно обновлять список
final List<VideoItem> videoItems = ContentLoader.getInstance().extractVideoItems(loadedPage.getItems());
if(loadThumbs) {
VideoThumbManager.getInstance().loadThumbs(context, videoItems);
ThumbManager.getInstance().loadVideoThumbs(context, videoItems);
}
callback.onResult(videoItems);

Expand Down
Loading

0 comments on commit c1f5f69

Please sign in to comment.