Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/1.1.4 #67

Merged
merged 36 commits into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cad4f59
1.切分出1.1.4开发分支
xuexiangjys Mar 9, 2020
35fcd95
增加内联布局使用演示
xuexiangjys Mar 11, 2020
030f637
增加vlayout演示
xuexiangjys Mar 19, 2020
a6350a2
修复AdapterItem可能存在的问题
xuexiangjys Mar 21, 2020
833548a
删除wiki图片
xuexiangjys Mar 24, 2020
be78ca6
调整快捷搜索功能页面
xuexiangjys Mar 31, 2020
14e93ba
修改多个页面的启动模式
xuexiangjys Apr 1, 2020
10dcaeb
MaterialEditText增加支持下划线高度设置的属性
xuexiangjys Apr 1, 2020
d84066f
增加控件自定义动画
xuexiangjys Apr 1, 2020
828dcf7
增加NestedScrollingParent2使用
xuexiangjys Apr 6, 2020
3ab59a4
完善vlayout的使用案例
xuexiangjys Apr 6, 2020
cdd6df0
完善阿里巴巴组件使用案例
xuexiangjys Apr 6, 2020
b589073
完善阿里巴巴组件使用案例
xuexiangjys Apr 8, 2020
d12d30c
完善阿里巴巴组件使用案例
xuexiangjys Apr 9, 2020
9508882
增加复杂嵌套滚动效果案例
xuexiangjys Apr 12, 2020
f86a4b0
增加内容
xuexiangjys Apr 18, 2020
c6fea3a
优化选项卡使用案例
xuexiangjys Apr 20, 2020
021088d
增加粘顶嵌套滚动布局使用案例
xuexiangjys Apr 24, 2020
6598a0a
增加多状态布局加载者
xuexiangjys Apr 28, 2020
30025c6
完善多状态布局加载者演示
xuexiangjys Apr 29, 2020
a99896e
粘顶效果的多种实现方式演示
xuexiangjys May 2, 2020
0df7ace
增加工具类
xuexiangjys May 2, 2020
f80b6d8
解决图片预览可能存在的崩溃问题
xuexiangjys May 3, 2020
0ca0e24
优化代码,提高代码质量
xuexiangjys May 3, 2020
0823acb
优化代码,提高代码质量
xuexiangjys May 7, 2020
624f79d
优化代码,提高代码质量
xuexiangjys May 8, 2020
2dd304a
增加工具类
May 13, 2020
9b08517
优化代码,提高代码质量
xuexiangjys May 13, 2020
c3a9680
升级target版本为29
xuexiangjys May 13, 2020
700f61e
升级字体库版本
xuexiangjys May 19, 2020
10b0d3e
增加自动断字演示
xuexiangjys May 19, 2020
88a96b6
完善组件
xuexiangjys May 20, 2020
513361f
设置存储兼容模式
xuexiangjys May 20, 2020
71128d2
增加ViewPager2使用案例
May 29, 2020
8782ae8
升级XUtil库的版本
xuexiangjys Jun 5, 2020
6bfc161
发布1.1.4版本
xuexiangjys Jun 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
增加多状态布局加载者
  • Loading branch information
