|
|
@@ -1,12 +1,15 @@
|
|
|
package com.sheep.gamegroup.util;
|
|
|
|
|
|
+import android.app.ActionBar;
|
|
|
import android.app.Activity;
|
|
|
+import android.app.Dialog;
|
|
|
import android.app.ProgressDialog;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.Color;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.media.MediaPlayer;
|
|
|
import android.net.Uri;
|
|
|
@@ -18,27 +21,50 @@ import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.Html;
|
|
|
import android.text.TextUtils;
|
|
|
import android.text.method.ScrollingMovementMethod;
|
|
|
+import android.util.DisplayMetrics;
|
|
|
+import android.util.TypedValue;
|
|
|
+import android.view.Display;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.Window;
|
|
|
import android.view.WindowManager;
|
|
|
-import android.webkit.WebView;
|
|
|
+
|
|
|
+import com.tencent.smtt.sdk.WebView;
|
|
|
+
|
|
|
+import android.widget.CheckBox;
|
|
|
+import android.widget.CompoundButton;
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.VideoView;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.RequestBuilder;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.kfzs.duanduan.fragment.FgtPersonalCenter;
|
|
|
+import com.sheep.gamegroup.dateview.DatePickerDialog;
|
|
|
+import com.sheep.gamegroup.dateview.DateUtil;
|
|
|
+import com.sheep.gamegroup.model.api.RedPackageMoney;
|
|
|
import com.sheep.gamegroup.model.entity.Advertising;
|
|
|
+import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.Container;
|
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
import com.sheep.gamegroup.model.entity.GameAccountEntity;
|
|
|
+import com.sheep.gamegroup.model.entity.HomeListEntity;
|
|
|
import com.sheep.gamegroup.model.entity.PayEntity;
|
|
|
+import com.sheep.gamegroup.model.entity.RobTask;
|
|
|
+import com.sheep.gamegroup.model.entity.TaskEty;
|
|
|
+import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
|
+import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.glide.RoundedCornersTransformation;
|
|
|
+import com.sheep.gamegroup.view.activity.PersonalInfoAct;
|
|
|
import com.sheep.gamegroup.view.activity.SplashAct;
|
|
|
+import com.sheep.gamegroup.view.activity.TaskDetailAct;
|
|
|
import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogAddAccount;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogModifyAccount;
|
|
|
@@ -50,6 +76,7 @@ import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
|
|
|
|
|
|
import org.afinal.simplecache.ACache;
|
|
|
|
|
|
@@ -61,7 +88,9 @@ import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.AD_TOAST;
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.QR_COPY;
|
|
|
@@ -73,11 +102,14 @@ import static com.sheep.gamegroup.util.UMConfigUtils.Event.QR_SHARE;
|
|
|
* realicing@sina.com
|
|
|
*/
|
|
|
public class ViewUtil {
|
|
|
+
|
|
|
public static final int REQUEST_CODE_TASK_LIST = 110;
|
|
|
private static ViewUtil viewUtil;
|
|
|
+ static int result = 0;
|
|
|
+ static RobTask mRobTask;
|
|
|
|
|
|
- public static ViewUtil newInstance(){
|
|
|
- if(viewUtil == null){
|
|
|
+ public static ViewUtil newInstance() {
|
|
|
+ if (viewUtil == null) {
|
|
|
viewUtil = new ViewUtil();
|
|
|
}
|
|
|
return viewUtil;
|
|
|
@@ -98,7 +130,8 @@ public class ViewUtil {
|
|
|
final ImageView iv_qr = view.findViewById(R.id.iv_qr);
|
|
|
View save_pic = view.findViewById(R.id.save_pic);
|
|
|
ImageView iv_qr_small = view.findViewById(R.id.iv_qr_small);
|
|
|
- GlideImageLoader.downloadAndSetImage(iv_qr, AppUtil.getQRLink(link, 800), 800);
|
|
|
+
|
|
|
+ GlideImageLoader.saveAndSetRqImage(iv_qr, AppUtil.getQRLink(link, 800), 800);
|
|
|
Glide.with(activity)
|
|
|
.load(R.drawable.icon)
|
|
|
.apply(new RequestOptions().override(G.WIDTH / 8))
|
|
|
@@ -135,6 +168,288 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @param context Activity的上下文
|
|
|
+ * @param mTextView 显示日期的TextView
|
|
|
+ */
|
|
|
+ public static void showDateDialog(final PersonalInfoAct context, final TextView mTextView, String time) {
|
|
|
+ List<Integer> date;
|
|
|
+ try {
|
|
|
+ date = DateUtil.getDateForString((TextUtils.isEmpty(time) && time.equals("0001-01-01T00:00:00Z")) ? "1990-01-01" : time);//从1990-01-01开始显示}
|
|
|
+ } catch (Exception e) {
|
|
|
+ date = DateUtil.getDateForString("1990-01-01");
|
|
|
+ }
|
|
|
+ DatePickerDialog.Builder builder = new DatePickerDialog.Builder(context);
|
|
|
+ builder.setOnDateSelectedListener(new DatePickerDialog.OnDateSelectedListener() {
|
|
|
+ @Override
|
|
|
+ public void onDateSelected(int[] dates) {
|
|
|
+ mTextView.setText(dates[0] + "-" + (dates[1] > 9 ? dates[1] : ("0" + dates[1])) + "-" + (dates[2] > 9 ? dates[2] : ("0" + dates[2])));
|
|
|
+ context.upLoadBirthday(mTextView.getText().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCancel() {
|
|
|
+
|
|
|
+ }
|
|
|
+ }).setSelectYear(date.get(0) - 1)
|
|
|
+ .setSelectMonth(date.get(1) - 1)
|
|
|
+ .setSelectDay(date.get(2) - 1);
|
|
|
+ Dialog dateDialog = builder.create();
|
|
|
+ dateDialog.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 主页抢任务,更换任务时,获取新的任务
|
|
|
+ *
|
|
|
+ * @return , TaskEty对象
|
|
|
+ */
|
|
|
+ public static RobTask getTask(final ImageView ivIcon, final TextView tvTitel, final TextView tvDutyMoney) {
|
|
|
+ LogUtil.logI(SpUtils.getOrder("order") + "开始的order");
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getNewTask(SpUtils.getOrder("order"))
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ try {
|
|
|
+ mRobTask = baseMessage.getData(RobTask.class);
|
|
|
+ LogUtil.logI(SpUtils.getOrder("order") + "保存后的order");
|
|
|
+ SpUtils.saveOrder("order", mRobTask.getOrder());
|
|
|
+ LogUtil.logI("---mRobTask" + new Gson().toJson(mRobTask));
|
|
|
+ LogUtil.logI("---" + new Gson().toJson(baseMessage));
|
|
|
+ tvDutyMoney.setText(mRobTask.getM().getBonus() + "元");//设置任务奖励金额
|
|
|
+ tvTitel.setText(mRobTask.getM().getTask().getTask_name());//设置任务名字
|
|
|
+ GlideImageLoader.setImage(ivIcon, mRobTask.getM().getTask().getIcon());//设置任务图标
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.showToast(baseMessage);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return mRobTask;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 抢任务弹框
|
|
|
+ *
|
|
|
+ * @param mActivity 当前Activity,
|
|
|
+ * @param viewAnchor 锚
|
|
|
+ */
|
|
|
+ public static void showRobDutyDialog(final Activity mActivity, View viewAnchor) {
|
|
|
+ View view = LayoutInflater.from(mActivity).inflate(R.layout.pop_robduty, null, false);
|
|
|
+ ImageView ivChangeOne = view.findViewById(R.id.iv_change_one);
|
|
|
+ ImageView ivDoNow = view.findViewById(R.id.iv_do_now);
|
|
|
+
|
|
|
+ final ImageView ivIcon = view.findViewById(R.id.iv_duty);
|
|
|
+ ImageView ivClose = view.findViewById(R.id.iv_close);
|
|
|
+ final TextView tvTitel = view.findViewById(R.id.tv_duty_title);
|
|
|
+ final TextView tvDutyMoney = view.findViewById(R.id.tv_robduty_money);
|
|
|
+ mRobTask = getTask(ivIcon, tvTitel, tvDutyMoney);
|
|
|
+ /**
|
|
|
+ * */
|
|
|
+ final PopupWindow popupWindow = new PopupWindow(mActivity);
|
|
|
+ popupWindow.setContentView(view);
|
|
|
+ popupWindow.setAnimationStyle(R.style.Rising);
|
|
|
+ popupWindow.setWidth(ActionBar.LayoutParams.MATCH_PARENT);
|
|
|
+ popupWindow.setHeight(ActionBar.LayoutParams.MATCH_PARENT);
|
|
|
+ popupWindow.setTouchable(true);
|
|
|
+ popupWindow.setFocusable(true);
|
|
|
+ popupWindow.setOutsideTouchable(false);
|
|
|
+ popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ backgroundAlpha(0.5f, mActivity);
|
|
|
+ popupWindow.showAtLocation(viewAnchor, Gravity.CENTER, 0, 0);
|
|
|
+ popupWindow.setOnDismissListener(new PopDismissListener(mActivity));
|
|
|
+ //更换任务
|
|
|
+ ivChangeOne.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mRobTask = getTask(ivIcon, tvTitel, tvDutyMoney);
|
|
|
+ LogUtil.logI("抢任务---"+new Gson().toJson(mRobTask));
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //立即去做,跳转到任务详情去
|
|
|
+ ivDoNow.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ if (mRobTask == null) {
|
|
|
+ G.showToast("抢任务失败!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Intent intent = new Intent(mActivity, TaskDetailAct.class);
|
|
|
+ intent.putExtra("btn_show", true);
|
|
|
+ intent.putExtra("is_from_task_list", true);
|
|
|
+ intent.putExtra("task_id", mRobTask.getM().getId());
|
|
|
+ mActivity.startActivity(intent);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ivClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 兑换红包弹窗
|
|
|
+ *
|
|
|
+ * @param mActivity 当前Activity的,
|
|
|
+ */
|
|
|
+ public static void changeRedPackage(final Activity mActivity, View viewAnchor, final FgtPersonalCenter fgtPersonalCenter) {
|
|
|
+ View view = LayoutInflater.from(mActivity).inflate(R.layout.pop_get_redpackage, null);
|
|
|
+ final EditText edInvitationCode = view.findViewById(R.id.ed_invitation_code);
|
|
|
+ TextView tvTitle = view.findViewById(R.id.tv_title);
|
|
|
+ final TextView tvGetRedPackage = view.findViewById(R.id.tv_get_redpackage);
|
|
|
+ ImageView ivClose = view.findViewById(R.id.iv_close);
|
|
|
+ final PopupWindow popupWindow = new PopupWindow(mActivity);
|
|
|
+ popupWindow.setContentView(view);
|
|
|
+ popupWindow.setWidth(ActionBar.LayoutParams.MATCH_PARENT);
|
|
|
+ popupWindow.setHeight(ActionBar.LayoutParams.MATCH_PARENT);
|
|
|
+ popupWindow.setTouchable(true);
|
|
|
+ popupWindow.setFocusable(true);
|
|
|
+ popupWindow.setOutsideTouchable(false);
|
|
|
+ popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ backgroundAlpha(0.7f, mActivity);
|
|
|
+ popupWindow.showAtLocation(viewAnchor, Gravity.CENTER, 0, 0);
|
|
|
+ popupWindow.setOnDismissListener(new PopDismissListener(mActivity));
|
|
|
+ tvTitle.setText("兑换");
|
|
|
+ tvGetRedPackage.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (TextUtils.isEmpty(edInvitationCode.getText())) {
|
|
|
+ G.showToast("邀请码不能为空!");
|
|
|
+ } else {
|
|
|
+ fgtPersonalCenter.getRedPackage(edInvitationCode.getText().toString(), popupWindow);
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ivClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测量屏幕的宽
|
|
|
+ *
|
|
|
+ * @param mActivity ,
|
|
|
+ * @return 屏幕的宽
|
|
|
+ */
|
|
|
+ private static int measureWidth(Activity mActivity) {
|
|
|
+ WindowManager manager = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
|
|
|
+ Display defaultDisplay = manager.getDefaultDisplay();
|
|
|
+ DisplayMetrics outMetrics = new DisplayMetrics();
|
|
|
+ defaultDisplay.getMetrics(outMetrics);
|
|
|
+ return outMetrics.widthPixels;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测量屏幕的宽
|
|
|
+ *
|
|
|
+ * @param mActivity ,
|
|
|
+ * @return 屏幕的宽
|
|
|
+ */
|
|
|
+ public static int measureHeight(Activity mActivity) {
|
|
|
+ WindowManager manager = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
|
|
|
+ Display defaultDisplay = manager.getDefaultDisplay();
|
|
|
+ DisplayMetrics outMetrics = new DisplayMetrics();
|
|
|
+ defaultDisplay.getMetrics(outMetrics);
|
|
|
+ return outMetrics.heightPixels;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param mActivity ,个人资料Activity
|
|
|
+ * @param viewAnchor ,锚
|
|
|
+ * 选择性别弹窗
|
|
|
+ */
|
|
|
+ public static void choiceSex(final PersonalInfoAct mActivity, View viewAnchor) {
|
|
|
+ View view = LayoutInflater.from(mActivity).inflate(R.layout.pop_choice_sex, null);
|
|
|
+ TextView tvOk = view.findViewById(R.id.tv_cancel);
|
|
|
+ final CheckBox cbMale = view.findViewById(R.id.btn_male);
|
|
|
+ final CheckBox cbFemale = view.findViewById(R.id.btn_female);
|
|
|
+ final PopupWindow popupWindow = new PopupWindow(mActivity);
|
|
|
+ cbFemale.setTextColor(Color.parseColor("#ff444444"));
|
|
|
+ cbMale.setTextColor(Color.parseColor("#ff444444"));
|
|
|
+ popupWindow.setContentView(view);
|
|
|
+ popupWindow.setWidth(measureWidth(mActivity));
|
|
|
+ popupWindow.setHeight(ActionBar.LayoutParams.WRAP_CONTENT);
|
|
|
+ popupWindow.setAnimationStyle(R.style.Rising);
|
|
|
+ popupWindow.setTouchable(true);
|
|
|
+ popupWindow.setFocusable(true);
|
|
|
+ popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ backgroundAlpha(0.5f, mActivity);
|
|
|
+ popupWindow.showAtLocation(viewAnchor, Gravity.BOTTOM, 0, 0);
|
|
|
+ popupWindow.setOnDismissListener(new PopDismissListener(mActivity));
|
|
|
+ tvOk.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mActivity.upLoadSex((!cbFemale.isChecked() && !cbMale.isChecked()) ? 0 : cbMale.isChecked() ? 1 : 2, popupWindow);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //选择男
|
|
|
+ cbMale.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (isChecked) {
|
|
|
+ cbMale.setTextColor(Color.parseColor("#ff2d4b"));
|
|
|
+ cbFemale.setTextColor(Color.parseColor("#ff444444"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //选择女
|
|
|
+ cbFemale.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
+ if (isChecked) {
|
|
|
+ cbFemale.setTextColor(Color.parseColor("#ff2d4b"));
|
|
|
+ cbMale.setTextColor(Color.parseColor("#ff444444"));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * popwindow消失监听类,消失恢复window透明度
|
|
|
+ */
|
|
|
+ public static class PopDismissListener implements PopupWindow.OnDismissListener {
|
|
|
+ Activity mActivity;
|
|
|
+
|
|
|
+ public PopDismissListener(Activity activity) {
|
|
|
+ mActivity = activity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ backgroundAlpha(1f, mActivity);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param bgAlpha ,透明度值
|
|
|
+ * @param activity 恢复透明度
|
|
|
+ */
|
|
|
+ public static void backgroundAlpha(float bgAlpha, Activity activity) {
|
|
|
+ WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
|
|
|
+ lp.alpha = bgAlpha;
|
|
|
+ activity.getWindow().setAttributes(lp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 分享对话框
|
|
|
*
|
|
|
* @param activity
|
|
|
@@ -159,7 +474,7 @@ public class ViewUtil {
|
|
|
if (!TextUtils.isEmpty(link))
|
|
|
tv_link.setText(link);
|
|
|
|
|
|
- GlideImageLoader.downloadAndSetImage(iv_qr, AppUtil.getQRLink(link, 800), 800);
|
|
|
+ GlideImageLoader.saveAndSetRqImage(iv_qr, AppUtil.getQRLink(link, 800), 800);
|
|
|
dialog_close.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
@@ -249,14 +564,14 @@ public class ViewUtil {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static void setH5Text(TextView textView,WebView webView, String content) {
|
|
|
- if(textView == null || webView == null){
|
|
|
+ public static void setH5Text(TextView textView, WebView webView, String content) {
|
|
|
+ if (textView == null || webView == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if(ViewUtil.isH5Content(content)){
|
|
|
+ if (ViewUtil.isH5Content(content)) {
|
|
|
webView.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
|
|
|
textView.setVisibility(View.GONE);
|
|
|
- } else if(content.startsWith("<p>")){
|
|
|
+ } else if (content.startsWith("<p>")) {
|
|
|
ViewUtil.loadDataWithBaseURL(webView, content);
|
|
|
textView.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
@@ -274,8 +589,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setH5Text(TextView textView, String content) {
|
|
|
- if(textView != null) {
|
|
|
- if(TextUtils.isEmpty(content)){
|
|
|
+ if (textView != null) {
|
|
|
+ if (TextUtils.isEmpty(content)) {
|
|
|
textView.setText("");
|
|
|
return;
|
|
|
}
|
|
|
@@ -302,6 +617,7 @@ public class ViewUtil {
|
|
|
public static AlertDialog showMsgDialog(final Context context, String msg, String title) {
|
|
|
return showMsgDialog(context, new DialogConfig().setMsg(msg).setTitle(title).setBtnLeftText("知道了"));
|
|
|
}
|
|
|
+
|
|
|
public static AlertDialog showMsgDialog(final Context context, String msg, String title, String leftBtn, String rightBtn,
|
|
|
View.OnClickListener onClickListener, View.OnClickListener onRightClickListener, View.OnClickListener onCloseClickListener) {
|
|
|
return showMsgDialog(context, new DialogConfig().setMsg(msg).setTitle(title).setBtnLeftText(leftBtn)
|
|
|
@@ -310,10 +626,12 @@ public class ViewUtil {
|
|
|
.setBtnRightOnClickListener(onRightClickListener)
|
|
|
.setBtnCloseOnClickListener(onCloseClickListener));
|
|
|
}
|
|
|
- public static AlertDialog showMsgDialog(final Context context, String msg, String title,boolean isFinish) {
|
|
|
+
|
|
|
+ public static AlertDialog showMsgDialog(final Context context, String msg, String title, boolean isFinish) {
|
|
|
return showMsgDialog(context, new DialogConfig().setMsg(msg).setTitle(title).setFinish(isFinish).setBtnLeftText("知道了"));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public static AlertDialog showMsgDialog(Context context, final DialogConfig dialogConfig) {
|
|
|
final Context mContext = context == null ? ActivityManager.getInstance().currentActivity() : context;
|
|
|
String title = dialogConfig.getTitle();
|
|
|
@@ -328,7 +646,7 @@ public class ViewUtil {
|
|
|
View dialog_parent = View.inflate(mContext, R.layout.dialog_parent, null);
|
|
|
final AlertDialog dialog = new AlertDialog.Builder(mContext, mContext instanceof Activity ? R.style.MyDialogActivityTheme : R.style.AppTheme_Dialog_Alert).setView(dialog_parent).create();
|
|
|
TextView dialog_title = dialog_parent.findViewById(R.id.dialog_title);
|
|
|
- switch (dialogConfig.getTheme()){//设置按钮风格
|
|
|
+ switch (dialogConfig.getTheme()) {//设置按钮风格
|
|
|
case DialogConfig.THEME_PURPLE:
|
|
|
dialog_title.setBackgroundResource(R.drawable.shape_purple_solid_rectangle_top);
|
|
|
break;
|
|
|
@@ -340,7 +658,7 @@ public class ViewUtil {
|
|
|
dialog_title.setText(title);
|
|
|
|
|
|
final TextView dialog_msg = view.findViewById(R.id.dialog_msg);
|
|
|
- if(dialog_msg != null) {
|
|
|
+ if (dialog_msg != null) {
|
|
|
if (TextUtils.isEmpty(msg)) {
|
|
|
dialog_msg.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
@@ -356,24 +674,24 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
final WebView dialog_msg_wv = view.findViewById(R.id.dialog_msg_wv);
|
|
|
- if(dialog_msg_wv != null) {
|
|
|
+ if (dialog_msg_wv != null) {
|
|
|
ViewUtil.loadDataWithBaseURL(dialog_msg_wv, msg);
|
|
|
}
|
|
|
|
|
|
TextView dialog_msg_more = view.findViewById(R.id.dialog_msg_more);
|
|
|
- if(dialog_msg_more != null) {
|
|
|
+ if (dialog_msg_more != null) {
|
|
|
if (TextUtils.isEmpty(msgMore)) {
|
|
|
dialog_msg_more.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
dialog_msg_more.setVisibility(View.VISIBLE);
|
|
|
dialog_msg_more.setText(msgMore);
|
|
|
- if(dialogConfig.getMsgMoreColor() > 0)
|
|
|
+ if (dialogConfig.getMsgMoreColor() > 0)
|
|
|
dialog_msg_more.setTextColor(mContext.getResources().getColor(dialogConfig.getMsgMoreColor()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TextView dialog_tip = view.findViewById(R.id.dialog_tip);
|
|
|
- if(dialog_tip != null) {
|
|
|
+ if (dialog_tip != null) {
|
|
|
if (TextUtils.isEmpty(tip)) {
|
|
|
dialog_tip.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
@@ -384,8 +702,8 @@ public class ViewUtil {
|
|
|
|
|
|
TextView dialog_btn_left = view.findViewById(R.id.dialog_btn_left);
|
|
|
boolean isLeftBtnShow = btnLeftText != null || btnLeftOnClickListener != null;
|
|
|
- if(dialog_btn_left != null) {
|
|
|
- switch (dialogConfig.getTheme()){//设置按钮风格
|
|
|
+ if (dialog_btn_left != null) {
|
|
|
+ switch (dialogConfig.getTheme()) {//设置按钮风格
|
|
|
case DialogConfig.THEME_PURPLE:
|
|
|
dialog_btn_left.setBackgroundResource(R.drawable.selector_button_full_purple);
|
|
|
dialog_btn_left.setTextColor(Color.WHITE);
|
|
|
@@ -408,8 +726,8 @@ public class ViewUtil {
|
|
|
|
|
|
TextView dialog_btn_right = view.findViewById(R.id.dialog_btn_right);
|
|
|
boolean isRigthBtnShow = btnRightText != null || btnRightOnClickListener != null;
|
|
|
- if(dialog_btn_right != null) {
|
|
|
- switch (dialogConfig.getTheme()){//设置按钮风格
|
|
|
+ if (dialog_btn_right != null) {
|
|
|
+ switch (dialogConfig.getTheme()) {//设置按钮风格
|
|
|
case DialogConfig.THEME_PURPLE:
|
|
|
dialog_btn_right.setBackgroundResource(R.drawable.selector_button_full_purple);
|
|
|
dialog_btn_right.setTextColor(Color.WHITE);
|
|
|
@@ -430,16 +748,16 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
View dialog_btn_center = view.findViewById(R.id.dialog_btn_center);
|
|
|
- if(dialog_btn_center != null) {
|
|
|
+ if (dialog_btn_center != null) {
|
|
|
dialog_btn_center.setVisibility(isLeftBtnShow && isRigthBtnShow ? View.VISIBLE : View.GONE);
|
|
|
}
|
|
|
|
|
|
- if(dialog_close != null) {
|
|
|
+ if (dialog_close != null) {
|
|
|
if (dialogConfig.isCancelable())//
|
|
|
dialog_close.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- if(btnCloseOnClickListener != null){
|
|
|
+ if (btnCloseOnClickListener != null) {
|
|
|
btnCloseOnClickListener.onClick(v);
|
|
|
}
|
|
|
dialog.dismiss();
|
|
|
@@ -452,7 +770,7 @@ public class ViewUtil {
|
|
|
@Override
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
try {
|
|
|
- if(dialogConfig.isFinish()) {
|
|
|
+ if (dialogConfig.isFinish()) {
|
|
|
if (mContext instanceof Activity) {
|
|
|
((Activity) mContext).finish();
|
|
|
}
|
|
|
@@ -463,10 +781,10 @@ public class ViewUtil {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if(!(mContext instanceof Activity) && dialog.getWindow() != null) {
|
|
|
+ if (!(mContext instanceof Activity) && dialog.getWindow() != null) {
|
|
|
dialog.getWindow().setType(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? WindowManager.LayoutParams.TYPE_PHONE : WindowManager.LayoutParams.TYPE_TOAST);
|
|
|
}
|
|
|
- if(!dialogConfig.isCancelable())
|
|
|
+ if (!dialogConfig.isCancelable())
|
|
|
dialog.setCancelable(false);
|
|
|
try {
|
|
|
dialog.show();
|
|
|
@@ -478,32 +796,33 @@ public class ViewUtil {
|
|
|
|
|
|
/**
|
|
|
* 通过map来设置字体颜色
|
|
|
+ *
|
|
|
* @param textView
|
|
|
* @param msg
|
|
|
* @param colorMsgMap key为文本,value为要设置的颜色(#FF0000)
|
|
|
*/
|
|
|
public static void setColorMapText(TextView textView, String msg, Map<String, String> colorMsgMap) {
|
|
|
- if(textView == null){
|
|
|
+ if (textView == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if(TextUtils.isEmpty(msg)){
|
|
|
+ if (TextUtils.isEmpty(msg)) {
|
|
|
textView.setText("");
|
|
|
}
|
|
|
- if(colorMsgMap.isEmpty()) {
|
|
|
+ if (colorMsgMap.isEmpty()) {
|
|
|
textView.setText(msg);
|
|
|
} else {
|
|
|
int index = 0;
|
|
|
for (Map.Entry<String, String> entry : colorMsgMap.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
String value = entry.getValue();//例如红色 #FF0000
|
|
|
- if(!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value) && msg.contains(key) && value.length() == 7){
|
|
|
+ if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value) && msg.contains(key) && value.length() == 7) {
|
|
|
int length = msg.length();
|
|
|
- if(index < length){
|
|
|
+ if (index < length) {
|
|
|
int position = msg.indexOf(key, index);
|
|
|
String start = msg.substring(0, position);
|
|
|
String middle = getHtmlText(key, value);
|
|
|
String end = msg.substring(position + key.length());
|
|
|
- index = (start+middle).length();
|
|
|
+ index = (start + middle).length();
|
|
|
msg = start + middle + end;
|
|
|
}
|
|
|
}
|
|
|
@@ -511,38 +830,40 @@ public class ViewUtil {
|
|
|
textView.setText(Html.fromHtml(msg));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 通过map来设置字体颜色
|
|
|
+ *
|
|
|
* @param textView
|
|
|
* @param msg
|
|
|
- * @param items key为文本,value为要设置的颜色(#FF0000)
|
|
|
+ * @param items key为文本,value为要设置的颜色(#FF0000)
|
|
|
*/
|
|
|
- public static void setColorMapText(TextView textView, String msg, String...items) {
|
|
|
- if(textView == null){
|
|
|
+ public static void setColorMapText(TextView textView, String msg, String... items) {
|
|
|
+ if (textView == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if(TextUtils.isEmpty(msg)){
|
|
|
+ if (TextUtils.isEmpty(msg)) {
|
|
|
textView.setText("");
|
|
|
}
|
|
|
- if(items == null || items.length < 1 || items.length % 2 == 1) {
|
|
|
+ if (items == null || items.length < 1 || items.length % 2 == 1) {
|
|
|
textView.setText(msg);
|
|
|
} else {
|
|
|
int index = 0;
|
|
|
for (int i = 0; i + 1 < items.length; ) {
|
|
|
String key = items[i];
|
|
|
- String value = items[i+1];//例如红色 #FF0000
|
|
|
- if(!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value) && msg.contains(key) && value.length() == 7){
|
|
|
+ String value = items[i + 1];//例如红色 #FF0000
|
|
|
+ if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value) && msg.contains(key) && value.length() == 7) {
|
|
|
int length = msg.length();
|
|
|
- if(index < length){
|
|
|
+ if (index < length) {
|
|
|
int position = msg.indexOf(key, index);
|
|
|
String start = msg.substring(0, position);
|
|
|
String middle = getHtmlText(key, value);
|
|
|
String end = msg.substring(position + key.length());
|
|
|
- index = (start+middle).length();
|
|
|
+ index = (start + middle).length();
|
|
|
msg = start + middle + end;
|
|
|
}
|
|
|
}
|
|
|
- i+=2;
|
|
|
+ i += 2;
|
|
|
}
|
|
|
textView.setText(Html.fromHtml(msg));
|
|
|
}
|
|
|
@@ -550,7 +871,8 @@ public class ViewUtil {
|
|
|
|
|
|
/**
|
|
|
* 获取html格式并带颜色的文字
|
|
|
- * @param text 文字
|
|
|
+ *
|
|
|
+ * @param text 文字
|
|
|
* @param color 颜色
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -573,12 +895,12 @@ public class ViewUtil {
|
|
|
|
|
|
ACache aCache = ACache.get(SheepApp.getInstance());
|
|
|
String wh = aCache.getAsString(advertising.getDisplay_src());
|
|
|
- if(!TextUtils.isEmpty(wh) && wh.contains(";")) {
|
|
|
+ if (!TextUtils.isEmpty(wh) && wh.contains(";")) {
|
|
|
String[] items = wh.split(";");
|
|
|
dialog_center_ll.setMinimumWidth(Integer.parseInt(items[0]));
|
|
|
dialog_center_ll.setMinimumHeight(Integer.parseInt(items[1]));
|
|
|
}
|
|
|
- dialog_center_ll.setPadding(0,activity.getResources().getDimensionPixelSize(R.dimen.content_padding_54),0,activity.getResources().getDimensionPixelSize(R.dimen.content_padding_15));
|
|
|
+ dialog_center_ll.setPadding(0, activity.getResources().getDimensionPixelSize(R.dimen.content_padding_54), 0, activity.getResources().getDimensionPixelSize(R.dimen.content_padding_15));
|
|
|
|
|
|
ImageView ad_iv = view.findViewById(R.id.ad_iv);
|
|
|
VideoView ad_video_view = view.findViewById(R.id.ad_video_view);
|
|
|
@@ -591,9 +913,9 @@ public class ViewUtil {
|
|
|
// ad_video_view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,G.WIDTH*4/7));
|
|
|
if (advertising.isImage()) {
|
|
|
RequestBuilder<Drawable> builder = Glide.with(activity).load(advertising.getDisplay_src());
|
|
|
- if(TextUtils.isEmpty(advertising.getDesc())) {//没有标题时 去掉下面的边距 并给图片左下理右下添加图角
|
|
|
+ if (TextUtils.isEmpty(advertising.getDesc())) {//没有标题时 去掉下面的边距 并给图片左下理右下添加图角
|
|
|
builder.apply(new RequestOptions().transform(new RoundedCornersTransformation(activity.getResources().getDimensionPixelSize(R.dimen.content_padding_36), 0, RoundedCornersTransformation.CornerType.BOTTOM)));
|
|
|
- dialog_center_ll.setPadding(0,activity.getResources().getDimensionPixelSize(R.dimen.content_padding_54),0, 0);
|
|
|
+ dialog_center_ll.setPadding(0, activity.getResources().getDimensionPixelSize(R.dimen.content_padding_54), 0, 0);
|
|
|
}
|
|
|
builder.into(ad_iv);
|
|
|
ad_video_view.setVisibility(View.GONE);
|
|
|
@@ -613,13 +935,13 @@ public class ViewUtil {
|
|
|
videoView.setVideoURI(uri);
|
|
|
videoView.start();
|
|
|
videoView.requestFocus();
|
|
|
- if(container != null){
|
|
|
+ if (container != null) {
|
|
|
container.setT(new Action1<Integer>() {
|
|
|
@Override
|
|
|
public void call(Integer integer) {
|
|
|
- if(integer == 1){//onResume
|
|
|
+ if (integer == 1) {//onResume
|
|
|
videoView.resume();
|
|
|
- } else if(integer == 2){//onPause
|
|
|
+ } else if (integer == 2) {//onPause
|
|
|
videoView.pause();
|
|
|
}
|
|
|
}
|
|
|
@@ -680,7 +1002,7 @@ public class ViewUtil {
|
|
|
Jump2View.getInstance().tryShowReservation(activity);
|
|
|
}
|
|
|
});
|
|
|
- if(TextUtils.isEmpty(advertising.getDesc())) {
|
|
|
+ if (TextUtils.isEmpty(advertising.getDesc())) {
|
|
|
ad_msg.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
ad_msg.setText(advertising.getDesc());
|
|
|
@@ -692,6 +1014,7 @@ public class ViewUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//显示定向货币详情
|
|
|
public static void showOrienteeringDetails(Activity activity) {
|
|
|
new DialogOrienteeringDetails(activity).showOrienteeringDetails();
|
|
|
@@ -700,98 +1023,109 @@ public class ViewUtil {
|
|
|
/**
|
|
|
* game 充值
|
|
|
*/
|
|
|
- public static void showGamePayAccount(Activity activity,String gameId, String gameName){
|
|
|
+ public static void showGamePayAccount(Activity activity, String gameId, String gameName) {
|
|
|
PayEntity payEntity = new PayEntity();
|
|
|
payEntity.setGame_id(gameId);
|
|
|
payEntity.setGame_name(gameName);
|
|
|
- newInstance().showGamePayAccount(activity,payEntity);
|
|
|
+ newInstance().showGamePayAccount(activity, payEntity);
|
|
|
}
|
|
|
- public void showGamePayAccount(Activity activity,PayEntity payEntity){
|
|
|
- new DialogPayAccount(activity,payEntity).showPayaccount();
|
|
|
+
|
|
|
+ public void showGamePayAccount(Activity activity, PayEntity payEntity) {
|
|
|
+ new DialogPayAccount(activity, payEntity).showPayaccount();
|
|
|
}
|
|
|
- public static void showGamePay(Activity activity, PayEntity payEntity){
|
|
|
+
|
|
|
+ public static void showGamePay(Activity activity, PayEntity payEntity) {
|
|
|
new DialogPayGame(activity, payEntity).showPayGame();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用户详情
|
|
|
*/
|
|
|
- public void showGameAccountDetail(Activity activity, int id){
|
|
|
+ public void showGameAccountDetail(Activity activity, int id) {
|
|
|
new DialogModifyAccount(activity, id).showAddAccount();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 用户详情
|
|
|
*/
|
|
|
- public void showGameAccountDetail(Activity activity, GameAccountEntity item){
|
|
|
+ public void showGameAccountDetail(Activity activity, GameAccountEntity item) {
|
|
|
new DialogModifyAccount(activity, item).showAddAccount();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 分享
|
|
|
+ *
|
|
|
* @param activity
|
|
|
* @param url
|
|
|
*/
|
|
|
- public void showShare(Activity activity, String url, String description){
|
|
|
+ public void showShare(Activity activity, String url, String description) {
|
|
|
new DialogShare(activity, url, description).showShare();
|
|
|
}
|
|
|
|
|
|
public static void centerImage(ImageView imageView, String pictures) {
|
|
|
- if(imageView != null && !TextUtils.isEmpty(pictures)){
|
|
|
- if(pictures.contains(";")){
|
|
|
+ if (imageView != null && !TextUtils.isEmpty(pictures)) {
|
|
|
+ if (pictures.contains(";")) {
|
|
|
pictures = pictures.split(";")[0];
|
|
|
}
|
|
|
GlideImageLoader.centerImage(imageView, pictures);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setImage(ImageView imageView, String pictures) {
|
|
|
- if(imageView != null && !TextUtils.isEmpty(pictures)){
|
|
|
- if(pictures.contains(";")){
|
|
|
+ if (imageView != null && !TextUtils.isEmpty(pictures)) {
|
|
|
+ if (pictures.contains(";")) {
|
|
|
pictures = pictures.split(";")[0];
|
|
|
}
|
|
|
GlideImageLoader.setImage(imageView, pictures);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setImage(ImageView imageView, String pictures, int radius) {
|
|
|
- if(imageView != null && !TextUtils.isEmpty(pictures)){
|
|
|
- if(pictures.contains(";")){
|
|
|
+ if (imageView != null && !TextUtils.isEmpty(pictures)) {
|
|
|
+ if (pictures.contains(";")) {
|
|
|
pictures = pictures.split(";")[0];
|
|
|
}
|
|
|
GlideImageLoader.roundedCornersImage(imageView, pictures, radius);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setTextTime(TextView textView, long time, String format) {
|
|
|
- if(textView != null){
|
|
|
+ if (textView != null) {
|
|
|
textView.setText(TimeUtil.TimeStamp2Date(time, format));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setText(TextView textView) {
|
|
|
- if(textView != null){
|
|
|
+ if (textView != null) {
|
|
|
textView.setText("");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static void setText(TextView textView, String msg) {
|
|
|
- if(textView != null){
|
|
|
+ if (textView != null) {
|
|
|
textView.setText(TextUtils.isEmpty(msg) ? "" : msg);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
public static final String INDENT = "\u3000";//用特殊字符显示空白的缩进字符
|
|
|
+
|
|
|
public static void setText(TextView textView, String msg, int indent) {
|
|
|
- if(textView != null){
|
|
|
+ if (textView != null) {
|
|
|
textView.setText(addIndent(msg, indent));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//在msg前面添加空格
|
|
|
public static String addIndent(String msg, int indent) {
|
|
|
- if(indent > 0){
|
|
|
+ if (indent > 0) {
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
for (int i = 0; i < indent; i++) {
|
|
|
stringBuilder.append(INDENT);
|
|
|
}
|
|
|
- if(!TextUtils.isEmpty(msg))
|
|
|
+ if (!TextUtils.isEmpty(msg))
|
|
|
stringBuilder.append(msg);
|
|
|
return stringBuilder.toString();
|
|
|
}
|
|
|
@@ -803,9 +1137,10 @@ public class ViewUtil {
|
|
|
*/
|
|
|
|
|
|
protected ProgressDialog mPd;
|
|
|
- public void showProgress(Activity activity){
|
|
|
+
|
|
|
+ public void showProgress(Activity activity) {
|
|
|
try {
|
|
|
- if(mPd!=null){
|
|
|
+ if (mPd != null) {
|
|
|
hideProgress(activity);
|
|
|
}
|
|
|
mPd = new ProgressDialog(activity);
|
|
|
@@ -819,9 +1154,10 @@ public class ViewUtil {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- public void showProgress(Activity activity, boolean cancel){
|
|
|
+
|
|
|
+ public void showProgress(Activity activity, boolean cancel) {
|
|
|
try {
|
|
|
- if(mPd!=null){
|
|
|
+ if (mPd != null) {
|
|
|
hideProgress(activity);
|
|
|
}
|
|
|
mPd = new ProgressDialog(activity);
|
|
|
@@ -837,11 +1173,11 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void hideProgress(Activity activity){
|
|
|
+ public void hideProgress(Activity activity) {
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- if(mPd!=null){
|
|
|
+ if (mPd != null) {
|
|
|
mPd.dismiss();
|
|
|
}
|
|
|
}
|
|
|
@@ -852,11 +1188,11 @@ public class ViewUtil {
|
|
|
/**
|
|
|
* 添加游戏账户
|
|
|
*/
|
|
|
- public void showAddAccount(Activity activity, Action1<Integer> action1){
|
|
|
+ public void showAddAccount(Activity activity, Action1<Integer> action1) {
|
|
|
new DialogAddAccount(activity).showAddAccount(action1);
|
|
|
}
|
|
|
|
|
|
- public static void showShareDialog(final Activity activity, final String url, final String description){
|
|
|
+ public static void showShareDialog(final Activity activity, final String url, final String description) {
|
|
|
View dialog_parent = View.inflate(activity, R.layout.ask_to_share, null);
|
|
|
final AlertDialog dialog = new AlertDialog.Builder(activity, R.style.AppTheme_Dialog_Alert)
|
|
|
.setView(dialog_parent)
|
|
|
@@ -915,7 +1251,7 @@ public class ViewUtil {
|
|
|
try {
|
|
|
dialog.show();
|
|
|
Window window = dialog.getWindow();
|
|
|
- if(window != null) {
|
|
|
+ if (window != null) {
|
|
|
window.setGravity(Gravity.BOTTOM);
|
|
|
WindowManager.LayoutParams params = window.getAttributes();
|
|
|
params.width = G.WIDTH > G.HEIGHT ? G.HEIGHT : G.WIDTH;
|
|
|
@@ -925,7 +1261,38 @@ public class ViewUtil {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- public static String getNetImgByName(String name){
|
|
|
+
|
|
|
+ public static String getNetImgByName(String name) {
|
|
|
return String.format(Locale.CHINA, "http://cdngame.kuaifazs.com/%s.png", name);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 标签类型(0无,1热门,2最新,3现金,4活跃,5福利)
|
|
|
+ * homepage item statues
|
|
|
+ */
|
|
|
+ public void showGridviewStatues(Context context, TextView textView, HomeListEntity entity) {
|
|
|
+ textView.setVisibility(View.INVISIBLE);
|
|
|
+
|
|
|
+ int padding = textView.getContext().getResources().getDimensionPixelSize(R.dimen.content_padding_2);
|
|
|
+ switch (entity.getTag()) {
|
|
|
+ default:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ textView.setVisibility(View.VISIBLE);
|
|
|
+ textView.setBackgroundResource(R.drawable.shape_red_stroke_rectangle_no_lb);
|
|
|
+ textView.setTextColor(context.getResources().getColor(R.color.red_FD2D54));
|
|
|
+ textView.setText("现金");
|
|
|
+ textView.setPadding(4 * padding, padding, 4 * padding, padding);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ textView.setVisibility(View.VISIBLE);
|
|
|
+ textView.setBackgroundResource(R.drawable.shape_red_f07422_stroke_retangle_no_lb);
|
|
|
+ textView.setTextColor(context.getResources().getColor(R.color.red_F07422));
|
|
|
+ textView.setText("活跃");
|
|
|
+ textView.setPadding(4 * padding, padding, 4 * padding, padding);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|