diff --git a/.gitignore b/.gitignore
index afbdab33e9e7967dafb71706fc99996cf4732d8e..37a4eb8b43d978ea05b2c6e3fb934f9b40dddd4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,15 @@
+*.iml
.gradle
/local.properties
-/.idea/workspace.xml
+/.idea/caches
/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
.DS_Store
/build
+/captures
+.externalNativeBuild
+/entry/.preview
+.cxx
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 96cc43efa6a0885098044e976cd780bb42c68a70..0000000000000000000000000000000000000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3377d40335424fd605124d4761390218bb..0000000000000000000000000000000000000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index b02ee6e63884f40525ef2a6397a627cf7987f796..0000000000000000000000000000000000000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index fbb68289f4352bf149aa31a2c9940faa99174224..0000000000000000000000000000000000000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 8905d9e4109d80e38f26a2ae410448795b833f02..0000000000000000000000000000000000000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460d8b38ac04e3a3224d7c79ef719b1991a9..0000000000000000000000000000000000000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7f4cb416c083d265558da75d457237d671..0000000000000000000000000000000000000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AdvancedPagerSlidingTabStrip.iml b/AdvancedPagerSlidingTabStrip.iml
deleted file mode 100644
index 668b6fb0eb46b45b5101d4d3ae020e322f01a3c1..0000000000000000000000000000000000000000
--- a/AdvancedPagerSlidingTabStrip.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..245e84af521af0a8f43a293f96f9b3a00c543216
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,8 @@
+## 0.0.1-SNAPSHOT
+* refactor: For module library Android-to-OpenHarmony
+
+## 1.4.0
+* 添加新的provider以及tab等新的设置。
+
+## 1.3.0
+* 修改参数属性,将tab标签换为apTab开头标签,避免与support包冲突。
\ No newline at end of file
diff --git a/ChangLog.md b/ChangLog.md
deleted file mode 100644
index 4b3da4a1856e42bf6851e36e74dbd0a1664d8899..0000000000000000000000000000000000000000
--- a/ChangLog.md
+++ /dev/null
@@ -1,9 +0,0 @@
-##更新日志
-
-v1.4.0
-
-添加新的provider以及tab等新的设置。
-
-v1.3.0
-
-修改参数属性,将tab标签换为apTab开头标签,避免与support包冲突。
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/app/.gitignore b/Library/.gitignore
similarity index 100%
rename from app/.gitignore
rename to Library/.gitignore
diff --git a/Library/AndroidManifest.xml b/Library/AndroidManifest.xml
deleted file mode 100644
index 4824669b571f2de868a74f573d9de7d5fac3f4fb..0000000000000000000000000000000000000000
--- a/Library/AndroidManifest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/Library/Library.iml b/Library/Library.iml
deleted file mode 100644
index ea7bea3090eb191a8b6a429777937250e1bd9d62..0000000000000000000000000000000000000000
--- a/Library/Library.iml
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Library/build.gradle b/Library/build.gradle
index 4e227955f6465c75e7220b5c70c7ac4d04086041..da087601706fe2980dcfce0d19b79003851641f5 100644
--- a/Library/build.gradle
+++ b/Library/build.gradle
@@ -1,27 +1,22 @@
-apply plugin: 'com.android.library'
-
-dependencies {
- compile 'com.android.support:appcompat-v7:23.1.0'
-}
-
-android {
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
- }
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- minSdkVersion 9
- compileSdkVersion 23
- buildToolsVersion "23.0.1"
+ compatibleSdkVersion 4
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
}
+
}
-apply from: 'https://raw.githubusercontent.com/HomHomLin/Gradle-Publish/master/bintray.gradle'
\ No newline at end of file
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
+}
diff --git a/Library/proguard-rules.pro b/Library/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/Library/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/Library/res/drawable/apsts_tips.xml b/Library/res/drawable/apsts_tips.xml
deleted file mode 100644
index e0439d4655679af402e20f51bd6f094ae6295aca..0000000000000000000000000000000000000000
--- a/Library/res/drawable/apsts_tips.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Library/res/drawable/psts_background_tab.xml b/Library/res/drawable/psts_background_tab.xml
deleted file mode 100644
index 885cf036a72e32dd5ad0963d8fc94d7c8e52ff2b..0000000000000000000000000000000000000000
--- a/Library/res/drawable/psts_background_tab.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Library/res/values/attrs.xml b/Library/res/values/attrs.xml
deleted file mode 100644
index 936c28b6163846e81ab21754ce9456fa01437138..0000000000000000000000000000000000000000
--- a/Library/res/values/attrs.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Library/res/values/colors.xml b/Library/res/values/colors.xml
deleted file mode 100644
index 2dea27ca731002bc0ccfa2da8b11d80d15589b11..0000000000000000000000000000000000000000
--- a/Library/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- #6633B5E5
- #E43F3E
-
\ No newline at end of file
diff --git a/Library/res/values/dimens.xml b/Library/res/values/dimens.xml
deleted file mode 100644
index 99a8db4efc1f3e7776e4ce9f165d971975e77cc6..0000000000000000000000000000000000000000
--- a/Library/res/values/dimens.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 10dp
- 4dp
- 9dp
- 8dp
- 7dp
- 23dp
- 10sp
-
\ No newline at end of file
diff --git a/Library/res/values/ids.xml b/Library/res/values/ids.xml
deleted file mode 100644
index 56a43720a5b87ad42dfd1931e4e3296067e7d151..0000000000000000000000000000000000000000
--- a/Library/res/values/ids.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
- - 888
-
\ No newline at end of file
diff --git a/Library/src/com/lhh/apst/library/AdvancedPagerSlidingTabStrip.java b/Library/src/com/lhh/apst/library/AdvancedPagerSlidingTabStrip.java
deleted file mode 100644
index 105db22b5bc0ae722a8df7c7cb03095b36ded889..0000000000000000000000000000000000000000
--- a/Library/src/com/lhh/apst/library/AdvancedPagerSlidingTabStrip.java
+++ /dev/null
@@ -1,1091 +0,0 @@
-package com.lhh.apst.library;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.Rect;
-import android.graphics.Typeface;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.v4.content.res.ResourcesCompat;
-import android.support.v4.view.ViewPager;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.SparseArray;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewTreeObserver.OnGlobalLayoutListener;
-import android.widget.HorizontalScrollView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import java.util.Locale;
-
-/**
- * Created by linhomhom on 2015/8/10.
- */
-public class AdvancedPagerSlidingTabStrip extends HorizontalScrollView {
-
- public interface LayoutProvider {
- public float getPageWeight(int position);
- public int[] getPageRule(int position);
- public Margins getPageMargins(int position);
- }
-
- public interface TipsProvider {
- public int[] getTipsRule(int position);
- public Margins getTipsMargins(int position);
- public Drawable getTipsDrawable(int position);
- }
-
- public interface IconTabProvider {
- public T getPageIcon(int position);
- public T getPageSelectIcon(int position);
- public Rect getPageIconBounds(int position);
- }
-
- public interface ViewTabProvider{
-// public View onCreateIconView(int position, View view, ViewGroup parent);
- public View onSelectIconView(int position, View view, ViewGroup parent);
- public View onIconView(int position, View view, ViewGroup parent);
- }
-
- // @formatter:off
- private static final int[] ATTRS = new int[]{
- android.R.attr.textSize,
- android.R.attr.textColor
- };
- // @formatter:on
- private LinearLayout.LayoutParams expandedTabLayoutParams;
-
- private final PageListener pageListener = new PageListener();
- public ViewPager.OnPageChangeListener delegatePageListener;
-
- private LinearLayout tabsContainer;
- private ViewPager pager;
-
- private int tabCount;
-
- private int currentPosition = 0;
- private float currentPositionOffset = 0f;
-
- private Paint rectPaint;
- private Paint dividerPaint;
-
- private boolean checkedTabWidths = false;
-
- private int indicatorColor = 0xFF666666;
- private int underlineColor = 0x1A000000;
- private int dividerColor = 0x1A000000;
-
- private boolean shouldExpand = true;
- private boolean textAllCaps = true;
-
- private int scrollOffset = 52;
- private int indicatorHeight = 3;
- private int underlineHeight = 2;
- private int dividerPadding = 12;
- private int tabPadding = 24;
- private int tabPaddingTopBottom = 0;
- private int dividerWidth = 1;
-
- private int tabTextSize = 15;
- private int tabTextColor = 0xFF666666;
- private int tabTextSelectColor = 0xFF666666;
- private Typeface tabTypeface = null;
- private int tabTypefaceStyle = Typeface.NORMAL;
- private int tabDrawMode = DRAW_MODE_NORMAL;
-
- public static final int DRAW_MODE_NORMAL = 0;
- public static final int DRAW_MODE_TEXT = 1;
-
- private int lastScrollX = 0;
-
- private int tabBackgroundResId = R.drawable.psts_background_tab;
-// private int tabBackgroundResId;
-
- private Locale locale;
- private OnTabClickListener mOnTabClickListener;
- public interface OnTabClickListener{
- public void onClick(int pos);
- }
-
- public AdvancedPagerSlidingTabStrip(Context context) {
- this(context, null);
- }
-
- public AdvancedPagerSlidingTabStrip(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public AdvancedPagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- setFillViewport(true);
- setWillNotDraw(false);
-
- tabsContainer = new LinearLayout(context);
- tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
- tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- addView(tabsContainer);
-
- DisplayMetrics dm = getResources().getDisplayMetrics();
-
- scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
- indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
- underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
- dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
- tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
- dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
- tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);
-
- // get system attrs (android:textSize and android:textColor)
-
- TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
-
- tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
- tabTextColor = a.getColor(1, tabTextColor);
-
- a.recycle();
-
- // get custom attrs
-
-
- a = context.obtainStyledAttributes(attrs, R.styleable.AdvancedPagerSlidingTabStrip);
-
- indicatorColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabIndicatorColor, indicatorColor);
- underlineColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabUnderlineColor, underlineColor);
- dividerColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabDividerColor, dividerColor);
- indicatorHeight = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabIndicatorHeight, indicatorHeight);
- underlineHeight = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabUnderlineHeight, underlineHeight);
- dividerPadding = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabDividerPadding, dividerPadding);
- tabPadding = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabPaddingLeftRight, tabPadding);
- tabPaddingTopBottom = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabPaddingTopBottom, tabPaddingTopBottom);
- tabBackgroundResId = a.getResourceId(R.styleable.AdvancedPagerSlidingTabStrip_apTabBackground, tabBackgroundResId);
- shouldExpand = a.getBoolean(R.styleable.AdvancedPagerSlidingTabStrip_apTabShouldExpand, shouldExpand);
- scrollOffset = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabScrollOffset, scrollOffset);
- textAllCaps = a.getBoolean(R.styleable.AdvancedPagerSlidingTabStrip_apTabTextAllCaps, textAllCaps);
- tabTextSelectColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabTextSelectColor, dividerColor);
- tabDrawMode = a.getInteger(R.styleable.AdvancedPagerSlidingTabStrip_apTabDrawMode,DRAW_MODE_NORMAL);
-
- a.recycle();
-
- rectPaint = new Paint();
- rectPaint.setAntiAlias(true);
- rectPaint.setStyle(Style.FILL);
-
- dividerPaint = new Paint();
- dividerPaint.setAntiAlias(true);
- dividerPaint.setStrokeWidth(dividerWidth);
-
-// defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
- expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
-
- if (locale == null) {
- locale = getResources().getConfiguration().locale;
- }
-
- if(mViewTabCache == null){
- mViewTabCache = new SparseArray<>();
- }
- }
-
- public void setOnTabClickListener(OnTabClickListener onTabClickListener){
- mOnTabClickListener = onTabClickListener;
- }
-
- public void setViewPager(ViewPager pager) {
- this.pager = pager;
-
- if (pager.getAdapter() == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
- }
-
- pager.addOnPageChangeListener(pageListener);
-
- notifyDataSetChanged();
- }
-
- public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
- this.delegatePageListener = listener;
- }
-
- public void notifyDataSetChanged() {
-
- tabsContainer.removeAllViews();
-
- tabCount = pager.getAdapter().getCount();
-
- for (int i = 0; i < tabCount; i++) {
-
- if (pager.getAdapter() instanceof IconTabProvider) {
- addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIcon(i), pager.getAdapter().getPageTitle(i).toString());
- } else if(pager.getAdapter() instanceof ViewTabProvider){
- addViewTab(i, ((ViewTabProvider) pager.getAdapter()),pager.getAdapter().getPageTitle(i).toString());
- } else {
-// addIconTab(i, R.drawable.home_categry_icon_n, pager.getAdapter().getPageTitle(i).toString());
-
- addTextTab(i, pager.getAdapter().getPageTitle(i).toString());
- }
-
- }
-
- updateTabStyles();
-
- checkedTabWidths = false;
-
- getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
-
- @SuppressWarnings("deprecation")
- @SuppressLint("NewApi")
- @Override
- public void onGlobalLayout() {
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
- getViewTreeObserver().removeGlobalOnLayoutListener(this);
- } else {
- getViewTreeObserver().removeOnGlobalLayoutListener(this);
- }
-
- currentPosition = pager.getCurrentItem();
- scrollToChild(currentPosition, 0);
- }
- });
-
- pageListener.onPageSelected(0);//default
-
- }
-
- private void addTextTab(final int position, String title) {
-
- RelativeLayout tab = new RelativeLayout(getContext());
- tab.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if(mOnTabClickListener != null){
- mOnTabClickListener.onClick(position);
- }
- scrollToChild(position, 0);
- pager.setCurrentItem(position);
- }
- });
-
- TextView txt = new TextView(getContext());
- txt.setText(title);
- txt.setFocusable(true);
- txt.setGravity(Gravity.CENTER);
- txt.setSingleLine();
- txt.setId(R.id.id_tab_txt);
- RelativeLayout.LayoutParams txtParams = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- txtParams.addRule(RelativeLayout.CENTER_IN_PARENT);
- if(pager.getAdapter() instanceof LayoutProvider){
- LayoutProvider layoutProvider = (LayoutProvider)pager.getAdapter();
- for(Integer rule : layoutProvider.getPageRule(position)){
- txtParams.addRule(rule);
- }
- Margins margins = layoutProvider.getPageMargins(position);
- if(margins != null) {
- txtParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
- }
- }
-// txtParams.addRule(RelativeLayout.CENTER_IN_PARENT);
- txt.setLayoutParams(txtParams);
-
- RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.psts_dot_wh), getResources().getDimensionPixelSize(R.dimen.psts_dot_wh));
- TextView dot = new TextView(getContext());
- dot.setTextColor(Color.WHITE);
- dot.setBackgroundColor(Color.BLUE);
- dot.setGravity(Gravity.CENTER);
- dot.setSingleLine();
- dot.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.psts_dot_txt_size));
- //16 new
- Drawable dot_drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.apsts_tips, null);
-
-
- boolean hasRule = false;
- layoutParams.setMargins(0, 0, getResources().getDimensionPixelSize(R.dimen.psts_dot_m_right), 0);
- if(pager.getAdapter() instanceof TipsProvider){
- TipsProvider tipsProvider = (TipsProvider)pager.getAdapter();
- for(Integer rule : tipsProvider.getTipsRule(position)){
- layoutParams.addRule(rule);
- hasRule = true;
- }
- Margins margins = tipsProvider.getTipsMargins(position);
- if(margins != null) {
- layoutParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
- }
- Drawable drawable = tipsProvider.getTipsDrawable(position);
- if(drawable != null){
- dot_drawable = drawable;
-
- }
- }
-
- if(!hasRule){
-// layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- layoutParams.addRule(RelativeLayout.ALIGN_RIGHT, R.id.id_tab_txt);
- layoutParams.addRule(RelativeLayout.ALIGN_TOP, R.id.id_tab_txt);
- int halfSize = getResources().getDimensionPixelSize(R.dimen.psts_dot_m_tv_right);
- layoutParams.setMargins(0, 0, -halfSize, 0);
- }
-
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- dot.setBackground(dot_drawable);
- }else{
- dot.setBackgroundDrawable(dot_drawable);
- }
- dot.setLayoutParams(layoutParams);
-
- tab.addView(txt);
- tab.addView(dot);
- dot.setVisibility(View.GONE);
- tabsContainer.addView(tab);
-
- }
-
- public void showDot(int index) {
- RelativeLayout tab = (RelativeLayout) tabsContainer.getChildAt(index);
- TextView dot_layout = (TextView) tab.getChildAt(tab.getChildCount() - 1);
- dot_layout.setText("");
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)dot_layout.getLayoutParams();
- layoutParams.width = getResources().getDimensionPixelSize(R.dimen.psts_dot_wh);
- layoutParams.height = getResources().getDimensionPixelSize(R.dimen.psts_dot_wh);
-
- dot_layout.setVisibility(View.VISIBLE);
- }
-
- public void showDot(int index,String dotTxt) {
- RelativeLayout tab = (RelativeLayout) tabsContainer.getChildAt(index);
- TextView dot_layout = (TextView) tab.getChildAt(tab.getChildCount() - 1);
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)dot_layout.getLayoutParams();
- layoutParams.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
- dot_layout.setText(dotTxt);
- dot_layout.setVisibility(View.VISIBLE);
- }
-
- public void hideDot(int index) {
- RelativeLayout tab = (RelativeLayout) tabsContainer.getChildAt(index);
- TextView dot_layout = (TextView) tab.getChildAt(tab.getChildCount() - 1);
- dot_layout.setVisibility(View.GONE);
- }
-
- private SparseArray mViewTabCache;//缓存
-
- private View getTabView(int position){
- return mViewTabCache.get(position);
- }
-
- private void setTabView( int position ,View view){
- mViewTabCache.put(position, view);
- }
-
- private void addViewTab(final int position, ViewTabProvider provider, String title) {
-
- RelativeLayout tab = new RelativeLayout(getContext());
- tab.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if(mOnTabClickListener != null){
- mOnTabClickListener.onClick(position);
- }
- scrollToChild(position, 0);
- pager.setCurrentItem(position);
- }
- });
-
- //文本和图
- TextView txt = new TextView(getContext());
- txt.setText(title);
- txt.setFocusable(true);
- txt.setGravity(Gravity.CENTER);
- txt.setSingleLine();
- txt.setId(R.id.id_tab_txt);
- RelativeLayout.LayoutParams txtParams = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- txtParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- txtParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- if(pager.getAdapter() instanceof LayoutProvider){
- LayoutProvider layoutProvider = (LayoutProvider)pager.getAdapter();
- for(Integer rule : layoutProvider.getPageRule(position)){
- txtParams.addRule(rule);
- }
- Margins margins = layoutProvider.getPageMargins(position);
- if(margins != null) {
- txtParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
- }
- }
- txtParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- txtParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- txt.setLayoutParams(txtParams);
-
- //使用缓存
- View view = provider.onIconView(position, getTabView(position), tab);
- setTabView(position, view);//保存view到缓存中
- RelativeLayout.LayoutParams viewLayoutParams
- = (RelativeLayout.LayoutParams)view.getLayoutParams();
- viewLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- viewLayoutParams.addRule(RelativeLayout.ABOVE, R.id.id_tab_txt);
-
-
- RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.psts_dot_wh), getResources().getDimensionPixelSize(R.dimen.psts_dot_wh));
- TextView dot = new TextView(getContext());
- dot.setTextColor(Color.WHITE);
- dot.setBackgroundColor(Color.BLUE);
- dot.setGravity(Gravity.CENTER);
- dot.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.psts_dot_txt_size));
- dot.setSingleLine();
-
- Drawable dot_drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.apsts_tips, null);
-
- boolean hasRule = false;
- layoutParams.setMargins(0, 0, getResources().getDimensionPixelSize(R.dimen.psts_dot_m_right), 0);
- if(pager.getAdapter() instanceof TipsProvider){
- TipsProvider tipsProvider = (TipsProvider)pager.getAdapter();
- for(Integer rule : tipsProvider.getTipsRule(position)){
- layoutParams.addRule(rule);
- hasRule = true;
- }
- Margins margins = tipsProvider.getTipsMargins(position);
- if(margins != null) {
- layoutParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
- }
- Drawable drawable = tipsProvider.getTipsDrawable(position);
- if(drawable != null){
- dot_drawable = drawable;
-
- }
- }
-
- if(!hasRule){
- layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- dot.setBackground(dot_drawable);
- }else{
- dot.setBackgroundDrawable(dot_drawable);
- }
- dot.setLayoutParams(layoutParams);
-
- tab.addView(txt);
- tab.addView(view);
- tab.addView(dot);
- dot.setVisibility(View.GONE);
- tabsContainer.addView(tab);
-
- }
-
- private void addIconTab(final int position, Object res, String text) {
-
- RelativeLayout tab = new RelativeLayout(getContext());
- tab.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if(mOnTabClickListener != null){
- mOnTabClickListener.onClick(position);
- }
- scrollToChild(position, 0);
- pager.setCurrentItem(position);
- }
- });
-
- //文本和图
- TextView txt = new TextView(getContext());
- txt.setText(text);
- txt.setFocusable(true);
- txt.setGravity(Gravity.CENTER);
- txt.setSingleLine();
- txt.setId(R.id.id_tab_txt);
- RelativeLayout.LayoutParams txtParams = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- txtParams.addRule(RelativeLayout.CENTER_IN_PARENT);
- if(pager.getAdapter() instanceof LayoutProvider){
- LayoutProvider layoutProvider = (LayoutProvider)pager.getAdapter();
- for(Integer rule : layoutProvider.getPageRule(position)){
- txtParams.addRule(rule);
-
- }
- Margins margins = layoutProvider.getPageMargins(position);
- if(margins != null) {
- txtParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
- }
- }
-// txtParams.addRule(RelativeLayout.CENTER_IN_PARENT);
- txt.setLayoutParams(txtParams);
-
- setViewResource(position,res, txt);
-
- RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.psts_dot_wh), getResources().getDimensionPixelSize(R.dimen.psts_dot_wh));
- TextView dot = new TextView(getContext());
- dot.setTextColor(Color.WHITE);
- dot.setBackgroundColor(Color.BLUE);
- dot.setGravity(Gravity.CENTER);
- dot.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.psts_dot_txt_size));
- dot.setSingleLine();
- Drawable dot_drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.apsts_tips, null);
-
- boolean hasRule = false;
- layoutParams.setMargins(0, 0, getResources().getDimensionPixelSize(R.dimen.psts_dot_m_right), 0);
- if(pager.getAdapter() instanceof TipsProvider){
- TipsProvider tipsProvider = (TipsProvider)pager.getAdapter();
- for(Integer rule : tipsProvider.getTipsRule(position)){
- layoutParams.addRule(rule);
- hasRule = true;
- }
- Margins margins = tipsProvider.getTipsMargins(position);
- if(margins != null) {
- layoutParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
- }
- Drawable drawable = tipsProvider.getTipsDrawable(position);
- if(drawable != null){
- dot_drawable = drawable;
-
- }
- }
-
- if(!hasRule){
- layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- }
-
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- dot.setBackground(dot_drawable);
- }else{
- dot.setBackgroundDrawable(dot_drawable);
- }
- dot.setLayoutParams(layoutParams);
-
- tab.addView(txt);
- tab.addView(dot);
- dot.setVisibility(View.GONE);
- tabsContainer.addView(tab);
-
- }
-
- public View getTabAt(int pos) {
- if (pos >= tabsContainer.getChildCount()) {
- throw new IllegalStateException("pos is too big.");
- }
- return tabsContainer.getChildAt(pos);
- }
-
- private void updateTabStyles() {
-
- for (int i = 0; i < tabCount; i++) {
-
- View v = tabsContainer.getChildAt(i);
-
- //v.setLayoutParams(defaultTabLayoutParams);
- //my modify
- v.setLayoutParams(expandedTabLayoutParams);
- v.setBackgroundResource(tabBackgroundResId);
- if (shouldExpand) {
- v.setPadding(0, 0, 0, 0);
- } else {
- v.setPadding(tabPadding, tabPaddingTopBottom, tabPadding, tabPaddingTopBottom);
- }
-
- if (v instanceof RelativeLayout) {
-
- RelativeLayout tab = (RelativeLayout) v;
- TextView tv = (TextView)tab.getChildAt(0);
- tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
- tv.setTypeface(tabTypeface, tabTypefaceStyle);
- tv.setTextColor(tabTextColor);
-
- // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
- // pre-ICS-build
- if (textAllCaps) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- tv.setAllCaps(true);
- } else {
- tv.setText(tv.getText().toString().toUpperCase(locale));
- }
- }
- }
- }
-
- }
-
- public boolean setTabLayoutParams(){
- if(pager.getAdapter() instanceof LayoutProvider){
- LayoutProvider weightProvider = (LayoutProvider)pager.getAdapter();
- if(weightProvider == null){
- return false;
- }
- for (int i = 0; i < tabCount; i++) {
- float weight = weightProvider.getPageWeight(i);
- if(weight != 0.0f){
- LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, weight == 0.0f ? 1.0f : weight);
- tabsContainer.getChildAt(i).setLayoutParams(layoutParams);
- }else{
- tabsContainer.getChildAt(i).setLayoutParams(expandedTabLayoutParams);
- }
-
- }
- }
- return false;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- if (!shouldExpand || MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED) {
- setTabLayoutParams();
- return;
- }
-
- int myWidth = getMeasuredWidth();
- int childWidth = 0;
- for (int i = 0; i < tabCount; i++) {
- childWidth += tabsContainer.getChildAt(i).getMeasuredWidth();
- }
-
- if (!checkedTabWidths && childWidth > 0 && myWidth > 0) {
-
- if (childWidth <= myWidth) {
- if(!setTabLayoutParams()){
- for (int i = 0; i < tabCount; i++) {
- tabsContainer.getChildAt(i).setLayoutParams(expandedTabLayoutParams);
- }
- }
- }
-
- checkedTabWidths = true;
- }
- }
-
- private void scrollToChild(int position, int offset) {
-
- if (tabCount == 0) {
- return;
- }
-
- int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
-
- if (position > 0 || offset > 0) {
- newScrollX -= scrollOffset;
- }
-
- if (newScrollX != lastScrollX) {
- lastScrollX = newScrollX;
- scrollTo(newScrollX, 0);
- }
-
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- if (isInEditMode() || tabCount == 0) {
- return;
- }
-
- if(tabDrawMode == DRAW_MODE_NORMAL) {
- drawTabNormalMode(canvas);
- }else {
- drawTabTextMode(canvas);
- }
- }
-
- private void drawTabNormalMode(Canvas canvas){
- final int height = getHeight();
-
- // 设置提示下划线的颜色
-
- rectPaint.setColor(indicatorColor);
-
- View currentTab = tabsContainer.getChildAt(currentPosition);
- float lineLeft = currentTab.getLeft();
- float lineRight = currentTab.getRight();
-
- if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
-
- View nextTab = tabsContainer.getChildAt(currentPosition + 1);
- final float nextTabLeft = nextTab.getLeft();
- final float nextTabRight = nextTab.getRight();
-
- lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
- lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
-
- }
-
- //绘制提示下划线
- canvas.drawRect(lineLeft , height - indicatorHeight, lineRight , height, rectPaint);
-
- // 绘制下划线
-
- rectPaint.setColor(underlineColor);
- canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
-
- // 绘制分割线
-
- dividerPaint.setColor(dividerColor);
- for (int i = 0; i < tabCount - 1; i++) {
- View tab = tabsContainer.getChildAt(i);
- canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
- }
- }
-
- private void drawTabTextMode(Canvas canvas){
-
- final int height = getHeight();
-
- // 设置提示下划线的颜色
-
- rectPaint.setColor(indicatorColor);
-
- View currentTab = tabsContainer.getChildAt(currentPosition);
- float lineLeft = currentTab.getLeft();
-
- View currentTextView = ((RelativeLayout)currentTab).getChildAt(0);
- float currentTextViewLeft = currentTextView.getLeft();
- float currentTextViewRight = currentTextView.getRight();
-
- // if there is an offset, start interpolating left and right coordinates between current and next tab
- if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
-
- View nextTab = tabsContainer.getChildAt(currentPosition + 1);
- final float nextTabLeft = nextTab.getLeft();
-
- lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
-
- View nextTextView = ((RelativeLayout)nextTab).getChildAt(0);
- float nextTextViewLeft = nextTextView.getLeft();
- float nextTextViewRight = nextTextView.getRight();
-
- currentTextViewLeft = (currentPositionOffset * nextTextViewLeft + (1f - currentPositionOffset) * currentTextViewLeft);
- currentTextViewRight = (currentPositionOffset * nextTextViewRight + (1f - currentPositionOffset) * currentTextViewRight);
- }
-
- //绘制提示下划线
- float r = ((float)indicatorHeight) / 2;
- canvas.drawCircle(lineLeft + currentTextViewLeft + r,height - indicatorHeight + r,r,rectPaint);
- canvas.drawCircle(lineLeft + currentTextViewRight - r,height - indicatorHeight + r,r,rectPaint);
-
- canvas.drawRect(lineLeft + currentTextViewLeft + r, height - indicatorHeight, lineLeft + currentTextViewRight-r , height, rectPaint);
-
- // 分割线paint
-
- dividerPaint.setColor(dividerColor);
-
- // 下划线paint
- rectPaint.setColor(underlineColor);
-
- for (int i = 0; i < tabCount; i++) {
- View tab = tabsContainer.getChildAt(i);
- //绘制分割线
- if(i < tabCount - 1) {
- canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
- }
- View tabTextView = ((RelativeLayout)tab).getChildAt(0);
- canvas.drawRect(tab.getLeft() + tabTextView.getLeft(), height - underlineHeight, tab.getLeft() + tabTextView.getRight(), height, rectPaint);
- }
- }
-
- private class PageListener implements ViewPager.OnPageChangeListener {
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- currentPosition = position;
- currentPositionOffset = positionOffset;
-
- if (tabsContainer != null && tabsContainer.getChildAt(position) != null) {
- scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth()));
- }
-
- invalidate();
-
- if (delegatePageListener != null) {
- delegatePageListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
- }
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- if (state == ViewPager.SCROLL_STATE_IDLE) {
- scrollToChild(pager.getCurrentItem(), 0);
- }
-
- if (delegatePageListener != null) {
- delegatePageListener.onPageScrollStateChanged(state);
- }
- }
-
- @Override
- public void onPageSelected(int position) {
-
- setSelectItem(position);
-
- if (delegatePageListener != null) {
- delegatePageListener.onPageSelected(position);
- }
- }
-
- }
-
- private void setViewResource(int position ,Object obj , TextView view){
- IconTabProvider iconTabProvider = (IconTabProvider)pager.getAdapter();
- Rect rect = iconTabProvider.getPageIconBounds(position);
- Drawable drawable = null;
- if(obj instanceof Integer) {
- int resId = (int) obj;
- if (resId != 0) {
- drawable = ResourcesCompat.getDrawable(getResources(),resId,null);
- }
- }else if(obj instanceof Bitmap){
- Bitmap bitmap = (Bitmap) obj;
- if (bitmap != null) {
- drawable = new BitmapDrawable(getResources(),bitmap);
- }
- }else if(obj instanceof Drawable){
- drawable = (Drawable) obj;
-
- }
-
- if (drawable != null) {
- if(rect != null){
- drawable.setBounds(rect);
- view.setCompoundDrawables(null, drawable, null, null);
- }else{
- view.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
- }
- }
- }
-
- public void setSelectItem(int position){
- for (int i = 0; i < tabsContainer.getChildCount(); i++) {
- RelativeLayout linearLayout = ((RelativeLayout) tabsContainer.getChildAt(i));
- if (i == position) {
- ((TextView) linearLayout.getChildAt(0)).setTextColor(tabTextSelectColor);
- if (pager.getAdapter() instanceof IconTabProvider) {
- Object obj = ((IconTabProvider) pager.getAdapter()).getPageSelectIcon(i);
- setViewResource(position, obj, (TextView) linearLayout.getChildAt(0));
-// ().setCompoundDrawablesWithIntrinsicBounds(0, ((IconTabProvider) pager.getAdapter()).getPageIconSelectResId(i), 0, 0);
- }else if(pager.getAdapter() instanceof ViewTabProvider){
- View view = ((ViewTabProvider) pager.getAdapter()).onSelectIconView(i,getTabView(i),linearLayout);
- setTabView(i,view);
- }
-// ((TextView) linearLayout.getChildAt(0)).setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.home_categry_icon_f_n, 0, 0);
- } else {
- ((TextView) linearLayout.getChildAt(0)).setTextColor(tabTextColor);
- if (pager.getAdapter() instanceof IconTabProvider) {
- Object obj = ((IconTabProvider) pager.getAdapter()).getPageIcon(i);
- setViewResource(position, obj, (TextView) linearLayout.getChildAt(0));
-// ((TextView) linearLayout.getChildAt(0)).setCompoundDrawablesWithIntrinsicBounds(0, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i), 0, 0);
- }else if(pager.getAdapter() instanceof ViewTabProvider){
- View view = ((ViewTabProvider) pager.getAdapter()).onIconView(i, getTabView(i), linearLayout);
- setTabView(i,view);
- }
-// ((TextView) linearLayout.getChildAt(0)).setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.home_categry_icon_n, 0, 0);
-
- }
- }
- }
-
- public void setIndicatorColor(int indicatorColor) {
- this.indicatorColor = indicatorColor;
- invalidate();
- }
-
- public void setIndicatorColorResource(int resId) {
- this.indicatorColor = getResources().getColor(resId);
- invalidate();
- }
-
- public int getIndicatorColor() {
- return this.indicatorColor;
- }
-
- public void setIndicatorHeight(int indicatorLineHeightPx) {
- this.indicatorHeight = indicatorLineHeightPx;
- invalidate();
- }
-
- public int getIndicatorHeight() {
- return indicatorHeight;
- }
-
- public void setUnderlineColor(int underlineColor) {
- this.underlineColor = underlineColor;
- invalidate();
- }
-
- public void setUnderlineColorResource(int resId) {
- this.underlineColor = getResources().getColor(resId);
- invalidate();
- }
-
- public int getUnderlineColor() {
- return underlineColor;
- }
-
- public void setDividerColor(int dividerColor) {
- this.dividerColor = dividerColor;
- invalidate();
- }
-
- public void setDividerColorResource(int resId) {
- this.dividerColor = getResources().getColor(resId);
- invalidate();
- }
-
- public int getDividerColor() {
- return dividerColor;
- }
-
- public void setUnderlineHeight(int underlineHeightPx) {
- this.underlineHeight = underlineHeightPx;
- invalidate();
- }
-
- public int getUnderlineHeight() {
- return underlineHeight;
- }
-
- public void setDividerPadding(int dividerPaddingPx) {
- this.dividerPadding = dividerPaddingPx;
- invalidate();
- }
-
- public int getDividerPadding() {
- return dividerPadding;
- }
-
- public void setScrollOffset(int scrollOffsetPx) {
- this.scrollOffset = scrollOffsetPx;
- invalidate();
- }
-
- public int getScrollOffset() {
- return scrollOffset;
- }
-
- public void setShouldExpand(boolean shouldExpand) {
- this.shouldExpand = shouldExpand;
- requestLayout();
- }
-
- public boolean getShouldExpand() {
- return shouldExpand;
- }
-
- public boolean isTextAllCaps() {
- return textAllCaps;
- }
-
- public void setAllCaps(boolean textAllCaps) {
- this.textAllCaps = textAllCaps;
- }
-
- public void setTextSize(int textSizePx) {
- this.tabTextSize = textSizePx;
- updateTabStyles();
- }
-
- public int getTextSize() {
- return tabTextSize;
- }
-
- public void setTextColor(int textColor) {
- this.tabTextColor = textColor;
- updateTabStyles();
- }
-
- public void setTextColorResource(int resId) {
- this.tabTextColor = getResources().getColor(resId);
- updateTabStyles();
- }
-
- public int getTextColor() {
- return tabTextColor;
- }
-
- public void setTypeface(Typeface typeface, int style) {
- this.tabTypeface = typeface;
- this.tabTypefaceStyle = style;
- updateTabStyles();
- }
-
- public void setTabBackground(int resId) {
- this.tabBackgroundResId = resId;
- }
-
- public int getTabBackground() {
- return tabBackgroundResId;
- }
-
- public void setTabPaddingLeftRight(int paddingPx) {
- this.tabPadding = paddingPx;
- updateTabStyles();
- }
-
- public int getTabPaddingLeftRight() {
- return tabPadding;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState savedState = (SavedState) state;
- super.onRestoreInstanceState(savedState.getSuperState());
- currentPosition = savedState.currentPosition;
- requestLayout();
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState savedState = new SavedState(superState);
- savedState.currentPosition = currentPosition;
- return savedState;
- }
-
- static class SavedState extends BaseSavedState {
- int currentPosition;
-
- public SavedState(Parcelable superState) {
- super(superState);
- }
-
- private SavedState(Parcel in) {
- super(in);
- currentPosition = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(currentPosition);
- }
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- @Override
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
-}
diff --git a/Library/src/com/lhh/apst/library/ViewHolder.java b/Library/src/com/lhh/apst/library/ViewHolder.java
deleted file mode 100644
index 5acd780a14572f1edcb3208e4f45f59e5b31f70a..0000000000000000000000000000000000000000
--- a/Library/src/com/lhh/apst/library/ViewHolder.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.lhh.apst.library;
-
-import android.util.SparseArray;
-import android.view.View;
-
-/**
- * Created by linhongong on 2015/9/22.
- */
-public class ViewHolder {
-
- public static T get(View view, int id) {
- @SuppressWarnings("unchecked")
- SparseArray viewHolder = (SparseArray) view.getTag();
- if (viewHolder == null) {
- viewHolder = new SparseArray();
- view.setTag(viewHolder);
- }
- View childView = viewHolder.get(id);
- if (childView == null) {
- childView = view.findViewById(id);
- viewHolder.put(id, childView);
- }
- return (T) childView;
- }
-}
diff --git a/Library/src/main/config.json b/Library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..a54b69842239a8c01728f7c960ddee63f9e3826a
--- /dev/null
+++ b/Library/src/main/config.json
@@ -0,0 +1,27 @@
+{
+ "app": {
+ "bundleName": "com.lhh.apst.advancedpagerslidingtabstrip",
+ "vendor": "lhh",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.lhh.apst.library",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "Library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Library/src/main/java/com/lhh/apst/library/AdvancedPagerSlidingTabStrip.java b/Library/src/main/java/com/lhh/apst/library/AdvancedPagerSlidingTabStrip.java
new file mode 100644
index 0000000000000000000000000000000000000000..96612fb3ac5a41d1d12478d28dc9bbabe6859a7c
--- /dev/null
+++ b/Library/src/main/java/com/lhh/apst/library/AdvancedPagerSlidingTabStrip.java
@@ -0,0 +1,1193 @@
+package com.lhh.apst.library;
+
+import com.lhh.apst.library.utils.TypedAttrUtils;
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.*;
+import ohos.agp.components.element.Element;
+import ohos.agp.components.element.PixelMapElement;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.text.Font;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Rect;
+import ohos.agp.utils.TextAlignment;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+import ohos.media.image.PixelMap;
+import ohos.utils.PlainArray;
+
+import java.io.IOException;
+import java.util.Locale;
+
+/**
+ * Created by linhomhom on 2015/8/10.
+ */
+public class AdvancedPagerSlidingTabStrip extends ScrollView implements Component.DrawTask,
+ Component.EstimateSizeListener {
+ /**
+ * 布局属性接口
+ *
+ * @since 2021-04-30
+ */
+ public interface LayoutProvider {
+ /**
+ * 比重
+ *
+ * @param position tab位置
+ * @return 比重值
+ */
+ float getPageWeight(int position);
+
+ /**
+ * 布局规则
+ *
+ * @param position tab位置
+ * @return 规则数组
+ */
+ int[] getPageRule(int position);
+
+ /**
+ * 获取margin属性
+ *
+ * @param position tab位置
+ * @return Margins
+ */
+ Margins getPageMargins(int position);
+ }
+
+ /**
+ * Tips属性接口
+ *
+ * @since 2021-04-30
+ */
+ public interface TipsProvider {
+ /**
+ * Tips Rule
+ *
+ * @param position tab位置
+ * @return 布局集合
+ */
+ int[] getTipsRule(int position);
+
+ /**
+ * TipsMargins
+ *
+ * @param position tab位置
+ * @return Margins
+ */
+ Margins getTipsMargins(int position);
+
+ /**
+ * TipsDrawable
+ *
+ * @param position tab位置
+ * @return Element
+ */
+ Element getTipsDrawable(int position);
+ }
+
+ /**
+ * IconTab接口
+ *
+ * @since 2021-04-30
+ */
+ public interface IconTabProvider {
+ /**
+ * 获取PageIcon
+ *
+ * @param position tab位置
+ * @param Icon泛型
+ * @return Icon
+ */
+ T getPageIcon(int position);
+
+ /**
+ * 获取选中icon
+ *
+ * @param position tab位置
+ * @param Icon泛型
+ * @return Icon
+ */
+ T getPageSelectIcon(int position);
+
+ /**
+ * 获取icon Bounds
+ *
+ * @param position tab位置
+ * @return Icon
+ */
+ Rect getPageIconBounds(int position);
+ }
+
+ /**
+ * ViewTabProvider
+ *
+ * @since 2021-04-30
+ */
+ public interface ViewTabProvider {
+ /**
+ * 选中的IconView
+ *
+ * @param position tab位置
+ * @param view Component
+ * @param parent ComponentContainer
+ * @return Component
+ */
+ Component onSelectIconView(int position, Component view, ComponentContainer parent);
+
+ /**
+ * IconView
+ *
+ * @param position tab位置
+ * @param view Component
+ * @param parent ComponentContainer
+ * @return Component
+ */
+ Component onIconView(int position, Component view, ComponentContainer parent);
+
+ /**
+ * 获取布局属性
+ *
+ * @return 布局属性
+ */
+ DependentLayout.LayoutConfig getLayoutConfig();
+ }
+
+ // @formatter:on
+ private DirectionalLayout.LayoutConfig expandedTabLayoutParams;
+
+ private final PageListener pageListener = new PageListener();
+
+ /**
+ * PageSlider页面切换监听
+ */
+ public PageSlider.PageChangedListener delegatePageListener;
+
+ private DirectionalLayout tabsContainer;
+ private PageSlider pager;
+
+ private int tabCount;
+
+ private int currentPosition = 0;
+ private float currentPositionOffset = 0f;
+
+ private Paint rectPaint;
+ private Paint dividerPaint;
+
+ private boolean checkedTabWidths = false;
+
+ private int indicatorColor = 0xFF666666;
+ private int underlineColor = 0x1A000000;
+ private int dividerColor = 0x1A000000;
+
+ private boolean shouldExpand = true;
+ private boolean textAllCaps = true;
+
+ private int scrollOffset = 52;
+ private int indicatorHeight = 0;
+ private int underlineHeight = 2;
+ private int dividerPadding = 12;
+ private int tabPadding = 24;
+ private int tabPaddingTopBottom = 0;
+ private int dividerWidth = 1;
+
+ private int tabTextSize = 15;
+ private int tabTextColor = 0xFF666666;
+ private int tabTextSelectColor = 0xFF666666;
+
+ private Font tabTypefaceStyle = Font.DEFAULT;
+ private int tabDrawMode = DRAW_MODE_NORMAL;
+
+ /**
+ * 绘制模式NORMAL
+ */
+ public static final int DRAW_MODE_NORMAL = 0;
+
+ /**
+ * 绘制模式TEXT
+ */
+ public static final int DRAW_MODE_TEXT = 1;
+
+ private int lastScrollX = 0;
+
+ private Locale locale;
+ private OnTabClickListener mOnTabClickListener;
+
+ /**
+ * OnTabClickListener
+ *
+ * @since 2021-04-30
+ */
+ public interface OnTabClickListener {
+ /**
+ * 点击接口
+ *
+ * @param pos 位置
+ */
+ void onClick(int pos);
+ }
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public AdvancedPagerSlidingTabStrip(Context context) {
+ this(context, null);
+ }
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ * @param attrSet AttrSet
+ */
+ public AdvancedPagerSlidingTabStrip(Context context, AttrSet attrSet) {
+ this(context, attrSet, null);
+ }
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ * @param attrSet AttrSet
+ * @param styleName String
+ */
+ public AdvancedPagerSlidingTabStrip(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ setMatchViewportEnabled(true);
+
+ tabsContainer = new DirectionalLayout(context);
+ tabsContainer.setOrientation(DirectionalLayout.HORIZONTAL);
+ LayoutConfig layoutConfig = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT);
+ tabsContainer.setLayoutConfig(layoutConfig);
+ addComponent(tabsContainer);
+
+ indicatorColor = TypedAttrUtils.getIntColor(attrSet, "apTabIndicatorColor", indicatorColor);
+ underlineColor = TypedAttrUtils.getIntColor(attrSet, "apTabUnderlineColor", underlineColor);
+ dividerColor = TypedAttrUtils.getIntColor(attrSet, "apTabDividerColor", dividerColor);
+ indicatorHeight = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabIndicatorHeight", indicatorHeight);
+ underlineHeight = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabUnderlineHeight", underlineHeight);
+ dividerPadding = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabDividerPadding", dividerPadding);
+ tabPadding = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabPaddingLeftRight", tabPadding);
+ tabPaddingTopBottom = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabPaddingTopBottom", tabPaddingTopBottom);
+ shouldExpand = TypedAttrUtils.getBoolean(attrSet, "apTabShouldExpand", shouldExpand);
+ scrollOffset = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabScrollOffset", scrollOffset);
+ textAllCaps = TypedAttrUtils.getBoolean(attrSet, "apTabTextAllCaps", textAllCaps);
+ tabTextSelectColor = TypedAttrUtils.getIntColor(attrSet, "apTabTextSelectColor", dividerColor);
+ tabDrawMode = TypedAttrUtils.getInt(attrSet, "apTabDrawMode", DRAW_MODE_NORMAL);
+ tabTextSize = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabTextSize", tabTextSize);
+ tabTextColor = TypedAttrUtils.getIntColor(attrSet, "apTabTextColor", tabTextColor);
+
+ rectPaint = new Paint();
+ rectPaint.setAntiAlias(true);
+ rectPaint.setStyle(Paint.Style.FILL_STYLE);
+
+ dividerPaint = new Paint();
+ dividerPaint.setAntiAlias(true);
+ dividerPaint.setStrokeWidth(dividerWidth);
+
+ expandedTabLayoutParams = new DirectionalLayout.LayoutConfig(0, LayoutConfig.MATCH_PARENT,
+ TableLayout.Alignment.ALIGNMENT_FILL, 1.0f);
+
+ if (locale == null) {
+ locale = getResourceManager().getConfiguration().getFirstLocale();
+ }
+
+ if (mViewTabCache == null) {
+ mViewTabCache = new PlainArray<>();
+ }
+
+ addDrawTask(this);
+ setEstimateSizeListener(this);
+ }
+
+ public void setOnTabClickListener(OnTabClickListener onTabClickListener) {
+ mOnTabClickListener = onTabClickListener;
+ }
+
+ /**
+ * 设置PageSlider
+ *
+ * @param pager PageSlider
+ */
+ public void setViewPager(PageSlider pager) {
+ this.pager = pager;
+
+ if (pager.getProvider() == null) {
+ throw new IllegalStateException("ViewPager does not have adapter instance.");
+ }
+
+ pager.addPageChangedListener(pageListener);
+
+ notifyDataSetChanged();
+ }
+
+ public void setOnPageChangeListener(PageSlider.PageChangedListener listener) {
+ this.delegatePageListener = listener;
+ }
+
+ /**
+ * 更新数据
+ */
+ public void notifyDataSetChanged() {
+ tabsContainer.removeAllComponents();
+ tabCount = pager.getProvider().getCount();
+
+ for (int i = 0; i < tabCount; i++) {
+ if (pager.getProvider() instanceof IconTabProvider) {
+ addIconTab(i, ((IconTabProvider) pager.getProvider()).getPageIcon(i), pager.getProvider().getPageTitle(i));
+ } else if (pager.getProvider() instanceof ViewTabProvider) {
+ addViewTab(i, ((ViewTabProvider) pager.getProvider()), pager.getProvider().getPageTitle(i));
+ } else {
+ addTextTab(i, pager.getProvider().getPageTitle(i));
+ }
+ }
+
+ updateTabStyles();
+ checkedTabWidths = false;
+ pageListener.onPageChosen(0);
+ }
+
+ private void addTextTab(final int position, String title) {
+ DependentLayout tab = new DependentLayout(getContext());
+ tab.setClickedListener(v -> {
+ if (mOnTabClickListener != null) {
+ mOnTabClickListener.onClick(position);
+ }
+ scrollToChild(position, 0);
+ pager.setCurrentPage(position);
+ });
+
+ Text txt = new Text(getContext());
+ txt.setText(title);
+ txt.setFocusable(Text.FOCUS_ENABLE);
+ txt.setTextAlignment(TextAlignment.CENTER);
+ txt.setMaxTextLines(1);
+ txt.setId(ResourceTable.String_id_tab_txt);
+ DependentLayout.LayoutConfig txtParams = new DependentLayout.LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
+ txtParams.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT);
+ if (pager.getProvider() instanceof LayoutProvider) {
+ LayoutProvider layoutProvider = (LayoutProvider) pager.getProvider();
+ for (Integer rule : layoutProvider.getPageRule(position)) {
+ txtParams.addRule(rule);
+ }
+ Margins margins = layoutProvider.getPageMargins(position);
+ if (margins != null) {
+ txtParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
+ }
+ }
+ txt.setLayoutConfig(txtParams);
+
+ int result = getResValue(ResourceTable.Float_psts_dot_wh);
+ DependentLayout.LayoutConfig layoutParams = new DependentLayout.LayoutConfig(result, result);
+ Text dot = new Text(getContext());
+ dot.setTextColor(Color.WHITE);
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setRgbColor(new RgbColor(Color.BLUE.getValue()));
+ dot.setBackground(shapeElement);
+ dot.setTextAlignment(TextAlignment.CENTER);
+ dot.setMaxTextLines(1);
+ dot.setTextSize(getResValue(ResourceTable.Float_psts_dot_txt_size));
+
+ Element dot_drawable = new ShapeElement(this.mContext, ResourceTable.Graphic_apsts_tips);
+
+ boolean hasRule = false;
+ layoutParams.setMargins(0, 0, getResValue(ResourceTable.Float_psts_dot_m_right), 0);
+ if (pager.getProvider() instanceof TipsProvider) {
+ TipsProvider tipsProvider = (TipsProvider) pager.getProvider();
+ for (Integer rule : tipsProvider.getTipsRule(position)) {
+ layoutParams.addRule(rule);
+ hasRule = true;
+ }
+ Margins margins = tipsProvider.getTipsMargins(position);
+ if (margins != null) {
+ layoutParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
+ }
+
+ Element drawable = tipsProvider.getTipsDrawable(position);
+ if (drawable != null) {
+ dot_drawable = drawable;
+ }
+ }
+
+ if (!hasRule) {
+ layoutParams.addRule(DependentLayout.LayoutConfig.ALIGN_RIGHT, ResourceTable.String_id_tab_txt);
+ layoutParams.addRule(DependentLayout.LayoutConfig.ALIGN_TOP, ResourceTable.String_id_tab_txt);
+ int halfSize = getResValue(ResourceTable.Float_psts_dot_m_tv_right);
+ layoutParams.setMargins(0, 0, -halfSize, 0);
+ }
+
+ dot.setBackground(dot_drawable);
+ dot.setLayoutConfig(layoutParams);
+
+ tab.addComponent(txt, 0);
+ tab.addComponent(dot, 1);
+ dot.setVisibility(Component.INVISIBLE);
+ tabsContainer.addComponent(tab);
+ }
+
+ /**
+ * 展示红点
+ *
+ * @param index 当前位置
+ */
+ public void showDot(int index) {
+ DependentLayout tab = (DependentLayout) tabsContainer.getComponentAt(index);
+ Text dot_layout = (Text) tab.getComponentAt(tab.getChildCount() - 1);
+ dot_layout.setText("");
+ dot_layout.setVisibility(Component.VISIBLE);
+ }
+
+ /**
+ * 展示红点
+ *
+ * @param index 当前位置
+ * @param dotTxt 红点文字
+ */
+ public void showDot(int index, String dotTxt) {
+ DependentLayout tab = (DependentLayout) tabsContainer.getComponentAt(index);
+ Text dot_layout = (Text) tab.getComponentAt(tab.getChildCount() - 1);
+ dot_layout.setText(dotTxt);
+ dot_layout.setPaddingLeft(10);
+ dot_layout.setPaddingRight(10);
+ dot_layout.setVisibility(Component.VISIBLE);
+ }
+
+ /**
+ * 隐藏红点
+ *
+ * @param index 当前位置
+ */
+ public void hideDot(int index) {
+ DependentLayout tab = (DependentLayout) tabsContainer.getComponentAt(index);
+ Text dot_layout = (Text) tab.getComponentAt(tab.getChildCount() - 1);
+ dot_layout.setVisibility(Component.INVISIBLE);
+ }
+
+ private PlainArray mViewTabCache;
+
+ private Component getTabView(int position) {
+ return mViewTabCache.get(position).get();
+ }
+
+ private void setTabView(int position, Component view) {
+ mViewTabCache.put(position, view);
+ }
+
+ private void addViewTab(final int position, ViewTabProvider provider, String title) {
+ DependentLayout tab = new DependentLayout(getContext());
+ tab.setClickedListener(v -> {
+ if (mOnTabClickListener != null) {
+ mOnTabClickListener.onClick(position);
+ }
+ scrollToChild(position, 0);
+ pager.setCurrentPage(position);
+ });
+
+ // 文本和图
+ Text txt = new Text(getContext());
+ txt.setText(title);
+ txt.setFocusable(Text.FOCUS_ENABLE);
+ txt.setTextAlignment(TextAlignment.CENTER);
+ txt.setMaxTextLines(1);
+ txt.setId(ResourceTable.String_id_tab_txt);
+ DependentLayout.LayoutConfig txtParams = new DependentLayout.LayoutConfig(
+ DependentLayout.LayoutConfig.MATCH_CONTENT,
+ DependentLayout.LayoutConfig.MATCH_CONTENT);
+ txtParams.addRule(DependentLayout.LayoutConfig.HORIZONTAL_CENTER);
+ txtParams.addRule(DependentLayout.LayoutConfig.ALIGN_PARENT_BOTTOM);
+ if (pager.getProvider() instanceof LayoutProvider) {
+ LayoutProvider layoutProvider = (LayoutProvider) pager.getProvider();
+ for (Integer rule : layoutProvider.getPageRule(position)) {
+ txtParams.addRule(rule);
+ }
+ Margins margins = layoutProvider.getPageMargins(position);
+ if (margins != null) {
+ txtParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
+ }
+ }
+ txtParams.addRule(DependentLayout.LayoutConfig.HORIZONTAL_CENTER);
+ txtParams.addRule(DependentLayout.LayoutConfig.ALIGN_PARENT_BOTTOM);
+ txt.setLayoutConfig(txtParams);
+
+ // 使用缓存
+ Component view = provider.onIconView(position, null, tab);
+
+ // 保存view到缓存中
+ setTabView(position, view);
+
+ DependentLayout.LayoutConfig viewLayoutParams
+ = provider.getLayoutConfig();
+ viewLayoutParams.addRule(DependentLayout.LayoutConfig.HORIZONTAL_CENTER);
+ viewLayoutParams.addRule(DependentLayout.LayoutConfig.ABOVE, ResourceTable.String_id_tab_txt);
+ view.setLayoutConfig(viewLayoutParams);
+
+ DependentLayout.LayoutConfig layoutParams =
+ new DependentLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT,
+ ComponentContainer.LayoutConfig.MATCH_CONTENT);
+ Text dot = new Text(getContext());
+ dot.setTextColor(Color.WHITE);
+
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setRgbColor(new RgbColor(Color.BLUE.getValue()));
+ dot.setBackground(shapeElement);
+ dot.setTextAlignment(TextAlignment.CENTER);
+ dot.setMaxTextLines(1);
+ dot.setTextSize(getResValue(ResourceTable.Float_psts_dot_txt_size));
+
+ Element dot_drawable = new ShapeElement(this.mContext, ResourceTable.Graphic_apsts_tips);
+
+ boolean hasRule = false;
+ layoutParams.setMargins(0, 15, getResValue(ResourceTable.Float_psts_dot_m_right), 0);
+ if (pager.getProvider() instanceof TipsProvider) {
+ TipsProvider tipsProvider = (TipsProvider) pager.getProvider();
+ for (Integer rule : tipsProvider.getTipsRule(position)) {
+ layoutParams.addRule(rule);
+ hasRule = true;
+ }
+ Margins margins = tipsProvider.getTipsMargins(position);
+ if (margins != null) {
+ layoutParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
+ }
+ Element drawable = tipsProvider.getTipsDrawable(position);
+ if (drawable != null) {
+ dot_drawable = drawable;
+ }
+ }
+
+ if (!hasRule) {
+ layoutParams.addRule(DependentLayout.LayoutConfig.ALIGN_PARENT_RIGHT);
+ }
+
+ dot.setBackground(dot_drawable);
+ dot.setLayoutConfig(layoutParams);
+
+ tab.addComponent(txt, 0);
+ tab.addComponent(view, 1);
+ tab.addComponent(dot, 2);
+ dot.setVisibility(Component.INVISIBLE);
+ tabsContainer.addComponent(tab);
+ }
+
+ private void addIconTab(final int position, Object res, String text) {
+ DependentLayout tab = new DependentLayout(getContext());
+ tab.setClickedListener(v -> {
+ if (mOnTabClickListener != null) {
+ mOnTabClickListener.onClick(position);
+ }
+ scrollToChild(position, 0);
+ pager.setCurrentPage(position);
+ });
+
+ // 文本和图
+ Text txt = new Text(getContext());
+ txt.setText(text);
+ txt.setFocusable(Text.FOCUS_ENABLE);
+ txt.setTextAlignment(TextAlignment.CENTER);
+ txt.setMaxTextLines(1);
+ txt.setId(ResourceTable.String_id_tab_txt);
+ DependentLayout.LayoutConfig txtParams = new DependentLayout.LayoutConfig(
+ DependentLayout.LayoutConfig.MATCH_CONTENT,
+ DependentLayout.LayoutConfig.MATCH_CONTENT);
+ txtParams.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT);
+ if (pager.getProvider() instanceof LayoutProvider) {
+ LayoutProvider layoutProvider = (LayoutProvider) pager.getProvider();
+ for (Integer rule : layoutProvider.getPageRule(position)) {
+ txtParams.addRule(rule);
+ }
+ Margins margins = layoutProvider.getPageMargins(position);
+ if (margins != null) {
+ txtParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
+ }
+ }
+ txt.setLayoutConfig(txtParams);
+
+ setViewResource(position, res, txt);
+
+ DependentLayout.LayoutConfig layoutParams = new DependentLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT);
+ Text dot = new Text(getContext());
+ dot.setTextColor(Color.WHITE);
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setRgbColor(new RgbColor(Color.BLUE.getValue()));
+ dot.setBackground(shapeElement);
+ dot.setTextAlignment(TextAlignment.CENTER);
+ dot.setMaxTextLines(1);
+ dot.setTextSize(getResValue(ResourceTable.Float_psts_dot_txt_size));
+
+ Element dot_drawable = new ShapeElement(this.mContext, ResourceTable.Graphic_apsts_tips);
+
+ boolean hasRule = false;
+ layoutParams.setMargins(0, 15, getResValue(ResourceTable.Float_psts_dot_m_right), 0);
+ if (pager.getProvider() instanceof TipsProvider) {
+ TipsProvider tipsProvider = (TipsProvider) pager.getProvider();
+ for (Integer rule : tipsProvider.getTipsRule(position)) {
+ layoutParams.addRule(rule);
+ hasRule = true;
+ }
+ Margins margins = tipsProvider.getTipsMargins(position);
+ if (margins != null) {
+ layoutParams.setMargins(margins.mLeft, margins.mTop, margins.mRight, margins.mBottom);
+ }
+ Element drawable = tipsProvider.getTipsDrawable(position);
+ if (drawable != null) {
+ dot_drawable = drawable;
+ }
+ }
+
+ if (!hasRule) {
+ layoutParams.addRule(DependentLayout.LayoutConfig.ALIGN_PARENT_RIGHT);
+ }
+
+ dot.setBackground(dot_drawable);
+ dot.setLayoutConfig(layoutParams);
+
+ tab.addComponent(txt, 0);
+ tab.addComponent(dot, 1);
+ dot.setVisibility(Component.INVISIBLE);
+ tabsContainer.addComponent(tab);
+ }
+
+ /**
+ * 获取tab Component
+ *
+ * @param pos tab位置
+ * @return Component tab元素
+ */
+ public Component getTabAt(int pos) {
+ if (pos >= tabsContainer.getChildCount()) {
+ throw new IllegalStateException("pos is too big.");
+ }
+ return tabsContainer.getComponentAt(pos);
+ }
+
+ private void updateTabStyles() {
+ for (int i = 0; i < tabCount; i++) {
+ Component v = tabsContainer.getComponentAt(i);
+ v.setLayoutConfig(expandedTabLayoutParams);
+
+ if (shouldExpand) {
+ v.setPadding(0, 0, 0, 0);
+ } else {
+ v.setPadding(tabPadding, tabPaddingTopBottom, tabPadding, tabPaddingTopBottom);
+ }
+
+ if (v instanceof DependentLayout) {
+ DependentLayout tab = (DependentLayout) v;
+ Text tv = (Text) tab.getComponentAt(0);
+ tv.setTextSize(tabTextSize, Text.TextSizeType.FP);
+ tv.setFont(tabTypefaceStyle);
+ tv.setTextColor(new Color(tabTextColor));
+
+ // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
+ // pre-ICS-build
+ if (textAllCaps) {
+ tv.setText(tv.getText().toUpperCase(locale));
+ }
+ }
+ }
+ }
+
+ /**
+ * 设置布局属性
+ *
+ * @return 是否设置成功
+ */
+ public boolean setTabLayoutParams() {
+ if (pager.getProvider() instanceof LayoutProvider) {
+ LayoutProvider weightProvider = (LayoutProvider) pager.getProvider();
+ if (weightProvider == null) {
+ return false;
+ }
+ for (int i = 0; i < tabCount; i++) {
+ float weight = weightProvider.getPageWeight(i);
+ if (weight != 0.0f) {
+ DirectionalLayout.LayoutConfig layoutParams = new DirectionalLayout.LayoutConfig(0, DirectionalLayout.LayoutConfig.MATCH_PARENT, TableLayout.Alignment.ALIGNMENT_FILL, weight == 0.0f ? 1.0f : weight);
+ tabsContainer.getComponentAt(i).setLayoutConfig(layoutParams);
+ } else {
+ tabsContainer.getComponentAt(i).setLayoutConfig(expandedTabLayoutParams);
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) {
+ if (!shouldExpand || EstimateSpec.getMode(widthMeasureSpec) == EstimateSpec.UNCONSTRAINT) {
+ setTabLayoutParams();
+ return false;
+ }
+
+ int myWidth = getEstimatedWidth();
+ int childWidth = 0;
+ for (int i = 0; i < tabCount; i++) {
+ childWidth += tabsContainer.getComponentAt(i).getEstimatedWidth();
+ }
+
+ if (!checkedTabWidths && childWidth > 0 && myWidth > 0) {
+ if (childWidth <= myWidth) {
+ if (!setTabLayoutParams()) {
+ for (int i = 0; i < tabCount; i++) {
+ tabsContainer.getComponentAt(i).setLayoutConfig(expandedTabLayoutParams);
+ }
+ }
+ }
+
+ checkedTabWidths = true;
+ }
+ return true;
+ }
+
+ private void scrollToChild(int position, int offset) {
+ if (tabCount == 0) {
+ return;
+ }
+
+ int newScrollX = tabsContainer.getComponentAt(position).getLeft() + offset;
+
+ if (position > 0 || offset > 0) {
+ newScrollX -= scrollOffset;
+ }
+
+ if (newScrollX != lastScrollX) {
+ lastScrollX = newScrollX;
+ scrollTo(newScrollX, 0);
+ }
+ }
+
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ if (tabCount == 0) {
+ return;
+ }
+
+ if (tabDrawMode == DRAW_MODE_NORMAL) {
+ drawTabNormalMode(canvas);
+ } else {
+ drawTabTextMode(canvas);
+ }
+ }
+
+ private void drawTabNormalMode(Canvas canvas) {
+ final int height = getHeight();
+ // 设置提示下划线的颜色
+ rectPaint.setColor(new Color(indicatorColor));
+
+ Component currentTab = tabsContainer.getComponentAt(currentPosition);
+ float lineLeft = currentTab.getLeft();
+ float lineRight = currentTab.getRight();
+
+ // 绘制提示下划线
+ canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
+
+ // 绘制下划线
+ rectPaint.setColor(new Color(underlineColor));
+ canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
+
+ // 绘制分割线
+ dividerPaint.setColor(new Color(dividerColor));
+ for (int i = 0; i < tabCount - 1; i++) {
+ Component tab = tabsContainer.getComponentAt(i);
+ canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
+ }
+ }
+
+ private void drawTabTextMode(Canvas canvas) {
+ final int height = getHeight();
+
+ // 设置提示下划线的颜色
+ rectPaint.setColor(new Color(indicatorColor));
+
+ Component currentTab = tabsContainer.getComponentAt(currentPosition);
+ float lineLeft = currentTab.getLeft();
+
+ Component currentTextView = ((DependentLayout) currentTab).getComponentAt(0);
+ float currentTextViewLeft = currentTextView.getLeft();
+ float currentTextViewRight = currentTextView.getRight();
+
+ // 绘制提示下划线
+ float r = ((float) indicatorHeight) / 2;
+ canvas.drawCircle(lineLeft + currentTextViewLeft + r, height - indicatorHeight + r, r, rectPaint);
+ canvas.drawCircle(lineLeft + currentTextViewRight - r, height - indicatorHeight + r, r, rectPaint);
+
+ canvas.drawRect(lineLeft + currentTextViewLeft + r, height - indicatorHeight, lineLeft + currentTextViewRight - r, height, rectPaint);
+
+ // 分割线paint
+ dividerPaint.setColor(new Color(dividerColor));
+
+ // 下划线paint
+ rectPaint.setColor(new Color(underlineColor));
+
+ for (int i = 0; i < tabCount; i++) {
+ Component tab = tabsContainer.getComponentAt(i);
+ //绘制分割线
+ if (i < tabCount - 1) {
+ canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
+ }
+ Component tabTextView = ((DependentLayout) tab).getComponentAt(0);
+ canvas.drawRect(tab.getLeft() + tabTextView.getLeft(), height - underlineHeight, tab.getLeft() + tabTextView.getRight(), height, rectPaint);
+ }
+ }
+
+ /**
+ * PageListener
+ *
+ * @since 2021-04-30
+ */
+ private class PageListener implements PageSlider.PageChangedListener {
+ @Override
+ public void onPageSliding(int position, float positionOffset, int positionOffsetPixels) {
+ currentPositionOffset = positionOffset;
+
+ if (tabsContainer != null && tabsContainer.getComponentAt(position) != null) {
+ scrollToChild(position, (int) (positionOffset * tabsContainer.getComponentAt(position).getWidth()));
+ }
+
+ invalidate();
+
+ if (delegatePageListener != null) {
+ delegatePageListener.onPageSliding(position, positionOffset, positionOffsetPixels);
+ }
+ }
+
+ @Override
+ public void onPageSlideStateChanged(int state) {
+ if (state == PageSlider.SCROLL_IDLE_STAGE) {
+ scrollToChild(pager.getCurrentPage(), 0);
+ }
+
+ if (delegatePageListener != null) {
+ delegatePageListener.onPageSlideStateChanged(state);
+ }
+ }
+
+ @Override
+ public void onPageChosen(int position) {
+ setSelectItem(position);
+
+ if (delegatePageListener != null) {
+ delegatePageListener.onPageChosen(position);
+ }
+ currentPosition = position;
+ invalidate();
+ }
+ }
+
+ private void setViewResource(int position, Object obj, Text view) {
+ IconTabProvider iconTabProvider = (IconTabProvider) pager.getProvider();
+ Rect rect = iconTabProvider.getPageIconBounds(position);
+ Element drawable = null;
+ if (obj instanceof Integer) {
+ int resId = (int) obj;
+ if (resId != 0) {
+ drawable = getResElement(resId);
+ }
+ } else if (obj instanceof PixelMap) {
+ PixelMap bitmap = (PixelMap) obj;
+ if (bitmap != null) {
+ drawable = new PixelMapElement(bitmap);
+ }
+ } else if (obj instanceof Element) {
+ drawable = (Element) obj;
+ }
+
+ if (drawable != null) {
+ if (rect != null) {
+ drawable.setBounds(rect);
+ view.setAroundElements(null, drawable, null, null);
+ } else {
+ view.setAroundElements(null, drawable, null, null);
+ }
+ }
+ }
+
+ /**
+ * 选中item刷新状态
+ *
+ * @param position item位置
+ */
+ public void setSelectItem(int position) {
+ for (int i = 0; i < tabsContainer.getChildCount(); i++) {
+ DependentLayout linearLayout = (DependentLayout) tabsContainer.getComponentAt(i);
+ if (i == position) {
+ ((Text) linearLayout.getComponentAt(0)).setTextColor(new Color(tabTextSelectColor));
+ if (pager.getProvider() instanceof IconTabProvider) {
+ Object obj = ((IconTabProvider) pager.getProvider()).getPageSelectIcon(i);
+ setViewResource(position, obj, (Text) linearLayout.getComponentAt(0));
+ } else if (pager.getProvider() instanceof ViewTabProvider) {
+ Component view = ((ViewTabProvider) pager.getProvider()).onSelectIconView(i, getTabView(i), linearLayout);
+ setTabView(i, view);
+ changeIconView(linearLayout, view);
+ }
+ } else {
+ ((Text) linearLayout.getComponentAt(0)).setTextColor(new Color(tabTextColor));
+ if (pager.getProvider() instanceof IconTabProvider) {
+ Object obj = ((IconTabProvider) pager.getProvider()).getPageIcon(i);
+ setViewResource(position, obj, (Text) linearLayout.getComponentAt(0));
+ } else if (pager.getProvider() instanceof ViewTabProvider) {
+ Component view = ((ViewTabProvider) pager.getProvider()).onIconView(i, getTabView(i), linearLayout);
+ setTabView(i, view);
+ changeIconView(linearLayout, view);
+ }
+ }
+ }
+ }
+
+ private void changeIconView(DependentLayout linearLayout, Component view) {
+ DependentLayout.LayoutConfig viewLayoutParams
+ = ((ViewTabProvider) pager.getProvider()).getLayoutConfig();
+ viewLayoutParams.addRule(DependentLayout.LayoutConfig.HORIZONTAL_CENTER);
+ viewLayoutParams.addRule(DependentLayout.LayoutConfig.ABOVE, ResourceTable.String_id_tab_txt);
+ view.setLayoutConfig(viewLayoutParams);
+ linearLayout.removeComponentAt(1);
+ linearLayout.addComponent(view, 1);
+ }
+
+ /**
+ * 设置指标颜色
+ *
+ * @param indicatorColor 颜色值
+ */
+ public void setIndicatorColor(int indicatorColor) {
+ this.indicatorColor = indicatorColor;
+ invalidate();
+ }
+
+ /**
+ * 设置指标颜色资源
+ *
+ * @param resId 资源id
+ */
+ public void setIndicatorColorResource(int resId) {
+ this.indicatorColor = getColorValue(resId);
+ invalidate();
+ }
+
+ public int getIndicatorColor() {
+ return this.indicatorColor;
+ }
+
+ /**
+ * 设置指标高度
+ *
+ * @param indicatorLineHeightPx 指标高度
+ */
+ public void setIndicatorHeight(int indicatorLineHeightPx) {
+ this.indicatorHeight = indicatorLineHeightPx;
+ invalidate();
+ }
+
+ public int getIndicatorHeight() {
+ return indicatorHeight;
+ }
+
+ /**
+ * 设置下划线颜色
+ *
+ * @param underlineColor 下划线颜色
+ */
+ public void setUnderlineColor(int underlineColor) {
+ this.underlineColor = underlineColor;
+ invalidate();
+ }
+
+ /**
+ * 设置下划线颜色资源
+ *
+ * @param resId 资源id
+ */
+ public void setUnderlineColorResource(int resId) {
+ this.underlineColor = getColorValue(resId);
+ invalidate();
+ }
+
+ public int getUnderlineColor() {
+ return underlineColor;
+ }
+
+ /**
+ * 设置风格线颜色
+ *
+ * @param dividerColor 分割线颜色
+ */
+ public void setDividerColor(int dividerColor) {
+ this.dividerColor = dividerColor;
+ invalidate();
+ }
+
+ /**
+ * 设置风格线颜色资源
+ *
+ * @param resId 分割线颜色资源id
+ */
+ public void setDividerColorResource(int resId) {
+ this.dividerColor = getColorValue(resId);
+ invalidate();
+ }
+
+ public int getDividerColor() {
+ return dividerColor;
+ }
+
+ /**
+ * 设置下划线高度
+ *
+ * @param underlineHeightPx 下划线高度值
+ */
+ public void setUnderlineHeight(int underlineHeightPx) {
+ this.underlineHeight = underlineHeightPx;
+ invalidate();
+ }
+
+ public int getUnderlineHeight() {
+ return underlineHeight;
+ }
+
+ /**
+ * 设置分割线间距
+ *
+ * @param dividerPaddingPx 分割线间距值
+ */
+ public void setDividerPadding(int dividerPaddingPx) {
+ this.dividerPadding = dividerPaddingPx;
+ invalidate();
+ }
+
+ public int getDividerPadding() {
+ return dividerPadding;
+ }
+
+ /**
+ * 设置滚动偏移量
+ *
+ * @param scrollOffsetPx 滚动偏移量
+ */
+ public void setScrollOffset(int scrollOffsetPx) {
+ this.scrollOffset = scrollOffsetPx;
+ invalidate();
+ }
+
+ public int getScrollOffset() {
+ return scrollOffset;
+ }
+
+ /**
+ * 设置是否平铺展开
+ *
+ * @param shouldExpand 是否展开
+ */
+ public void setShouldExpand(boolean shouldExpand) {
+ this.shouldExpand = shouldExpand;
+ postLayout();
+ }
+
+ public boolean getShouldExpand() {
+ return shouldExpand;
+ }
+
+ public boolean isTextAllCaps() {
+ return textAllCaps;
+ }
+
+ public void setAllCaps(boolean textAllCaps) {
+ this.textAllCaps = textAllCaps;
+ }
+
+ /**
+ * 设置字体大小
+ *
+ * @param textSizePx 字体大小
+ */
+ public void setTextSize(int textSizePx) {
+ this.tabTextSize = textSizePx;
+ updateTabStyles();
+ }
+
+ public int getTextSize() {
+ return tabTextSize;
+ }
+
+ /**
+ * 设置文字颜色
+ *
+ * @param textColor 文字颜色
+ */
+ public void setTextColor(int textColor) {
+ this.tabTextColor = textColor;
+ updateTabStyles();
+ }
+
+ /**
+ * 设置字体颜色资源
+ *
+ * @param resId 资源id
+ */
+ public void setTextColorResource(int resId) {
+ this.tabTextColor = getColorValue(resId);
+ updateTabStyles();
+ }
+
+ public int getTextColor() {
+ return tabTextColor;
+ }
+
+ /**
+ * 设置字体类型
+ *
+ * @param style 字体类型
+ */
+ public void setTypeface(Font style) {
+ this.tabTypefaceStyle = style;
+ updateTabStyles();
+ }
+
+ /**
+ * 设置tab左右padding
+ *
+ * @param paddingPx padding值
+ */
+ public void setTabPaddingLeftRight(int paddingPx) {
+ this.tabPadding = paddingPx;
+ updateTabStyles();
+ }
+
+ public int getTabPaddingLeftRight() {
+ return tabPadding;
+ }
+
+ private int getResValue(int resId) {
+ ResourceManager resManager = this.getResourceManager();
+ int result = 0;
+ try {
+ result = (int) resManager.getElement(resId).getFloat();
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ e.fillInStackTrace();
+ }
+ return result;
+ }
+
+ private int getColorValue(int resId) {
+ ResourceManager resManager = this.getResourceManager();
+ int color = 0;
+ try {
+ color = resManager.getElement(resId).getColor();
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ e.fillInStackTrace();
+ }
+ return color;
+ }
+
+ private Element getResElement(int resId) {
+ Element element = null;
+ try {
+ element = new PixelMapElement(this.getResourceManager().getResource(resId));
+ } catch (IOException | NotExistException e) {
+ e.fillInStackTrace();
+ }
+ return element;
+ }
+}
diff --git a/Library/src/com/lhh/apst/library/CustomPagerSlidingTabStrip.java b/Library/src/main/java/com/lhh/apst/library/CustomPagerSlidingTabStrip.java
similarity index 36%
rename from Library/src/com/lhh/apst/library/CustomPagerSlidingTabStrip.java
rename to Library/src/main/java/com/lhh/apst/library/CustomPagerSlidingTabStrip.java
index e304b7c0b50611caf4bb90dad5e328a462d95936..4eeeaf7f88cbddee443a7f23af86dd736ad2973a 100644
--- a/Library/src/com/lhh/apst/library/CustomPagerSlidingTabStrip.java
+++ b/Library/src/main/java/com/lhh/apst/library/CustomPagerSlidingTabStrip.java
@@ -1,47 +1,32 @@
package com.lhh.apst.library;
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.v4.view.ViewPager;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.SparseArray;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewTreeObserver.OnGlobalLayoutListener;
-import android.widget.HorizontalScrollView;
-import android.widget.LinearLayout;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Locale;
+import com.lhh.apst.library.utils.TypedAttrUtils;
+import ohos.agp.components.*;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.WrongTypeException;
+import ohos.utils.PlainArray;
+
+import java.io.IOException;
/**
* Created by linhomhom on 2015/9/22.
*/
-public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
-
- public interface CustomTabProvider{
- public View getSelectTabView(int position, View convertView);
- public View getDisSelectTabView(int position, View convertView);
- }
- // @formatter:on
-
- private LinearLayout.LayoutParams defaultTabLayoutParams;
- private LinearLayout.LayoutParams expandedTabLayoutParams;
+public class CustomPagerSlidingTabStrip extends ScrollView implements Component.DrawTask, Component.EstimateSizeListener {
+ private DirectionalLayout.LayoutConfig expandedTabLayoutParams;
private final PageListener pageListener = new PageListener();
- public ViewPager.OnPageChangeListener delegatePageListener;
- private LinearLayout tabsContainer;
- private ViewPager pager;
+ /**
+ * PageSlider页面切换监听
+ */
+ public PageSlider.PageChangedListener delegatePageListener;
+
+ private DirectionalLayout tabsContainer;
+ private PageSlider pager;
private int tabCount;
@@ -60,8 +45,8 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
private boolean shouldExpand = true;
private int scrollOffset = 52;
- private int indicatorHeight = 3;
- private int underlineHeight = 2;
+ private int indicatorHeight = 10;
+ private int underlineHeight = 10;
private int dividerPadding = 12;
private int tabPadding = 24;
private int tabPaddingTopBottom = 0;
@@ -69,186 +54,215 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
private int lastScrollX = 0;
- private int tabBackgroundResId = R.drawable.psts_background_tab;
-// private int tabBackgroundResId;
-
- private Locale locale;
private OnTabClickListener mOnTabClickListener;
- public interface OnTabClickListener{
- public void onClick(int pos);
- }
+ /**
+ * Tab点击接口
+ *
+ * @since 2021-04-30
+ */
+ public interface OnTabClickListener {
+ /**
+ * 点击方法
+ *
+ * @param pos 点击位置
+ */
+ void onClick(int pos);
+ }
+
+ /**
+ * CustomTabProvider
+ *
+ * @since 2021-04-30
+ */
+ public interface CustomTabProvider {
+ /**
+ * 获取选中tabView
+ *
+ * @param position 选中位置
+ * @param convertView Component
+ * @return Component
+ */
+ Component getSelectTabView(int position, Component convertView);
+
+ /**
+ * 获取未选中tabView
+ *
+ * @param position 选中位置
+ * @param convertView Component
+ * @return Component
+ */
+ Component getDisSelectTabView(int position, Component convertView);
+ }
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
public CustomPagerSlidingTabStrip(Context context) {
this(context, null);
}
- public CustomPagerSlidingTabStrip(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public CustomPagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- setFillViewport(true);
- setWillNotDraw(false);
-
- tabsContainer = new LinearLayout(context);
- tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
- tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- addView(tabsContainer);
-
- DisplayMetrics dm = getResources().getDisplayMetrics();
-
- scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
- indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
- underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
- dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
- tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
- dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
-
- // get system attrs (android:textSize and android:textColor)
-
- TypedArray a = null;
-
- // get custom attrs
-
-
- a = context.obtainStyledAttributes(attrs, R.styleable.AdvancedPagerSlidingTabStrip);
-
- indicatorColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabIndicatorColor, indicatorColor);
- underlineColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabUnderlineColor, underlineColor);
- dividerColor = a.getColor(R.styleable.AdvancedPagerSlidingTabStrip_apTabDividerColor, dividerColor);
- indicatorHeight = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabIndicatorHeight, indicatorHeight);
- underlineHeight = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabUnderlineHeight, underlineHeight);
- dividerPadding = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabDividerPadding, dividerPadding);
- tabPadding = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabPaddingLeftRight, tabPadding);
- tabPaddingTopBottom = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabPaddingTopBottom, tabPaddingTopBottom);
- tabBackgroundResId = a.getResourceId(R.styleable.AdvancedPagerSlidingTabStrip_apTabBackground, tabBackgroundResId);
- shouldExpand = a.getBoolean(R.styleable.AdvancedPagerSlidingTabStrip_apTabShouldExpand, shouldExpand);
- scrollOffset = a.getDimensionPixelSize(R.styleable.AdvancedPagerSlidingTabStrip_apTabScrollOffset, scrollOffset);
-
- a.recycle();
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ * @param attrSet AttrSet
+ */
+ public CustomPagerSlidingTabStrip(Context context, AttrSet attrSet) {
+ this(context, attrSet, null);
+ }
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ * @param attrSet AttrSet
+ * @param styleName String
+ */
+ public CustomPagerSlidingTabStrip(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ setMatchViewportEnabled(true);
+
+ tabsContainer = new DirectionalLayout(context);
+ tabsContainer.setOrientation(DirectionalLayout.HORIZONTAL);
+ LayoutConfig layoutConfig = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT);
+ tabsContainer.setLayoutConfig(layoutConfig);
+ addComponent(tabsContainer);
+
+ indicatorColor = TypedAttrUtils.getIntColor(attrSet, "apTabIndicatorColor", indicatorColor);
+ underlineColor = TypedAttrUtils.getIntColor(attrSet, "apTabUnderlineColor", underlineColor);
+ dividerColor = TypedAttrUtils.getIntColor(attrSet, "apTabDividerColor", dividerColor);
+ indicatorHeight = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabIndicatorHeight", indicatorHeight);
+ underlineHeight = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabUnderlineHeight", underlineHeight);
+ dividerPadding = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabDividerPadding", dividerPadding);
+ tabPadding = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabPaddingLeftRight", tabPadding);
+ tabPaddingTopBottom = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabPaddingTopBottom", tabPaddingTopBottom);
+ shouldExpand = TypedAttrUtils.getBoolean(attrSet, "apTabShouldExpand", shouldExpand);
+ scrollOffset = TypedAttrUtils.getDimensionPixelSize(attrSet, "apTabScrollOffset", scrollOffset);
rectPaint = new Paint();
rectPaint.setAntiAlias(true);
- rectPaint.setStyle(Style.FILL);
+ rectPaint.setStyle(Paint.Style.FILL_STYLE);
dividerPaint = new Paint();
dividerPaint.setAntiAlias(true);
dividerPaint.setStrokeWidth(dividerWidth);
- defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
- expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
+ expandedTabLayoutParams = new DirectionalLayout.LayoutConfig(0, LayoutConfig.MATCH_PARENT, TableLayout.Alignment.ALIGNMENT_FILL, 1.0f);
- if (locale == null) {
- locale = getResources().getConfiguration().locale;
+ if (mDisSelectTabViewCache == null) {
+ mDisSelectTabViewCache = new PlainArray<>();
}
-
- if(mDisSelectTabViewCache == null){
- mDisSelectTabViewCache = new SparseArray<>();
- }
- if(mSelectTabViewCache == null){
- mSelectTabViewCache = new SparseArray<>();
+ if (mSelectTabViewCache == null) {
+ mSelectTabViewCache = new PlainArray<>();
}
+
+ addDrawTask(this);
+ setEstimateSizeListener(this);
}
- public void setOnTabClickListener(OnTabClickListener onTabClickListener){
+ public void setOnTabClickListener(OnTabClickListener onTabClickListener) {
mOnTabClickListener = onTabClickListener;
}
- public void setViewPager(ViewPager pager) {
+ /**
+ * 设置PageSlider
+ *
+ * @param pager PageSlider
+ */
+ public void setViewPager(PageSlider pager) {
this.pager = pager;
- if (pager.getAdapter() == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
+ if (pager.getProvider() == null) {
+ throw new IllegalStateException("PageSlider does not have Provider instance.");
}
- pager.addOnPageChangeListener(pageListener);
+ pager.addPageChangedListener(pageListener);
notifyDataSetChanged();
}
- public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
+ public void setOnPageChangeListener(PageSlider.PageChangedListener listener) {
this.delegatePageListener = listener;
}
+ /**
+ * 更新数据
+ */
public void notifyDataSetChanged() {
-
- tabsContainer.removeAllViews();
-
- tabCount = pager.getAdapter().getCount();
+ tabsContainer.removeAllComponents();
+ tabCount = pager.getProvider().getCount();
for (int i = 0; i < tabCount; i++) {
-
- if (pager.getAdapter() instanceof CustomTabProvider) {
- View view = ((CustomTabProvider) pager.getAdapter()).getSelectTabView(i, getSelectTabView(i));
+ if (pager.getProvider() instanceof CustomTabProvider) {
+ Component view = ((CustomTabProvider) pager.getProvider()).getSelectTabView(i, null);
setSelectTabView(i, view);
updateViewStyle(view);
addTab(i, view);
}
-
}
-// updateTabStyles();
-
checkedTabWidths = false;
-
- getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
-
- @SuppressWarnings("deprecation")
- @SuppressLint("NewApi")
- @Override
- public void onGlobalLayout() {
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
- getViewTreeObserver().removeGlobalOnLayoutListener(this);
- } else {
- getViewTreeObserver().removeOnGlobalLayoutListener(this);
- }
-
- currentPosition = pager.getCurrentItem();
- scrollToChild(currentPosition, 0);
- }
- });
-
- pageListener.onPageSelected(0);//default
-
+ pageListener.onPageChosen(0);
}
private PageOnClickListener mPageOnClickListener;
- private void addTab(final int position, View view){
- if(mPageOnClickListener == null){
- mPageOnClickListener = new PageOnClickListener();
+ /**
+ * PageOnClickListener
+ *
+ * @since 2021-04-30
+ */
+ class PageOnClickListener implements ClickedListener {
+ @Override
+ public void onClick(Component component) {
+ int tag = (int) component.getTag();
+ if (mOnTabClickListener != null) {
+ mOnTabClickListener.onClick(tag);
+ }
+ scrollToChild(tag, 0);
+ pager.setCurrentPage(tag);
}
- view.setTag(R.id.tag_position, position);
- view.setOnClickListener(mPageOnClickListener);
- tabsContainer.addView(view);
}
- public View getTabAt(int pos) {
+ private void addTab(final int position, Component view) {
+ if (mPageOnClickListener == null) {
+ mPageOnClickListener = new PageOnClickListener();
+ }
+ view.setTag(position);
+ view.setClickedListener(mPageOnClickListener);
+ tabsContainer.addComponent(view, position);
+ }
+
+ /**
+ * 获取tab Component
+ *
+ * @param pos 选中位置
+ * @return Component
+ */
+ public Component getTabAt(int pos) {
if (pos >= tabsContainer.getChildCount()) {
throw new IllegalStateException("pos is too big.");
}
- return tabsContainer.getChildAt(pos);
+ return tabsContainer.getComponentAt(pos);
}
private void updateTabStyles() {
-
for (int i = 0; i < tabCount; i++) {
-
- View v = tabsContainer.getChildAt(i);
-
- //v.setLayoutParams(defaultTabLayoutParams);
- //my modify
+ Component v = tabsContainer.getComponentAt(i);
updateViewStyle(v);
}
-
}
- public void updateViewStyle(View v){
- v.setLayoutParams(expandedTabLayoutParams);
- v.setBackgroundResource(tabBackgroundResId);
+ /**
+ * 更新view样式
+ *
+ * @param v Component
+ */
+ public void updateViewStyle(Component v) {
+ v.setLayoutConfig(expandedTabLayoutParams);
if (shouldExpand) {
v.setPadding(0, 0, 0, 0);
} else {
@@ -257,38 +271,39 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) {
+ if (!shouldExpand || EstimateSpec.getMode(widthMeasureSpec) == EstimateSpec.UNCONSTRAINT) {
+ return false;
+ }
- if (!shouldExpand || MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED) {
- return;
+ if (tabsContainer.getChildCount() == 0) {
+ return false;
}
- int myWidth = getMeasuredWidth();
+ int myWidth = getEstimatedWidth();
int childWidth = 0;
for (int i = 0; i < tabCount; i++) {
- childWidth += tabsContainer.getChildAt(i).getMeasuredWidth();
+ childWidth += tabsContainer.getComponentAt(i).getEstimatedWidth();
}
if (!checkedTabWidths && childWidth > 0 && myWidth > 0) {
-
if (childWidth <= myWidth) {
for (int i = 0; i < tabCount; i++) {
- tabsContainer.getChildAt(i).setLayoutParams(expandedTabLayoutParams);
+ tabsContainer.getComponentAt(i).setLayoutConfig(expandedTabLayoutParams);
}
}
-
checkedTabWidths = true;
}
+
+ return true;
}
private void scrollToChild(int position, int offset) {
-
if (tabCount == 0) {
return;
}
- int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
+ int newScrollX = tabsContainer.getComponentAt(position).getLeft() + offset;
if (position > 0 || offset > 0) {
newScrollX -= scrollOffset;
@@ -298,175 +313,163 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
lastScrollX = newScrollX;
scrollTo(newScrollX, 0);
}
-
}
@Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- if (isInEditMode() || tabCount == 0) {
+ public void onDraw(Component component, Canvas canvas) {
+ if (tabCount == 0) {
return;
}
-
drawTabNormalMode(canvas);
}
- private void drawTabNormalMode(Canvas canvas){
+ private void drawTabNormalMode(Canvas canvas) {
final int height = getHeight();
// 设置提示下划线的颜色
-
- rectPaint.setColor(indicatorColor);
+ rectPaint.setColor(new Color(indicatorColor));
// default: line below current tab
- View currentTab = tabsContainer.getChildAt(currentPosition);
+ Component currentTab = tabsContainer.getComponentAt(currentPosition);
+ if (currentTab == null) {
+ return;
+ }
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
- // if there is an offset, start interpolating left and right coordinates between current and next tab
- if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
-
- View nextTab = tabsContainer.getChildAt(currentPosition + 1);
- final float nextTabLeft = nextTab.getLeft();
- final float nextTabRight = nextTab.getRight();
-
- lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
- lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
-
- }
-
//绘制提示下划线
- canvas.drawRect(lineLeft , height - indicatorHeight, lineRight , height, rectPaint);
+ canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
// 绘制下划线
-
- rectPaint.setColor(underlineColor);
+ rectPaint.setColor(new Color(underlineColor));
canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
// 绘制分割线
-
- dividerPaint.setColor(dividerColor);
+ dividerPaint.setColor(new Color(dividerColor));
for (int i = 0; i < tabCount - 1; i++) {
- View tab = tabsContainer.getChildAt(i);
+ Component tab = tabsContainer.getComponentAt(i);
canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
}
}
- private class PageListener implements ViewPager.OnPageChangeListener {
-
+ /**
+ * PageListener
+ *
+ * @since 2021-04-30
+ */
+ private class PageListener implements PageSlider.PageChangedListener {
@Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- currentPosition = position;
+ public void onPageSliding(int position, float positionOffset, int positionOffsetPixels) {
currentPositionOffset = positionOffset;
-
- scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth()));
-
+ scrollToChild(position, (int) (positionOffset * tabsContainer.getComponentAt(position).getWidth()));
invalidate();
if (delegatePageListener != null) {
- delegatePageListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
+ delegatePageListener.onPageSliding(position, positionOffset, positionOffsetPixels);
}
}
@Override
- public void onPageScrollStateChanged(int state) {
- if (state == ViewPager.SCROLL_STATE_IDLE) {
- scrollToChild(pager.getCurrentItem(), 0);
+ public void onPageSlideStateChanged(int state) {
+ if (state == PageSlider.SLIDING_STATE_IDLE) {
+ scrollToChild(pager.getCurrentPage(), 0);
}
if (delegatePageListener != null) {
- delegatePageListener.onPageScrollStateChanged(state);
+ delegatePageListener.onPageSlideStateChanged(state);
}
}
@Override
- public void onPageSelected(int position) {
-
+ public void onPageChosen(int position) {
setSelectItem(position);
-
if (delegatePageListener != null) {
- delegatePageListener.onPageSelected(position);
+ delegatePageListener.onPageChosen(position);
}
+ currentPosition = position;
+ invalidate();
}
-
}
- private SparseArray mDisSelectTabViewCache;//缓存
+ private PlainArray mDisSelectTabViewCache;
- private View getDisSelectTabView(int position){
- return mDisSelectTabViewCache.get(position);
+ private Component getDisSelectTabView(int position) {
+ return mDisSelectTabViewCache.get(position).get();
}
- private void setDisSelectTabView(int position , View view){
- mDisSelectTabViewCache.put(position,view);
+ private void setDisSelectTabView(int position, Component view) {
+ mDisSelectTabViewCache.put(position, view);
}
- private SparseArray mSelectTabViewCache;//缓存
+ private PlainArray mSelectTabViewCache;
- private View getSelectTabView(int position){
- return mSelectTabViewCache.get(position);
+ private Component getSelectTabView(int position) {
+ return mSelectTabViewCache.get(position).get();
}
- private void setSelectTabView( int position ,View view){
- mSelectTabViewCache.put(position,view);
- }
-
- class PageOnClickListener implements View.OnClickListener{
-
- @Override
- public void onClick(View view) {
- int tag = (int)view.getTag(R.id.tag_position);
- if(mOnTabClickListener != null){
- mOnTabClickListener.onClick(tag);
- }
- scrollToChild(tag, 0);
- pager.setCurrentItem(tag);
- }
+ private void setSelectTabView(int position, Component view) {
+ mSelectTabViewCache.put(position, view);
}
- public void setSelectItem(int position){
- if (!(pager.getAdapter() instanceof CustomTabProvider)) {
+ /**
+ * 设置选中item
+ *
+ * @param position 当前位置
+ */
+ public void setSelectItem(int position) {
+ if (!(pager.getProvider() instanceof CustomTabProvider)) {
return;
}
- for (int i = 0; i < tabsContainer.getChildCount(); i++) {
- tabsContainer.removeViewAt(i);
+ for (int i = 0; i < tabsContainer.getChildCount(); i++) {
+ tabsContainer.removeComponentAt(i);
- View view = null;
+ Component view;
if (i == position) {
- view = ((CustomTabProvider) pager.getAdapter()).getSelectTabView(i, getSelectTabView(i));
+ view = ((CustomTabProvider) pager.getProvider()).getSelectTabView(i, null);
setSelectTabView(i, view);
-
} else {
- view = ((CustomTabProvider) pager.getAdapter()).getDisSelectTabView(i, getDisSelectTabView(i));
+ view = ((CustomTabProvider) pager.getProvider()).getDisSelectTabView(i, null);
setDisSelectTabView(i, view);
}
- view.setTag(R.id.tag_position, i);
+ view.setTag(i);
- if(mPageOnClickListener == null){
+ if (mPageOnClickListener == null) {
mPageOnClickListener = new PageOnClickListener();
}
- view.setOnClickListener(mPageOnClickListener);
+ view.setClickedListener(mPageOnClickListener);
- tabsContainer.addView(view, i);
+ tabsContainer.addComponent(view, i);
updateViewStyle(view);
}
}
+ /**
+ * 设置下标颜色值
+ *
+ * @param indicatorColor 下标颜色值
+ */
public void setIndicatorColor(int indicatorColor) {
this.indicatorColor = indicatorColor;
invalidate();
}
+ /**
+ * 设置下标颜色值
+ *
+ * @param resId 下标颜色值资源id
+ */
public void setIndicatorColorResource(int resId) {
- this.indicatorColor = getResources().getColor(resId);
+ try {
+ this.indicatorColor = getResourceManager().getElement(resId).getColor();
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ e.fillInStackTrace();
+ }
invalidate();
}
@@ -474,6 +477,11 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return this.indicatorColor;
}
+ /**
+ * 设置下标线高度
+ *
+ * @param indicatorLineHeightPx 下标线高度
+ */
public void setIndicatorHeight(int indicatorLineHeightPx) {
this.indicatorHeight = indicatorLineHeightPx;
invalidate();
@@ -483,13 +491,27 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return indicatorHeight;
}
+ /**
+ * 设置下边线颜色值
+ *
+ * @param underlineColor 下边线颜色值
+ */
public void setUnderlineColor(int underlineColor) {
this.underlineColor = underlineColor;
invalidate();
}
+ /**
+ * 设置下边线颜色值
+ *
+ * @param resId 资源id
+ */
public void setUnderlineColorResource(int resId) {
- this.underlineColor = getResources().getColor(resId);
+ try {
+ this.underlineColor = getResourceManager().getElement(resId).getColor();
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ e.fillInStackTrace();
+ }
invalidate();
}
@@ -497,13 +519,27 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return underlineColor;
}
+ /**
+ * 设置分割线颜色值
+ *
+ * @param dividerColor 资源id
+ */
public void setDividerColor(int dividerColor) {
this.dividerColor = dividerColor;
invalidate();
}
+ /**
+ * 设置分割线颜色值
+ *
+ * @param resId 资源id
+ */
public void setDividerColorResource(int resId) {
- this.dividerColor = getResources().getColor(resId);
+ try {
+ this.dividerColor = getResourceManager().getElement(resId).getColor();
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ e.fillInStackTrace();
+ }
invalidate();
}
@@ -511,6 +547,11 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return dividerColor;
}
+ /**
+ * 设置下标线高度
+ *
+ * @param underlineHeightPx 下标线高度
+ */
public void setUnderlineHeight(int underlineHeightPx) {
this.underlineHeight = underlineHeightPx;
invalidate();
@@ -520,6 +561,11 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return underlineHeight;
}
+ /**
+ * 设置分割线padding
+ *
+ * @param dividerPaddingPx 分割线padding
+ */
public void setDividerPadding(int dividerPaddingPx) {
this.dividerPadding = dividerPaddingPx;
invalidate();
@@ -529,6 +575,11 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return dividerPadding;
}
+ /**
+ * 设置滚动偏移量
+ *
+ * @param scrollOffsetPx 滚动偏移量
+ */
public void setScrollOffset(int scrollOffsetPx) {
this.scrollOffset = scrollOffsetPx;
invalidate();
@@ -538,23 +589,25 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
return scrollOffset;
}
+ /**
+ * 是否展开
+ *
+ * @param shouldExpand 是否展开
+ */
public void setShouldExpand(boolean shouldExpand) {
this.shouldExpand = shouldExpand;
- requestLayout();
+ postLayout();
}
public boolean getShouldExpand() {
return shouldExpand;
}
- public void setTabBackground(int resId) {
- this.tabBackgroundResId = resId;
- }
-
- public int getTabBackground() {
- return tabBackgroundResId;
- }
-
+ /**
+ * tab左右padding
+ *
+ * @param paddingPx 左右padding值
+ */
public void setTabPaddingLeftRight(int paddingPx) {
this.tabPadding = paddingPx;
updateTabStyles();
@@ -563,52 +616,4 @@ public class CustomPagerSlidingTabStrip extends HorizontalScrollView {
public int getTabPaddingLeftRight() {
return tabPadding;
}
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState savedState = (SavedState) state;
- super.onRestoreInstanceState(savedState.getSuperState());
- currentPosition = savedState.currentPosition;
- requestLayout();
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState savedState = new SavedState(superState);
- savedState.currentPosition = currentPosition;
- return savedState;
- }
-
- static class SavedState extends BaseSavedState {
- int currentPosition;
-
- public SavedState(Parcelable superState) {
- super(superState);
- }
-
- private SavedState(Parcel in) {
- super(in);
- currentPosition = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(currentPosition);
- }
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- @Override
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
}
diff --git a/Library/src/com/lhh/apst/library/Margins.java b/Library/src/main/java/com/lhh/apst/library/Margins.java
similarity index 40%
rename from Library/src/com/lhh/apst/library/Margins.java
rename to Library/src/main/java/com/lhh/apst/library/Margins.java
index dbdbc89a7045403a935c10c1c021295b340d89de..3a4ffa9a4f1f7e91f4c74a0a17d13e6bd64a37a3 100644
--- a/Library/src/com/lhh/apst/library/Margins.java
+++ b/Library/src/main/java/com/lhh/apst/library/Margins.java
@@ -3,12 +3,36 @@ package com.lhh.apst.library;
/**
* Created by Linhh on 16/3/8.
*/
-public class Margins{
+public class Margins {
+ /**
+ * 左Margin
+ */
public int mLeft;
+
+ /**
+ * 右Margin
+ */
public int mRight;
+
+ /**
+ * 上Margin
+ */
public int mTop;
+
+ /**
+ * 下Margin
+ */
public int mBottom;
- public Margins(int left, int top, int right, int bottom){
+
+ /**
+ * 构造函数
+ *
+ * @param left 左Margin
+ * @param top 上Margin
+ * @param right 右Margin
+ * @param bottom 下Margin
+ */
+ public Margins(int left, int top, int right, int bottom) {
mLeft = left;
mRight = right;
mTop = top;
diff --git a/Library/src/main/java/com/lhh/apst/library/utils/TypedAttrUtils.java b/Library/src/main/java/com/lhh/apst/library/utils/TypedAttrUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..0e4c44d34ad9846ee6eaa926158c496cbebf7347
--- /dev/null
+++ b/Library/src/main/java/com/lhh/apst/library/utils/TypedAttrUtils.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2021 The Chinese Software International Co., Ltd.
+ * 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.lhh.apst.library.utils;
+
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.element.Element;
+import ohos.agp.utils.Color;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * TypedAttrUtils
+ *
+ * @since 2021-04-13
+ */
+public class TypedAttrUtils {
+ /**
+ * 日志常量
+ */
+ public static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, 0x00201, "TypedAttrUtils");
+
+ /**
+ * 颜色工具类
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return int
+ */
+ public static int getIntColor(AttrSet attrs, String attrName, int defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getColorValue().getValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getColor
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return Color
+ */
+ public static Color getColor(AttrSet attrs, String attrName, Color defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getColorValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getBoolean
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param isDefValue 默认值
+ * @return boolean
+ */
+ public static boolean getBoolean(AttrSet attrs, String attrName, boolean isDefValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getBoolValue();
+ } else {
+ return isDefValue;
+ }
+ }
+
+ /**
+ * getString
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return String
+ */
+ public static String getString(AttrSet attrs, String attrName, String defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getStringValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getFloat
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return float
+ */
+ public static float getFloat(AttrSet attrs, String attrName, float defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getFloatValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getInt
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return int
+ */
+ public static int getInt(AttrSet attrs, String attrName, int defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getIntegerValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getDimensionPixelSize
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return int
+ */
+ public static int getDimensionPixelSize(AttrSet attrs, String attrName, int defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return attrs.getAttr(attrName).get().getIntegerValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getLayoutDimension
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return int
+ */
+ public static int getLayoutDimension(AttrSet attrs, String attrName, int defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ HiLog.info(LABEL, "attr.getDimensionValue() = " + attrs.getAttr(attrName).get().getDimensionValue());
+ return attrs.getAttr(attrName).get().getDimensionValue();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * getElement
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @param defValue 默认值
+ * @return Element
+ */
+ public static Element getElement(AttrSet attrs, String attrName, Element defValue) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ HiLog.info(LABEL, "attr.getElement() = " + attrs.getAttr(attrName).get().getElement());
+ return attrs.getAttr(attrName).get().getElement();
+ } else {
+ return defValue;
+ }
+ }
+
+ /**
+ * hasValue
+ *
+ * @param attrs 属性
+ * @param attrName 属性名
+ * @return boolean
+ */
+ public static boolean hasValue(AttrSet attrs, String attrName) {
+ if (attrs.getAttr(attrName) != null && attrs.getAttr(attrName).isPresent()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/Library/src/main/resources/base/element/color.json b/Library/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..7b220e67cdf4a989767ea909351489ab7153de00
--- /dev/null
+++ b/Library/src/main/resources/base/element/color.json
@@ -0,0 +1,12 @@
+{
+ "color": [
+ {
+ "name": "background_tab_pressed",
+ "value": "#6633B5E5"
+ },
+ {
+ "name": "red",
+ "value": "#E43F3E"
+ }
+ ]
+}
diff --git a/Library/src/main/resources/base/element/float.json b/Library/src/main/resources/base/element/float.json
new file mode 100644
index 0000000000000000000000000000000000000000..19e2916d324806136aeb340e85edd12a20614100
--- /dev/null
+++ b/Library/src/main/resources/base/element/float.json
@@ -0,0 +1,32 @@
+{
+ "float": [
+ {
+ "name": "psts_dot_wh",
+ "value": "10vp"
+ },
+ {
+ "name": "psts_indicator_circle",
+ "value": "4vp"
+ },
+ {
+ "name": "psts_dot_m_right",
+ "value": "9vp"
+ },
+ {
+ "name": "psts_dot_m_tv_right",
+ "value": "8vp"
+ },
+ {
+ "name": "psts_dot_m_top",
+ "value": "7vp"
+ },
+ {
+ "name": "psts_dot_linelayout_h",
+ "value": "23vp"
+ },
+ {
+ "name": "psts_dot_txt_size",
+ "value": "10fp"
+ }
+ ]
+}
diff --git a/Library/src/main/resources/base/element/string.json b/Library/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b2f9e9b09bd9e34576d3e97ffce01b89dd299ecb
--- /dev/null
+++ b/Library/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "Library"
+ },
+ {
+ "name": "tag_position",
+ "value": "tag_position"
+ },
+ {
+ "name": "id_tab_txt",
+ "value": "id_tab_txt"
+ }
+ ]
+}
diff --git a/Library/src/main/resources/base/graphic/apsts_tips.xml b/Library/src/main/resources/base/graphic/apsts_tips.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7ba893f31ded3bfb51d27b5e5300713d011cb226
--- /dev/null
+++ b/Library/src/main/resources/base/graphic/apsts_tips.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Library/src/main/resources/base/graphic/psts_background_tab.xml b/Library/src/main/resources/base/graphic/psts_background_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c8359955a1322f2cb128043976929be64af11ee9
--- /dev/null
+++ b/Library/src/main/resources/base/graphic/psts_background_tab.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Library/src/test/java/com/lhh/apst/library/ExampleTest.java b/Library/src/test/java/com/lhh/apst/library/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0387338af17ec32c462511acc96534035675c26
--- /dev/null
+++ b/Library/src/test/java/com/lhh/apst/library/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.lhh.apst.library;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/Pic/Screen_20160216163404.png b/Pic/Screen_20160216163404.png
deleted file mode 100644
index 2a220a3b1ca9542ed1f39ca6fffcfd547a2a7698..0000000000000000000000000000000000000000
Binary files a/Pic/Screen_20160216163404.png and /dev/null differ
diff --git a/Pic/Screen_20160216163428.png b/Pic/Screen_20160216163428.png
deleted file mode 100644
index b50acfaeaef02c83faf3bc910e3044dcc81929df..0000000000000000000000000000000000000000
Binary files a/Pic/Screen_20160216163428.png and /dev/null differ
diff --git a/Pic/Screen_20160216163452.png b/Pic/Screen_20160216163452.png
deleted file mode 100644
index 3bc6ca36ef009e5de553f434ec0cf526bcebb4bd..0000000000000000000000000000000000000000
Binary files a/Pic/Screen_20160216163452.png and /dev/null differ
diff --git a/Pic/Screen_20160411141706.png b/Pic/Screen_20160411141706.png
deleted file mode 100644
index 08da89fbdaa812164f58a368703fec5db5843273..0000000000000000000000000000000000000000
Binary files a/Pic/Screen_20160411141706.png and /dev/null differ
diff --git a/Pic/categry_icon_n.png b/Pic/categry_icon_n.png
deleted file mode 100755
index 578e5e6fca5020add776c5cf6ce76988ed8c1757..0000000000000000000000000000000000000000
Binary files a/Pic/categry_icon_n.png and /dev/null differ
diff --git a/Pic/categry_icon_p.png b/Pic/categry_icon_p.png
deleted file mode 100755
index 1ff85e49b307afb766b2d1ecd81a3a150c2dacb9..0000000000000000000000000000000000000000
Binary files a/Pic/categry_icon_p.png and /dev/null differ
diff --git a/Pic/classify_icon_n.png b/Pic/classify_icon_n.png
deleted file mode 100755
index 0eb34d1e0871e55c6268476594fd0b3155a2873d..0000000000000000000000000000000000000000
Binary files a/Pic/classify_icon_n.png and /dev/null differ
diff --git a/Pic/classify_icon_p.png b/Pic/classify_icon_p.png
deleted file mode 100755
index 5f1f86cd7bb45f0bba8ae63b07b4d736585cd99d..0000000000000000000000000000000000000000
Binary files a/Pic/classify_icon_p.png and /dev/null differ
diff --git a/Pic/mine_icon_n.png b/Pic/mine_icon_n.png
deleted file mode 100755
index 6780a2fbc97eef717a6413ebbef2e0d1a920a34a..0000000000000000000000000000000000000000
Binary files a/Pic/mine_icon_n.png and /dev/null differ
diff --git a/Pic/mine_icon_p.png b/Pic/mine_icon_p.png
deleted file mode 100755
index c5d61b2d790db26831b820671e63e315047d2e17..0000000000000000000000000000000000000000
Binary files a/Pic/mine_icon_p.png and /dev/null differ
diff --git a/Pic/update_dynamic_n.png b/Pic/update_dynamic_n.png
deleted file mode 100755
index dd1f0d250edf7cb5c894bf222d7d1177dde4d37d..0000000000000000000000000000000000000000
Binary files a/Pic/update_dynamic_n.png and /dev/null differ
diff --git a/Pic/update_dynamic_p.png b/Pic/update_dynamic_p.png
deleted file mode 100755
index 3d39b065e4600451f681e9f860f5e80465f602aa..0000000000000000000000000000000000000000
Binary files a/Pic/update_dynamic_p.png and /dev/null differ
diff --git a/README.md b/README.md
index 6c3a911db4c7499ef1059f9567e028791fb2dd24..29f317e4afc22f8d5886e87de87aa2a5eec64706 100644
--- a/README.md
+++ b/README.md
@@ -1,183 +1,202 @@
-# Android AdvancedPagerSlidingTabStrip
+# AdvancedPagerSlidingTabStrip
-Android AdvancedPagerSlidingTabStrip是一种Android平台的导航控件,完美兼容Android自带库和兼容库的`ViewPager`组件,最低支持Android api v9。
+**本项目是基于开源项目AdvancedPagerSlidingTabStrip进行openHarmony的移植和开发的,可以通过项目标签以及github地址()追踪到原项目版本**
-## Feature
- * 支持Tab小圆点以及数量显示和隐藏
- * 支持自定义Tab View
- * 支持使用Bitmap、Drawable和本地resId来显示Tab图标
- * 支持对Tab图标替换成自定义View来加载网络图片
- * 支持自由设置小圆点、tab大小和位置等设置
- * 支持实现如:微博等不均匀Tab的APP风格,并支持滑动
+#### 项目介绍
-Project site: .
+- 项目名称:AdvancedPagerSlidingTabStrip
+- 所属系列:openHarmony的第三方组件适配移植
+- 功能:支持Tab小圆点以及数量显示和隐藏、支持自定义Tab Component,支持使用Component、Element和本地resId来显示Tab图标,
+支持自由设置小圆点、tab大小和位置等设置,支持实现如:微博等不均匀Tab的APP风格,并支持滑动
+- 项目移植状态:100%
+- 调用差异:无
+- 开发版本:sdk5,DevEco Studio2.1 beta3
+- 基线版本:无
+- 项目作者和维护人:高建明
+- 联系方式:
+- 原项目Doc地址:
-最新版本:v1.8.0
+#### 效果演示
-效果图:
+
+
-
+
+
-
+
-
+#### 安装教程
-
-
-##导入项目
-
-**Gradle dependency:**
-``` groovy
-compile 'homhomlin.lib:apsts:1.8.0'
-```
-
-or
+1.在项目根目录下的build.gradle文件中,
+ ```
+allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+}
+ ```
-**Maven dependency:**
-``` xml
-
- homhomlin.lib
- apsts
- 1.8.0
-
+2.在entry模块的build.gradle文件中,
+ ```
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:AdvancedPagerSlidingTabStrip:0.0.1-SNAPSHOT')
+ ......
+ }
+ ```
+在sdk5,DevEco Studio2.1 beta3下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
+
+#### 使用说明
+
+在 layout 文件中:
+
+```xml
+
```
-
-##用法
-
-基本AdvancedPagerPagerSlidingTabStrip:
-
-在需要添加的界面xml中添加组件和ViewPager
-``` xml
-
-
-
+在代码中find该组件,并且设置provider和PageSlider。
```
-在代码中find该组件,并且设置adapter和ViewPager。
-``` java
- ViewPager pager = (ViewPager) findViewById(R.id.pager);
- pager.setAdapter(new TestAdapter(getSupportFragmentManager()));
-
-
+ PageSlider pager = (PageSlider) findViewById(R.id.pager);
+ pager.setProvider(new MySlidePagerProvider(this));
+
AdvancedPagerSlidingTabStrip tabs = (AdvancedPagerSlidingTabStrip) findViewById(R.id.tabs);
tabs.setViewPager(pager);
```
AdvancedPagerSlidingTabStrip支持绑定OnPageChangeListener,并且不影响使用效果。
-
-``` java
+```
tabs.setOnPageChangeListener(mPageChangeListener);
```
通过调用AdvancedPagerSlidingTabStrip的showDot(int index)和hideDot(int index)来显示或者隐藏Tab上的小圆点,index代表需要显示和隐藏的tab序列位置(0 ~ N)。
通过调用showDot(int index,String txt)方法可以显示小圆点文字,并同样通过hideDot来隐藏。如:
-
-``` java
+```
tabs.showDot(0, “99+”);
```
+
+
+
+
+
+
-## Tab显示模式
-
-* 基本Adapter显示
+基本Adapter显示
1.纯文本显示
- 通过实现Adapter内的getPageTitle()接口即可显示纯文本情况的效果。
+ 通过实现Provider内的getPageTitle()接口即可显示纯文本情况的效果。
2.图文显示
- 通过将Adapter实现AdvancedPagerSlidingTabStrip.IconTabProvider接口,并实现其中的getPageIcon(展示未选中的图片)、getPageSelectIcon(展示选中的图片)和getPageIconText(展示的文本)方法即可显示图文效果。
+ 通过将Provider实现AdvancedPagerSlidingTabStrip.IconTabProvider接口,并实现其中的getPageIcon(展示未选中的图片)、getPageSelectIcon(展示选中的图片)和getPageIconText(展示的文本)方法即可显示图文效果。
- 其中getPageIcon(展示未选中的图片)和getPageSelectIcon方法可以通过改变方法返回值来显示不同类型的图片,可以选择的返回值为Bitmap、Drawable和ResId。
+ 其中getPageIcon(展示未选中的图片)和getPageSelectIcon方法可以通过改变方法返回值来显示不同类型的图片,可以选择的返回值为Component、Element和本地resId。
3.自定义图片View显示
- 通过将Adapter实现AdvancedPagerSlidingTabStrip.ViewTabProvider接口,并实现其中的onSelectIconView(选中的自定义图片View)、onIconView(未选中的自定义图片View)和getPageIconText(文本)方法即可。
+ 通过将Provider实现AdvancedPagerSlidingTabStrip.ViewTabProvider接口,并实现其中的onSelectIconView(选中的自定义图片View)、onIconView(未选中的自定义图片View)和getPageIconText(文本)方法即可。
- 需要注意的是,onSelectIconView和onIconView两个方法的返回值均为View,并会回调回上一次使用的View缓存对象,你可以通过判断返回的View是否为null来决定是否新建View对象。(PS:不判断缓存将导致你每次调用都会创建新的View对象。)
+ 需要注意的是,onSelectIconView和onIconView两个方法的返回值均为Component,并会回调回上一次使用的Component缓存对象,你可以通过判断返回的Component是否为null来决定是否新建Component对象 。
- 你可以直接创建并返回ImageView对象,也可以返回其他View子类,该模式可以用于显示网络图片,需要注意的是你需要手动给View添加LayoutParams来控制其大小,并只能使用RelativeLayout.LayoutParams,具体实现方式可以查看[Demo](https://github.com/HomHomLin/AdvancedPagerSlidingTabStrip/blob/master/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabActivity.java)。
+
+
+
+
+
+
-* 自定义Tab
+自定义Tab
我知道以上模式可能并不能完全满足需求,有时候可能我们需要的是更复杂的Tab,所以添加自定义tab来满足各种各样的需求。
当前自定义tab被封装到另一个tab类中,通过使用CustomPagerSlidingTabStrip控件来实现,该控件的所有使用方法和AdvancedPagerSlidingTabStrip一致。
- 通过将Adapter实现CustomPagerSlidingTabStrip.CustomTabProvider并实现其中getSelectTabView(选中的View)和getDisSelectTabView(未选中的View)方法来实现自定义Tab,两个方法同样会回调上一次使用的View缓存对象。具体实现方式可以查看[Demo](https://github.com/HomHomLin/AdvancedPagerSlidingTabStrip/blob/master/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabActivity.java)。
-
-## 拓展的Provider显示设置
+
+
+
+
+
+
- 有时候我们不使用自定义View显示模式又想调整现有的Tab,比如设置小圆点位置、tab大小和间距等来满足原有就可以实现的需求。
+拓展的Provider显示设置
- AdvancedPagerSlidingTabStrip提供了几个Provider来实现这些功能,你可以通过将你的Adapter实现定制的接口方法来实现,具体可以查看demo中的WeiboTabActivity.java。
+ 有时候我们不使用自定义Component显示模式又想调整现有的Tab,比如设置小圆点位置、tab大小和间距等来满足原有就可以实现的需求。
-* AdvancedPagerSlidingTabStrip.LayoutProvider
+ AdvancedPagerSlidingTabStrip提供了几个Provider来实现这些功能,你可以通过将你的Provider实现定制的接口方法来实现,具体可以查看demo中的WeiboTabActivity.java。
+
+
+
+
+
+
+
+
+AdvancedPagerSlidingTabStrip.LayoutProvider
通过将Adapter实现AdvancedPagerSlidingTabStrip.LayoutProvider可以实现对Tab以及内容icon的Layout设置。
- ``` java
+ ```
public float getPageWeight(int position);
```
-
该方法用于设置每个pageTab在整个tabs中的权重。
-``` java
+```
public int[] getPageRule(int position);
```
+该方法用于设置每个tab的相对位置。
-该方法用于设置每个tab的相对位置,如将tab设置为靠左:return new int[]{
- RelativeLayout.ALIGN_PARENT_LEFT};。
-
- ``` java
+ ```
public Margins getPageMargins(int position);
```
+ 该方法用于设置每个tab的间距大小,如将tab设置为距离左边距30:return new Margins(30,0,0,0);
- 该方法用于设置每个tab的间距大小,如将tab设置为距离左边距30px:return new Margins(30,0,0,0);。
+
+
+
+
+
+
- * AdvancedPagerSlidingTabStrip.TipsProvider
+AdvancedPagerSlidingTabStrip.TipsProvider
通过将Adapter实现AdvancedPagerSlidingTabStrip.TipsProvider可以实现对小圆点的设置。
-
- ``` java
+ ```
public int[] getTipsRule(int position);
```
-
该方法用于设置小圆点的相对位置。
-
- ``` java
+ ```
public Margins getTipsMargins(int position);
```
-
该方法用于设置小圆点在tab中的间距大小。
-``` java
+```
public Drawable getTipsDrawable(int position);
```
该方法用于设置小圆点的背景,默认为红色圆角图。
-## XML样式参数
+配置
* `apTabIndicatorColor` 导航条的颜色
* `apTabUnderlineColor` Tab底部下划线的颜色
@@ -195,11 +214,24 @@ public Drawable getTipsDrawable(int position);
* `apTabTextSelectColor` 你所选择的那个tab的颜色
* `apTabDrawMode` 绘制模式,text或者normal,用于是否将下划线绘制为跟随TextView
-## Developed By
+#### 测试信息
+
+CodeCheck代码测试无异常
- * Linhonghong -
+CloudTest代码测试无异常
+
+火绒安全病毒安全检测通过
+
+当前版本demo功能与原组件基本无差异
+
+测试员:李文琪
+
+#### 版本迭代
+
+- 0.0.1-SNAPSHOT
+
+#### 版权和许可信息
-##License
Copyright 2016 LinHongHong
Licensed under the Apache License, Version 2.0 (the "License");
@@ -212,4 +244,7 @@ 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.
\ No newline at end of file
+limitations under the License.
+
+
+
diff --git a/app/app.iml b/app/app.iml
deleted file mode 100644
index a5bdf5af8f156e60036fa533d3d74f7b9af1c549..0000000000000000000000000000000000000000
--- a/app/app.iml
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index c02b18cb577ba0b44f66accb002436664f28e399..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.1"
-
- defaultConfig {
- applicationId "com.lhh.apst.advancedpagerslidingtabstrip"
- minSdkVersion 9
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:support-v4:23.1.1'
- compile 'com.android.support:design:23.1.1'
-
- compile project(':Library')
-
- compile 'homhomlin.lib:frescoimageview:1.2.0'
-
- compile 'com.facebook.fresco:fresco:0.9.0'
- compile 'com.facebook.fresco:imagepipeline-okhttp:0.9.0'
-// compile 'homhomlin.lib:apsts:1.4.0'
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index 40bdd43a3d1867700c78851949621234f31fc6f8..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in F:\Android\sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/app/src/androidTest/java/com/lhh/apst/advancedpagerslidingtabstrip/ApplicationTest.java b/app/src/androidTest/java/com/lhh/apst/advancedpagerslidingtabstrip/ApplicationTest.java
deleted file mode 100644
index a7d16a542a656c423716d71e9cee29e74cea6791..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/com/lhh/apst/advancedpagerslidingtabstrip/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index e1c8bf7f96f6cd653676db5ff5fc7331a0793a72..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/APSTSViewPager.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/APSTSViewPager.java
deleted file mode 100644
index 7fd8cad1f79da040f6ca69ff46a5588113052afa..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/APSTSViewPager.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.content.Context;
-import android.support.v4.view.ViewPager;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-
-/**
- * Created by linhonghong on 2015/8/10.
- */
-public class APSTSViewPager extends ViewPager {
- private boolean mNoFocus = false; //if true, keep View don't move
- public APSTSViewPager(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- public APSTSViewPager(Context context){
- this(context,null);
- }
-
- public boolean onInterceptTouchEvent(MotionEvent event) {
- if (mNoFocus) {
- return false;
- }
- return super.onInterceptTouchEvent(event);
- }
-
- public void setNoFocus(boolean b){
- mNoFocus = b;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/App.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/App.java
deleted file mode 100644
index 5527eb16338b7b6d044c4f03bcf7722fc65f5b8f..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/App.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.app.Application;
-
-import com.facebook.drawee.backends.pipeline.Fresco;
-import com.facebook.imagepipeline.backends.okhttp.OkHttpImagePipelineConfigFactory;
-import com.facebook.imagepipeline.core.ImagePipelineConfig;
-import com.squareup.okhttp.OkHttpClient;
-
-/**
- * Created by Linhh on 16/2/16.
- */
-public class App extends Application{
- @Override
- public void onCreate() {
- super.onCreate();
- ImagePipelineConfig frescoConfig = OkHttpImagePipelineConfigFactory
- .newBuilder(this, new OkHttpClient())
- .build();
- Fresco.initialize(this,frescoConfig);
- }
-}
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabActivity.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabActivity.java
deleted file mode 100644
index 283be2136a2ca378270b0d60d52133d0ed23c686..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabActivity.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBarActivity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-
-import com.lhh.apst.fragments.FirstFragment;
-import com.lhh.apst.fragments.FourthFragment;
-import com.lhh.apst.fragments.SecondFragment;
-import com.lhh.apst.fragments.ThirdFragment;
-import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
-import com.lhh.apst.library.CustomPagerSlidingTabStrip;
-import com.lhh.apst.library.ViewHolder;
-
-/**
- * Created by linhonghong on 2015/8/10.
- */
-public class CustomTabActivity extends ActionBarActivity implements ViewPager.OnPageChangeListener{
-
- public CustomPagerSlidingTabStrip mAPSTS;
- public APSTSViewPager mVP;
-
- private static final int VIEW_FIRST = 0;
- private static final int VIEW_SECOND = 1;
- private static final int VIEW_THIRD = 2;
- private static final int VIEW_FOURTH = 3;
-
- private static final int VIEW_SIZE = 4;
-
- private Context mContext;
-
- private FirstFragment mFirstFragment = null;
- private SecondFragment mSecondFragment = null;
- private ThirdFragment mThirdFragment = null;
- private FourthFragment mFourthFragment = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mContext = this;
- setContentView(R.layout.activity_custom_tab);
- findViews();
- init();
- }
-
- private void findViews(){
- mAPSTS = (CustomPagerSlidingTabStrip)findViewById(R.id.tabs);
- mVP = (APSTSViewPager)findViewById(R.id.vp_main);
- }
-
- private void init(){
- mVP.setOffscreenPageLimit(VIEW_SIZE);
- FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
-
- mVP.setAdapter(new FragmentAdapter(getSupportFragmentManager()));
-
- adapter.notifyDataSetChanged();
- mAPSTS.setViewPager(mVP);
- mAPSTS.setOnPageChangeListener(this);
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
-
- public class FragmentAdapter extends FragmentStatePagerAdapter implements CustomPagerSlidingTabStrip.CustomTabProvider{
-
- protected LayoutInflater mInflater;
-
- public FragmentAdapter(FragmentManager fm) {
- super(fm);
- mInflater = LayoutInflater.from(mContext);
- }
-
- @Override
- public Fragment getItem(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- if(null == mFirstFragment)
- mFirstFragment = FirstFragment.instance();
- return mFirstFragment;
-
- case VIEW_SECOND:
- if(null == mSecondFragment)
- mSecondFragment = SecondFragment.instance();
- return mSecondFragment;
-
- case VIEW_THIRD:
- if(null == mThirdFragment)
- mThirdFragment = ThirdFragment.instance();
- return mThirdFragment;
-
- case VIEW_FOURTH:
- if(null == mFourthFragment)
- mFourthFragment = FourthFragment.instance();
- return mFourthFragment;
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public int getCount() {
- return VIEW_SIZE;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return "FIRST";
- case VIEW_SECOND:
- return "SECOND";
- case VIEW_THIRD:
- return "THIRD";
- case VIEW_FOURTH:
- return "FOURTH";
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public View getSelectTabView(int position, View convertView) {
- if (convertView == null){
- convertView = mInflater.inflate(R.layout.custom_select_tab, null);
- }
-
- TextView tv = ViewHolder.get(convertView, R.id.tvTab);
-
- tv.setText(getPageTitle(position));
-
- return convertView;
- }
-
- @Override
- public View getDisSelectTabView(int position, View convertView) {
- if (convertView == null){
- convertView = mInflater.inflate(R.layout.custom_disselect_tab, null);
- }
-
- TextView tv = ViewHolder.get(convertView, R.id.tvTab);
-
- tv.setText(getPageTitle(position));
-
- return convertView;
- }
- }
-}
-
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/IconTabActivity.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/IconTabActivity.java
deleted file mode 100644
index db835f8aa2c6542c476009c16d9fc380cfbee335..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/IconTabActivity.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBarActivity;
-import android.widget.RelativeLayout;
-
-import com.lhh.apst.fragments.FirstFragment;
-import com.lhh.apst.fragments.FourthFragment;
-import com.lhh.apst.fragments.SecondFragment;
-import com.lhh.apst.fragments.ThirdFragment;
-import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
-
-/**
- * Created by linhonghong on 2015/8/11.
- */
-public class IconTabActivity extends ActionBarActivity implements ViewPager.OnPageChangeListener{
-
- public AdvancedPagerSlidingTabStrip mAPSTS;
- public APSTSViewPager mVP;
-
- private static final int VIEW_FIRST = 0;
- private static final int VIEW_SECOND = 1;
- private static final int VIEW_THIRD = 2;
- private static final int VIEW_FOURTH = 3;
-
- private static final int VIEW_SIZE = 4;
-
- private FirstFragment mFirstFragment = null;
- private SecondFragment mSecondFragment = null;
- private ThirdFragment mThirdFragment = null;
- private FourthFragment mFourthFragment = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_icon_tab);
- findViews();
- init();
- }
-
- private void findViews(){
- mAPSTS = (AdvancedPagerSlidingTabStrip)findViewById(R.id.tabs);
- mVP = (APSTSViewPager)findViewById(R.id.vp_main);
- }
-
- private void init(){
- mVP.setOffscreenPageLimit(VIEW_SIZE);
- FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
-
- mVP.setAdapter(new FragmentAdapter(getSupportFragmentManager()));
-
- adapter.notifyDataSetChanged();
- mAPSTS.setViewPager(mVP);
- mAPSTS.setOnPageChangeListener(this);
- mVP.setCurrentItem(VIEW_FIRST);
- mAPSTS.showDot(VIEW_FIRST,"99+");
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
-
- public class FragmentAdapter extends FragmentStatePagerAdapter implements AdvancedPagerSlidingTabStrip.IconTabProvider{
-
- public FragmentAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- if(null == mFirstFragment)
- mFirstFragment = FirstFragment.instance();
- return mFirstFragment;
-
- case VIEW_SECOND:
- if(null == mSecondFragment)
- mSecondFragment = SecondFragment.instance();
- return mSecondFragment;
-
- case VIEW_THIRD:
- if(null == mThirdFragment)
- mThirdFragment = ThirdFragment.instance();
- return mThirdFragment;
-
- case VIEW_FOURTH:
- if(null == mFourthFragment)
- mFourthFragment = FourthFragment.instance();
- return mFourthFragment;
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public int getCount() {
- return VIEW_SIZE;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return "first";
- case VIEW_SECOND:
- return "second";
- case VIEW_THIRD:
- return "third";
- case VIEW_FOURTH:
- return "fourth";
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public Integer getPageIcon(int index) {
- if(index >= 0 && index < VIEW_SIZE){
- switch (index){
- case VIEW_FIRST:
- return R.mipmap.home_main_icon_n;
- case VIEW_SECOND:
- return R.mipmap.home_categry_icon_n;
- case VIEW_THIRD:
- return R.mipmap.home_live_icon_n;
- case VIEW_FOURTH:
- return R.mipmap.home_mine_icon_n;
- default:
- break;
- }
- }
- return 0;
- }
-
- @Override
- public Integer getPageSelectIcon(int index) {
- if(index >= 0 && index < VIEW_SIZE){
- switch (index){
- case VIEW_FIRST:
- return R.mipmap.home_main_icon_f_n;
- case VIEW_SECOND:
- return R.mipmap.home_categry_icon_f_n;
- case VIEW_THIRD:
- return R.mipmap.home_live_icon_f_n;
- case VIEW_FOURTH:
- return R.mipmap.home_mine_icon_f_n;
- default:
- break;
- }
- }
- return 0;
- }
-
- @Override
- public Rect getPageIconBounds(int position) {
- return null;
- }
- }
-}
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/MainActivity.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/MainActivity.java
deleted file mode 100644
index 72a5ffb1110eafd37d69e62ad11644bdfad5ed4f..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/MainActivity.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v7.app.ActionBarActivity;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-
-
-public class MainActivity extends ActionBarActivity {
-
- private Button mNormalTab;
- private Button mIconTab;
- private Button mCustomTab;
- private Button mViewTab;
- private Button mWeiboTab;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- findViews();
- setButton();
- }
-
- private void findViews(){
- mIconTab = (Button)findViewById(R.id.icontab);
- mNormalTab = (Button)findViewById(R.id.noramltab);
- mCustomTab = (Button)findViewById(R.id.customtab);
- mViewTab = (Button)findViewById(R.id.viewtab);
- mWeiboTab = (Button)findViewById(R.id.weibotab);
- }
-
- private void setButton(){
- mIconTab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- MainActivity.this.startActivity(new Intent(MainActivity.this,IconTabActivity.class));
- }
- });
- mNormalTab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- MainActivity.this.startActivity(new Intent(MainActivity.this,NormalTabActivity.class));
- }
- });
- mCustomTab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- MainActivity.this.startActivity(new Intent(MainActivity.this,CustomTabActivity.class));
- }
- });
- mViewTab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MainActivity.this.startActivity(new Intent(MainActivity.this,ViewTabActivity.class));
-
- }
- });
- mWeiboTab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MainActivity.this.startActivity(new Intent(MainActivity.this,WeiboTabActivity.class));
- }
- });
- }
-
-}
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/NormalTabActivity.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/NormalTabActivity.java
deleted file mode 100644
index 4efb2363cb4c112111680e10ba918d4ca32d9a68..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/NormalTabActivity.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBarActivity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-
-import com.lhh.apst.fragments.FirstFragment;
-import com.lhh.apst.fragments.FourthFragment;
-import com.lhh.apst.fragments.SecondFragment;
-import com.lhh.apst.fragments.ThirdFragment;
-import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
-
-/**
- * Created by linhonghong on 2015/8/10.
- */
-public class NormalTabActivity extends ActionBarActivity implements ViewPager.OnPageChangeListener{
-
- public AdvancedPagerSlidingTabStrip mAPSTS;
- public APSTSViewPager mVP;
-
- private static final int VIEW_FIRST = 0;
- private static final int VIEW_SECOND = 1;
- private static final int VIEW_THIRD = 2;
- private static final int VIEW_FOURTH = 3;
-
- private static final int VIEW_SIZE = 4;
-
- private FirstFragment mFirstFragment = null;
- private SecondFragment mSecondFragment = null;
- private ThirdFragment mThirdFragment = null;
- private FourthFragment mFourthFragment = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_normal_tab);
- findViews();
- init();
- }
-
- private void findViews(){
- mAPSTS = (AdvancedPagerSlidingTabStrip)findViewById(R.id.tabs);
- mVP = (APSTSViewPager)findViewById(R.id.vp_main);
- }
-
- private void init(){
- mVP.setOffscreenPageLimit(VIEW_SIZE);
- FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
-
- mVP.setAdapter(new FragmentAdapter(getSupportFragmentManager()));
-
- adapter.notifyDataSetChanged();
- mAPSTS.setViewPager(mVP);
- mAPSTS.setOnPageChangeListener(this);
- mAPSTS.showDot(VIEW_FIRST);
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
-
- public class FragmentAdapter extends FragmentStatePagerAdapter{
-
- public FragmentAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- if(null == mFirstFragment)
- mFirstFragment = FirstFragment.instance();
- return mFirstFragment;
-
- case VIEW_SECOND:
- if(null == mSecondFragment)
- mSecondFragment = SecondFragment.instance();
- return mSecondFragment;
-
- case VIEW_THIRD:
- if(null == mThirdFragment)
- mThirdFragment = ThirdFragment.instance();
- return mThirdFragment;
-
- case VIEW_FOURTH:
- if(null == mFourthFragment)
- mFourthFragment = FourthFragment.instance();
- return mFourthFragment;
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public int getCount() {
- return VIEW_SIZE;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return "FIRST";
- case VIEW_SECOND:
- return "SECOND";
- case VIEW_THIRD:
- return "THIRD";
- case VIEW_FOURTH:
- return "FOURTH";
- default:
- break;
- }
- }
- return null;
- }
-//
-// @Override
-// public float getPageWeight(int position) {
-// if(position >= 0 && position < VIEW_SIZE){
-// switch (position){
-// case VIEW_FIRST:
-// return 1.0f;
-// case VIEW_SECOND:
-// return 2.0f;
-// case VIEW_THIRD:
-// return 2.0f;
-// case VIEW_FOURTH:
-// return 1.0f;
-// default:
-// break;
-// }
-// }
-// return 1.0f;
-// }
- }
-}
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabActivity.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabActivity.java
deleted file mode 100644
index e9a5ed747fa1b1f3e9a13bd37af23764ef68466a..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabActivity.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBarActivity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.RelativeLayout;
-
-import com.lhh.apst.fragments.FirstFragment;
-import com.lhh.apst.fragments.FourthFragment;
-import com.lhh.apst.fragments.SecondFragment;
-import com.lhh.apst.fragments.ThirdFragment;
-import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
-
-import lib.lhh.fiv.library.FrescoImageView;
-
-/**
- * Created by Linhh on 16/2/16.
- */
-public class ViewTabActivity extends ActionBarActivity implements ViewPager.OnPageChangeListener{
-
- public AdvancedPagerSlidingTabStrip mAPSTS;
- public APSTSViewPager mVP;
-
- private static final int VIEW_FIRST = 0;
- private static final int VIEW_SECOND = 1;
- private static final int VIEW_THIRD = 2;
- private static final int VIEW_FOURTH = 3;
-
- private static final int VIEW_SIZE = 4;
-
- private FirstFragment mFirstFragment = null;
- private SecondFragment mSecondFragment = null;
- private ThirdFragment mThirdFragment = null;
- private FourthFragment mFourthFragment = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_icon_tab);
- findViews();
- init();
- }
-
- private void findViews(){
- mAPSTS = (AdvancedPagerSlidingTabStrip)findViewById(R.id.tabs);
- mVP = (APSTSViewPager)findViewById(R.id.vp_main);
- }
-
- private void init(){
- mVP.setOffscreenPageLimit(VIEW_SIZE);
- FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
-
- mVP.setAdapter(new FragmentAdapter(getSupportFragmentManager()));
-
- adapter.notifyDataSetChanged();
- mAPSTS.setViewPager(mVP);
- mAPSTS.setOnPageChangeListener(this);
- mVP.setCurrentItem(VIEW_FIRST);
- mAPSTS.showDot(VIEW_FIRST,"99+");
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
-
- public class FragmentAdapter extends FragmentStatePagerAdapter implements AdvancedPagerSlidingTabStrip.ViewTabProvider{
-
- public FragmentAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- if(null == mFirstFragment)
- mFirstFragment = FirstFragment.instance();
- return mFirstFragment;
-
- case VIEW_SECOND:
- if(null == mSecondFragment)
- mSecondFragment = SecondFragment.instance();
- return mSecondFragment;
-
- case VIEW_THIRD:
- if(null == mThirdFragment)
- mThirdFragment = ThirdFragment.instance();
- return mThirdFragment;
-
- case VIEW_FOURTH:
- if(null == mFourthFragment)
- mFourthFragment = FourthFragment.instance();
- return mFourthFragment;
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public int getCount() {
- return VIEW_SIZE;
- }
-
- @Override
- public View onSelectIconView(int position, View view, ViewGroup parent) {
- FrescoImageView draweeView;
- if(view == null){
- draweeView = new FrescoImageView(ViewTabActivity.this);
- draweeView.setLayoutParams(new RelativeLayout.LayoutParams(50,50));
- view = draweeView;
- }
- draweeView = (FrescoImageView)view;
- switch (position){
- case VIEW_FIRST:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/categry_icon_p.png",R.mipmap.home_categry_icon_f_n);
- break;
- case VIEW_SECOND:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/classify_icon_p.png",R.mipmap.home_auther_icon_f_p);
- break;
- case VIEW_THIRD:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/mine_icon_p.png",R.mipmap.home_live_icon_f_n);
- break;
- case VIEW_FOURTH:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/update_dynamic_p.png",R.mipmap.home_main_icon_f_n);
- break;
- default:
- break;
- }
- return draweeView;
- }
-
- @Override
- public View onIconView(int position, View view, ViewGroup parent) {
- FrescoImageView draweeView;
- if(view == null){
- draweeView = new FrescoImageView(ViewTabActivity.this);
- draweeView.setLayoutParams(new RelativeLayout.LayoutParams(50,50));
- view = draweeView;
- }
- draweeView = (FrescoImageView)view;
- switch (position){
- case VIEW_FIRST:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/categry_icon_n.png",R.mipmap.home_categry_icon_n);
- break;
- case VIEW_SECOND:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/classify_icon_n.png",R.mipmap.home_auther_icon_f_n);
- break;
- case VIEW_THIRD:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/mine_icon_n.png",R.mipmap.home_live_icon_n);
- break;
- case VIEW_FOURTH:
- draweeView.loadView("https://raw.githubusercontent.com/HomHomLin/AdvancedPagerSlidingTabStrip/master/Pic/update_dynamic_n.png",R.mipmap.home_main_icon_n);
- break;
- default:
- break;
- }
- return draweeView;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return "first";
- case VIEW_SECOND:
- return "second";
- case VIEW_THIRD:
- return "third";
- case VIEW_FOURTH:
- return "fourth";
- default:
- break;
- }
- }
- return null;
- }
-
- }
-}
-
diff --git a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/WeiboTabActivity.java b/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/WeiboTabActivity.java
deleted file mode 100644
index aedf6acfdcdac744ee8c460807c5937e2872fb4c..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/WeiboTabActivity.java
+++ /dev/null
@@ -1,303 +0,0 @@
-package com.lhh.apst.advancedpagerslidingtabstrip;
-
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBarActivity;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.Toast;
-
-import com.lhh.apst.fragments.FirstFragment;
-import com.lhh.apst.fragments.FourthFragment;
-import com.lhh.apst.fragments.SecondFragment;
-import com.lhh.apst.fragments.ThirdFragment;
-import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
-import com.lhh.apst.library.Margins;
-
-/**
- * Created by Linhh on 16/3/8.
- */
-public class WeiboTabActivity extends ActionBarActivity implements ViewPager.OnPageChangeListener{
-
- public AdvancedPagerSlidingTabStrip mAPSTS;
- public APSTSViewPager mVP;
-
- private static final int VIEW_FIRST = 0;
- private static final int VIEW_SECOND = 1;
- private static final int VIEW_THIRD = 2;
- private static final int VIEW_FOURTH = 3;
-
- private static final int VIEW_SIZE = 4;
-
- private FirstFragment mFirstFragment = null;
- private SecondFragment mSecondFragment = null;
- private ThirdFragment mThirdFragment = null;
- private FourthFragment mFourthFragment = null;
- private ImageView mIvCenterBtn = null;
-
- private int mSize = 0;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_weibo_tab);
- findViews();
- init();
- }
-
- private void findViews(){
- mAPSTS = (AdvancedPagerSlidingTabStrip)findViewById(R.id.tabs);
- mVP = (APSTSViewPager)findViewById(R.id.vp_main);
- mIvCenterBtn = (ImageView)findViewById(R.id.ivCenterBtn);
- }
-
- private void init(){
- mIvCenterBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Toast.makeText(WeiboTabActivity.this, "Center Btn is Clicked.",Toast.LENGTH_SHORT).show();
- }
- });
- mSize = getResources().getDimensionPixelSize(R.dimen.weibo_tab_size);
- mVP.setOffscreenPageLimit(VIEW_SIZE);
- FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager());
-
- mVP.setAdapter(new FragmentAdapter(getSupportFragmentManager()));
-
- adapter.notifyDataSetChanged();
- mAPSTS.setViewPager(mVP);
- mAPSTS.setOnPageChangeListener(this);
- mVP.setCurrentItem(VIEW_FIRST);
- mAPSTS.showDot(VIEW_FIRST,"99+");
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
-
- public class FragmentAdapter extends FragmentStatePagerAdapter implements
- AdvancedPagerSlidingTabStrip.IconTabProvider,
- AdvancedPagerSlidingTabStrip.LayoutProvider,
- AdvancedPagerSlidingTabStrip.TipsProvider{
-
- public FragmentAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- if(null == mFirstFragment)
- mFirstFragment = FirstFragment.instance();
- return mFirstFragment;
-
- case VIEW_SECOND:
- if(null == mSecondFragment)
- mSecondFragment = SecondFragment.instance();
- return mSecondFragment;
-
- case VIEW_THIRD:
- if(null == mThirdFragment)
- mThirdFragment = ThirdFragment.instance();
- return mThirdFragment;
-
- case VIEW_FOURTH:
- if(null == mFourthFragment)
- mFourthFragment = FourthFragment.instance();
- return mFourthFragment;
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public int getCount() {
- return VIEW_SIZE;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return "first";
- case VIEW_SECOND:
- return "second";
- case VIEW_THIRD:
- return "third";
- case VIEW_FOURTH:
- return "fourth";
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public float getPageWeight(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return 0.92f;
- case VIEW_SECOND:
- return 1.0f;
- case VIEW_THIRD:
- return 1.0f;
- case VIEW_FOURTH:
- return 0.92f;
- default:
- break;
- }
- }
- return 1.0f;
- }
-
- @Override
- public int[] getPageRule(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_LEFT};
- case VIEW_SECOND:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_LEFT};
- case VIEW_THIRD:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_RIGHT};
- case VIEW_FOURTH:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_RIGHT};
- default:
- break;
- }
- }
- return new int[0];
- }
-
- @Override
- public Margins getPageMargins(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return new Margins(getResources().getDimensionPixelSize(R.dimen.home_bar_icon_margins),0,0,0);
- case VIEW_SECOND:
- return null;
- case VIEW_THIRD:
- return null;
- case VIEW_FOURTH:
- return new Margins(0,0,getResources().getDimensionPixelSize(R.dimen.home_bar_icon_margins),0);
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public Integer getPageIcon(int index) {
- if(index >= 0 && index < VIEW_SIZE){
- switch (index){
- case VIEW_FIRST:
- return R.mipmap.tabbar_home;
- case VIEW_SECOND:
- return R.mipmap.tabbar_message_center;
- case VIEW_THIRD:
- return R.mipmap.tabbar_discover;
- case VIEW_FOURTH:
- return R.mipmap.tabbar_profile;
- default:
- break;
- }
- }
- return 0;
- }
-
- @Override
- public Integer getPageSelectIcon(int index) {
- if(index >= 0 && index < VIEW_SIZE){
- switch (index){
- case VIEW_FIRST:
- return R.mipmap.tabbar_home_selected;
- case VIEW_SECOND:
- return R.mipmap.tabbar_message_center_highlighted;
- case VIEW_THIRD:
- return R.mipmap.tabbar_discover_highlighted;
- case VIEW_FOURTH:
- return R.mipmap.tabbar_profile_highlighted;
- default:
- break;
- }
- }
- return 0;
- }
-
- @Override
- public Rect getPageIconBounds(int position) {
- return new Rect(0, 0, mSize, mSize);
- }
-
- @Override
- public int[] getTipsRule(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_LEFT};
- case VIEW_SECOND:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_LEFT};
- case VIEW_THIRD:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_RIGHT};
- case VIEW_FOURTH:
- return new int[]{
- RelativeLayout.ALIGN_PARENT_RIGHT};
- default:
- break;
- }
- }
- return new int[0];
- }
-
- @Override
- public Margins getTipsMargins(int position) {
- if(position >= 0 && position < VIEW_SIZE){
- switch (position){
- case VIEW_FIRST:
- return new Margins(4 *getResources().getDimensionPixelSize(R.dimen.psts_dot_m_right), 0, 0, 0);
- default:
- break;
- }
- }
- return null;
- }
-
- @Override
- public Drawable getTipsDrawable(int position) {
- return null;
- }
- }
-}
diff --git a/app/src/main/java/com/lhh/apst/fragments/FirstFragment.java b/app/src/main/java/com/lhh/apst/fragments/FirstFragment.java
deleted file mode 100644
index 148121c43dfa8fd47c99ce14f18010d23b0011b1..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/fragments/FirstFragment.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.lhh.apst.fragments;
-
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.lhh.apst.advancedpagerslidingtabstrip.R;
-
-/**
- * Created by linhonghong on 2015/8/11.
- */
-public class FirstFragment extends Fragment{
-
- public static FirstFragment instance() {
- FirstFragment view = new FirstFragment();
- return view;
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.first_fragment, null);
- return view;
- }
-}
diff --git a/app/src/main/java/com/lhh/apst/fragments/FourthFragment.java b/app/src/main/java/com/lhh/apst/fragments/FourthFragment.java
deleted file mode 100644
index ae0c3123bd56c40ad73c29ddac3c447a4a763017..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/fragments/FourthFragment.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.lhh.apst.fragments;
-
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.lhh.apst.advancedpagerslidingtabstrip.R;
-
-/**
- * Created by linhonghong on 2015/8/11.
- */
-public class FourthFragment extends Fragment {
-
- public static FourthFragment instance() {
- FourthFragment view = new FourthFragment();
- return view;
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fourth_fragment, null);
- return view;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lhh/apst/fragments/SecondFragment.java b/app/src/main/java/com/lhh/apst/fragments/SecondFragment.java
deleted file mode 100644
index bdc3d889958b78621d7e0c5626ba4303b0ac4927..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/fragments/SecondFragment.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.lhh.apst.fragments;
-
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.lhh.apst.advancedpagerslidingtabstrip.R;
-
-/**
- * Created by linhonghong on 2015/8/11.
- */
-public class SecondFragment extends Fragment {
-
- public static SecondFragment instance() {
- SecondFragment view = new SecondFragment();
- return view;
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.second_fragment, null);
- return view;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lhh/apst/fragments/ThirdFragment.java b/app/src/main/java/com/lhh/apst/fragments/ThirdFragment.java
deleted file mode 100644
index ac02ae784529a12430e354d75c0561b4af81832b..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/lhh/apst/fragments/ThirdFragment.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.lhh.apst.fragments;
-
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.lhh.apst.advancedpagerslidingtabstrip.R;
-
-/**
- * Created by linhonghong on 2015/8/11.
- */
-public class ThirdFragment extends Fragment {
-
- public static ThirdFragment instance() {
- ThirdFragment view = new ThirdFragment();
- return view;
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.third_fragment, null);
- return view;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/sub_background.xml b/app/src/main/res/drawable/sub_background.xml
deleted file mode 100644
index 0b70e57694c941c3614fec4d115789e21ad1150d..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/sub_background.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tab_bg_normal.xml b/app/src/main/res/drawable/tab_bg_normal.xml
deleted file mode 100644
index 006280b12510951fa163f083ec68b8004d1948c6..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/tab_bg_normal.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tab_bg_transparent.xml b/app/src/main/res/drawable/tab_bg_transparent.xml
deleted file mode 100644
index 42ee901ec382e69c93d73130bbe308be3e7ae8e5..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/tab_bg_transparent.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tab_bg_white.xml b/app/src/main/res/drawable/tab_bg_white.xml
deleted file mode 100644
index f192df8de9b6615ad4c341dd419a39e15da0c7c0..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/tab_bg_white.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tab_color_select.xml b/app/src/main/res/drawable/tab_color_select.xml
deleted file mode 100644
index cf354de3f5f9a08764a8b8821679606a0f686568..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/tab_color_select.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/weibo_tab_bg_normal.xml b/app/src/main/res/drawable/weibo_tab_bg_normal.xml
deleted file mode 100644
index 339a5e9019c5aa4d13dbcf2fff454ec60910f165..0000000000000000000000000000000000000000
--- a/app/src/main/res/drawable/weibo_tab_bg_normal.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_custom_tab.xml b/app/src/main/res/layout/activity_custom_tab.xml
deleted file mode 100644
index 469dd9883e5dab3d38e28c3aea46b01d487cb1b1..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_custom_tab.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_icon_tab.xml b/app/src/main/res/layout/activity_icon_tab.xml
deleted file mode 100644
index 13c4a9cdfc48089abf637c42ba6da6fff50a188f..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_icon_tab.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index ed85311b9ca1a7062d19a6aa2870849a9aba6fe9..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_normal_tab.xml b/app/src/main/res/layout/activity_normal_tab.xml
deleted file mode 100644
index 0bca81c6267285c3aee55e84b87b5061a4d3899a..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_normal_tab.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_weibo_tab.xml b/app/src/main/res/layout/activity_weibo_tab.xml
deleted file mode 100644
index 1c3c6da8caab8468efcafd76a0f596f895a9f426..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_weibo_tab.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/custom_disselect_tab.xml b/app/src/main/res/layout/custom_disselect_tab.xml
deleted file mode 100644
index 12f58914e352fdd0ef38dcf85d4cfbe90b8b297d..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/custom_disselect_tab.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/custom_select_tab.xml b/app/src/main/res/layout/custom_select_tab.xml
deleted file mode 100644
index fb1f0df853798b87c55ed4758fde1e8353a28fa1..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/custom_select_tab.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/first_fragment.xml b/app/src/main/res/layout/first_fragment.xml
deleted file mode 100644
index 9491278a708283f0eac8f12306fbe27c9e91ebb9..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/first_fragment.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fourth_fragment.xml b/app/src/main/res/layout/fourth_fragment.xml
deleted file mode 100644
index 2f89eeeb1f2ea4fa14826a102ef15b1a54b5ab43..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/fourth_fragment.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/second_fragment.xml b/app/src/main/res/layout/second_fragment.xml
deleted file mode 100644
index 9c7a008a6e6731edd6d1eac20a1641e361dc9fb2..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/second_fragment.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/third_fragment.xml b/app/src/main/res/layout/third_fragment.xml
deleted file mode 100644
index 8e9df642b2469bf3dcc42f5af5683dd42f0cb574..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/third_fragment.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
deleted file mode 100644
index b1cb90811d785634832cd130f3dd257d3f86560e..0000000000000000000000000000000000000000
--- a/app/src/main/res/menu/menu_main.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 106eab92848fe1e8deef00f28fa8eb350ff29de4..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- #6a6c6f
- #ff5959
- #adadad
-
- #ffacac
- #ff5959
-
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index b930e8695cc3741e2da2a06d1a640a1d0b47ea88..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- 16dp
- 16dp
- 30dp
-
- 360dip
- 15dp
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index ca1f22d21f88d68baf6096bfd963981cac8fb434..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
- AdvancedPagerSlidingTabStrip
-
- Hello world!
- Settings
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 9aa1842c9a12b2441a1d97efc220e61b7f2dd90a..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build.gradle b/build.gradle
index f34002d8c170d5ac7863a087d7af629aeb390d39..69bbf9da1be03bd77d08adb955aa0b1a2b6a07c5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,24 +1,37 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
+
buildscript {
repositories {
- jcenter()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.3.0'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
- classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.2.5'
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
allprojects {
repositories {
- jcenter()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/entry/.gitignore b/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..796b96d1c402326528b4ba3c12ee9d92d0e212e9
--- /dev/null
+++ b/entry/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..0f5834d26a8591fc90a82b9c29552255573f37be
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+
+ implementation 'io.openharmony.tpc.thirdlib:fresco:1.0.0'
+ implementation 'com.facebook.fresco:imagepipeline-okhttp:0.9.0'
+
+ implementation project(':Library')
+}
+decc {
+ supportType = ['html','xml']
+}
diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/entry/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..3d581e356f50dbe94c791b72728e28008d351e3c
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,99 @@
+{
+ "app": {
+ "bundleName": "com.lhh.apst.advancedpagerslidingtabstrip",
+ "vendor": "lhh",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.lhh.apst.advancedpagerslidingtabstrip",
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.App",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "configChanges": "orientation",
+ "label": "$string:app_title_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.CustomTabAbility",
+ "orientation": "unspecified",
+ "configChanges": "orientation",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_title_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.IconTabAbility",
+ "orientation": "unspecified",
+ "configChanges": "orientation",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_title_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.NormalTabAbility",
+ "orientation": "unspecified",
+ "configChanges": "orientation",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_title_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.ViewTabAbility",
+ "orientation": "unspecified",
+ "configChanges": "orientation",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_title_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "name": "com.lhh.apst.advancedpagerslidingtabstrip.WeiboTabAbility",
+ "orientation": "unspecified",
+ "configChanges": "orientation",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_title_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/App.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/App.java
new file mode 100644
index 0000000000000000000000000000000000000000..14879c85f6db81176f9d188dcb226859db496c75
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/App.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * App
+ *
+ * @since 2021-04-30
+ */
+public class App extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabAbility.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..6698e799fea71a12cdfc44ab24a18c7adc2ee13a
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/CustomTabAbility.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.slice.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * CustomTabAbility
+ *
+ * @since 2021-04-30
+ */
+public class CustomTabAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(CustomTabSlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/IconTabAbility.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/IconTabAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..591c2ca514dc9da22f2455a02a653f1c4c830ee5
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/IconTabAbility.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.slice.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * IconTabAbility
+ *
+ * @since 2021-04-30
+ */
+public class IconTabAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(IconTabSlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/MainAbility.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3cdd6add1efc8ebaf6da60a3b06ea0342675950
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/MainAbility.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.slice.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * MainAbility
+ *
+ * @since 2021-04-30
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/NormalTabAbility.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/NormalTabAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..8bb93fb8505238a402858819a93996f413ba642b
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/NormalTabAbility.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.slice.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * NormalTabAbility
+ *
+ * @since 2021-04-30
+ */
+public class NormalTabAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(NormalTabSlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabAbility.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..0cf2fc6b9716a6d2a75607e7224239d8dbae8b39
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/ViewTabAbility.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.slice.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * ViewTabAbility
+ *
+ * @since 2021-04-30
+ */
+public class ViewTabAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(ViewTabSlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/WeiboTabAbility.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/WeiboTabAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..14597a1e2959597502c96286eeadadf051ffb0fa
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/WeiboTabAbility.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.slice.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * WeiboTabAbility
+ *
+ * @since 2021-04-30
+ */
+public class WeiboTabAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(WeiboTabSlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/BaseFragment.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/BaseFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..edbcaca71d1d0c195ec73aae71a1bec2d7b90c3d
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/BaseFragment.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.fragments;
+
+import ohos.agp.components.Component;
+import ohos.agp.components.LayoutScatter;
+import ohos.app.Context;
+
+/**
+ * BaseFragment
+ *
+ * @since 2021-04-30
+ */
+public abstract class BaseFragment {
+
+ abstract int setXmlId();
+
+ private Context mContext;
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public BaseFragment(Context context) {
+ this.mContext = context;
+ }
+
+ /**
+ * 获取Component
+ *
+ * @return Component
+ */
+ public Component get() {
+ Component component = LayoutScatter.getInstance(this.mContext).parse(setXmlId(),
+ null, false);
+ return component;
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/FirstFragment.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/FirstFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..166db26246f47b75b69df56a52a30a3579e70924
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/FirstFragment.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.fragments;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import ohos.app.Context;
+
+/**
+ * FirstFragment
+ *
+ * @since 2021-04-30
+ */
+public class FirstFragment extends BaseFragment {
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public FirstFragment(Context context) {
+ super(context);
+ }
+
+ @Override
+ int setXmlId() {
+ return ResourceTable.Layout_first_fragment;
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/FourthFragment.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/FourthFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7f09185f37933891ed7be285c67929d043ddf37
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/FourthFragment.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.fragments;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import ohos.app.Context;
+
+/**
+ * FourthFragment
+ *
+ * @since 2021-04-30
+ */
+public class FourthFragment extends BaseFragment {
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public FourthFragment(Context context) {
+ super(context);
+ }
+
+ @Override
+ int setXmlId() {
+ return ResourceTable.Layout_fourth_fragment;
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/SecondFragment.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/SecondFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..5af043fe4b46c04c329ec8644d67c2f3eef966ec
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/SecondFragment.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.fragments;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import ohos.app.Context;
+
+/**
+ * SecondFragment
+ *
+ * @since 2021-04-30
+ */
+public class SecondFragment extends BaseFragment {
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public SecondFragment(Context context) {
+ super(context);
+ }
+
+ @Override
+ int setXmlId() {
+ return ResourceTable.Layout_second_fragment;
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/ThirdFragment.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/ThirdFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..05c48cbfd9841c31fb79f799d54234e1c96445e1
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/fragments/ThirdFragment.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.fragments;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import ohos.app.Context;
+
+/**
+ * ThirdFragment
+ *
+ * @since 2021-04-30
+ */
+public class ThirdFragment extends BaseFragment {
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public ThirdFragment(Context context) {
+ super(context);
+ }
+
+ @Override
+ int setXmlId() {
+ return ResourceTable.Layout_third_fragment;
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/CustomTabSlice.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/CustomTabSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..646898391fc1f232608548ec6ef53f02453e181b
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/CustomTabSlice.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.slice;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FirstFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FourthFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.SecondFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.ThirdFragment;
+import com.lhh.apst.library.CustomPagerSlidingTabStrip;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.*;
+import ohos.app.Context;
+
+/**
+ * CustomTabSlice
+ *
+ * @since 2021-04-30
+ */
+public class CustomTabSlice extends AbilitySlice implements PageSlider.PageChangedListener {
+ private static final int VIEW_FIRST = 0;
+ private static final int VIEW_SECOND = 1;
+ private static final int VIEW_THIRD = 2;
+ private static final int VIEW_FOURTH = 3;
+
+ private static final int VIEW_SIZE = 4;
+
+ private Component mFirstFragment = null;
+ private Component mSecondFragment = null;
+ private Component mThirdFragment = null;
+ private Component mFourthFragment = null;
+
+ private CustomPagerSlidingTabStrip mAPSTS;
+ private PageSlider mVP;
+
+ @Override
+ public void onPageSliding(int i, float v, int i1) {
+ }
+
+ @Override
+ public void onPageSlideStateChanged(int i) {
+ }
+
+ @Override
+ public void onPageChosen(int i) {
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_custom_tab);
+ findViews();
+ initViews();
+ }
+
+ private void findViews() {
+ mAPSTS = (CustomPagerSlidingTabStrip) findComponentById(ResourceTable.Id_tabs);
+ mVP = (PageSlider) findComponentById(ResourceTable.Id_vp_main);
+ }
+
+ private void initViews() {
+ mVP.setPageCacheSize(VIEW_SIZE);
+ mVP.setProvider(new MySlidePagerProvider(this));
+
+ mAPSTS.setViewPager(mVP);
+ mAPSTS.setOnPageChangeListener(this);
+ }
+
+ /**
+ * MySlidePagerProvider
+ *
+ * @since 2021-04-30
+ */
+ public class MySlidePagerProvider extends PageSliderProvider implements CustomPagerSlidingTabStrip.CustomTabProvider {
+ private final Context context;
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public MySlidePagerProvider(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return VIEW_SIZE;
+ }
+
+ @Override
+ public String getPageTitle(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return "FIRST";
+ case VIEW_SECOND:
+ return "SECOND";
+ case VIEW_THIRD:
+ return "THIRD";
+ case VIEW_FOURTH:
+ return "FOURTH";
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object createPageInContainer(ComponentContainer componentContainer, int position) {
+ switch (position) {
+ case VIEW_FIRST:
+ if (null == mFirstFragment) {
+ mFirstFragment = new FirstFragment(context).get();
+ }
+ componentContainer.addComponent(mFirstFragment);
+ return mFirstFragment;
+
+ case VIEW_SECOND:
+ if (null == mSecondFragment) {
+ mSecondFragment = new SecondFragment(context).get();
+ }
+ componentContainer.addComponent(mSecondFragment);
+ return mSecondFragment;
+
+ case VIEW_THIRD:
+ if (null == mThirdFragment) {
+ mThirdFragment = new ThirdFragment(context).get();
+ }
+ componentContainer.addComponent(mThirdFragment);
+ return mThirdFragment;
+
+ case VIEW_FOURTH:
+ if (null == mFourthFragment) {
+ mFourthFragment = new FourthFragment(context).get();
+ }
+ componentContainer.addComponent(mFourthFragment);
+ return mFourthFragment;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public void destroyPageFromContainer(ComponentContainer componentContainer, int position, Object object) {
+ Component contentView = (Component) object;
+ componentContainer.removeComponent(contentView);
+ }
+
+ @Override
+ public boolean isPageMatchToObject(Component component, Object o) {
+ return component == o;
+ }
+
+ @Override
+ public Component getSelectTabView(int position, Component convertView) {
+ if (convertView == null) {
+ convertView = LayoutScatter.getInstance(this.context).parse(ResourceTable.Layout_custom_select_tab,
+ null, false);
+ }
+ Text tv = (Text) convertView.findComponentById(ResourceTable.Id_tvTab);
+ tv.setText(getPageTitle(position));
+
+ return convertView;
+ }
+
+ @Override
+ public Component getDisSelectTabView(int position, Component convertView) {
+ if (convertView == null) {
+ convertView = LayoutScatter.getInstance(this.context).parse(ResourceTable.Layout_custom_disselect_tab,
+ null, false);
+ }
+
+ Text tv = (Text) convertView.findComponentById(ResourceTable.Id_tvTab);
+ tv.setText(getPageTitle(position));
+
+ return convertView;
+ }
+ }
+}
+
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/IconTabSlice.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/IconTabSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..175cec0a433731116d8960646d7a345db425b38b
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/IconTabSlice.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.slice;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FirstFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FourthFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.SecondFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.ThirdFragment;
+import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.PageSlider;
+import ohos.agp.components.PageSliderProvider;
+import ohos.agp.utils.Rect;
+import ohos.app.Context;
+
+/**
+ * IconTabSlice
+ *
+ * @since 2021-04-30
+ */
+public class IconTabSlice extends AbilitySlice implements PageSlider.PageChangedListener {
+ private AdvancedPagerSlidingTabStrip mAPSTS;
+ private PageSlider mVP;
+
+ private static final int VIEW_FIRST = 0;
+ private static final int VIEW_SECOND = 1;
+ private static final int VIEW_THIRD = 2;
+ private static final int VIEW_FOURTH = 3;
+
+ private static final int VIEW_SIZE = 4;
+
+ private Component mFirstFragment = null;
+ private Component mSecondFragment = null;
+ private Component mThirdFragment = null;
+ private Component mFourthFragment = null;
+
+ @Override
+ public void onPageSliding(int i, float v, int i1) {
+ }
+
+ @Override
+ public void onPageSlideStateChanged(int i) {
+ }
+
+ @Override
+ public void onPageChosen(int i) {
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_icon_tab);
+ findViews();
+ initViews();
+ }
+
+ private void findViews() {
+ mAPSTS = (AdvancedPagerSlidingTabStrip) findComponentById(ResourceTable.Id_tabs);
+ mVP = (PageSlider) findComponentById(ResourceTable.Id_vp_main);
+ }
+
+ private void initViews() {
+ mVP.setPageCacheSize(VIEW_SIZE);
+ mVP.setProvider(new MySlidePagerProvider(this));
+ mVP.setCurrentPage(VIEW_FIRST);
+
+ mAPSTS.setViewPager(mVP);
+ mAPSTS.setOnPageChangeListener(this);
+ mAPSTS.showDot(VIEW_FIRST, "99+");
+ }
+
+ /**
+ * MySlidePagerProvider
+ *
+ * @since 2021-04-30
+ */
+ public class MySlidePagerProvider extends PageSliderProvider implements AdvancedPagerSlidingTabStrip.IconTabProvider {
+ private final Context context;
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public MySlidePagerProvider(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return VIEW_SIZE;
+ }
+
+ @Override
+ public String getPageTitle(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return "FIRST";
+ case VIEW_SECOND:
+ return "SECOND";
+ case VIEW_THIRD:
+ return "THIRD";
+ case VIEW_FOURTH:
+ return "FOURTH";
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object createPageInContainer(ComponentContainer componentContainer, int position) {
+ switch (position) {
+ case VIEW_FIRST:
+ if (null == mFirstFragment) {
+ mFirstFragment = new FirstFragment(context).get();
+ }
+ componentContainer.addComponent(mFirstFragment);
+ return mFirstFragment;
+
+ case VIEW_SECOND:
+ if (null == mSecondFragment) {
+ mSecondFragment = new SecondFragment(context).get();
+ }
+ componentContainer.addComponent(mSecondFragment);
+ return mSecondFragment;
+
+ case VIEW_THIRD:
+ if (null == mThirdFragment) {
+ mThirdFragment = new ThirdFragment(context).get();
+ }
+ componentContainer.addComponent(mThirdFragment);
+ return mThirdFragment;
+
+ case VIEW_FOURTH:
+ if (null == mFourthFragment) {
+ mFourthFragment = new FourthFragment(context).get();
+ }
+ componentContainer.addComponent(mFourthFragment);
+ return mFourthFragment;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public void destroyPageFromContainer(ComponentContainer componentContainer, int position, Object object) {
+ Component contentView = (Component) object;
+ componentContainer.removeComponent(contentView);
+ }
+
+ @Override
+ public boolean isPageMatchToObject(Component component, Object o) {
+ return component == o;
+ }
+
+ @Override
+ public Integer getPageIcon(int index) {
+ if (index >= 0 && index < VIEW_SIZE) {
+ switch (index) {
+ case VIEW_FIRST:
+ return ResourceTable.Media_home_main_icon_n;
+ case VIEW_SECOND:
+ return ResourceTable.Media_home_categry_icon_n;
+ case VIEW_THIRD:
+ return ResourceTable.Media_home_live_icon_n;
+ case VIEW_FOURTH:
+ return ResourceTable.Media_home_mine_icon_n;
+ default:
+ break;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public Integer getPageSelectIcon(int index) {
+ if (index >= 0 && index < VIEW_SIZE) {
+ switch (index) {
+ case VIEW_FIRST:
+ return ResourceTable.Media_home_main_icon_f_n;
+ case VIEW_SECOND:
+ return ResourceTable.Media_home_categry_icon_f_n;
+ case VIEW_THIRD:
+ return ResourceTable.Media_home_live_icon_f_n;
+ case VIEW_FOURTH:
+ return ResourceTable.Media_home_mine_icon_f_n;
+ default:
+ break;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public Rect getPageIconBounds(int position) {
+ return new Rect(0, 0, 70, 60);
+ }
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/MainAbilitySlice.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f0a16626a062034e665703c807a15dcd5963a4d
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/MainAbilitySlice.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.slice;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.*;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+
+/**
+ * MainAbilitySlice
+ *
+ * @since 2021-04-30
+ */
+public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener {
+ private Button mNormalTab;
+ private Button mIconTab;
+ private Button mCustomTab;
+ private Button mViewTab;
+ private Button mWeiboTab;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ findViews();
+ setButton();
+ }
+
+ private void findViews() {
+ mIconTab = (Button) findComponentById(ResourceTable.Id_icontab);
+ mNormalTab = (Button) findComponentById(ResourceTable.Id_noramltab);
+ mCustomTab = (Button) findComponentById(ResourceTable.Id_customtab);
+ mViewTab = (Button) findComponentById(ResourceTable.Id_viewtab);
+ mWeiboTab = (Button) findComponentById(ResourceTable.Id_weibotab);
+ }
+
+ private void setButton() {
+ mIconTab.setClickedListener(this);
+ mNormalTab.setClickedListener(this);
+ mCustomTab.setClickedListener(this);
+ mViewTab.setClickedListener(this);
+ mWeiboTab.setClickedListener(this);
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+
+ @Override
+ public void onClick(Component component) {
+ switch (component.getId()) {
+ case ResourceTable.Id_icontab:
+ launchAbility(new IconTabAbility());
+ break;
+ case ResourceTable.Id_noramltab:
+ launchAbility(new NormalTabAbility());
+ break;
+ case ResourceTable.Id_customtab:
+ launchAbility(new CustomTabAbility());
+ break;
+ case ResourceTable.Id_viewtab:
+ launchAbility(new ViewTabAbility());
+ break;
+ case ResourceTable.Id_weibotab:
+ launchAbility(new WeiboTabAbility());
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void launchAbility(Ability ability) {
+ Intent intent = new Intent();
+ Operation operation = new Intent.OperationBuilder()
+ .withBundleName(getBundleName())
+ .withDeviceId("")
+ .withAbilityName(ability.getClass().getName())
+ .build();
+ intent.setOperation(operation);
+ startAbility(intent);
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/NormalTabSlice.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/NormalTabSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..73338ebe6389e18bee5e6fce3bb4b452c02ff80c
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/NormalTabSlice.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.slice;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FirstFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FourthFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.SecondFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.ThirdFragment;
+import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.*;
+import ohos.app.Context;
+
+/**
+ * NormalTabSlice
+ *
+ * @since 2021-04-30
+ */
+public class NormalTabSlice extends AbilitySlice implements PageSlider.PageChangedListener {
+ private AdvancedPagerSlidingTabStrip mAPSTS;
+ private PageSlider mVP;
+
+ private static final int VIEW_FIRST = 0;
+ private static final int VIEW_SECOND = 1;
+ private static final int VIEW_THIRD = 2;
+ private static final int VIEW_FOURTH = 3;
+
+ private static final int VIEW_SIZE = 4;
+
+ private Component mFirstFragment = null;
+ private Component mSecondFragment = null;
+ private Component mThirdFragment = null;
+ private Component mFourthFragment = null;
+
+ @Override
+ public void onPageSliding(int i, float v, int i1) {
+
+ }
+
+ @Override
+ public void onPageSlideStateChanged(int i) {
+
+ }
+
+ @Override
+ public void onPageChosen(int i) {
+
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_normal_tab);
+ findViews();
+ initViews();
+
+ }
+
+ private void findViews() {
+ mAPSTS = (AdvancedPagerSlidingTabStrip) findComponentById(ResourceTable.Id_tabs);
+ mVP = (PageSlider) findComponentById(ResourceTable.Id_vp_main);
+ }
+
+ private void initViews() {
+ mVP.setPageCacheSize(VIEW_SIZE);
+ mVP.setProvider(new MySlidePagerProvider(this));
+
+ mAPSTS.setViewPager(mVP);
+ mAPSTS.setOnPageChangeListener(this);
+ mAPSTS.showDot(VIEW_FIRST);
+ }
+
+ /**
+ * MySlidePagerProvider
+ *
+ * @since 2021-04-30
+ */
+ public class MySlidePagerProvider extends PageSliderProvider {
+
+ private final Context context;
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public MySlidePagerProvider(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return VIEW_SIZE;
+ }
+
+ @Override
+ public Object createPageInContainer(ComponentContainer componentContainer, int position) {
+ switch (position) {
+ case VIEW_FIRST:
+ if (null == mFirstFragment) {
+ mFirstFragment = new FirstFragment(context).get();
+ }
+ componentContainer.addComponent(mFirstFragment);
+ return mFirstFragment;
+
+ case VIEW_SECOND:
+ if (null == mSecondFragment) {
+ mSecondFragment = new SecondFragment(context).get();
+ }
+ componentContainer.addComponent(mSecondFragment);
+ return mSecondFragment;
+
+ case VIEW_THIRD:
+ if (null == mThirdFragment) {
+ mThirdFragment = new ThirdFragment(context).get();
+ }
+ componentContainer.addComponent(mThirdFragment);
+ return mThirdFragment;
+
+ case VIEW_FOURTH:
+ if (null == mFourthFragment) {
+ mFourthFragment = new FourthFragment(context).get();
+ }
+ componentContainer.addComponent(mFourthFragment);
+ return mFourthFragment;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public void destroyPageFromContainer(ComponentContainer componentContainer, int position, Object object) {
+ Component contentView = (Component) object;
+ componentContainer.removeComponent(contentView);
+ }
+
+ @Override
+ public String getPageTitle(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return "FIRST";
+ case VIEW_SECOND:
+ return "SECOND";
+ case VIEW_THIRD:
+ return "THIRD";
+ case VIEW_FOURTH:
+ return "FOURTH";
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isPageMatchToObject(Component component, Object o) {
+ return component == o;
+ }
+ }
+}
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/ViewTabSlice.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/ViewTabSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..20d00b0d64e34986691b74461a6d1890a0092a85
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/ViewTabSlice.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.slice;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FirstFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FourthFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.SecondFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.ThirdFragment;
+import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
+import com.lhh.apst.library.Margins;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.*;
+import ohos.agp.components.element.Element;
+import ohos.agp.components.element.PixelMapElement;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+
+import java.io.IOException;
+
+/**
+ * ViewTabSlice
+ *
+ * @since 2021-04-30
+ */
+public class ViewTabSlice extends AbilitySlice implements PageSlider.PageChangedListener {
+
+ private AdvancedPagerSlidingTabStrip mAPSTS;
+ private PageSlider mVP;
+
+ private static final int VIEW_FIRST = 0;
+ private static final int VIEW_SECOND = 1;
+ private static final int VIEW_THIRD = 2;
+ private static final int VIEW_FOURTH = 3;
+
+ private static final int VIEW_SIZE = 4;
+
+ private Component mFirstFragment = null;
+ private Component mSecondFragment = null;
+ private Component mThirdFragment = null;
+ private Component mFourthFragment = null;
+
+ @Override
+ public void onPageSliding(int i, float v, int i1) {
+
+ }
+
+ @Override
+ public void onPageSlideStateChanged(int i) {
+
+ }
+
+ @Override
+ public void onPageChosen(int i) {
+
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_icon_tab);
+ findViews();
+ initViews();
+ }
+
+ private void findViews() {
+ mAPSTS = (AdvancedPagerSlidingTabStrip) findComponentById(ResourceTable.Id_tabs);
+ mVP = (PageSlider) findComponentById(ResourceTable.Id_vp_main);
+ }
+
+ private void initViews() {
+ mVP.setPageCacheSize(VIEW_SIZE);
+ mVP.setProvider(new MySlidePagerProvider(this));
+ mVP.setCurrentPage(VIEW_FIRST);
+
+ mAPSTS.setViewPager(mVP);
+ mAPSTS.setOnPageChangeListener(this);
+ mAPSTS.showDot(VIEW_FIRST, "99+");
+ }
+
+ /**
+ * MySlidePagerProvider
+ *
+ * @since 2021-04-30
+ */
+ public class MySlidePagerProvider extends PageSliderProvider implements AdvancedPagerSlidingTabStrip.ViewTabProvider, AdvancedPagerSlidingTabStrip.LayoutProvider {
+
+ private final Context context;
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public MySlidePagerProvider(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return VIEW_SIZE;
+ }
+
+ @Override
+ public String getPageTitle(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return "first";
+ case VIEW_SECOND:
+ return "second";
+ case VIEW_THIRD:
+ return "third";
+ case VIEW_FOURTH:
+ return "fourth";
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object createPageInContainer(ComponentContainer componentContainer, int position) {
+ switch (position) {
+ case VIEW_FIRST:
+ if (null == mFirstFragment) {
+ mFirstFragment = new FirstFragment(context).get();
+ }
+ componentContainer.addComponent(mFirstFragment);
+ return mFirstFragment;
+
+ case VIEW_SECOND:
+ if (null == mSecondFragment) {
+ mSecondFragment = new SecondFragment(context).get();
+ }
+ componentContainer.addComponent(mSecondFragment);
+ return mSecondFragment;
+
+ case VIEW_THIRD:
+ if (null == mThirdFragment) {
+ mThirdFragment = new ThirdFragment(context).get();
+ }
+ componentContainer.addComponent(mThirdFragment);
+ return mThirdFragment;
+
+ case VIEW_FOURTH:
+ if (null == mFourthFragment) {
+ mFourthFragment = new FourthFragment(context).get();
+ }
+ componentContainer.addComponent(mFourthFragment);
+ return mFourthFragment;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public void destroyPageFromContainer(ComponentContainer componentContainer, int position, Object object) {
+ Component contentView = (Component) object;
+ componentContainer.removeComponent(contentView);
+ }
+
+ @Override
+ public boolean isPageMatchToObject(Component component, Object o) {
+ return component == o;
+ }
+
+ @Override
+ public Component onSelectIconView(int position, Component view, ComponentContainer parent) {
+ Component component = new Component(this.context);
+ Element drawView = null;
+ switch (position) {
+ case VIEW_FIRST:
+ drawView = getResElement(ResourceTable.Media_home_categry_icon_f_n);
+ break;
+ case VIEW_SECOND:
+ drawView = getResElement(ResourceTable.Media_home_auther_icon_f_p);
+ break;
+ case VIEW_THIRD:
+ drawView = getResElement(ResourceTable.Media_home_live_icon_f_n);
+ break;
+ case VIEW_FOURTH:
+ drawView = getResElement(ResourceTable.Media_home_main_icon_f_n);
+ break;
+ default:
+ break;
+ }
+ component.setBackground(drawView);
+ return component;
+ }
+
+ @Override
+ public Component onIconView(int position, Component view, ComponentContainer parent) {
+ Component component = new Component(this.context);
+ Element drawView = null;
+ switch (position) {
+ case VIEW_FIRST:
+ drawView = getResElement(ResourceTable.Media_home_categry_icon_n);
+ break;
+ case VIEW_SECOND:
+ drawView = getResElement(ResourceTable.Media_home_auther_icon_f_n);
+ break;
+ case VIEW_THIRD:
+ drawView = getResElement(ResourceTable.Media_home_live_icon_n);
+ break;
+ case VIEW_FOURTH:
+ drawView = getResElement(ResourceTable.Media_home_main_icon_n);
+ break;
+ default:
+ break;
+ }
+ component.setBackground(drawView);
+ return component;
+ }
+
+ @Override
+ public DependentLayout.LayoutConfig getLayoutConfig() {
+ return new DependentLayout.LayoutConfig(45, 40);
+ }
+
+ @Override
+ public float getPageWeight(int position) {
+ return 0;
+ }
+
+ @Override
+ public int[] getPageRule(int position) {
+ return new int[0];
+ }
+
+ @Override
+ public Margins getPageMargins(int position) {
+ return new Margins(0, 0, 0, 15);
+ }
+ }
+
+ private Element getResElement(int resId) {
+ Element element = null;
+ try {
+ element = new PixelMapElement(this.getResourceManager().getResource(resId));
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (NotExistException e) {
+ e.printStackTrace();
+ }
+ return element;
+ }
+}
+
diff --git a/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/WeiboTabSlice.java b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/WeiboTabSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..2385132fee6863dacb1ff27c5e9eac14a4362c8b
--- /dev/null
+++ b/entry/src/main/java/com/lhh/apst/advancedpagerslidingtabstrip/slice/WeiboTabSlice.java
@@ -0,0 +1,352 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.lhh.apst.advancedpagerslidingtabstrip.slice;
+
+import com.lhh.apst.advancedpagerslidingtabstrip.ResourceTable;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FirstFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.FourthFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.SecondFragment;
+import com.lhh.apst.advancedpagerslidingtabstrip.fragments.ThirdFragment;
+import com.lhh.apst.library.AdvancedPagerSlidingTabStrip;
+import com.lhh.apst.library.Margins;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.*;
+import ohos.agp.components.element.Element;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.agp.utils.Rect;
+import ohos.agp.window.dialog.ToastDialog;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.ResourceManager;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * WeiboTabSlice
+ *
+ * @since 2021-04-30
+ */
+public class WeiboTabSlice extends AbilitySlice implements PageSlider.PageChangedListener {
+ private AdvancedPagerSlidingTabStrip mAPSTS;
+ private PageSlider mVP;
+
+ private static final int VIEW_FIRST = 0;
+ private static final int VIEW_SECOND = 1;
+ private static final int VIEW_THIRD = 2;
+ private static final int VIEW_FOURTH = 3;
+
+ private static final int VIEW_SIZE = 4;
+
+ private Component mFirstFragment = null;
+ private Component mSecondFragment = null;
+ private Component mThirdFragment = null;
+ private Component mFourthFragment = null;
+ private Image mIvCenterBtn = null;
+
+ private int mSize = 30;
+
+ @Override
+ public void onPageSliding(int i, float v, int i1) {
+ }
+
+ @Override
+ public void onPageSlideStateChanged(int i) {
+ }
+
+ @Override
+ public void onPageChosen(int i) {
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_weibo_tab);
+ findViews();
+ initViews();
+ }
+
+ private void findViews() {
+ mAPSTS = (AdvancedPagerSlidingTabStrip) findComponentById(ResourceTable.Id_tabs);
+ mVP = (PageSlider) findComponentById(ResourceTable.Id_vp_main);
+ mIvCenterBtn = (Image) findComponentById(ResourceTable.Id_ivCenterBtn);
+ }
+
+ private void initViews() {
+ mIvCenterBtn.setClickedListener(component -> {
+ Component toastLayout = LayoutScatter.getInstance(getContext())
+ .parse(ResourceTable.Layout_layout_toast, null, false);
+ new ToastDialog(getContext())
+ .setComponent(toastLayout)
+ .setSize(DirectionalLayout.LayoutConfig.MATCH_CONTENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT)
+ .setAlignment(LayoutAlignment.BOTTOM)
+ .setTransparent(true)
+ .show();
+ });
+
+ mSize = getResValue(ResourceTable.Float_weibo_tab_size);
+
+ mVP.setPageCacheSize(VIEW_SIZE);
+ mVP.setProvider(new MySlidePagerProvider(this));
+ mVP.setCurrentPage(VIEW_FIRST);
+
+ mAPSTS.setViewPager(mVP);
+ mAPSTS.setOnPageChangeListener(this);
+ mAPSTS.showDot(VIEW_FIRST, "99+");
+ }
+
+ /**
+ * MySlidePagerProvider
+ *
+ * @since 2021-04-30
+ */
+ public class MySlidePagerProvider extends PageSliderProvider implements
+ AdvancedPagerSlidingTabStrip.IconTabProvider,
+ AdvancedPagerSlidingTabStrip.LayoutProvider,
+ AdvancedPagerSlidingTabStrip.TipsProvider {
+
+ private final Context context;
+
+ /**
+ * 构造函数
+ *
+ * @param context 上下文
+ */
+ public MySlidePagerProvider(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return VIEW_SIZE;
+ }
+
+ @Override
+ public String getPageTitle(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return "FIRST";
+ case VIEW_SECOND:
+ return "SECOND";
+ case VIEW_THIRD:
+ return "THIRD";
+ case VIEW_FOURTH:
+ return "FOURTH";
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object createPageInContainer(ComponentContainer componentContainer, int position) {
+ switch (position) {
+ case VIEW_FIRST:
+ if (null == mFirstFragment) {
+ mFirstFragment = new FirstFragment(context).get();
+ }
+ componentContainer.addComponent(mFirstFragment);
+ return mFirstFragment;
+
+ case VIEW_SECOND:
+ if (null == mSecondFragment) {
+ mSecondFragment = new SecondFragment(context).get();
+ }
+ componentContainer.addComponent(mSecondFragment);
+ return mSecondFragment;
+
+ case VIEW_THIRD:
+ if (null == mThirdFragment) {
+ mThirdFragment = new ThirdFragment(context).get();
+ }
+ componentContainer.addComponent(mThirdFragment);
+ return mThirdFragment;
+
+ case VIEW_FOURTH:
+ if (null == mFourthFragment) {
+ mFourthFragment = new FourthFragment(context).get();
+ }
+ componentContainer.addComponent(mFourthFragment);
+ return mFourthFragment;
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public void destroyPageFromContainer(ComponentContainer componentContainer, int position, Object object) {
+ Component contentView = (Component) object;
+ componentContainer.removeComponent(contentView);
+ }
+
+ @Override
+ public boolean isPageMatchToObject(Component component, Object o) {
+ return component == o;
+ }
+
+ @Override
+ public float getPageWeight(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return 0.92f;
+ case VIEW_SECOND:
+ return 1.0f;
+ case VIEW_THIRD:
+ return 1.0f;
+ case VIEW_FOURTH:
+ return 0.92f;
+ default:
+ break;
+ }
+ }
+ return 1.0f;
+ }
+
+ @Override
+ public int[] getPageRule(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ case VIEW_SECOND:
+ return new int[]{
+ DependentLayout.LayoutConfig.ALIGN_PARENT_LEFT};
+ case VIEW_THIRD:
+ case VIEW_FOURTH:
+ return new int[]{
+ DependentLayout.LayoutConfig.ALIGN_PARENT_RIGHT};
+ default:
+ break;
+ }
+ }
+ return new int[0];
+ }
+
+ @Override
+ public Margins getPageMargins(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return new Margins(getResValue(ResourceTable.Float_home_bar_icon_margins), 0, 0, 0);
+ case VIEW_SECOND:
+ return null;
+ case VIEW_THIRD:
+ return null;
+ case VIEW_FOURTH:
+ return new Margins(0, 0, getResValue(ResourceTable.Float_home_bar_icon_margins), 0);
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public int[] getTipsRule(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ case VIEW_SECOND:
+ return new int[]{
+ DependentLayout.LayoutConfig.ALIGN_PARENT_LEFT};
+ case VIEW_THIRD:
+ case VIEW_FOURTH:
+ return new int[]{
+ DependentLayout.LayoutConfig.ALIGN_PARENT_RIGHT};
+ default:
+ break;
+ }
+ }
+ return new int[0];
+ }
+
+ @Override
+ public Margins getTipsMargins(int position) {
+ if (position >= 0 && position < VIEW_SIZE) {
+ switch (position) {
+ case VIEW_FIRST:
+ return new Margins(4 * getResValue(ResourceTable.Float_psts_dot_m_right), 10, 0, 0);
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Element getTipsDrawable(int position) {
+ return null;
+ }
+
+ @Override
+ public Integer getPageIcon(int index) {
+ if (index >= 0 && index < VIEW_SIZE) {
+ switch (index) {
+ case VIEW_FIRST:
+ return ResourceTable.Media_tabbar_home;
+ case VIEW_SECOND:
+ return ResourceTable.Media_tabbar_message_center;
+ case VIEW_THIRD:
+ return ResourceTable.Media_tabbar_discover;
+ case VIEW_FOURTH:
+ return ResourceTable.Media_tabbar_profile;
+ default:
+ break;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public Integer getPageSelectIcon(int index) {
+ if (index >= 0 && index < VIEW_SIZE) {
+ switch (index) {
+ case VIEW_FIRST:
+ return ResourceTable.Media_tabbar_home_selected;
+ case VIEW_SECOND:
+ return ResourceTable.Media_tabbar_message_center_highlighted;
+ case VIEW_THIRD:
+ return ResourceTable.Media_tabbar_discover_highlighted;
+ case VIEW_FOURTH:
+ return ResourceTable.Media_tabbar_profile_highlighted;
+ default:
+ break;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public Rect getPageIconBounds(int position) {
+ return new Rect(0, 0, mSize, mSize);
+ }
+ }
+
+ private int getResValue(int resId) {
+ ResourceManager resManager = this.getResourceManager();
+ int result = 0;
+ try {
+ result = (int) resManager.getElement(resId).getFloat();
+ } catch (IOException | NotExistException | WrongTypeException e) {
+ e.fillInStackTrace();
+ }
+ return result;
+ }
+}
diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb04b142cd1acda040cc3d2d0423f0fba76a29d8
--- /dev/null
+++ b/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,24 @@
+{
+ "color": [
+ {
+ "name": "home_bar_text_normal",
+ "value": "#6a6c6f"
+ },
+ {
+ "name": "home_bar_text_push",
+ "value": "#ff5959"
+ },
+ {
+ "name": "textnormal",
+ "value": "#adadad"
+ },
+ {
+ "name": "btn_bg_pressed_color",
+ "value": "#ffacac"
+ },
+ {
+ "name": "btn_bg_color",
+ "value": "#ff5959"
+ }
+ ]
+}
diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json
new file mode 100644
index 0000000000000000000000000000000000000000..2f73d769f0a7cc8c17b9edb3abea9a7bcbce026b
--- /dev/null
+++ b/entry/src/main/resources/base/element/float.json
@@ -0,0 +1,24 @@
+{
+ "float": [
+ {
+ "name": "activity_horizontal_margin",
+ "value": "16vp"
+ },
+ {
+ "name": "activity_vertical_margin",
+ "value": "16vp"
+ },
+ {
+ "name": "weibo_tab_size",
+ "value": "28vp"
+ },
+ {
+ "name": "button_drawable_padding",
+ "value": "360vp"
+ },
+ {
+ "name": "home_bar_icon_margins",
+ "value": "15vp"
+ }
+ ]
+}
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..86697d35fb0e82fedf335be6f83ba3d322885360
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "app_title_name",
+ "value": "AdvancedPagerSlidingTabStrip"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_button.xml b/entry/src/main/resources/base/graphic/background_button.xml
new file mode 100644
index 0000000000000000000000000000000000000000..47e5b3242c63d0fe410373e9710e851d62554383
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_button.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/sub_background.xml b/entry/src/main/resources/base/graphic/sub_background.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cf9f362b1b06d4f71ddbeb58fbf922ded1896da9
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/sub_background.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/sub_bg_normal.xml b/entry/src/main/resources/base/graphic/sub_bg_normal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7070c86ade94abfac165eaefaf240071fb94a0fb
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/sub_bg_normal.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/sub_bg_pressed.xml b/entry/src/main/resources/base/graphic/sub_bg_pressed.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4dda2261f54e216ad5acb6086adcb74695d47171
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/sub_bg_pressed.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/tab_bg_normal.xml b/entry/src/main/resources/base/graphic/tab_bg_normal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ad94e4adbc46aa23dcfc0d22ca1e5fe6e731e481
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/tab_bg_normal.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/tab_bg_transparent.xml b/entry/src/main/resources/base/graphic/tab_bg_transparent.xml
new file mode 100644
index 0000000000000000000000000000000000000000..edfe0817cf82b32f4beaf0642d16ad1988227dc8
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/tab_bg_transparent.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/tab_bg_white.xml b/entry/src/main/resources/base/graphic/tab_bg_white.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d9619db14c1d09913f137528f3e0e04bf5d62142
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/tab_bg_white.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/tab_color_select.xml b/entry/src/main/resources/base/graphic/tab_color_select.xml
new file mode 100644
index 0000000000000000000000000000000000000000..27f22f606dbe597862095b1b4848b2519ea107a9
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/tab_color_select.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/toast_bg.xml b/entry/src/main/resources/base/graphic/toast_bg.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4f8927858c3efe092591a8d18e234e7f260fabdf
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/toast_bg.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/weibo_tab_bg_normal.xml b/entry/src/main/resources/base/graphic/weibo_tab_bg_normal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..8a7b591713f1bd95400caf9c69d0a1e36a66376c
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/weibo_tab_bg_normal.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_custom_tab.xml b/entry/src/main/resources/base/layout/ability_custom_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5c6fd5463c0d7aeeba4a2aeb57d3432b786a03fd
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_custom_tab.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_icon_tab.xml b/entry/src/main/resources/base/layout/ability_icon_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..82e97d206731a3989cd49b2ad5f5a3ee1cc85829
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_icon_tab.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..df05850dff6903ebd52448532eb5eb33dd380987
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_normal_tab.xml b/entry/src/main/resources/base/layout/ability_normal_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2eead28077c04d74de4e08e87abaa7149fc282b2
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_normal_tab.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_weibo_tab.xml b/entry/src/main/resources/base/layout/ability_weibo_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9b22e916c618731e7aeeecde7a4ed112bf12e32d
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_weibo_tab.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/custom_disselect_tab.xml b/entry/src/main/resources/base/layout/custom_disselect_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5b67e3d8572d8403b622db502ff7accfd78e2600
--- /dev/null
+++ b/entry/src/main/resources/base/layout/custom_disselect_tab.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/custom_select_tab.xml b/entry/src/main/resources/base/layout/custom_select_tab.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5d0d2e3862e3971c6d5be45c52ab13cbf350e452
--- /dev/null
+++ b/entry/src/main/resources/base/layout/custom_select_tab.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/first_fragment.xml b/entry/src/main/resources/base/layout/first_fragment.xml
new file mode 100644
index 0000000000000000000000000000000000000000..19673d115e9a9729b235e3bd428c802f8e92f5c6
--- /dev/null
+++ b/entry/src/main/resources/base/layout/first_fragment.xml
@@ -0,0 +1,15 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/fourth_fragment.xml b/entry/src/main/resources/base/layout/fourth_fragment.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c89f71703368480930dd8b8c05f9fe05c337d832
--- /dev/null
+++ b/entry/src/main/resources/base/layout/fourth_fragment.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/layout_toast.xml b/entry/src/main/resources/base/layout/layout_toast.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e2645764810e47ac6f41b8b36a611f5296b7f7cb
--- /dev/null
+++ b/entry/src/main/resources/base/layout/layout_toast.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/second_fragment.xml b/entry/src/main/resources/base/layout/second_fragment.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2f045c9f2d4667508e69af6504b019a1f094a646
--- /dev/null
+++ b/entry/src/main/resources/base/layout/second_fragment.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/third_fragment.xml b/entry/src/main/resources/base/layout/third_fragment.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a5fa7b626c8319d088289618c24796c21c41366d
--- /dev/null
+++ b/entry/src/main/resources/base/layout/third_fragment.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xhdpi/home_auther_icon_f_n.png b/entry/src/main/resources/base/media/home_auther_icon_f_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_auther_icon_f_n.png
rename to entry/src/main/resources/base/media/home_auther_icon_f_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_auther_icon_f_p.png b/entry/src/main/resources/base/media/home_auther_icon_f_p.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_auther_icon_f_p.png
rename to entry/src/main/resources/base/media/home_auther_icon_f_p.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_categry_icon_f_n.png b/entry/src/main/resources/base/media/home_categry_icon_f_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_categry_icon_f_n.png
rename to entry/src/main/resources/base/media/home_categry_icon_f_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_categry_icon_n.png b/entry/src/main/resources/base/media/home_categry_icon_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_categry_icon_n.png
rename to entry/src/main/resources/base/media/home_categry_icon_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_live_icon_f_n.png b/entry/src/main/resources/base/media/home_live_icon_f_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_live_icon_f_n.png
rename to entry/src/main/resources/base/media/home_live_icon_f_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_live_icon_n.png b/entry/src/main/resources/base/media/home_live_icon_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_live_icon_n.png
rename to entry/src/main/resources/base/media/home_live_icon_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_main_icon_f_n.png b/entry/src/main/resources/base/media/home_main_icon_f_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_main_icon_f_n.png
rename to entry/src/main/resources/base/media/home_main_icon_f_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_main_icon_n.png b/entry/src/main/resources/base/media/home_main_icon_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_main_icon_n.png
rename to entry/src/main/resources/base/media/home_main_icon_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_mine_icon_f_n.png b/entry/src/main/resources/base/media/home_mine_icon_f_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_mine_icon_f_n.png
rename to entry/src/main/resources/base/media/home_mine_icon_f_n.png
diff --git a/app/src/main/res/mipmap-xhdpi/home_mine_icon_n.png b/entry/src/main/resources/base/media/home_mine_icon_n.png
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/home_mine_icon_n.png
rename to entry/src/main/resources/base/media/home_mine_icon_n.png
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_compose_icon_add_highlighted.png b/entry/src/main/resources/base/media/tabbar_compose_icon_add_highlighted.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_compose_icon_add_highlighted.png
rename to entry/src/main/resources/base/media/tabbar_compose_icon_add_highlighted.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_discover.png b/entry/src/main/resources/base/media/tabbar_discover.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_discover.png
rename to entry/src/main/resources/base/media/tabbar_discover.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_discover_highlighted.png b/entry/src/main/resources/base/media/tabbar_discover_highlighted.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_discover_highlighted.png
rename to entry/src/main/resources/base/media/tabbar_discover_highlighted.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_home.png b/entry/src/main/resources/base/media/tabbar_home.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_home.png
rename to entry/src/main/resources/base/media/tabbar_home.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_home_highlighted.png b/entry/src/main/resources/base/media/tabbar_home_highlighted.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_home_highlighted.png
rename to entry/src/main/resources/base/media/tabbar_home_highlighted.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_home_selected.png b/entry/src/main/resources/base/media/tabbar_home_selected.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_home_selected.png
rename to entry/src/main/resources/base/media/tabbar_home_selected.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_message_center.png b/entry/src/main/resources/base/media/tabbar_message_center.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_message_center.png
rename to entry/src/main/resources/base/media/tabbar_message_center.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_message_center_highlighted.png b/entry/src/main/resources/base/media/tabbar_message_center_highlighted.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_message_center_highlighted.png
rename to entry/src/main/resources/base/media/tabbar_message_center_highlighted.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_profile.png b/entry/src/main/resources/base/media/tabbar_profile.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_profile.png
rename to entry/src/main/resources/base/media/tabbar_profile.png
diff --git a/app/src/main/res/mipmap-xhdpi/tabbar_profile_highlighted.png b/entry/src/main/resources/base/media/tabbar_profile_highlighted.png
old mode 100755
new mode 100644
similarity index 100%
rename from app/src/main/res/mipmap-xhdpi/tabbar_profile_highlighted.png
rename to entry/src/main/resources/base/media/tabbar_profile_highlighted.png
diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..de113e7ecbd46f511d2c090e3135bb7f8ffb7e63
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "bundleName": "com.lhh.apst.advancedpagerslidingtabstrip",
+ "vendor": "lhh",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.lhh.apst.advancedpagerslidingtabstrip",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/lhh/apst/advancedpagerslidingtabstrip/ExampleOhosTest.java b/entry/src/ohosTest/java/com/lhh/apst/advancedpagerslidingtabstrip/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..32f5309c2a62766cfb01ed9db6c3ac07740b5c56
--- /dev/null
+++ b/entry/src/ohosTest/java/com/lhh/apst/advancedpagerslidingtabstrip/ExampleOhosTest.java
@@ -0,0 +1,14 @@
+package com.lhh.apst.advancedpagerslidingtabstrip;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.lhh.apst.advancedpagerslidingtabstrip", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/lhh/apst/advancedpagerslidingtabstrip/ExampleTest.java b/entry/src/test/java/com/lhh/apst/advancedpagerslidingtabstrip/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c0e5005277e1700a0a5b5d0e6f00cf32e7dc1ca
--- /dev/null
+++ b/entry/src/test/java/com/lhh/apst/advancedpagerslidingtabstrip/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.lhh.apst.advancedpagerslidingtabstrip;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index fda6911c32bce709e982a1b54227d32c43223341..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,30 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-PROJ_GROUP=homhomlin.lib
-PROJ_VERSION=1.8.1
-PROJ_NAME=AdvancedPagerSlidingTabStrip
-PROJ_WEBSITEURL=https://github.com/HomHomLin/AdvancedPagerSlidingTabStrip
-PROJ_ISSUETRACKERURL=
-PROJ_VCSURL=https://github.com/HomHomLin/AdvancedPagerSlidingTabStrip.git
-PROJ_DESCRIPTION=AdvancedPagerSlidingTabStrip
-PROJ_ARTIFACTID=apsts
-
-DEVELOPER_ID=homhomlin
-DEVELOPER_NAME=linhonghong
-DEVELOPER_EMAIL=linhh90@163.com
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index d534f1165dd78905f56974cbc246c7ece4d24945..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon Mar 13 16:14:53 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 100644
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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
+#
+# https://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.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,26 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/img/page1.png b/img/page1.png
new file mode 100644
index 0000000000000000000000000000000000000000..e6fa2e643e21db4286ab58c95f7a7b6558cd9c04
Binary files /dev/null and b/img/page1.png differ
diff --git a/img/page2.png b/img/page2.png
new file mode 100644
index 0000000000000000000000000000000000000000..5f3bf518ef1c12d3a9e69f907580c039179ba0d8
Binary files /dev/null and b/img/page2.png differ
diff --git a/img/page3.png b/img/page3.png
new file mode 100644
index 0000000000000000000000000000000000000000..683247286ce3157426aec0889386bbd31bb37a10
Binary files /dev/null and b/img/page3.png differ
diff --git a/img/page4.png b/img/page4.png
new file mode 100644
index 0000000000000000000000000000000000000000..e5d3f7b0597ea6b5c7e99b51ea752442266b5f57
Binary files /dev/null and b/img/page4.png differ
diff --git a/img/page5.png b/img/page5.png
new file mode 100644
index 0000000000000000000000000000000000000000..2189e5d47d8adeefdbc691ffa877235601473d7e
Binary files /dev/null and b/img/page5.png differ
diff --git a/local.properties b/local.properties
new file mode 100644
index 0000000000000000000000000000000000000000..884bd2bd353ba922e942ba71a38bafe37160aa16
--- /dev/null
+++ b/local.properties
@@ -0,0 +1,13 @@
+## This file is automatically generated by DevEco Studio.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Thu May 13 10:52:24 CST 2021
+nodejs.dir=C\:\\Program Files (x86)\\nodejs
+npm.dir=C\:\\Program Files\\Huawei\\DevEco Studio 2.1.0.301\\tools\\nodejs
+hwsdk.dir=C\:\\Users\\Administrator\\AppData\\Local\\Huawei\\Sdk
diff --git a/settings.gradle b/settings.gradle
index d945c7e4c0209b56d752cb3370c812ee30887b1a..0330f9c23909f6c01f3328c32bc99d015c4d9b3e 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app',':Library'
+include ':entry', ':Library'