Skip to content

Commit 9d56c09

Browse files
committed
优化演示案例
1 parent 3d07269 commit 9d56c09

19 files changed

+242
-16
lines changed

app/src/main/java/com/xuexiang/xuidemo/fragment/SearchComponentFragment.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.xuexiang.xpage.model.PageInfo;
3131
import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder;
3232
import com.xuexiang.xui.widget.actionbar.TitleBar;
33+
import com.xuexiang.xui.widget.guidview.GuideCaseView;
3334
import com.xuexiang.xui.widget.searchview.DefaultSearchFilter;
3435
import com.xuexiang.xui.widget.searchview.MaterialSearchView;
3536
import com.xuexiang.xuidemo.R;
@@ -61,10 +62,12 @@ public class SearchComponentFragment extends BaseFragment implements RecyclerVie
6162
private DBService<SearchRecord> mDBService;
6263
private SearchRecordTagAdapter mAdapter;
6364

65+
private View mAction;
66+
6467
@Override
6568
protected TitleBar initTitle() {
6669
TitleBar titleBar = super.initTitle();
67-
titleBar.addAction(new TitleBar.ImageAction(R.drawable.icon_action_query) {
70+
mAction = titleBar.addAction(new TitleBar.ImageAction(R.drawable.icon_action_query) {
6871

6972
@Override
7073
@SingleClick
@@ -87,6 +90,12 @@ protected int getLayoutId() {
8790

8891
@Override
8992
protected void initViews() {
93+
new GuideCaseView.Builder(getActivity())
94+
.title("点击按钮开始搜索")
95+
.focusOn(mAction)
96+
.showOnce("key_start_search")
97+
.show();
98+
9099
mSearchView.setVoiceSearch(false);
91100
mSearchView.setEllipsize(true);
92101
mSearchView.setSuggestions(getPageSuggestions());
@@ -114,6 +123,8 @@ public boolean onQueryTextChange(String newText) {
114123
recyclerView.setLayoutManager(Utils.getFlexboxLayoutManager(getContext()));
115124
recyclerView.setAdapter(mAdapter = new SearchRecordTagAdapter());
116125
refreshRecord();
126+
127+
117128
}
118129

119130
@SingleClick

app/src/main/java/com/xuexiang/xuidemo/fragment/components/spinner/DropDownMenuFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected void initViews() {
119119
constellationView.findViewById(R.id.btn_ok).setOnClickListener(new View.OnClickListener() {
120120
@Override
121121
public void onClick(View v) {
122-
mDropDownMenu.setTabMenuText(mConstellationAdapter.getSelectPosition() == 0 ? mHeaders[3] : mConstellationAdapter.getSelectItem());
122+
mDropDownMenu.setTabMenuText(mConstellationAdapter.getSelectPosition() <= 0 ? mHeaders[3] : mConstellationAdapter.getSelectItem());
123123
mDropDownMenu.closeMenu();
124124
}
125125
});

app/src/main/java/com/xuexiang/xuidemo/fragment/expands/materialdesign/ConstraintLayoutFragment.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package com.xuexiang.xuidemo.fragment.expands.materialdesign;
1919

20+
import android.os.Build;
21+
2022
import com.xuexiang.xpage.annotation.Page;
2123
import com.xuexiang.xpage.core.PageOption;
2224
import com.xuexiang.xuidemo.R;
@@ -25,6 +27,7 @@
2527
import com.xuexiang.xuidemo.fragment.expands.materialdesign.constraintlayout.ConstraintLayoutContainerFragment;
2628
import com.xuexiang.xuidemo.fragment.expands.materialdesign.constraintlayout.ConstraintLayoutGroupFragment;
2729
import com.xuexiang.xuidemo.fragment.expands.materialdesign.constraintlayout.ConstraintLayoutPlaceholderFragment;
30+
import com.xuexiang.xuidemo.utils.XToastUtils;
2831

2932
import java.util.List;
3033

@@ -76,7 +79,11 @@ protected void onItemClick(int position) {
7679
openPage(ConstraintLayoutPlaceholderFragment.class);
7780
break;
7881
case 7:
79-
openPage(ConstraintLayoutConstraintSetFragment.class);
82+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
83+
XToastUtils.warning("当前手机版本过低,暂不支持");
84+
} else {
85+
openPage(ConstraintLayoutConstraintSetFragment.class);
86+
}
8087
break;
8188
default:
8289
break;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2020 xuexiangjys(xuexiangjys@163.com)
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
20+
<item android:state_pressed="true">
21+
<shape android:shape="rectangle">
22+
<solid android:color="@color/colorAccent" />
23+
<corners android:radius="17dp" />
24+
</shape>
25+
</item>
26+
<item android:state_selected="true">
27+
<shape android:shape="rectangle">
28+
<solid android:color="@color/colorAccent" />
29+
<corners android:radius="17dp" />
30+
</shape>
31+
</item>
32+
<item>
33+
<shape android:shape="rectangle">
34+
<solid android:color="#1A636365" />
35+
<corners android:radius="17dp" />
36+
</shape>
37+
</item>
38+
</selector>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (C) 2020 xuexiangjys(xuexiangjys@163.com)
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
~
16+
-->
17+
18+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
19+
<item android:state_selected="true">
20+
<shape>
21+
<corners android:radius="2dp" />
22+
<stroke android:width="1dp" android:color="@color/colorAccent" />
23+
<solid android:color="@color/xui_config_color_transparent" />
24+
</shape>
25+
</item>
26+
<item android:state_pressed="true">
27+
<shape>
28+
<corners android:radius="2dp" />
29+
<stroke android:width="1dp" android:color="@color/colorAccent" />
30+
<solid android:color="@color/xui_config_color_transparent" />
31+
</shape>
32+
</item>
33+
<item>
34+
<shape>
35+
<corners android:radius="2dp" />
36+
<stroke android:width="1dp" android:color="@color/xui_config_color_separator_light_phone" />
37+
<solid android:color="@color/xui_config_color_transparent" />
38+
</shape>
39+
</item>
40+
</selector>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2019 xuexiangjys(xuexiangjys@163.com)
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
20+
<item android:state_pressed="true">
21+
<shape android:shape="rectangle">
22+
<solid android:color="?attr/colorAccent" />
23+
<corners android:radius="17dp" />
24+
</shape>
25+
</item>
26+
<item android:state_selected="true">
27+
<shape android:shape="rectangle">
28+
<solid android:color="?attr/colorAccent" />
29+
<corners android:radius="17dp" />
30+
</shape>
31+
</item>
32+
<item>
33+
<shape android:shape="rectangle">
34+
<solid android:color="#1A636365" />
35+
<corners android:radius="17dp" />
36+
</shape>
37+
</item>
38+
</selector>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (C) 2019 xuexiangjys(xuexiangjys@163.com)
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
~
16+
-->
17+
18+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
19+
<item android:state_selected="true">
20+
<shape>
21+
<corners android:radius="2dp" />
22+
<stroke android:width="1dp" android:color="?attr/colorAccent" />
23+
<solid android:color="@color/xui_config_color_transparent" />
24+
</shape>
25+
</item>
26+
<item android:state_pressed="true">
27+
<shape>
28+
<corners android:radius="2dp" />
29+
<stroke android:width="1dp" android:color="?attr/colorAccent" />
30+
<solid android:color="@color/xui_config_color_transparent" />
31+
</shape>
32+
</item>
33+
<item>
34+
<shape>
35+
<corners android:radius="2dp" />
36+
<stroke android:width="1dp" android:color="?attr/xui_config_color_separator_light" />
37+
<solid android:color="@color/xui_config_color_transparent" />
38+
</shape>
39+
</item>
40+
</selector>

app/src/main/res/layout/fragment_search_component.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
<com.xuexiang.xui.widget.searchview.MaterialSearchView
6363
android:id="@+id/search_view"
6464
android:layout_width="match_parent"
65-
android:layout_height="wrap_content" />
65+
android:layout_height="wrap_content"
66+
android:hint="请输入组件的名称"/>
6667

6768

6869
</FrameLayout>

app/src/main/res/layout/layout_constraintset_big.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
app:layout_constraintDimensionRatio="h,16:9"
4141
app:layout_constraintLeft_toLeftOf="parent"
4242
app:layout_constraintRight_toRightOf="parent"
43-
app:layout_constraintTop_toTopOf="parent"
44-
tools:layout_constraintLeft_creator="1"
45-
tools:layout_constraintRight_creator="1" />
43+
app:layout_constraintTop_toTopOf="parent"/>
4644

4745
<TextView
4846
android:id="@+id/tv_title"
@@ -66,9 +64,7 @@
6664
app:layout_constraintLeft_toLeftOf="@id/tv_title"
6765
app:layout_constraintRight_toRightOf="@id/iv_content"
6866
app:layout_constraintTop_toBottomOf="@id/tv_title"
69-
app:layout_constraintVertical_bias="0.0"
70-
tools:layout_constraintBottom_creator="1"
71-
tools:layout_constraintTop_creator="1" />
67+
app:layout_constraintVertical_bias="0.0" />
7268

7369
</androidx.constraintlayout.widget.ConstraintLayout>
7470

Binary file not shown.

0 commit comments

Comments
 (0)