XML
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_title_vip"
android:layout_marginStart="12dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="20dp"/>
android:adjustViewBounds 让ImageView根据图片的实际宽高比自动调整边界
方法block回调,参数透传
fun checkShowEmoteGuide(callback: (() -> Unit)?= null) {
callback?.invoke()
}
fun videoFeedConfig(val scene: String?, val canSlide: Boolean? = false) {
}
接收 new
emoteView.checkShowEmoteGuide(new Function0<Unit>() {
@Override
public Unit invoke() {
isShowEmote = true;
return null;
}
});
本地存储
getUserSp 用户纬度
UserHelper.getGlobleSp 设备纬度
UserHelper.getGlobleSp().putBoolean(PreferencesConst.POST_INFO_COMMENT_GUIDE, true);
boolean isShowComment = UserHelper.getGlobleSp().getBoolean(PreferencesConst.POST_INFO_COMMENT_GUIDE, false);
动画
java
contentView.animate()
.alpha(0f)
.setDuration(300)
.withEndAction(new Runnable() {
@Override
public void run() {
if (guidePopupWindow != null) {
guidePopupWindow.safeDismiss();
guidePopupWindow = null;
}
}
})
.start();
kt
contentView.alpha = 0f
contentView.animate()
.alpha(1f)
.setDuration(300)
.start()
runnable 任务
private Runnable showGuidePopupRunnable() {
return new Runnable() {
@Override
public void run() {
mBottomView.removeCallbacks(null);
if (isShowEmote == false && guidePopupWindow != null && commentContentOnTheScreen(1)) {
guidePopupWindow.showAsDropDown(mBottomView, DpAndPxUtils.dip2px(-16), DpAndPxUtils.dip2px(-100));
isShowComment = true;
UserHelper.getGlobleSp().putBoolean(PreferencesConst.POST_INFO_COMMENT_GUIDE, true);
contentView.setAlpha(0f);
contentView.animate()
.alpha(1f)
.setDuration(300)
.start();
mBottomView.postDelayed(new Runnable() {
@Override
public void run() {
dismissGuidePopup();
}
}, 3000);
}
}
};
}
延迟展示
mBottomView.postDelayed(showGuidePopupRunnable(), 3000);
操作取消
mBottomView.removeCallbacks(null);
弱引用
// 改用静态内部类 + 弱引用解决
private static class SafeRunnable implements Runnable {
private final WeakReference<Activity> activityRef;
private final WeakReference<View> anchorViewRef;
private final OnShowGuideTipListener listener;
SafeRunnable(Activity activity, View view, OnShowGuideTipListener l) {
this.activityRef = new WeakReference<>(activity);
this.anchorViewRef = new WeakReference<>(view);
this.listener = l;
}
@Override
public void run() {
Activity activity = activityRef.get();
View view = anchorViewRef.get();
if (activity == null || view == null) return;
dismissGuideTipBox();
if (listener != null) {
listener.showGuideTip();
}
}
}
imageloader 图片加载
private void loadImg(String imgUrl, ImageView imageView, boolean autoSize, int width, int height) {
if (!TextUtils.isEmpty(imgUrl)) {
IImageLoader imageLoader = ImageLoader.get(context).load(imgUrl)
.autoSize(autoSize);
if (width > 0) {
imageLoader = imageLoader.urlWidth(width);
}
if (height > 0) {
imageLoader = imageLoader.urlHeight(height);
}
if (width > 0 && height > 0 && !autoSize) {
imageLoader = imageLoader.size(width, height);
}
imageLoader.target(new LoadCompleteCallback<Bitmap>() {
@Override
public void onLoadComplete(Bitmap resource) {
if (resource != null) {
imageView.setImageBitmap(resource);
}
}
@Override
public void onLoadFailed(Exception info) {
}
}).request();
}
}
IDE报错
Couldn't resolve the package 'shimmer' in 'package:shimmer/shimmer.dart'.
local.properties
本地 #application.debug.flutterAAR=false
ndk {
abiFilters "armeabi-v7a"
packagingOptions {
doNotStrip "*/armeabi-v7a/*.so"
}
}
安卓硬改32位系统在64位上运行
跳转到flutter页面
HashMap<String, Object> maps = new HashMap<>();
maps.put("blogId", blogId);
maps.put("otherBlogId", otherBlogId);
maps.put("otherBlogName", otherBlogName);
maps.put("dnd", dndInt);
maps.put("menuShowStatus", isMenuStyleInt);
FlutterNativeManager.route(((Activity) mcontext), RouteConfig.SingleChatDetailPage, maps);
实例化对象查找
singleChatActivity.Class