Skip to content

Commit

Permalink
Revert to internal browser on redgifs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Sep 15, 2020
1 parent d0b7ff3 commit c69465d
Showing 1 changed file with 42 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,11 @@ private void revertToWeb() {

Log.i(TAG, "Using internal browser");

final Runnable r = new Runnable() {
@Override
public void run() {
if(!mHaveReverted) {
mHaveReverted = true;
LinkHandler.onLinkClicked(ImageViewActivity.this, mUrl, true);
finish();
}
final Runnable r = () -> {
if(!mHaveReverted) {
mHaveReverted = true;
LinkHandler.onLinkClicked(this, mUrl, true);
finish();
}
};

Expand All @@ -812,15 +809,9 @@ private void openInExternalBrowser() {

Log.i(TAG, "Using external browser");

final Runnable r = new Runnable() {
@Override
public void run() {
LinkHandler.openWebBrowser(
ImageViewActivity.this,
Uri.parse(mUrl),
false);
finish();
}
final Runnable r = () -> {
LinkHandler.openWebBrowser(this, Uri.parse(mUrl), false);
finish();
};

if(General.isThisUIThread()) {
Expand Down Expand Up @@ -1125,13 +1116,10 @@ protected void onCallbackException(final Throwable t) {

@Override
protected void onDownloadNecessary() {
AndroidCommon.UI_THREAD_HANDLER.post(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(true);
manageAspectRatioIndicator(progressBar);
}
AndroidCommon.UI_THREAD_HANDLER.post(() -> {
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(true);
manageAspectRatioIndicator(progressBar);
});
}

Expand All @@ -1150,28 +1138,32 @@ protected void onFailure(

if(!failed.getAndSet(true)) {

if(type == REQUEST_FAILURE_CONNECTION
&& url.getHost().contains("redgifs")) {

// Redgifs have lots of server issues
revertToWeb();
return;
}

final RRError error = General.getGeneralErrorForFailure(
context,
type,
t,
status,
url.toString());

AndroidCommon.UI_THREAD_HANDLER.post(new Runnable() {
@Override
public void run() {
// TODO handle properly
mRequest = null;
final LinearLayout layout = new LinearLayout(
context);
final ErrorView errorView = new ErrorView(
ImageViewActivity.this,
error);
layout.addView(errorView);
errorView.getLayoutParams().width
= ViewGroup.LayoutParams.MATCH_PARENT;
setMainView(layout);
}
AndroidCommon.UI_THREAD_HANDLER.post(() -> {
mRequest = null;
final LinearLayout layout = new LinearLayout(
context);
final ErrorView errorView = new ErrorView(
ImageViewActivity.this,
error);
layout.addView(errorView);
errorView.getLayoutParams().width
= ViewGroup.LayoutParams.MATCH_PARENT;
setMainView(layout);
});
}
}
Expand All @@ -1182,20 +1174,17 @@ protected void onProgress(
final boolean authorizationInProgress,
final long bytesRead,
final long totalBytes) {
AndroidCommon.UI_THREAD_HANDLER.post(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(authorizationInProgress);
progressBar.setProgress(((float)((1000 * bytesRead)
/ totalBytes)) / 1000);
manageAspectRatioIndicator(progressBar);

if(!mProgressTextSet) {
mProgressText.setText(General.bytesToMegabytes(
totalBytes));
mProgressTextSet = true;
}
AndroidCommon.UI_THREAD_HANDLER.post(() -> {
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(authorizationInProgress);
progressBar.setProgress(((float)((1000 * bytesRead)
/ totalBytes)) / 1000);
manageAspectRatioIndicator(progressBar);

if(!mProgressTextSet) {
mProgressText.setText(General.bytesToMegabytes(
totalBytes));
mProgressTextSet = true;
}
});
}
Expand Down

0 comments on commit c69465d

Please sign in to comment.