fixed errors
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
package ru.vtosters.lite.translators;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
public class Translate{
|
||||
public static void dialog(String text) {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
String translated;
|
||||
|
||||
Log.d("Translate", text + " will be translated");
|
||||
|
||||
try {
|
||||
translated = YandexTranslator.translate(text); // for future
|
||||
} catch (Exception e) {
|
||||
translated = "Error";
|
||||
Log.e("Translate", e.getMessage());
|
||||
}
|
||||
|
||||
Context ctx = getGlobalContext();
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx);
|
||||
alertDialog.setTitle("Переводчик");
|
||||
alertDialog.setMessage(translated);
|
||||
alertDialog.setPositiveButton("Закрыть", (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import ru.vtosters.lite.translators.YandexTranslator;
|
||||
|
||||
public class Translate {
|
||||
public static void showTranslatedText(Context context, String text) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
var translation = YandexTranslator.translate(text);
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
showDialog(context, translation);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("Translate", e + "");
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private static void showDialog(Context context, String text) {
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
|
||||
alertDialog.setTitle("Переводчик");
|
||||
alertDialog.setMessage(text);
|
||||
alertDialog.setPositiveButton("Закрыть", (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -583,7 +583,11 @@
|
||||
.method public a(Lcom/vk/im/ui/components/common/MsgAction;Lcom/vk/im/engine/models/messages/Msg;)V
|
||||
.locals 1
|
||||
|
||||
invoke-static {p1, p2}, Lru/vtosters/lite/dnr/DNRInjector;->onClickMsg(Lcom/vk/im/ui/components/common/MsgAction;Lcom/vk/im/engine/models/messages/Msg;)Z
|
||||
invoke-direct {p0}, Lcom/vk/im/ui/components/msg_list/OnViewControllerCallbackImpl;->g()Landroid/content/Context;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0, p1, p2}, Lru/vtosters/lite/dnr/DNRInjector;->onClickMsg(Landroid/content/Context;Lcom/vk/im/ui/components/common/MsgAction;Lcom/vk/im/engine/models/messages/Msg;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user