mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-09 00:28:56 +01:00
removed logcat, bug fix
This commit is contained in:
parent
3d2f5018a6
commit
171ada0abf
@ -3,7 +3,6 @@ package org.nuclearfog.twidda.backend;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
@ -20,7 +19,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
public class ImageLoader extends AsyncTask<String, Void, Boolean> {
|
||||
public class ImageLoader extends AsyncTask<String, Void, Bitmap[]> {
|
||||
|
||||
public enum Mode {
|
||||
ONLINE,
|
||||
@ -28,7 +27,6 @@ public class ImageLoader extends AsyncTask<String, Void, Boolean> {
|
||||
}
|
||||
private WeakReference<MediaViewer> ui;
|
||||
private ImageAdapter imageAdapter;
|
||||
private Bitmap[] images;
|
||||
private Mode mode;
|
||||
|
||||
|
||||
@ -41,7 +39,8 @@ public class ImageLoader extends AsyncTask<String, Void, Boolean> {
|
||||
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... links) {
|
||||
protected Bitmap[] doInBackground(String[] links) {
|
||||
Bitmap[] images = new Bitmap[0];
|
||||
try {
|
||||
int i = 0;
|
||||
images = new Bitmap[links.length];
|
||||
@ -59,28 +58,26 @@ public class ImageLoader extends AsyncTask<String, Void, Boolean> {
|
||||
}
|
||||
}
|
||||
} catch (Exception err) {
|
||||
if (err.getMessage() != null)
|
||||
Log.e("Image Popup", err.getMessage());
|
||||
return false;
|
||||
err.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
return images;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
if (ui.get() == null) return;
|
||||
protected void onPostExecute(Bitmap[] images) {
|
||||
if (ui.get() != null) {
|
||||
ProgressBar progress = ui.get().findViewById(R.id.image_load);
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
|
||||
ProgressBar progress = ui.get().findViewById(R.id.image_load);
|
||||
progress.setVisibility(View.INVISIBLE);
|
||||
|
||||
if (success && images.length > 0) {
|
||||
ui.get().setImage(images[0]);
|
||||
imageAdapter.setImages(images);
|
||||
imageAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
Toast.makeText(ui.get(), R.string.connection_failed, Toast.LENGTH_SHORT).show();
|
||||
ui.get().finish();
|
||||
if (images.length > 0) {
|
||||
ui.get().setImage(images[0]);
|
||||
imageAdapter.setImages(images);
|
||||
imageAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
Toast.makeText(ui.get(), R.string.connection_failed, Toast.LENGTH_SHORT).show();
|
||||
ui.get().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package org.nuclearfog.twidda.backend;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@ -26,6 +25,7 @@ public class MessageUpload extends AsyncTask<String, Void, Boolean> {
|
||||
private TwitterEngine mTwitter;
|
||||
private TwitterException err;
|
||||
|
||||
|
||||
public MessageUpload(@NonNull MessagePopup c) {
|
||||
ui = new WeakReference<>(c);
|
||||
popup = new WeakReference<>(new Dialog(c));
|
||||
@ -35,33 +35,33 @@ public class MessageUpload extends AsyncTask<String, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (popup.get() == null || ui.get() == null) return;
|
||||
|
||||
final Dialog window = popup.get();
|
||||
window.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
window.setCanceledOnTouchOutside(false);
|
||||
if (window.getWindow() != null)
|
||||
window.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
LayoutInflater inflater = LayoutInflater.from(ui.get());
|
||||
View load = inflater.inflate(R.layout.item_load, null, false);
|
||||
View cancelButton = load.findViewById(R.id.kill_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
window.dismiss();
|
||||
}
|
||||
});
|
||||
window.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (getStatus() == Status.RUNNING) {
|
||||
Toast.makeText(ui.get(), R.string.abort, Toast.LENGTH_SHORT).show();
|
||||
cancel(true);
|
||||
if (popup.get() != null && ui.get() != null) {
|
||||
final Dialog window = popup.get();
|
||||
window.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
window.setCanceledOnTouchOutside(false);
|
||||
if (window.getWindow() != null)
|
||||
window.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
LayoutInflater inflater = LayoutInflater.from(ui.get());
|
||||
View load = inflater.inflate(R.layout.item_load, null, false);
|
||||
View cancelButton = load.findViewById(R.id.kill_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
window.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
window.setContentView(load);
|
||||
window.show();
|
||||
});
|
||||
window.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (getStatus() == Status.RUNNING) {
|
||||
Toast.makeText(ui.get(), R.string.abort, Toast.LENGTH_SHORT).show();
|
||||
cancel(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
window.setContentView(load);
|
||||
window.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,8 +78,7 @@ public class MessageUpload extends AsyncTask<String, Void, Boolean> {
|
||||
this.err = err;
|
||||
return false;
|
||||
} catch (Exception err) {
|
||||
if (err.getMessage() != null)
|
||||
Log.e("DirectMessage", err.getMessage());
|
||||
err.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -88,22 +87,23 @@ public class MessageUpload extends AsyncTask<String, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
if (ui.get() == null || popup.get() == null) return;
|
||||
|
||||
if (success) {
|
||||
Toast.makeText(ui.get(), R.string.dmsend, Toast.LENGTH_SHORT).show();
|
||||
ui.get().finish();
|
||||
} else {
|
||||
if (err != null)
|
||||
ErrorHandler.printError(ui.get(), err);
|
||||
if (ui.get() != null && popup.get() != null) {
|
||||
if (success) {
|
||||
Toast.makeText(ui.get(), R.string.dmsend, Toast.LENGTH_SHORT).show();
|
||||
ui.get().finish();
|
||||
} else {
|
||||
if (err != null)
|
||||
ErrorHandler.printError(ui.get(), err);
|
||||
}
|
||||
popup.get().dismiss();
|
||||
}
|
||||
popup.get().dismiss();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (popup.get() == null) return;
|
||||
popup.get().dismiss();
|
||||
if (popup.get() != null) {
|
||||
popup.get().dismiss();
|
||||
}
|
||||
}
|
||||
}
|
@ -126,7 +126,6 @@ public class ProfileEditor extends AsyncTask<Void, Void, TwitterUser> {
|
||||
@Override
|
||||
protected void onPostExecute(TwitterUser user) {
|
||||
if (ui.get() != null && popup.get() != null) {
|
||||
|
||||
if (user != null) {
|
||||
switch (mode) {
|
||||
case READ_DATA:
|
||||
|
@ -2,7 +2,6 @@ package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -54,8 +53,6 @@ public class Registration extends AsyncTask<String, Void, Boolean> {
|
||||
} catch (TwitterException err) {
|
||||
this.err = err;
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Registration", e.getMessage());
|
||||
err.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@ -64,23 +61,23 @@ public class Registration extends AsyncTask<String, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
if (ui.get() == null) return;
|
||||
if (ui.get() != null) {
|
||||
if (success) {
|
||||
switch (mode) {
|
||||
case LINK:
|
||||
ui.get().connect(redirectionURL);
|
||||
break;
|
||||
|
||||
if (success) {
|
||||
switch (mode) {
|
||||
case LINK:
|
||||
ui.get().connect(redirectionURL);
|
||||
break;
|
||||
|
||||
case LOGIN:
|
||||
ui.get().setResult(Activity.RESULT_OK);
|
||||
ui.get().finish();
|
||||
break;
|
||||
case LOGIN:
|
||||
ui.get().setResult(Activity.RESULT_OK);
|
||||
ui.get().finish();
|
||||
break;
|
||||
}
|
||||
} else if (err != null) {
|
||||
ErrorHandler.printError(ui.get(), err);
|
||||
} else {
|
||||
Toast.makeText(ui.get(), R.string.pin_verification_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else if (err != null) {
|
||||
ErrorHandler.printError(ui.get(), err);
|
||||
} else {
|
||||
Toast.makeText(ui.get(), R.string.pin_verification_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
@ -87,31 +87,32 @@ public class StatusUploader extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean success) {
|
||||
if (ui.get() == null || popup.get() == null) return;
|
||||
if (ui.get() != null && popup.get() != null) {
|
||||
if (success) {
|
||||
ui.get().close();
|
||||
} else {
|
||||
if (err != null)
|
||||
ErrorHandler.printError(ui.get(), err);
|
||||
|
||||
if (success) {
|
||||
ui.get().close();
|
||||
} else {
|
||||
if (err != null)
|
||||
ErrorHandler.printError(ui.get(), err);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ui.get());
|
||||
builder.setTitle(R.string.error).setMessage(R.string.error_sending_tweet)
|
||||
.setPositiveButton(R.string.retry, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ui.get().findViewById(R.id.sendTweet).callOnClick();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null).show();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ui.get());
|
||||
builder.setTitle(R.string.error).setMessage(R.string.error_sending_tweet)
|
||||
.setPositiveButton(R.string.retry, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ui.get().findViewById(R.id.sendTweet).callOnClick();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null).show();
|
||||
}
|
||||
popup.get().dismiss();
|
||||
}
|
||||
popup.get().dismiss();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (popup.get() == null) return;
|
||||
popup.get().dismiss();
|
||||
if (popup.get() != null) {
|
||||
popup.get().dismiss();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user