xuexiangjys committed Apr 28, 2020
commit 6598a0a9f566525c663fb65c4da7d9ff3bec7cb9
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ dependencies {
// implementation deps.glide
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'

//XUI框架
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.xuexiang.xuidemo.base.ComponentContainerFragment;
import com.xuexiang.xuidemo.fragment.components.statelayout.MultipleStatusViewFragment;
import com.xuexiang.xuidemo.fragment.components.statelayout.StatefulLayoutFragment;
import com.xuexiang.xuidemo.fragment.components.statelayout.StatusLoaderFragment;
import com.xuexiang.xuidemo.fragment.components.statelayout.StatusViewFragment;

/**
Expand All @@ -21,7 +22,8 @@ public Class[] getPagesClasses() {
return new Class[] {
StatefulLayoutFragment.class,
MultipleStatusViewFragment.class,
StatusViewFragment.class
StatusViewFragment.class,
StatusLoaderFragment.class
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ void onClick(View v) {
case R.id.fab_content:
mMultipleStatusView.showContent();
break;
default:
break;
}
mFloatingActionMenu.toggle(false);
}

@Override
public void onDestroyView() {
super.onDestroyView();
mLoadingHandler.removeCallbacksAndMessages(null);
super.onDestroyView();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (C) 2020 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.statelayout;

import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.LinearLayout;

import com.github.clans.fab.FloatingActionMenu;
import com.xuexiang.xaop.annotation.SingleClick;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xui.widget.statelayout.StatusLoader;
import com.xuexiang.xuidemo.R;
import com.xuexiang.xuidemo.base.BaseFragment;
import com.xuexiang.xuidemo.fragment.components.statelayout.status.DefaultStatusAdapter;
import com.xuexiang.xuidemo.utils.XToastUtils;

import butterknife.BindView;
import butterknife.OnClick;

import static com.xuexiang.xui.widget.statelayout.StatusLoader.STATUS_LOADING;

/**
* @author xuexiang
* @since 2020/4/29 12:34 AM
*/
@Page(name = "StatusLoader\n使用状态适配器动态设置")
public class StatusLoaderFragment extends BaseFragment {

@BindView(R.id.ll_content)
LinearLayout llContent;
@BindView(R.id.fab_menu)
FloatingActionMenu mFloatingActionMenu;

private Handler mLoadingHandler = new Handler(Looper.getMainLooper());

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

@Override
protected void initArgs() {
StatusLoader.initDefault(new DefaultStatusAdapter());
}

@Override
protected void initViews() {

}


@SingleClick
@OnClick({R.id.fab_loading, R.id.fab_empty, R.id.fab_error, R.id.fab_no_network, R.id.fab_content})
public void onClick(View v) {
switch (v.getId()) {
case R.id.fab_loading:
showLoading();
break;
case R.id.fab_empty:
showEmpty();
break;
case R.id.fab_error:
showError();
break;
case R.id.fab_no_network:
showCustom();
break;
case R.id.fab_content:
showContent();
break;
default:
break;
}
mFloatingActionMenu.toggle(false);
}

@Override
public void onDestroyView() {
mLoadingHandler.removeCallbacksAndMessages(null);
super.onDestroyView();
}

//=============StatusLoader================//

protected StatusLoader.Holder mHolder;

protected void initLoadingStatusViewIfNeed() {
if (mHolder == null) {
//此处设置需要包裹的布局
mHolder = StatusLoader.getDefault().wrap(llContent).withRetry(this::onLoadRetry);
}
}

/**
* 重试
*/
protected void onLoadRetry(View view) {
XToastUtils.toast("点击重试");
showLoading();
}

protected void showLoading() {
initLoadingStatusViewIfNeed();
mHolder.showLoading();
// 模拟加载
mLoadingHandler.postDelayed(() -> {
if (mHolder.getCurState() == STATUS_LOADING) {
showContent();
}
}, 3000);
}

protected void showContent() {
initLoadingStatusViewIfNeed();
mHolder.showLoadSuccess();
}

protected void showError() {
initLoadingStatusViewIfNeed();
mHolder.showLoadFailed();
}

protected void showEmpty() {
initLoadingStatusViewIfNeed();
mHolder.showEmpty();
}

protected void showCustom() {
initLoadingStatusViewIfNeed();
mHolder.showCustom();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2020 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.statelayout.status;

import android.view.View;

import com.xuexiang.xui.widget.statelayout.StatusLoader;

/**
* 默认状态适配器
*
* @author xuexiang
* @since 2020/4/29 12:59 AM
*/
public class DefaultStatusAdapter implements StatusLoader.Adapter {

@Override
public View getView(StatusLoader.Holder holder, View convertView, int status) {
return new DefaultStatusView(holder.getContext(), status, holder.getRetryListener());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright (C) 2020 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.statelayout.status;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.xuexiang.xuidemo.R;

import static com.xuexiang.xui.widget.statelayout.StatusLoader.STATUS_CUSTOM;
import static com.xuexiang.xui.widget.statelayout.StatusLoader.STATUS_EMPTY_DATA;
import static com.xuexiang.xui.widget.statelayout.StatusLoader.STATUS_LOADING;
import static com.xuexiang.xui.widget.statelayout.StatusLoader.STATUS_LOAD_FAILED;
import static com.xuexiang.xui.widget.statelayout.StatusLoader.STATUS_LOAD_SUCCESS;

/**
* 默认状态布局
*
* @author xuexiang
* @since 2020/4/29 1:12 AM
*/
@SuppressLint("ViewConstructor")
public class DefaultStatusView extends LinearLayout implements View.OnClickListener {

private final OnClickListener mRetryListener;

public DefaultStatusView(Context context, int status, OnClickListener retryListener) {
super(context);
setOrientation(VERTICAL);
setGravity(Gravity.CENTER);
int layoutId = getLayoutIdByStatus(status);
if (layoutId != 0) {
LayoutInflater.from(context).inflate(layoutId, this, true);
}
mRetryListener = retryListener;
setStatus(status);
setBackgroundColor(0xFFF0F0F0);
}

/**
* 设置状态
*
* @param status 状态
*/
private void setStatus(int status) {
switch (status) {
case STATUS_LOAD_SUCCESS:
setVisibility(View.GONE);
break;
case STATUS_LOADING:
setVisibility(View.VISIBLE);
break;
case STATUS_LOAD_FAILED:
case STATUS_EMPTY_DATA:
case STATUS_CUSTOM:
setVisibility(View.VISIBLE);
setOnClickListener(this);
break;
default:
break;
}
}

private int getLayoutIdByStatus(int status) {
int layoutId = 0;
switch (status) {
case STATUS_LOADING:
layoutId = R.layout.msv_layout_loading_view;
break;
case STATUS_LOAD_FAILED:
layoutId = R.layout.msv_layout_empty_view;
break;
case STATUS_EMPTY_DATA:
layoutId = R.layout.msv_layout_error_view;
break;
case STATUS_CUSTOM:
layoutId = R.layout.msv_layout_no_network_view;
break;
default:
break;
}
return layoutId;
}


@Override
public void onClick(View v) {
if (mRetryListener != null) {
mRetryListener.onClick(v);
}
}
}
30 changes: 30 additions & 0 deletions app/src/main/res/layout/fragment_status_loader.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2020 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.
~
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include
layout="@layout/layout_content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/xui_actionbar_height" />

<include layout="@layout/menu_statelayout_fab" />

</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/layout_content_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Expand Down
4 changes: 4 additions & 0 deletions xui_lib/src/main/java/com/xuexiang/xui/logs/UILog.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public static void setDebug(boolean isDebug) {
sIsDebug = isDebug;
}

public static boolean isDebug() {
return sIsDebug;
}

/**
* 设置打印日志的等级(只打印改等级以上的日志)
*
Expand Down
Loading