|
|
@@ -252,6 +252,7 @@ public class ViewUtil {
|
|
|
mWebView.loadUrl("javascript:" + js);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//加载js
|
|
|
public static void loadJs(WebView mWebView, String js) {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
@@ -268,7 +269,7 @@ public class ViewUtil {
|
|
|
|
|
|
//刷新RecyclerView的adapter
|
|
|
public static void notifyDataSetChanged(RecyclerView recyclerView) {
|
|
|
- if(recyclerView != null && recyclerView.getAdapter() != null)
|
|
|
+ if (recyclerView != null && recyclerView.getAdapter() != null)
|
|
|
recyclerView.getAdapter().notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
@@ -344,6 +345,7 @@ public class ViewUtil {
|
|
|
public void showRobDutyDialog(final Activity mActivity, RobTask robTask) {
|
|
|
showRobDutyDialog(mActivity, robTask, R.layout.dialog_game_or_task_or_gift, null);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 抢任务弹框
|
|
|
*
|
|
|
@@ -354,7 +356,7 @@ public class ViewUtil {
|
|
|
final AlertDialog mAlertDialog = new AlertDialog.Builder(mActivity, R.style.MyDialogActivityTheme)
|
|
|
.setView(view)
|
|
|
.create();
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(view);
|
|
|
View dialog_btn_left = view.findViewById(R.id.dialog_btn_left);
|
|
|
View dialog_btn_right = view.findViewById(R.id.dialog_btn_right);
|
|
|
@@ -704,6 +706,10 @@ public class ViewUtil {
|
|
|
* @param link
|
|
|
*/
|
|
|
public static void shareLink(final Activity activity, final String link) {
|
|
|
+ shareLink(activity, null, link, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void shareLink(final Activity activity, String viewTitle, final String link, final String title, final String content, final ShareCallback callback) {
|
|
|
View dialog_parent = View.inflate(activity, R.layout.dialog_parent, null);
|
|
|
final AlertDialog dialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
|
|
|
.setView(dialog_parent)
|
|
|
@@ -712,7 +718,7 @@ public class ViewUtil {
|
|
|
View dialog_close = dialog_parent.findViewById(R.id.dialog_close);
|
|
|
LinearLayout dialog_center_ll = dialog_parent.findViewById(R.id.dialog_center_ll);
|
|
|
View view = LayoutInflater.from(activity).inflate(R.layout.x_recommend_dialog, dialog_center_ll, true);
|
|
|
- dialog_title.setText("推荐给好友");
|
|
|
+ dialog_title.setText(TextUtils.isEmpty(viewTitle) ? "推荐给好友" : viewTitle);
|
|
|
|
|
|
View wx = view.findViewById(R.id.but_share_wx);
|
|
|
View qq = view.findViewById(R.id.but_share_qq);
|
|
|
@@ -726,7 +732,7 @@ public class ViewUtil {
|
|
|
wx.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- shareAction(activity, link, SHARE_MEDIA.WEIXIN);
|
|
|
+ shareAction(activity, title, content, link, SHARE_MEDIA.WEIXIN, callback);
|
|
|
dialog.dismiss();
|
|
|
}
|
|
|
});
|
|
|
@@ -735,7 +741,7 @@ public class ViewUtil {
|
|
|
qq.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- shareAction(activity, link, SHARE_MEDIA.QQ);
|
|
|
+ shareAction(activity, title, content, link, SHARE_MEDIA.QQ, callback);
|
|
|
dialog.dismiss();
|
|
|
}
|
|
|
});
|
|
|
@@ -744,7 +750,7 @@ public class ViewUtil {
|
|
|
pyq.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- shareAction(activity, link, SHARE_MEDIA.WEIXIN_CIRCLE);
|
|
|
+ shareAction(activity, title, content, link, SHARE_MEDIA.WEIXIN_CIRCLE, callback);
|
|
|
dialog.dismiss();
|
|
|
}
|
|
|
});
|
|
|
@@ -753,7 +759,7 @@ public class ViewUtil {
|
|
|
zone.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- shareAction(activity, link, SHARE_MEDIA.QZONE);
|
|
|
+ shareAction(activity, title, content, link, SHARE_MEDIA.QZONE, callback);
|
|
|
dialog.dismiss();
|
|
|
}
|
|
|
});
|
|
|
@@ -811,16 +817,16 @@ public class ViewUtil {
|
|
|
* @param url 分享链接
|
|
|
* @param media 分享平台
|
|
|
*/
|
|
|
- private static void shareAction(Activity activity, String url, SHARE_MEDIA media) {
|
|
|
+ private static void shareAction(Activity activity, String title, String content, String url, SHARE_MEDIA media, final ShareCallback callback) {
|
|
|
/* 缩略图 */
|
|
|
UMImage image = new UMImage(activity, R.drawable.icon);
|
|
|
/* URL */
|
|
|
UMWeb web = new UMWeb(url);
|
|
|
/* 标题 */
|
|
|
- web.setTitle("赚钱就来小绵羊");
|
|
|
+ web.setTitle(!TextUtils.isEmpty(title) ? "赚钱就来小绵羊" : title);
|
|
|
web.setThumb(image);
|
|
|
- web.setDescription("更懂你的赚钱工具,超多福利,超多赏金,拿到你手软!");
|
|
|
- switch (media){
|
|
|
+ web.setDescription(!TextUtils.isEmpty(content) ? "更懂你的赚钱工具,超多福利,超多赏金,拿到你手软!" : content);
|
|
|
+ switch (media) {
|
|
|
case WEIXIN_CIRCLE:
|
|
|
web.setTitle(web.getTitle() + "\n" + web.getDescription());
|
|
|
break;
|
|
|
@@ -837,6 +843,9 @@ public class ViewUtil {
|
|
|
@Override
|
|
|
public void onResult(SHARE_MEDIA share_media) {
|
|
|
G.showToast("分享成功!");
|
|
|
+ if (callback != null) {
|
|
|
+ callback.callback();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -852,6 +861,10 @@ public class ViewUtil {
|
|
|
action.share();
|
|
|
}
|
|
|
|
|
|
+ public static interface ShareCallback {
|
|
|
+ void callback();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 领取福利成功的对话框
|
|
|
*
|
|
|
@@ -1022,6 +1035,7 @@ public class ViewUtil {
|
|
|
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setH5ImgText(TextView textView, String content, int maxWidth, Html.TagHandler tagHandler) {
|
|
|
if (textView != null) {
|
|
|
if (TextUtils.isEmpty(content)) {
|
|
|
@@ -1514,8 +1528,8 @@ public class ViewUtil {
|
|
|
|
|
|
|
|
|
public static void centerImage(ImageView imageView, String pictures) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1527,8 +1541,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setAvatar(ImageView imageView, String pictures) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1540,8 +1554,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setBlur(ImageView imageView, String pictures) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1553,8 +1567,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setImage(ImageView imageView, String pictures) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1578,8 +1592,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setImageLoading(ImageView imageView, String pictures) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1591,8 +1605,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setImage(ImageView imageView, String pictures, int radius) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1604,8 +1618,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setGameImage(ImageView imageView, String pictures) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1617,8 +1631,8 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setGameImage(ImageView imageView, String pictures, int radius) {
|
|
|
- if (imageView != null){
|
|
|
- if(TextUtils.isEmpty(pictures)) {
|
|
|
+ if (imageView != null) {
|
|
|
+ if (TextUtils.isEmpty(pictures)) {
|
|
|
imageView.setImageResource(R.mipmap.icon);
|
|
|
} else {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1661,6 +1675,7 @@ public class ViewUtil {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setText(TextView textView, IContentTypeContainer<Integer, String> contentTypeContainer, int maxWidth, Html.TagHandler tagHandler) {
|
|
|
switch (contentTypeContainer.getContentType()) {
|
|
|
case StringUtils.CONTENT_TYPE_FONT:
|
|
|
@@ -1690,9 +1705,10 @@ public class ViewUtil {
|
|
|
|
|
|
/**
|
|
|
* 设置视频播放和播放按钮与占位图
|
|
|
+ *
|
|
|
* @param videoView
|
|
|
* @param placeHolderlView 占位图片
|
|
|
- * @param control 控制播放的按钮
|
|
|
+ * @param control 控制播放的按钮
|
|
|
* @param url
|
|
|
*/
|
|
|
public static void setVideoAndFull(final VideoView videoView, final ImageView placeHolderlView, final ImageView control, final String url) {
|
|
|
@@ -1760,6 +1776,7 @@ public class ViewUtil {
|
|
|
view.setEnabled(enabled);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setVisibility(View view, boolean isVisible) {
|
|
|
if (view != null) {
|
|
|
view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
|
|
@@ -1868,9 +1885,10 @@ public class ViewUtil {
|
|
|
|
|
|
/**
|
|
|
* 显示分享弹出框
|
|
|
+ *
|
|
|
* @param activity
|
|
|
* @param shareLinkConfig
|
|
|
- * @param action1 回调的view为nul时,代表流程结束;不为空时,代表初始化dialog的view,可以做自定义
|
|
|
+ * @param action1 回调的view为nul时,代表流程结束;不为空时,代表初始化dialog的view,可以做自定义
|
|
|
*/
|
|
|
public static void showShareDialog(final Activity activity, final ShareLinkConfig shareLinkConfig, final Action1<View> action1) {
|
|
|
View dialogView = View.inflate(activity, R.layout.ask_to_share, null);
|
|
|
@@ -1879,7 +1897,7 @@ public class ViewUtil {
|
|
|
.create();
|
|
|
// TextView ask_share_title = dialogView.findViewById(R.id.ask_share_title);
|
|
|
RecyclerView ask_share_list = dialogView.findViewById(R.id.ask_share_list);
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(dialogView);
|
|
|
// ask_share_list.setHasFixedSize(true);
|
|
|
// ask_share_list.setNestedScrollingEnabled(false);
|
|
|
@@ -1941,7 +1959,7 @@ public class ViewUtil {
|
|
|
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
@Override
|
|
|
public void onDismiss(DialogInterface dialogInterface) {
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(null);
|
|
|
}
|
|
|
});
|
|
|
@@ -1956,7 +1974,7 @@ public class ViewUtil {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- if(action1 != null)
|
|
|
+ if (action1 != null)
|
|
|
action1.call(null);
|
|
|
}
|
|
|
}
|