Commit 270be334 authored by fallenstardust's avatar fallenstardust

方便自定义toast位置和时长

parent 82bfe34f
......@@ -226,6 +226,7 @@ public class GameUriManager {
if ("file".equals(uri.getScheme()) || "content".equals(uri.getScheme())) {
File file = toLocalFile(uri);
if (file == null || !file.exists()) {
YGOUtil.showTextToast("open file error");
Toast.makeText(activity, "open file error", Toast.LENGTH_LONG).show();
return;
}
......
......@@ -14,6 +14,7 @@ import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -109,14 +110,14 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
break;
case DownloadUtil.TYPE_DOWNLOAD_OK:
if (msg.obj.toString().endsWith(Constants.YDK_FILE_EX)) {
YGOUtil.showTextToast(getString(R.string.tip_download_OK) + getString(R.string.deck_list));
YGOUtil.showTextToast(Gravity.TOP, getString(R.string.tip_download_OK) + getString(R.string.deck_list), Toast.LENGTH_SHORT);
} else if (msg.obj.toString().endsWith(Constants.YRP_FILE_EX)) {
YGOUtil.showTextToast(getString(R.string.tip_download_OK) + getString(R.string.replay_list));
YGOUtil.showTextToast(Gravity.TOP, getString(R.string.tip_download_OK) + getString(R.string.replay_list), Toast.LENGTH_SHORT);
} else if (msg.obj.toString().endsWith(Constants.YPK_FILE_EX) || msg.obj.toString().endsWith(Constants.CORE_LIMIT_PATH)) {
YGOUtil.showTextToast(getString(R.string.ypk_installed) + getString(R.string.restart_app));
YGOUtil.showTextToast(Gravity.TOP, getString(R.string.ypk_installed) + getString(R.string.restart_app), Toast.LENGTH_SHORT);
DataManager.get().load(true);
} else {
YGOUtil.showTextToast(getString(R.string.tip_download_OK) + AppsSettings.get().getResourcePath());
YGOUtil.showTextToast(Gravity.TOP, getString(R.string.tip_download_OK) + AppsSettings.get().getResourcePath(), Toast.LENGTH_LONG);
}
break;
......
......@@ -7,6 +7,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
......@@ -18,6 +19,8 @@ import androidx.recyclerview.widget.RecyclerView;
import com.ourygo.lib.duelassistant.util.PermissionUtil;
import com.ourygo.lib.duelassistant.util.Util;
import java.time.Duration;
import cn.garymb.ygomobile.App;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
......@@ -26,7 +29,23 @@ public class YGOUtil {
//提示
public static void showTextToast(String message) {
Toast.makeText(App.get(), message, Toast.LENGTH_SHORT).show();
showTextToast(Gravity.BOTTOM, message, Toast.LENGTH_SHORT);
}
public static void showTextToast(String message, int duration) {
showTextToast(Gravity.BOTTOM, message, duration);
}
public static void showTextToast(int gravity, String message) {
showTextToast(gravity, message, Toast.LENGTH_SHORT);
}
public static void showTextToast(int gravity, String message, int duration) {
Toast toast = new Toast(App.get());
toast.setDuration(duration);
toast.setGravity(gravity,0, 0);
toast.setText(message);
toast.show();
}
public static int c(int colorId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment