|
|
@@ -277,7 +277,7 @@ public class ViewUtil {
|
|
|
|
|
|
//加载js
|
|
|
public static void loadJs(com.tencent.smtt.sdk.WebView mWebView, String js, com.tencent.smtt.sdk.ValueCallback<String> stringValueCallback) {
|
|
|
- if(mWebView == null){
|
|
|
+ if (mWebView == null) {
|
|
|
return;
|
|
|
}
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
@@ -351,6 +351,7 @@ public class ViewUtil {
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(observer);
|
|
|
}
|
|
|
+
|
|
|
public static void delay2(Observer<Integer> observer, long delay) {
|
|
|
io.reactivex.Observable.just(1)
|
|
|
.delay(delay, TimeUnit.MILLISECONDS)
|
|
|
@@ -378,20 +379,21 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void setImageLevel(ImageView imageView, int level) {
|
|
|
- if(imageView != null){
|
|
|
+ if (imageView != null) {
|
|
|
imageView.setImageLevel(level);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void showMiddleLine(TextView textView) {
|
|
|
- if(textView != null){
|
|
|
- textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG );
|
|
|
+ if (textView != null) {
|
|
|
+ textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void showUnderLine(TextView textView) {
|
|
|
- if(textView != null){
|
|
|
- textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG );
|
|
|
+ if (textView != null) {
|
|
|
+ textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -780,6 +782,24 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
public static void shareLink(final Activity activity, String viewTitle, final String link, final String title, final String content, final ShareCallback callback) {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getShortUrl(link)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ toShare(activity, viewTitle, baseMessage.getData().toString(), title, content, callback);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ G.shortToast("分享失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void toShare(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)
|
|
|
@@ -1625,8 +1645,8 @@ public class ViewUtil {
|
|
|
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);
|
|
|
- ViewGroup parent = (ViewGroup)dialog_center_ll.getParent();
|
|
|
- ((FrameLayout.LayoutParams)parent.getLayoutParams()).setMargins(0, 0, 0, 0);
|
|
|
+ ViewGroup parent = (ViewGroup) dialog_center_ll.getParent();
|
|
|
+ ((FrameLayout.LayoutParams) parent.getLayoutParams()).setMargins(0, 0, 0, 0);
|
|
|
Window win = dialog.getWindow();
|
|
|
win.getDecorView().setPadding(0, 0, 0, 0);
|
|
|
WindowManager.LayoutParams lp = win.getAttributes();
|
|
|
@@ -2124,11 +2144,13 @@ public class ViewUtil {
|
|
|
textView.setText(TextUtils.isEmpty(msg) ? "" : msg);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setTextId(TextView textView, int msg) {
|
|
|
if (textView != null) {
|
|
|
textView.setText(SheepApp.getInstance().getString(msg));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public static void setOnClickListener(View view, View.OnClickListener onClickListener) {
|
|
|
if (view != null && onClickListener != null) {
|
|
|
view.setOnClickListener(onClickListener);
|