|
|
@@ -18,6 +18,7 @@ import android.media.MediaPlayer;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
import android.provider.MediaStore;
|
|
|
+import android.support.v4.app.ActivityOptionsCompat;
|
|
|
import android.support.v4.app.FragmentActivity;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.widget.GridLayoutManager;
|
|
|
@@ -53,6 +54,9 @@ import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
|
|
import com.kfzs.duanduan.utils.NumberFormatUtils;
|
|
|
import com.mdad.sdk.mdsdk.common.AdData;
|
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
+import com.sheep.gamegroup.absBase.IContentContainer;
|
|
|
+import com.sheep.gamegroup.absBase.IContentTypeContainer;
|
|
|
+import com.sheep.gamegroup.absBase.ITag;
|
|
|
import com.sheep.gamegroup.dateview.DatePickerDialog;
|
|
|
import com.sheep.gamegroup.dateview.DateUtil;
|
|
|
import com.sheep.gamegroup.model.entity.Advertising;
|
|
|
@@ -81,6 +85,7 @@ import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
|
|
|
import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.ui.activity.PlayVideoActivity;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.PackageUtil;
|
|
|
@@ -218,7 +223,7 @@ public class ViewUtil {
|
|
|
|
|
|
public static void refreshXrv(XRecyclerView view_list) {
|
|
|
try {
|
|
|
- if(view_list != null)
|
|
|
+ if (view_list != null)
|
|
|
view_list.refresh();
|
|
|
/**
|
|
|
* java.lang.NullPointerException: Attempt to invoke virtual method 'void com.jcodecraeer.xrecyclerview.ArrowRefreshHeader.setState(int)' on a null object reference
|
|
|
@@ -260,7 +265,7 @@ public class ViewUtil {
|
|
|
/**
|
|
|
* 抢任务弹框
|
|
|
*
|
|
|
- * @param mActivity 当前Activity,
|
|
|
+ * @param mActivity 当前Activity,
|
|
|
*/
|
|
|
public void showRobDutyDialog(final Activity mActivity, RobTask robTask) {
|
|
|
View view = LayoutInflater.from(mActivity).inflate(R.layout.dialog_game_or_task_or_gift, null, false);
|
|
|
@@ -337,6 +342,7 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static final String BLOCK = "\u2588";//用特殊字符显示方块
|
|
|
+
|
|
|
/**
|
|
|
* 设置默认方块文本
|
|
|
*
|
|
|
@@ -690,7 +696,7 @@ public class ViewUtil {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
QR_SAVE.onEvent();
|
|
|
- try{
|
|
|
+ try {
|
|
|
File file = ViewUtil.saveImage((View) iv_qr.getParent(), ClassFileHelper.DIR, System.currentTimeMillis() + ".jpg");
|
|
|
if (file != null) {
|
|
|
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
|
|
@@ -833,10 +839,11 @@ public class ViewUtil {
|
|
|
* 获取一个 View 的缓存视图
|
|
|
* 如果报错:Software rendering doesn't support hardware bitmaps
|
|
|
* 在Glide 4.3上,hardware bitmaps(开启hardware bitmaps作用大概就是在使用ARGB_8888这种高质量的图片时,图片在内存中只会存在一份,反正就是一种节省内存的机制。) 配置默认是开启的,这也是Glide的一个Bug,高版本不知道修复了没有。
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 解决方案是在构建RequestOptions时,将该配置关掉。
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* requestOptions.disallowHardwareConfig();
|
|
|
+ *
|
|
|
* @param view
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -912,6 +919,7 @@ public class ViewUtil {
|
|
|
textView.setMovementMethod(new ScrollingMovementMethod());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setH5ImgText(TextView textView, String content) {
|
|
|
if (textView != null) {
|
|
|
if (TextUtils.isEmpty(content)) {
|
|
|
@@ -994,13 +1002,13 @@ public class ViewUtil {
|
|
|
if (dialogConfig.getMsgIndent() > 0) {
|
|
|
msg = addIndent(msg, dialogConfig.getMsgIndent());
|
|
|
}
|
|
|
- if(msg.startsWith("<p>")){//<p></p>这种格式的用dialog_msg.setText(Html.fromHtml(msg));方式显示,避免高度变化,影响用户体验
|
|
|
+ if (msg.startsWith("<p>")) {//<p></p>这种格式的用dialog_msg.setText(Html.fromHtml(msg));方式显示,避免高度变化,影响用户体验
|
|
|
dialog_msg.setText(Html.fromHtml(msg));
|
|
|
- if(msg.split("<p>").length > 1){
|
|
|
+ if (msg.split("<p>").length > 1) {
|
|
|
ViewGroup.LayoutParams msgLayoutParams = dialog_msg.getLayoutParams();
|
|
|
- if(msgLayoutParams instanceof LinearLayout.LayoutParams){
|
|
|
+ if (msgLayoutParams instanceof LinearLayout.LayoutParams) {
|
|
|
((LinearLayout.LayoutParams) msgLayoutParams).bottomMargin *= -2;
|
|
|
- } else if(BuildConfig.DEBUG){
|
|
|
+ } else if (BuildConfig.DEBUG) {
|
|
|
G.showToast("这里的bottomMargin显得多了,需要干掉");
|
|
|
}
|
|
|
dialog_msg.setLayoutParams(msgLayoutParams);
|
|
|
@@ -1430,6 +1438,7 @@ public class ViewUtil {
|
|
|
GlideImageLoader.setAvatar(imageView, pictures);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setBlur(ImageView imageView, String pictures) {
|
|
|
if (imageView != null && !TextUtils.isEmpty(pictures)) {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1438,6 +1447,7 @@ public class ViewUtil {
|
|
|
GlideImageLoader.setBlur(imageView, pictures);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setImage(ImageView imageView, String pictures) {
|
|
|
if (imageView != null && !TextUtils.isEmpty(pictures)) {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1455,6 +1465,7 @@ public class ViewUtil {
|
|
|
GlideImageLoader.roundedCornersImage(imageView, pictures, radius);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setGameImage(ImageView imageView, String pictures) {
|
|
|
if (imageView != null && !TextUtils.isEmpty(pictures)) {
|
|
|
if (pictures.contains(";")) {
|
|
|
@@ -1490,16 +1501,78 @@ public class ViewUtil {
|
|
|
textView.setText(TextUtils.isEmpty(msg) ? "" : msg);
|
|
|
}
|
|
|
}
|
|
|
+ public static void setText(TextView textView, IContentTypeContainer<Integer, String> contentTypeContainer) {
|
|
|
+ switch (contentTypeContainer.getContentType()){
|
|
|
+ case StringUtils.CONTENT_TYPE_FONT:
|
|
|
+ setText(textView, contentTypeContainer.getContentResult());
|
|
|
+ break;
|
|
|
+ case StringUtils.CONTENT_TYPE_H5:
|
|
|
+ setH5Text(textView, contentTypeContainer.getContentResult());
|
|
|
+ break;
|
|
|
+ case StringUtils.CONTENT_TYPE_EXP:
|
|
|
+ setH5ImgText(textView, contentTypeContainer.getContentResult());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void setText(TextView textView, int integer) {
|
|
|
if (textView != null) {
|
|
|
textView.setText(String.valueOf(integer));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setText(TextView textView, float f) {
|
|
|
if (textView != null) {
|
|
|
textView.setText(String.valueOf(f));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static void setVideoAndFull(final VideoView videoView, View fullView, final View loading, String url) {
|
|
|
+ if (videoView == null || url == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final Activity activity = ActivityManager.getInstance().currentActivity();
|
|
|
+ videoView.setVideoURI(Uri.parse(url));
|
|
|
+ videoView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (videoView.isPlaying()) {
|
|
|
+ videoView.pause();
|
|
|
+ } else if (!videoView.isPlaying()) {
|
|
|
+ videoView.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ videoView.setOnInfoListener(new MediaPlayer.OnInfoListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onInfo(MediaPlayer mediaPlayer, int what, int extra) {
|
|
|
+ if(!mediaPlayer.isLooping())
|
|
|
+ mediaPlayer.setLooping(true);
|
|
|
+ LogUtil.println("onInfo what = " + what + " extra = " + extra);
|
|
|
+ if(MediaPlayer.MEDIA_INFO_BUFFERING_START == what){
|
|
|
+ if(loading != null)
|
|
|
+ loading.setVisibility(View.GONE);
|
|
|
+// btnJoin.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Uri uri = Uri.parse(url);
|
|
|
+ videoView.setVideoURI(uri);
|
|
|
+ videoView.start();
|
|
|
+ videoView.requestFocus();
|
|
|
+ if (fullView == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ fullView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ activity.startActivity(new Intent(activity, PlayVideoActivity.class),
|
|
|
+ ActivityOptionsCompat.makeSceneTransitionAnimation(activity, videoView, "video").toBundle());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
public static void setTextRetainMost2(TextView textView, float f) {
|
|
|
if (textView != null) {
|
|
|
textView.setText(NumberFormatUtils.retainMost2(f));
|
|
|
@@ -1511,6 +1584,7 @@ public class ViewUtil {
|
|
|
view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setVisibility2(View view, boolean isVisible) {
|
|
|
if (view != null) {
|
|
|
view.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
|
|
|
@@ -1692,12 +1766,13 @@ public class ViewUtil {
|
|
|
* 标签类型(0无,1热门,2最新,3现金,4活跃,5福利,6红包)
|
|
|
* homepage item statues
|
|
|
*/
|
|
|
- public void showGridviewStatues(Context context, TextView textView, HomeListEntity entity) {
|
|
|
+ public static void updateTag(TextView textView, ITag tag) {
|
|
|
+ Context context = SheepApp.getInstance();
|
|
|
textView.setVisibility(View.INVISIBLE);
|
|
|
|
|
|
int padding1 = textView.getContext().getResources().getDimensionPixelSize(R.dimen.content_padding_1);
|
|
|
int padding2 = textView.getContext().getResources().getDimensionPixelSize(R.dimen.content_padding_2);
|
|
|
- switch (entity.getTag()) {
|
|
|
+ switch (tag.getTag()) {
|
|
|
default:
|
|
|
|
|
|
break;
|