diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-22 11:47:36 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-22 11:47:36 +0000 |
commit | 0a5b5cb2094e0f56c35a39fb9d0af63b6063b162 (patch) | |
tree | 5d725f1ec28270d4c5f1b153ede32e99a6e2128c /app/src | |
parent | 25b812fe4af7e5a94fc51870d27e12b2b50dd2da (diff) | |
download | infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.tar infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.tar.gz infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.tar.bz2 infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.tar.lz infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.tar.xz infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.tar.zst infinity-for-reddit-0a5b5cb2094e0f56c35a39fb9d0af63b6063b162.zip |
Remove uploadImageToReddit in CommentActivity.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java index cbbcdd17..7d835d5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java @@ -4,7 +4,6 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -29,7 +28,6 @@ import androidx.core.content.FileProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.bumptech.glide.Glide; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; @@ -37,13 +35,10 @@ import com.google.android.material.snackbar.Snackbar; import org.commonmark.ext.gfm.tables.TableBlock; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; -import org.json.JSONException; -import org.xmlpull.v1.XmlPullParserException; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import javax.inject.Inject; @@ -73,7 +68,6 @@ import ml.docilealligator.infinityforreddit.comment.SendComment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; -import ml.docilealligator.infinityforreddit.utils.UploadImageUtils; import ml.docilealligator.infinityforreddit.utils.Utils; import retrofit2.Retrofit; @@ -447,41 +441,6 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA } } - private void uploadImageToReddit(Uri imageUri) { - Toast.makeText(this, R.string.uploading_image, Toast.LENGTH_SHORT).show(); - Handler handler = new Handler(); - mExecutor.execute(() -> { - try { - Bitmap bitmap = Glide.with(CommentActivity.this).asBitmap().load(imageUri).submit().get(); - String imageUrlOrError = UploadImageUtils.uploadImage(mOauthRetrofit, mUploadMediaRetrofit, mAccessToken, bitmap); - handler.post(() -> { - if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) { - String fileName = Utils.getFileName(this, imageUri); - if (fileName == null) { - fileName = imageUrlOrError; - } - uploadedImages.add(new UploadedImage(fileName, imageUrlOrError)); - - int start = Math.max(commentEditText.getSelectionStart(), 0); - int end = Math.max(commentEditText.getSelectionEnd(), 0); - commentEditText.getText().replace(Math.min(start, end), Math.max(start, end), - "[" + fileName + "](" + imageUrlOrError + ")", - 0, "[]()".length() + fileName.length() + imageUrlOrError.length()); - Snackbar.make(coordinatorLayout, R.string.upload_image_success, Snackbar.LENGTH_LONG).show(); - } else { - Toast.makeText(CommentActivity.this, R.string.upload_image_failed, Toast.LENGTH_LONG).show(); - } - }); - } catch (ExecutionException | InterruptedException e) { - e.printStackTrace(); - handler.post(() -> Toast.makeText(CommentActivity.this, R.string.get_image_bitmap_failed, Toast.LENGTH_LONG).show()); - } catch (XmlPullParserException | JSONException | IOException e) { - e.printStackTrace(); - handler.post(() -> Toast.makeText(CommentActivity.this, R.string.error_processing_image, Toast.LENGTH_LONG).show()); - } - }); - } - @Override public void onBackPressed() { if (isSubmitting) { |