Skip to content

Commit

Permalink
6.9.0.4 update
Browse files Browse the repository at this point in the history
- 新增组件 AsyncActivityLayoutLoader 可以提前完成异步的 BaseActivity 或 BaseFragment 布局加载;
  使用方法:在 App 初始化时:`AsyncActivityLayoutLoader.preCreateActivityLayoutCache(AdapterTestActivity.class);` 即可,剩下的都是全自动的。
  此工具会执行布局的预载,在BaseActivity或BaseFragment使用到布局时直接取已经实例化好的布局View,因为是异步的不影响未完成预载的布局加载,未完成预载的界面依然将执行正常的主线程布局加载流程。

6.9.0.1 update
- ViewController 新增适用于 LinearLayout.LayoutParams 的方法 `set/getWeight(...)`、`set/getGravity(...)`、适用于 RelativeLayout.LayoutParams 的方法 `get/addRule(...)`、`(int[])getRules()`。

6.9.0 update
- 新增工具 ViewController,可以通过它快捷的为 view 获取/设置宽高、内外边距等操作;
  使用方法:`ViewController.of(view).setMarginHorizontal(px).setPaddingTop(px);`
- BaseActivity 和 BaseFragment 新增 `createView(int layoutResId)` 方法以通过布局资源 id 快捷构建 view 实例;
- 跳转参数 JumpParameter 的默认 `(Any)get(key)` 方法不再需要强转类型,将自动适配变量类型,
  例如:`Bitmap result = parameter.get("参数2")` 而无需:`Bitmap result = (Bitmap)parameter.get("参数2")`;
- JumpParameter 支持从 json 文本或者已有的 Map 构建,也支持通过 `toJsonString()` 一键输出为 json 文本,方便在必要时存储参数内容;
- BaseFragment 新增 jump(cls, view...) 多元素衔接跳转方法;
  • Loading branch information
kongzue committed May 29, 2023
1 parent e8409f4 commit 50f4c84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion baseframework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {
minSdkVersion 15
targetSdkVersion 30
versionCode 129
versionName "6.9.0.3"
versionName "6.9.0.4"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.kongzue.baseframework.BaseApp.isNull;

import android.content.Context;
import android.content.MutableContextWrapper;
import android.view.View;
import android.view.ViewGroup;

Expand All @@ -16,6 +17,7 @@
import java.util.Map;

public class AsyncActivityLayoutLoader {

static Map<String, ViewPackage> cachedView;

private static void preCreateActivityLayoutCache(Context context, String baseActivityName, int layoutId) {
Expand Down Expand Up @@ -48,7 +50,7 @@ public static void preCreateActivityLayoutCache(Class baseActivityClass) {
Layout layout = (Layout) baseActivityClass.getAnnotation(Layout.class);
if (layout != null) {
if (layout.value() != -1) {
preCreateActivityLayoutCache(BaseApp.getPrivateInstance(), baseActivityName, layout.value());
preCreateActivityLayoutCache(new MutableContextWrapper(BaseApp.getPrivateInstance()), baseActivityName, layout.value());
}
}
}
Expand All @@ -60,6 +62,8 @@ public static View getActivityLayout(Context context,String baseActivityName) {
ViewPackage pkg = cachedView.get(baseActivityName);
if (pkg != null && pkg.getView() != null) {
View view = pkg.getView();
MutableContextWrapper contextWrapper = (MutableContextWrapper) view.getContext();
contextWrapper.setBaseContext(context);
cachedView.remove(baseActivityName);
preCreateActivityLayoutCache(context,baseActivityName, pkg.resId);
pkg.cleanAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ private static class Dispather {
private final AtomicInteger mCount = new AtomicInteger(1);

public Thread newThread(Runnable r) {
return new Thread(r, "AsyncLayoutInflatePlus #" + mCount.getAndIncrement());
return new Thread(r, "AsyncLayoutInflate" + mCount.getAndIncrement());
}
};

//LinkedBlockingQueue 默认构造器,队列容量是Integer.MAX_VALUE
private static final BlockingQueue<Runnable> sPoolWorkQueue =
new LinkedBlockingQueue<Runnable>();

/**
* An {@link Executor} that can be used to execute tasks in parallel.
*/
public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR;

static {
Expand Down

0 comments on commit 50f4c84

Please sign in to comment.