Increase timeout of Echo images
This commit is contained in:
parent
b2ea588b54
commit
3410d79eb2
|
@ -12,7 +12,6 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -70,6 +69,7 @@ public class EchoActivity extends AppCompatActivity {
|
||||||
private long timeTouchDown;
|
private long timeTouchDown;
|
||||||
private long timeLastFrame;
|
private long timeLastFrame;
|
||||||
private Disposable disposable;
|
private Disposable disposable;
|
||||||
|
private Disposable disposableFavorite;
|
||||||
|
|
||||||
private long totalTime = 0;
|
private long totalTime = 0;
|
||||||
private int totalActivePodcasts = 0;
|
private int totalActivePodcasts = 0;
|
||||||
|
@ -80,7 +80,8 @@ public class EchoActivity extends AppCompatActivity {
|
||||||
private long queueSecondsLeft = 0;
|
private long queueSecondsLeft = 0;
|
||||||
private long timeBetweenReleaseAndPlay = 0;
|
private long timeBetweenReleaseAndPlay = 0;
|
||||||
private long oldestDate = 0;
|
private long oldestDate = 0;
|
||||||
private final ArrayList<Pair<String, Drawable>> favoritePods = new ArrayList<>();
|
private final ArrayList<String> favoritePodNames = new ArrayList<>();
|
||||||
|
private final ArrayList<Drawable> favoritePodImages = new ArrayList<>();
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
|
@ -179,6 +180,9 @@ public class EchoActivity extends AppCompatActivity {
|
||||||
if (disposable != null) {
|
if (disposable != null) {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
|
if (disposableFavorite != null) {
|
||||||
|
disposableFavorite.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadScreen(int screen, boolean force) {
|
private void loadScreen(int screen, boolean force) {
|
||||||
|
@ -288,7 +292,7 @@ public class EchoActivity extends AppCompatActivity {
|
||||||
viewBinding.largeLabel.setText("");
|
viewBinding.largeLabel.setText("");
|
||||||
viewBinding.belowLabel.setText("");
|
viewBinding.belowLabel.setText("");
|
||||||
viewBinding.smallLabel.setText("");
|
viewBinding.smallLabel.setText("");
|
||||||
currentDrawable = new FinalShareScreen(this, favoritePods);
|
currentDrawable = new FinalShareScreen(this, favoritePodNames, favoritePodImages);
|
||||||
break;
|
break;
|
||||||
default: // Keep
|
default: // Keep
|
||||||
}
|
}
|
||||||
|
@ -340,25 +344,11 @@ public class EchoActivity extends AppCompatActivity {
|
||||||
Collections.sort(statisticsData.feedTime, (item1, item2) ->
|
Collections.sort(statisticsData.feedTime, (item1, item2) ->
|
||||||
Long.compare(item2.timePlayed, item1.timePlayed));
|
Long.compare(item2.timePlayed, item1.timePlayed));
|
||||||
|
|
||||||
favoritePods.clear();
|
favoritePodNames.clear();
|
||||||
for (int i = 0; i < 5 && i < statisticsData.feedTime.size(); i++) {
|
for (int i = 0; i < 5 && i < statisticsData.feedTime.size(); i++) {
|
||||||
BitmapDrawable cover = new BitmapDrawable(getResources(), (Bitmap) null);
|
favoritePodNames.add(statisticsData.feedTime.get(i).feed.getTitle());
|
||||||
try {
|
|
||||||
final int size = SHARE_SIZE / 3;
|
|
||||||
final int radius = (i == 0) ? (size / 16) : (size / 8);
|
|
||||||
cover = new BitmapDrawable(getResources(), Glide.with(this)
|
|
||||||
.asBitmap()
|
|
||||||
.load(statisticsData.feedTime.get(i).feed.getImageUrl())
|
|
||||||
.apply(new RequestOptions()
|
|
||||||
.fitCenter()
|
|
||||||
.transform(new RoundedCorners(radius)))
|
|
||||||
.submit(size, size)
|
|
||||||
.get(1, TimeUnit.SECONDS));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
favoritePods.add(new Pair<>(statisticsData.feedTime.get(i).feed.getTitle(), cover));
|
|
||||||
}
|
}
|
||||||
|
loadFavoritePodImages(statisticsData);
|
||||||
|
|
||||||
totalActivePodcasts = 0;
|
totalActivePodcasts = 0;
|
||||||
playedActivePodcasts = 0;
|
playedActivePodcasts = 0;
|
||||||
|
@ -407,4 +397,37 @@ public class EchoActivity extends AppCompatActivity {
|
||||||
.subscribe(result -> loadScreen(currentScreen, true),
|
.subscribe(result -> loadScreen(currentScreen, true),
|
||||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadFavoritePodImages(DBReader.StatisticsResult statisticsData) {
|
||||||
|
if (disposableFavorite != null) {
|
||||||
|
disposableFavorite.dispose();
|
||||||
|
}
|
||||||
|
disposableFavorite = Observable.fromCallable(
|
||||||
|
() -> {
|
||||||
|
favoritePodImages.clear();
|
||||||
|
for (int i = 0; i < 5 && i < statisticsData.feedTime.size(); i++) {
|
||||||
|
BitmapDrawable cover = new BitmapDrawable(getResources(), (Bitmap) null);
|
||||||
|
try {
|
||||||
|
final int size = SHARE_SIZE / 3;
|
||||||
|
final int radius = (i == 0) ? (size / 16) : (size / 8);
|
||||||
|
cover = new BitmapDrawable(getResources(), Glide.with(this)
|
||||||
|
.asBitmap()
|
||||||
|
.load(statisticsData.feedTime.get(i).feed.getImageUrl())
|
||||||
|
.apply(new RequestOptions()
|
||||||
|
.fitCenter()
|
||||||
|
.transform(new RoundedCorners(radius)))
|
||||||
|
.submit(size, size)
|
||||||
|
.get(5, TimeUnit.SECONDS));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.d(TAG, "Loading cover: " + e.getMessage());
|
||||||
|
}
|
||||||
|
favoritePodImages.add(cover);
|
||||||
|
}
|
||||||
|
return statisticsData;
|
||||||
|
})
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(result -> { },
|
||||||
|
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.Pair;
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import de.danoeh.antennapod.ui.echo.EchoActivity;
|
import de.danoeh.antennapod.ui.echo.EchoActivity;
|
||||||
|
@ -22,16 +21,19 @@ public class FinalShareScreen extends BubbleScreen {
|
||||||
private final String heading;
|
private final String heading;
|
||||||
private final String year;
|
private final String year;
|
||||||
private final Drawable logo;
|
private final Drawable logo;
|
||||||
private final ArrayList<Pair<String, Drawable>> favoritePods;
|
private final ArrayList<String> favoritePodNames;
|
||||||
|
private final ArrayList<Drawable> favoritePodImages;
|
||||||
private final Typeface typefaceNormal;
|
private final Typeface typefaceNormal;
|
||||||
private final Typeface typefaceBold;
|
private final Typeface typefaceBold;
|
||||||
|
|
||||||
public FinalShareScreen(Context context, ArrayList<Pair<String, Drawable>> favoritePods) {
|
public FinalShareScreen(Context context,
|
||||||
|
ArrayList<String> favoritePodNames, ArrayList<Drawable> favoritePodImages) {
|
||||||
super(context);
|
super(context);
|
||||||
this.heading = context.getString(R.string.echo_share_heading);
|
this.heading = context.getString(R.string.echo_share_heading);
|
||||||
this.logo = AppCompatResources.getDrawable(context, R.drawable.echo);
|
this.logo = AppCompatResources.getDrawable(context, R.drawable.echo);
|
||||||
|
this.favoritePodNames = favoritePodNames;
|
||||||
|
this.favoritePodImages = favoritePodImages;
|
||||||
this.year = String.valueOf(EchoActivity.RELEASE_YEAR);
|
this.year = String.valueOf(EchoActivity.RELEASE_YEAR);
|
||||||
this.favoritePods = favoritePods;
|
|
||||||
typefaceNormal = ResourcesCompat.getFont(context, R.font.sarabun_regular);
|
typefaceNormal = ResourcesCompat.getFont(context, R.font.sarabun_regular);
|
||||||
typefaceBold = ResourcesCompat.getFont(context, R.font.sarabun_semi_bold);
|
typefaceBold = ResourcesCompat.getFont(context, R.font.sarabun_semi_bold);
|
||||||
paintTextMain = new Paint();
|
paintTextMain = new Paint();
|
||||||
|
@ -57,7 +59,7 @@ public class FinalShareScreen extends BubbleScreen {
|
||||||
paintTextMain.setTextAlign(Paint.Align.LEFT);
|
paintTextMain.setTextAlign(Paint.Align.LEFT);
|
||||||
float fontSizePods = innerBoxSize / 18; // First one only
|
float fontSizePods = innerBoxSize / 18; // First one only
|
||||||
float textY = innerBoxY + 0.62f * innerBoxSize;
|
float textY = innerBoxY + 0.62f * innerBoxSize;
|
||||||
for (int i = 0; i < favoritePods.size(); i++) {
|
for (int i = 0; i < favoritePodNames.size(); i++) {
|
||||||
float coverSize = (i == 0) ? (0.4f * innerBoxSize) : (0.2f * innerBoxSize);
|
float coverSize = (i == 0) ? (0.4f * innerBoxSize) : (0.2f * innerBoxSize);
|
||||||
float coverX = COVER_POSITIONS[i][0];
|
float coverX = COVER_POSITIONS[i][0];
|
||||||
float coverY = COVER_POSITIONS[i][1];
|
float coverY = COVER_POSITIONS[i][1];
|
||||||
|
@ -71,12 +73,16 @@ public class FinalShareScreen extends BubbleScreen {
|
||||||
logo1Pos.inset((int) (0.003f * innerBoxSize), (int) (0.003f * innerBoxSize));
|
logo1Pos.inset((int) (0.003f * innerBoxSize), (int) (0.003f * innerBoxSize));
|
||||||
Rect pos = new Rect();
|
Rect pos = new Rect();
|
||||||
logo1Pos.round(pos);
|
logo1Pos.round(pos);
|
||||||
favoritePods.get(i).second.setBounds(pos);
|
if (favoritePodImages.size() > i) {
|
||||||
favoritePods.get(i).second.draw(canvas);
|
favoritePodImages.get(i).setBounds(pos);
|
||||||
|
favoritePodImages.get(i).draw(canvas);
|
||||||
|
} else {
|
||||||
|
canvas.drawText(" ...", pos.left, pos.centerY(), paintTextMain);
|
||||||
|
}
|
||||||
|
|
||||||
paintTextMain.setTextSize(fontSizePods);
|
paintTextMain.setTextSize(fontSizePods);
|
||||||
canvas.drawText((i + 1) + ".", innerBoxX, textY, paintTextMain);
|
canvas.drawText((i + 1) + ".", innerBoxX, textY, paintTextMain);
|
||||||
canvas.drawText(favoritePods.get(i).first, innerBoxX + 0.055f * innerBoxSize, textY, paintTextMain);
|
canvas.drawText(favoritePodNames.get(i), innerBoxX + 0.055f * innerBoxSize, textY, paintTextMain);
|
||||||
fontSizePods = innerBoxSize / 24; // Starting with second text is smaller
|
fontSizePods = innerBoxSize / 24; // Starting with second text is smaller
|
||||||
textY += 1.3f * fontSizePods;
|
textY += 1.3f * fontSizePods;
|
||||||
paintTextMain.setTypeface(typefaceNormal);
|
paintTextMain.setTypeface(typefaceNormal);
|
||||||
|
|
Loading…
Reference in New Issue