|
|
@@ -4,10 +4,13 @@ import android.app.ActionBar;
|
|
|
import android.app.Activity;
|
|
|
import android.app.Dialog;
|
|
|
import android.app.ProgressDialog;
|
|
|
+import android.content.ClipData;
|
|
|
+import android.content.ClipboardManager;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Bitmap;
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
import android.graphics.Color;
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
@@ -18,6 +21,7 @@ import android.provider.MediaStore;
|
|
|
import android.support.v4.app.FragmentActivity;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.widget.GridLayoutManager;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.Html;
|
|
|
import android.text.TextUtils;
|
|
|
@@ -43,6 +47,13 @@ import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.RequestBuilder;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.jcodecraeer.xrecyclerview.CustomFooterViewCallBack;
|
|
|
+import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
|
|
+import com.kfzs.duanduan.cardview.BlurBitmapUtils;
|
|
|
+import com.kfzs.duanduan.cardview.CardAdapter;
|
|
|
+import com.kfzs.duanduan.cardview.CardScaleHelper;
|
|
|
+import com.kfzs.duanduan.cardview.SpeedRecyclerView;
|
|
|
+import com.kfzs.duanduan.cardview.ViewSwitchUtils;
|
|
|
import com.kfzs.duanduan.fragment.FgtPersonalCenter;
|
|
|
import com.sheep.gamegroup.dateview.DatePickerDialog;
|
|
|
import com.sheep.gamegroup.dateview.DateUtil;
|
|
|
@@ -79,6 +90,7 @@ import java.io.File;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
@@ -102,6 +114,9 @@ public class ViewUtil {
|
|
|
public static final int REQUEST_CODE_TASK_LIST = 110;
|
|
|
private static ViewUtil viewUtil;
|
|
|
static RobTask mRobTask;
|
|
|
+ private static int mLastPos = -1;
|
|
|
+ private static CardScaleHelper mCardScaleHelper = new CardScaleHelper();
|
|
|
+ private static Runnable mBlurRunnable;
|
|
|
|
|
|
public static ViewUtil newInstance() {
|
|
|
if (viewUtil == null) {
|
|
|
@@ -266,7 +281,7 @@ public class ViewUtil {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
mRobTask = getTask(ivIcon, tvTitel, tvDutyMoney);
|
|
|
- LogUtil.logI("抢任务---"+new Gson().toJson(mRobTask));
|
|
|
+ LogUtil.logI("抢任务---" + new Gson().toJson(mRobTask));
|
|
|
|
|
|
}
|
|
|
});
|
|
|
@@ -298,6 +313,7 @@ public class ViewUtil {
|
|
|
|
|
|
/**
|
|
|
* 设置默认方块文本
|
|
|
+ *
|
|
|
* @param textView
|
|
|
*/
|
|
|
public static void setDefaultText(TextView textView) {
|
|
|
@@ -349,6 +365,24 @@ public class ViewUtil {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ edInvitationCode.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onLongClick(View view) {
|
|
|
+ // 获取系统剪贴板
|
|
|
+ ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService(Context.CLIPBOARD_SERVICE);
|
|
|
+ // 获取剪贴板的剪贴数据集
|
|
|
+ ClipData clipData = clipboard.getPrimaryClip();
|
|
|
+
|
|
|
+ if (clipData != null && clipData.getItemCount() > 0) {
|
|
|
+ // 从数据集中获取(粘贴)第一条文本数据
|
|
|
+ CharSequence codetext = clipData.getItemAt(0).getText();
|
|
|
+ if (!TextUtils.isEmpty(codetext)){
|
|
|
+ edInvitationCode.setText(codetext);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
ivClose.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
@@ -443,6 +477,35 @@ public class ViewUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static void setBottomLine(final XRecyclerView view_list) {
|
|
|
+ View view = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.common_foot_view, null);
|
|
|
+ view_list.setFootView(view, new CustomFooterViewCallBack() {
|
|
|
+ @Override
|
|
|
+ public void onLoadingMore(View yourFooterView) {
|
|
|
+ TextView bottom_line_text = yourFooterView.findViewById(R.id.bottom_line_text);
|
|
|
+ bottom_line_text.setText("羊羊努力加载中...");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoadMoreComplete(View yourFooterView) {
|
|
|
+ TextView bottom_line_text = yourFooterView.findViewById(R.id.bottom_line_text);
|
|
|
+ bottom_line_text.setText("羊羊努力加载中...");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSetNoMore(View yourFooterView, boolean noMore) {
|
|
|
+ TextView bottom_line_text = yourFooterView.findViewById(R.id.bottom_line_text);
|
|
|
+ bottom_line_text.setText("我是有底线的,点击我回到顶部");
|
|
|
+ yourFooterView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ view_list.scrollToPosition(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* popwindow消失监听类,消失恢复window透明度
|
|
|
*/
|
|
|
@@ -535,6 +598,7 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 领取福利成功的对话框
|
|
|
*
|
|
|
@@ -686,6 +750,7 @@ public class ViewUtil {
|
|
|
new StringBuilder("<html><head><meta name=\"viewport\" content=\"width=device-width,height=auto, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" /><style>img{max-width:100% !important;height:auto !important;}</style><style>body{max-width:100% !important;}</style></head><body>").append(content).append("</body></html>").toString()
|
|
|
, "text/html", "utf-8", null);
|
|
|
}
|
|
|
+
|
|
|
public static void loadDataWithBaseURL(WebView webView, String content) {
|
|
|
webView.loadDataWithBaseURL(null,
|
|
|
new StringBuilder("<html><head><meta name=\"viewport\" content=\"width=device-width,height=auto, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" /><style>img{max-width:100% !important;height:auto !important;}</style><style>body{max-width:100% !important;}</style></head><body>").append(content).append("</body></html>").toString()
|
|
|
@@ -1273,6 +1338,79 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 初始化画廊
|
|
|
+ *
|
|
|
+ * @param mRecyclerView ,recycleView
|
|
|
+ * @param mBlurView 显示的ImageView
|
|
|
+ * @param mList 图片文件地址集合,
|
|
|
+ * @param context 。。。
|
|
|
+ */
|
|
|
+ private static void init(SpeedRecyclerView mRecyclerView, ImageView mBlurView, List<Integer> mList, Context context) {
|
|
|
+ if (mList == null) {
|
|
|
+ mList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ mList.add(R.drawable.kaipin);
|
|
|
+ mList.add(R.drawable.kaipin);
|
|
|
+ mList.add(R.drawable.kaipin);
|
|
|
+ }
|
|
|
+
|
|
|
+ final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
|
|
|
+ mRecyclerView.setLayoutManager(linearLayoutManager);
|
|
|
+ mRecyclerView.setAdapter(new CardAdapter(mList));
|
|
|
+ // mRecyclerView绑定scale效果
|
|
|
+ mCardScaleHelper.setCurrentItemPos(2);
|
|
|
+ mCardScaleHelper.attachToRecyclerView(mRecyclerView);
|
|
|
+
|
|
|
+ initBlurBackground(mBlurView, mRecyclerView, mList, context);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给画廊设置背景
|
|
|
+ *
|
|
|
+ * @param mBlurView
|
|
|
+ * @param mRecyclerView
|
|
|
+ * @param mList
|
|
|
+ * @param context
|
|
|
+ */
|
|
|
+ private static void initBlurBackground(ImageView mBlurView, RecyclerView mRecyclerView, final List<Integer> mList, final Context context) {
|
|
|
+ final ImageView finalMBlurView = mBlurView;
|
|
|
+ mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
|
+ @Override
|
|
|
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
|
+ super.onScrollStateChanged(recyclerView, newState);
|
|
|
+ if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
|
|
+ notifyBackgroundChange(finalMBlurView, mList, context);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ notifyBackgroundChange(mBlurView, mList, context);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检测画廊图片变化
|
|
|
+ *
|
|
|
+ * @param mBlurView
|
|
|
+ * @param mList
|
|
|
+ * @param context
|
|
|
+ */
|
|
|
+ private static void notifyBackgroundChange(final ImageView mBlurView, List<Integer> mList, final Context context) {
|
|
|
+ if (mLastPos == mCardScaleHelper.getCurrentItemPos()) return;
|
|
|
+ mLastPos = mCardScaleHelper.getCurrentItemPos();
|
|
|
+ final int resId = mList.get(mCardScaleHelper.getCurrentItemPos());
|
|
|
+ mBlurView.removeCallbacks(mBlurRunnable);
|
|
|
+ mBlurRunnable = new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId);
|
|
|
+ ViewSwitchUtils.startSwitchBackgroundAnim(mBlurView, BlurBitmapUtils.getBlurBitmap(mBlurView.getContext(), bitmap, 15));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ mBlurView.postDelayed(mBlurRunnable, 500);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 添加游戏账户
|
|
|
*/
|
|
|
public void showAddAccount(Activity activity, Action1<Integer> action1) {
|
|
|
@@ -1282,8 +1420,19 @@ public class ViewUtil {
|
|
|
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)
|
|
|
+ .setView(dialog_parent).setCancelable(true)
|
|
|
.create();
|
|
|
+ Window windows = dialog.getWindow();
|
|
|
+ windows.setGravity(Gravity.BOTTOM); //Dialog在屏幕底部弹出来
|
|
|
+ WindowManager.LayoutParams layoutParams = windows.getAttributes();//获得布局属性
|
|
|
+ layoutParams.width = 400; //设置Dialog的宽
|
|
|
+ layoutParams.height = 200; //设置Dialog的高
|
|
|
+ windows.setWindowAnimations(R.style.Rising);//设置动画效果
|
|
|
+ View viewEmpty = dialog_parent.findViewById(R.id.empty_view);
|
|
|
+ // SpeedRecyclerView speedRecyclerView = dialog_parent.findViewById(R.id.recyclerView);
|
|
|
+ // ImageView card = dialog_parent.findViewById(R.id.blurView);
|
|
|
+ // List<Integer> mList = new ArrayList<>();
|
|
|
+ // init(speedRecyclerView, card, mList, activity);
|
|
|
// TextView ask_share_title = dialog_parent.findViewById(R.id.ask_share_title);
|
|
|
RecyclerView ask_share_list = dialog_parent.findViewById(R.id.ask_share_list);
|
|
|
GridLayoutManager gridLayoutManager = new GridLayoutManager(activity, 5);
|
|
|
@@ -1308,6 +1457,12 @@ public class ViewUtil {
|
|
|
nameList.add("QQ好友");
|
|
|
nameList.add("朋友圈");
|
|
|
nameList.add("复制链接");
|
|
|
+ viewEmpty.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ dialog.cancel();
|
|
|
+ }
|
|
|
+ });
|
|
|
AdbCommonRecycler<String> adapter = new AdbCommonRecycler<String>(activity, list) {
|
|
|
|
|
|
@Override
|
|
|
@@ -1371,23 +1526,24 @@ public class ViewUtil {
|
|
|
textView.setBackgroundResource(R.drawable.shape_red_stroke_rectangle_no_lb);
|
|
|
textView.setTextColor(context.getResources().getColor(R.color.red_FD2D54));
|
|
|
textView.setText("现金");
|
|
|
- textView.setPadding( padding2, padding1, padding2, padding1);
|
|
|
+ textView.setPadding(padding2, padding1, padding2, padding1);
|
|
|
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( padding2, padding1, padding2, padding1);
|
|
|
+ textView.setPadding(padding2, padding1, padding2, padding1);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取状态栏高度
|
|
|
*
|
|
|
- * @return , 状态栏高度
|
|
|
* @param activity
|
|
|
+ * @return , 状态栏高度
|
|
|
*/
|
|
|
public static int getBarHeight(FragmentActivity activity) {
|
|
|
int result = 0;
|