Skip to content

Commit

Permalink
Merge pull request #161 from xuexiangjys/dev/1.2.1
Browse files Browse the repository at this point in the history
Dev/1.2.1
  • Loading branch information
xuexiangjys committed Jun 25, 2023
2 parents 491d9f7 + 3c6407f commit 61ede43
Show file tree
Hide file tree
Showing 76 changed files with 3,685 additions and 137 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ allprojects {
dependencies {
...
//androidx project
implementation 'com.github.xuexiangjys:XUI:1.2.0'
implementation 'com.github.xuexiangjys:XUI:1.2.1'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
Expand Down
2 changes: 1 addition & 1 deletion README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ allprojects {
dependencies {
...
//androidx项目
implementation 'com.github.xuexiangjys:XUI:1.2.0'
implementation 'com.github.xuexiangjys:XUI:1.2.1'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
Expand Down
Binary file modified apk/xuidemo.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.xuexiang.xuidemo"
minSdkVersion 17
targetSdkVersion build_versions.target_sdk
versionCode 21
versionName "1.2.0"
versionCode 22
versionName "1.2.1"

multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
android:name=".base.BaseActivity"
android:configChanges="screenSize|keyboardHidden|orientation|keyboard|locale|layoutDirection"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".activity.MaterialDesignThemeActivity"
android:configChanges="screenSize|keyboardHidden|orientation|keyboard|locale|layoutDirection"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".widget.iconfont.IconFontActivity"
android:configChanges="screenSize|keyboardHidden|orientation|keyboard"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/xuexiang/xuidemo/DemoDataProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ public static List<StickyItem> getStickyDemoData() {
*/
@MemoryCache
public static List<NewInfo> getDemoNewInfos() {
return getRefreshDemoNewInfos();
}

public static List<NewInfo> getRefreshDemoNewInfos() {
List<NewInfo> list = new ArrayList<>();
list.add(new NewInfo("公众号", "X-Library系列文章视频介绍")
.setSummary("获取更多咨询,欢迎点击关注公众号:【我的Android开源之旅】,里面有一整套X-Library系列文章视频介绍!\n")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xuexiang.xuidemo.activity;

import com.xuexiang.xuidemo.R;
import com.xuexiang.xuidemo.base.BaseActivity;

/**
* 使用Theme.MaterialComponents作为主题的Activity
*
* @author xuexiang
* @since 5/14/23 10:30 PM
*/
public class MaterialDesignThemeActivity extends BaseActivity {

@Override
protected void initAppTheme() {
setTheme(R.style.MaterialDesignTheme);
}
}
10 changes: 10 additions & 0 deletions app/src/main/java/com/xuexiang/xuidemo/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.xuexiang.xpage.base.XPageFragment;
import com.xuexiang.xpage.core.CoreSwitchBean;
import com.xuexiang.xui.utils.ResUtils;
import com.xuexiang.xui.utils.WidgetUtils;
import com.xuexiang.xui.widget.slideback.SlideBack;
import com.xuexiang.xuidemo.utils.Utils;

Expand Down Expand Up @@ -42,6 +43,7 @@ protected void attachBaseContext(Context newBase) {
protected void onCreate(Bundle savedInstanceState) {
initAppTheme();
initStatusBarStyle();
initOthers();
super.onCreate(savedInstanceState);
mUnbinder = ButterKnife.bind(this);

Expand All @@ -62,6 +64,14 @@ protected void initStatusBarStyle() {

}

/**
* 初始化其他事务
*/
private void initOthers() {
// 用于检测控件的加载速度
// WidgetUtils.installLayoutInflaterLogger(this);
}

/**
* 打开fragment
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.xuexiang.xuidemo.fragment.components.refresh;

import android.os.Handler;
import android.os.Looper;

import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
Expand Down Expand Up @@ -60,7 +61,7 @@ private void refresh() {
}

private void loadData() {
new Handler().postDelayed(() -> {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
mAdapter.refresh(DemoDataProvider.getDemoData());
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setRefreshing(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.xuexiang.xuidemo.base.ComponentContainerFragment;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.diffutil.DiffUtilRefreshFragment;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.edit.NewsListEditFragment;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.preload.PreloadViewHolderFragment;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.selection.ListSelectionFragment;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.sortedlist.SortedListRefreshFragment;

Expand All @@ -36,7 +37,8 @@ protected Class[] getPagesClasses() {
DiffUtilRefreshFragment.class,
SortedListRefreshFragment.class,
ListSelectionFragment.class,
NewsListEditFragment.class
NewsListEditFragment.class,
PreloadViewHolderFragment.class
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xuexiang.xuidemo.fragment.components.refresh.sample.preload;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter;
import com.xuexiang.xui.utils.WidgetUtils;
import com.xuexiang.xuidemo.DemoDataProvider;
import com.xuexiang.xuidemo.R;
import com.xuexiang.xuidemo.adapter.entity.NewInfo;
import com.xuexiang.xuidemo.base.BaseFragment;

import butterknife.BindView;

/**
* @author xuexiang
* @since 6/21/23 1:29 AM
*/
public abstract class AbstractNewListFragment extends BaseFragment {

@BindView(R.id.recyclerView)
RecyclerView recyclerView;
@BindView(R.id.refreshLayout)
SmartRefreshLayout refreshLayout;

private BaseRecyclerAdapter<NewInfo> mAdapter;

@Override
protected int getLayoutId() {
return R.layout.fragment_refresh_load_more_recyclerview;
}

@Override
protected void initViews() {
WidgetUtils.initRecyclerView(recyclerView);
recyclerView.setAdapter(mAdapter = createAdapter());
}

protected abstract BaseRecyclerAdapter<NewInfo> createAdapter();

@Override
protected void initListeners() {
refreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
refreshLayout.getLayout().postDelayed(() -> {
mAdapter.refresh(DemoDataProvider.getRefreshDemoNewInfos());
refreshLayout.finishRefresh();
}, 1000);

}

@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
refreshLayout.getLayout().postDelayed(() -> {
mAdapter.loadMore(DemoDataProvider.getRefreshDemoNewInfos());
refreshLayout.finishLoadMore();
}, 1000);

}
});
refreshLayout.autoRefresh();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xuexiang.xuidemo.fragment.components.refresh.sample.preload;

import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter;
import com.xuexiang.xuidemo.adapter.entity.NewInfo;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.preload.adapter.OptimizeListAdapter;

/**
* @author xuexiang
* @since 6/21/23 12:47 AM
*/
@Page(name = "ViewHolder加载优化后")
public class AfterOptimizeFragment extends AbstractNewListFragment {

@Override
protected BaseRecyclerAdapter<NewInfo> createAdapter() {
return new OptimizeListAdapter(recyclerView);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xuexiang.xuidemo.fragment.components.refresh.sample.preload;

import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xui.adapter.recyclerview.BaseRecyclerAdapter;
import com.xuexiang.xuidemo.adapter.entity.NewInfo;
import com.xuexiang.xuidemo.fragment.components.refresh.sample.preload.adapter.MockLongTimeLoadListAdapter;

/**
* @author xuexiang
* @since 6/21/23 12:46 AM
*/
@Page(name = "ViewHolder加载优化前")
public class BeforeOptimizeFragment extends AbstractNewListFragment {

@Override
protected BaseRecyclerAdapter<NewInfo> createAdapter() {
return new MockLongTimeLoadListAdapter();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.xuexiang.xuidemo.fragment.components.refresh.sample.preload;

import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xuidemo.base.ComponentContainerFragment;

/**
* @author xuexiang
* @since 6/20/23 12:33 AM
*/
@Page(name = "ViewHolder异步预加载优化")
public class PreloadViewHolderFragment extends ComponentContainerFragment {

@Override
protected Class[] getPagesClasses() {
return new Class[]{
BeforeOptimizeFragment.class,
AfterOptimizeFragment.class
};
}
}
Loading

0 comments on commit 61ede43

Please sign in to comment.