|
@@ -7,6 +7,7 @@ import android.text.TextUtils;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TableLayout;
|
|
|
import android.widget.TextView;
|
|
@@ -18,7 +19,6 @@ public class ToastUtil {
|
|
|
|
|
|
public volatile static ToastUtil instance;
|
|
|
private Toast toast;
|
|
|
- private TextView mContentView;
|
|
|
|
|
|
public static ToastUtil getInstance() {
|
|
|
if (null == instance) {
|
|
@@ -42,18 +42,16 @@ public class ToastUtil {
|
|
|
* 创建自定义Toasts :
|
|
|
*/
|
|
|
public void showShort(String toastStr) {
|
|
|
- if (mContentView == null) {
|
|
|
- int dp26 = SizeUtils.dp2px(26);
|
|
|
- int dp10 = SizeUtils.dp2px(10);
|
|
|
- mContentView = new TextView(Utils.getApp());
|
|
|
- mContentView.setGravity(Gravity.CENTER);
|
|
|
- mContentView.setBackgroundResource(R.drawable.shape_toast);
|
|
|
- mContentView.setTextSize(15);
|
|
|
- mContentView.setTextColor(Utils.getApp().getResources().getColor(R.color.white));
|
|
|
- mContentView.setPadding(dp26, dp10, dp26, dp10);
|
|
|
- }
|
|
|
+ int dp26 = SizeUtils.dp2px(26);
|
|
|
+ int dp10 = SizeUtils.dp2px(10);
|
|
|
+ TextView mContentView = new TextView(Utils.getApp());
|
|
|
+ mContentView.setGravity(Gravity.CENTER);
|
|
|
+ mContentView.setBackgroundResource(R.drawable.shape_toast);
|
|
|
+ mContentView.setTextSize(15);
|
|
|
+ mContentView.setTextColor(Utils.getApp().getResources().getColor(R.color.white));
|
|
|
+ mContentView.setPadding(dp26, dp10, dp26, dp10);
|
|
|
mContentView.setText(toastStr);
|
|
|
- ToastUtils.getDefaultMaker().setGravity(Gravity.CENTER,0,0).show(mContentView);
|
|
|
+ ToastUtils.getDefaultMaker().setGravity(Gravity.CENTER, 0, 0).show(mContentView);
|
|
|
// if (init(toastStr, Toast.LENGTH_SHORT) == null) {
|
|
|
// toast = new Toast(Utils.getApp());
|
|
|
// toast.setText(toastStr);
|
|
@@ -79,7 +77,6 @@ public class ToastUtil {
|
|
|
contentView.setTextColor(Utils.getApp().getResources().getColor(R.color.white));
|
|
|
contentView.setPadding(dp26, dp10, dp26, dp10);
|
|
|
contentView.setText(message);
|
|
|
- ToastUtils.getDefaultMaker().show(contentView);
|
|
|
toast = new Toast(Utils.getApp());
|
|
|
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
|
|
|
toast.setView(contentView);
|