Repository: lsjwzh/FastTextView Branch: master Commit: c6234059f97c Files: 91 Total size: 290.4 KB Directory structure: gitextract_dtlfnmzy/ ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ ├── lsjwzh/ │ │ │ └── test/ │ │ │ ├── AutoScrollHandler.java │ │ │ ├── Const.java │ │ │ ├── FastTextLayoutView.java │ │ │ ├── FastTextView.java │ │ │ ├── FpsCalculator.java │ │ │ ├── GhostThread.java │ │ │ ├── StaticLayoutManager.java │ │ │ ├── TestSingleLineTextView.java │ │ │ ├── TestSpan.java │ │ │ ├── TestStats.java │ │ │ ├── TestTextView.java │ │ │ ├── TextLineView.java │ │ │ └── Util.java │ │ └── wechat/ │ │ └── testdemo/ │ │ ├── EllipseFragment.java │ │ ├── FastTextViewListTestFragment.java │ │ ├── MainActivity.java │ │ ├── MainActivityFragment.java │ │ ├── NormalLayoutTestFragment.java │ │ ├── ReadMoreFragment.java │ │ ├── ReadMoreListTestFragment.java │ │ ├── StaticLayoutCacheTestFragment.java │ │ └── TestListAdapter.java │ └── res/ │ ├── anim/ │ │ ├── popup_enter.xml │ │ └── popup_exit.xml │ ├── drawable/ │ │ └── popup_background.xml │ ├── layout/ │ │ ├── activity_main.xml │ │ ├── ellipse_demo.xml │ │ ├── fast_layout_ui.xml │ │ ├── fast_list_item.xml │ │ ├── fragment_main.xml │ │ ├── layout_cache_demo.xml │ │ ├── normal_layout_ui.xml │ │ ├── normal_list_item.xml │ │ ├── read_more_demo.xml │ │ ├── readmore_list_item.xml │ │ ├── spinner_item.xml │ │ ├── static_layout_ui.xml │ │ └── static_list_item.xml │ ├── menu/ │ │ └── menu_main.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── values-v23/ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── text.Textline/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ └── java/ │ └── android/ │ └── text/ │ ├── Directions.java │ ├── ITextLine.java │ ├── TextLineCompat.java │ ├── TextLineImpl15.java │ └── TextLineImpl23.java └── widget.FastTextView/ ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src/ └── main/ ├── AndroidManifest.xml ├── java/ │ ├── android/ │ │ └── text/ │ │ ├── EllipsisSpannedContainer.java │ │ ├── LayoutUtils.java │ │ ├── SpanSetCompat.java │ │ ├── StaticLayoutBuilderCompat.java │ │ ├── TextLayoutCache.java │ │ └── TextLayoutWarmer.java │ └── com/ │ └── lsjwzh/ │ └── widget/ │ └── text/ │ ├── ClickableSpanLayoutView.java │ ├── ClickableSpanUtil.java │ ├── FastTextLayoutView.java │ ├── FastTextView.java │ ├── ItalicReplacementSpan.java │ ├── LineUtil.java │ ├── NestReplacementSpan.java │ ├── ReadMoreTextView.java │ ├── SingleLineTextView.java │ ├── StrokableTextView.java │ ├── StrokeReplacementSpan.java │ ├── StrokeSpan.java │ ├── StrokeSpanUtil.java │ ├── TextMeasureUtil.java │ └── TextViewAttrsHelper.java └── res/ └── values/ └── attrs.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.iml .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures .externalNativeBuild ================================================ FILE: LICENSE ================================================ 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. ================================================ FILE: README.md ================================================ # FastTextView FastTextView is faster than Android TextView. FastTextView use StaticLayout to render Spanned String, so it support most features of Android TextView. Inspired by : https://engineering.instagram.com/improving-comment-rendering-on-android-a77d5db3d82e http://ragnraok.github.io/textview-pre-render-research.html ## Features 1.Faster than Android TextView 2.More flexibility 3.Support Stroke Text (More accurate method to measure stroke text and italic text) 4.Correct Ellipsis handle with ImageSpan ![](ellipsis.png) 5.Custom Read More Support ![](readmore.gif) ## FastTextView vs Android TextView Rendering a SpannableString of 389 chars with ClickableSpan and ImageSpan. Call 'onMeasure'、'onDraw' 1000 times. Here are the test results on MI MAX (Android 6.0.1): ``` D/FastTextLayoutView: FastTextLayoutView onMeasure cost:0 D/FastTextView: FastTextView onMeasure cost:1 D/TestTextView: TestTextView measure cost:104 D/FastTextLayoutView: FastTextLayoutView onDraw cost:271 D/FastTextView: FastTextView onDraw cost:250 D/TestTextView: TestTextView onDraw cost:249 ``` You can see FastTextView's 'onMeasure' almost no time consuming. ## Basic Usage ``` repositories { ... jcenter() ... } dependencies { ... compile 'com.lsjwzh.widget:FastTextView:1.2.15' ... } ``` java code ``` FastTextView fastTextView = (FastTextView) mRootView.findViewById(R.id.fast_tv2); fastTextView.setText(spannableString); ``` ## Advance Usage ### Use Layout directly java code ``` TextPaint textPaint = new TextPaint(); textPaint.setAntiAlias(true); textPaint.setColor(Color.WHITE); float textSize = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()); textPaint.setTextSize(textSize); FastTextLayoutView fastTextLayoutView = (FastTextLayoutView) mRootView.findViewById(R.id.fast_tv); int width = Layout.getDesiredWidth(spannableStringBuilder, textPaint); StaticLayout layout = new StaticLayout(spannableStringBuilder, textPaint, Math.min(width, getResources().getDisplayMetrics().widthPixels), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true); fastTextLayoutView.setTextLayout(layout); ``` ### Single Line Stroke Text java code ``` ... ... StrokeSpan strokeSpan = new StrokeSpan(Color.BLUE, Color.YELLOW, 20); spannableStringBuilder.setSpan(strokeSpan, 0, spannableStringBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); FastTextView fastTextView = (FastTextView) mRootView.findViewById(R.id.fast_tv2); fastTextView.setText(spannableStringBuilder); ``` ### Read More ``` ReadMoreTextView readMoreTextView = (ReadMoreTextView) mRootView.findViewById(R.id.readmore_tv); readMoreTextView.setText(spannableStringBuilder); readMoreTextView.setCustomEllipsisSpan(new ReadMoreTextView.EllipsisSpan(" Read More")); readMoreTextView.setCustomCollapseSpan(new ReadMoreTextView.EllipsisSpan(" Collapse")); ``` # Build Project https://github.com/anggrayudi/android-hidden-api You should use 'android-hidden-api' to build project. 1.Go to /platforms/. 2.Copy, paste and replace the downloaded hidden API file into this directory, e.g. android-25/android.jar. 3.Change compileSdkVersion and targetSdkVersion to 25 (for example). 4.Finally, rebuild your project. # TODO List 1.Layout Cache (For List Scene) 2.ColorState background 3.ReadMore 4.Ellipsis 5.AutoSize 6.ColorState textColor # License ``` Copyright 2017 lsjwzh 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. ``` ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion "28.0.3" defaultConfig { applicationId "com.wechat.testdemo" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions { abortOnError false } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:design:28.0.0' implementation project(':widget.FastTextView') // compile project(':text.Textline') // compile 'com.lsjwzh.widget:FastTextView:0.9.3' } task cleanAndroidMock(type: Delete) { description = 'Deletes the mockable Android jar' delete fileTree("${project.buildDir}/generated") { include 'mockable-android*.jar' } } project.afterEvaluate { tasks['createMockableJar'].dependsOn cleanAndroidMock } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Users/wenye/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 *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/com/lsjwzh/test/AutoScrollHandler.java ================================================ package com.lsjwzh.test; import android.os.Handler; import android.os.Looper; import android.widget.AbsListView; import android.widget.ListView; /** * Created by ragnarok on 15/7/22. */ public class AutoScrollHandler { private ListView listView; private int itemCount; private Handler uiHandler = new Handler(Looper.getMainLooper()); public AutoScrollHandler(ListView listView, int itemCount) { this.listView = listView; this.itemCount = itemCount; } public void startAutoScrollDown(final Callback callback) { FpsCalculator.instance().startCalculate(); final int position = listView.getAdapter().getCount() - 1; startPositionAndTrack(position, callback); } public void startAutoScrollUp(final Callback callback) { FpsCalculator.instance().startCalculate(); startPositionAndTrack(0, callback); } private void startPositionAndTrack(final int position, final Callback callback) { FpsCalculator.instance().startCalculate(); listView.smoothScrollToPosition(position); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == SCROLL_STATE_IDLE && (position == 0 ? listView.getFirstVisiblePosition() == 0 : listView.getLastVisiblePosition() == position)) { listView.setOnScrollListener(null); final int fps = FpsCalculator.instance().stopGetAvgFPS(); callback.callback(fps); } } }); } public interface Callback { void callback(int fps); } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/Const.java ================================================ package com.lsjwzh.test; /** * Created by wenye on 2017/11/6. */ public class Const { public final static int LOOP_COUNT = 1; } ================================================ FILE: app/src/main/java/com/lsjwzh/test/FastTextLayoutView.java ================================================ package com.lsjwzh.test; import android.content.Context; import android.graphics.Canvas; import android.os.Build; import android.os.SystemClock; import android.support.annotation.Nullable; import android.support.annotation.Px; import android.support.annotation.RequiresApi; import android.util.AttributeSet; import android.util.Log; /** * A custom view for rendering layout directly. */ public class FastTextLayoutView extends com.lsjwzh.widget.text.ClickableSpanLayoutView { private static final String TAG = FastTextLayoutView.class.getSimpleName(); private boolean mIsDebug = false; public static final TestStats TEST_STATS = new TestStats(); public FastTextLayoutView(Context context) { super(context); } public FastTextLayoutView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public FastTextLayoutView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public FastTextLayoutView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onDraw(Canvas canvas) { TEST_STATS.drawStart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { // TODO for test super.onDraw(canvas); } TEST_STATS.drawEnd(); if (mIsDebug) { Log.d(TAG, TAG + " onDraw cost:" + TEST_STATS.getDrawCost()); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { TEST_STATS.measuretart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { // TODO for test super.onMeasure(widthMeasureSpec, heightMeasureSpec); } TEST_STATS.measureEnd(); if (mIsDebug) { Log.d(TAG, TAG + " onMeasure cost:" + TEST_STATS.getMeasureCost()); } } @Override public void layout(@Px int l, @Px int t, @Px int r, @Px int b) { TEST_STATS.layoutStart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { // TODO for test super.layout(l, t, r, b); } TEST_STATS.layoutEnd(); } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/FastTextView.java ================================================ package com.lsjwzh.test; import android.content.Context; import android.graphics.Canvas; import android.os.Build; import android.os.SystemClock; import android.support.annotation.Nullable; import android.support.annotation.Px; import android.support.annotation.RequiresApi; import android.util.AttributeSet; import android.util.Log; /** * Simple and Fast TextView. */ public class FastTextView extends com.lsjwzh.widget.text.FastTextView { private static final String TAG = FastTextView.class.getSimpleName(); private boolean mIsDebug = false; public static final TestStats TEST_STATS = new TestStats(); public FastTextView(Context context) { super(context); } public FastTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public FastTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public FastTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onDraw(Canvas canvas) { TEST_STATS.drawStart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { super.onDraw(canvas); } TEST_STATS.drawEnd(); if (mIsDebug) { Log.d(TAG, TAG + " onDraw cost:" + TEST_STATS.getDrawCost()); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { TEST_STATS.measuretart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } TEST_STATS.measureEnd(); if (mIsDebug) { Log.d(TAG, TAG + " onMeasure cost:" + TEST_STATS.getMeasureCost()); } } @Override public void layout(@Px int l, @Px int t, @Px int r, @Px int b) { TEST_STATS.layoutStart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { // TODO for test super.layout(l, t, r, b); } TEST_STATS.layoutEnd(); } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/FpsCalculator.java ================================================ package com.lsjwzh.test; import android.annotation.TargetApi; import android.os.Build; import android.util.Log; import android.view.Choreographer; import android.view.Choreographer.FrameCallback; import java.lang.reflect.Field; import java.util.concurrent.atomic.AtomicInteger; public class FpsCalculator { private final static String TAG = "FpsCalculator"; private long mFrameIntervalNanos; private boolean mRunning = false; private static FpsCalculator instance; private AtomicInteger atom = new AtomicInteger(0); private Thread syncCheckThread = null; static { instance = new FpsCalculator(); } public static FpsCalculator instance() { return instance; } private int totalFps; private int fpsCalculateCount; private boolean isCalculatingFPS; // calculate the average fps public void startCalculate() { totalFps = 0; fpsCalculateCount = 0; isCalculatingFPS = true; } public int stopGetAvgFPS() { isCalculatingFPS = false; int avgFPS = totalFps / fpsCalculateCount; totalFps = 0; fpsCalculateCount = 0; return avgFPS; } private void syncCheckThread(){ if(!mRunning){ return; } int val = atom.getAndSet(0); if (isCalculatingFPS) { totalFps += val; fpsCalculateCount++; } android.util.Log.i(TAG, "FPS: " + val); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } private FrameCallback frameCallback = new FrameCallback() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void doFrame(long frameTimeNanos) { if (!mRunning) { return; } Choreographer.getInstance().postFrameCallback(frameCallback); atom.incrementAndGet(); }}; @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void start() { Log.d(TAG, "start vsync detect"); if (mRunning) { return; } mRunning = true; syncCheckThread = new Thread(new Runnable() { @Override public void run() { for (;;) { if (!mRunning) { break; } syncCheckThread(); } } }); syncCheckThread.start(); Choreographer chor = Choreographer.getInstance(); Field field; try { field = chor.getClass().getDeclaredField("mFrameIntervalNanos"); field.setAccessible(true); mFrameIntervalNanos = field.getLong(chor); Log.d(TAG, "mFrameIntervalNanos " + mFrameIntervalNanos); } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage()); } chor.postFrameCallback(frameCallback); } public void stop() { mRunning = false; if (syncCheckThread != null) { try { syncCheckThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/GhostThread.java ================================================ package com.lsjwzh.test; import android.util.Log; import java.util.Random; /** * Created by ragnarok on 15/7/22. * The GhostThread is used to simulate the heavily jobs behind the UI thread in the * real world apps * Currently, the implementation is work by launch several threads and calculate floating point * multiplication infinity */ public class GhostThread { private static final String TAG = "GhostThread"; private static boolean isStart = false; private static Thread[] threads = new Thread[0]; private static Random random = new Random(); private static Runnable runnable = new Runnable() { @Override public void run() { for (; ;) { if (!isStart) { break; } double c = Math.PI * Math.PI * Math.PI * random.nextFloat(); // Log.e("test", "v:" + c); } } }; public static void start() { if (isStart) { return; } isStart = true; for (int i = 0; i < threads.length; i++) { Thread thread = new Thread(runnable); thread.setPriority(Thread.NORM_PRIORITY); thread.start(); threads[i] = thread; } } public static void stop() { isStart = false; for (Thread thread : threads) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/StaticLayoutManager.java ================================================ package com.lsjwzh.test; import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Build; import android.text.Layout; import android.text.StaticLayout; import android.text.TextDirectionHeuristic; import android.text.TextDirectionHeuristics; import android.text.TextLayoutWarmer; import android.text.TextPaint; /** * Created by ragnarok on 15/7/21. */ public class StaticLayoutManager { public final static TextLayoutWarmer sLayoutWarmer = new TextLayoutWarmer<>(); private StaticLayout[] layout = new StaticLayout[Util.TEST_LIST_ITEM_COUNT]; private StaticLayout longStringLayout; private TextPaint textPaint; private TextDirectionHeuristic textDir; private Layout.Alignment alignment; private Canvas dummyCanvas; private int hardCodeWidth; @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) public void initLayout(Context context, CharSequence source, CharSequence longString) { textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.density = context.getResources().getDisplayMetrics().density; textPaint.setTextSize(Util.fromDPtoPix(context, Util.TEXT_SIZE_DP)); textDir = TextDirectionHeuristics.LTR; alignment = Layout.Alignment.ALIGN_NORMAL; hardCodeWidth = Util.getScreenWidth(context); longStringLayout = new StaticLayout(longString, textPaint, hardCodeWidth, alignment, 1.0f, 0f, true); dummyCanvas = new Canvas(); longStringLayout.draw(dummyCanvas); for (int i = 0; i < layout.length; i++) { layout[i] = new StaticLayout(TestSpan.getSpanString(i), textPaint, hardCodeWidth, alignment, 1.0f, 0f, true); layout[i].draw(dummyCanvas); } } public StaticLayout getLayout(int index) { return layout[index] != null ? layout[index] : sLayoutWarmer.getLayout(TestSpan.getSpanString(index)); } public StaticLayout getLongStringLayout() { return longStringLayout; } private static StaticLayoutManager INSTANCE = null; public static StaticLayoutManager getInstance() { if (INSTANCE == null) { INSTANCE = new StaticLayoutManager(); } return INSTANCE; } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/TestSingleLineTextView.java ================================================ package com.lsjwzh.test; import android.content.Context; import android.graphics.Canvas; import android.os.Build; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; import android.util.AttributeSet; import android.util.Log; import com.lsjwzh.widget.text.SingleLineTextView; /** * Created by wenye on 2017/11/5. */ public class TestSingleLineTextView extends SingleLineTextView { private static final String TAG = "TestSingleLineTextView"; private boolean mIsDebug = true; public TestSingleLineTextView(Context context) { super(context); } public TestSingleLineTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public TestSingleLineTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public TestSingleLineTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onDraw(Canvas canvas) { long start = System.currentTimeMillis(); for (int i = 0; i < Const.LOOP_COUNT; i++) { super.onDraw(canvas); } long end = System.currentTimeMillis(); if (mIsDebug) { Log.d(TAG, TAG + " onDraw cost:" + (end - start)); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { long start = System.currentTimeMillis(); for (int i = 0; i < Const.LOOP_COUNT; i++) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } long end = System.currentTimeMillis(); if (mIsDebug) { Log.d(TAG, TAG + " onMeasure cost:" + (end - start)); } } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/TestSpan.java ================================================ package com.lsjwzh.test; import android.content.Context; import android.graphics.BitmapFactory; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ImageSpan; import com.wechat.testdemo.R; import java.util.Random; /** * Created by ragnarok on 15/7/21. */ public class TestSpan { private static String testString = "(\uD83E\uDDC0|\uD83E\uDD84|\uD83E\uDD83|\uD83E\uDD82|\uD83E" + "\uDD81" + "|\uD83E\uDD80|\uD83E\uDD18\uD83C\uDFFF|\uD83E\uDD18\uD83C\uDFFE|\uD83E\uDD18\uD83C" + "\uDFFD|\uD83E\uDD18\uD83C\uDFFC|\uD83E\uDD18\uD83C\uDFFB|\uD83E\uDD18|\uD83E\uDD17" + "|\uD83E\uDD16|\uD83E\uDD15|\uD83E\uDD14|\uD83E\uDD13|\uD83E\uDD12|\uD83E\uDD11|\uD83E" + "\uDD10|\uD83DuDEA4|\uD83D\uDEA3\uD83C\uDFFF|\uD83D\uDEA3\uD83C\uDFFE|\uD83D\uDEA3" + "\uD83C\uDFFD|\uD83D\uDEA3\uD83C\uDFFC|\uD83D\uDEA3\uD83C\uDFFB|\uD83D\uDEA3\u200D" + "\u2640\uFE0F|\uD83D" + "\uD83D\uDC87\uD83C\uDFFC|\uD83D\uDC87\uD83C\uDFFB|\uD83D\uDC87\u200D\u2642" + "\uFE0F|\uD83D\uDC87|\uD83D\uDC86\uD83C\uDFFF|\uD83D\uDC86\uD83C\uDFFE" + "|\uD83D\uDC86\uD83C\uDFFD|\uD83D\uDC86\uD83C\uDFFC|\uD83D\uDC86\uD83C" + "\uDFFB|\uD83D\uDC86\u200D\u2642\uFE0F|\uD83D\uDC86|\uD83D\uDC85\uD83C" + "\uDFFF|\uD83D\uDC85\uD83C\uDFFE|\uD83D\uDC85\uD83C\uDFFD|\uD83D\uDC85" + "\uD83C\uDFFC|\uD83D\uDC85\uD83C\uDFFB|\uD83D\uDC85|\uD83D\uDC84|\uD83D" + "\uDC83\uD83C\uDFFF|\uD83D\uDC83\uD83C\uDFFE|\uD83D\uDC83\uD83C\uDFFD" + "|\uD83D\uDC83\uD83C\uDFFC|\uD83D\uDC83\uD83C\uDFFB|\uD83D\uDC83|\uD83D" + "\uDC82\uD83C\uDFFF|\uD83D\uDC82\uD83C\uDFFE|\uD83D\uDC82\uD83C\uDFFD" + "|\uD83D\uDC82\uD83C\uDFFC|\uD83D\uDC82\uD83C\uDFFB|\uD83D\uDC82\u200D" + "\u2640\uFE0F|\uD83D\uDC82|\uD83D\uDC81\uD83C\uDFFF|\uD83D\uDC81\uD83C" + "\uDFFE|\uD83D\uDC81\uD83C\uDFFD|\uD83D\uDC81\uD83C\uDFFC|\uD83D\uDC81" + "\uD83C\uDFFB|\uD83D\uDC81\u200D\u2642\uFE0F|\uD83D\uDC81|\uD83D\uDC80" + "|\uD83D\uDC7F|\uD83D\uDC7E|\uD83D\uDC7D|\uD83D\uDC7C\uD83C\uDFFF|\uD83D" + "\uDC7C\uD83C\uDFFE|\uD83D\uDC7C\uD83C\uDFFD|\uD83D\uDC7C\uD83C\uDFFC" + "|\uD83D\uDC7C\uD83C\uDFFB|\uD83D\uDC7C|\uD83D\uDC7B|\uD83D\uDC7A|\uD83D" + "\uDC79|\uD83D\uDC78\uD83C\uDFFF|\uD83D\uDC78\uD83C\uDFFE|\uD83D\uDC78" + "\uD83C\uDFFD|\uD83D\uDC78\uD83C\uDFFC|\uD83D\uDC78\uD83C\uDFFB|\uD83D" + "\uDC78|\uD83D\uDC77\uD83C\uDFFF|\uD83D\uDC77\uD83C\uDFFE|\uD83D\uDC77" + "\uD83C\uDFFD|\uD83D\uDC77\uD83C\uDFFC|\uD83D\uDC77\uD83C\uDFFB|\uD83D" + "\uDC77\u200D\u2640\uFE0F|\uD83D\uDC77|\uD83D\uDC76\uD83C\uDFFF|\uD83D" + "\uDC76\uD83C\uDFFE|\uD83D\uDC76\uD83C\uDFFD|\uD83D\uDC76\uD83C\uDFFC" + "|\uD83D\uDC76\uD83C\uDFFB|\uD83D\uDC76|\uD83D\uDC75\uD83C\uDFFF|\uD83D" + "\uDC75\uD83C\uDFFE|\uD83D\uDC75\uD83C\uDFFD|\uD83D\uDC75\uD83C\uDFFC" + "|\uD83D\uDC75\uD83C\uDFFB|\uD83D\uDC75|\uD83D\uDC74\uD83C\uDFFF|\uD83D" + "\uDC74\uD83C\uDFFE|\uD83D\uDC74\uD83C\uDFFD|\uD83D\uDC74\uD83C\uDFFC" + "|\uD83D\uDC74\uD83C\uDFFB|\uD83D\uDC74|\uD83D\uDC73\uD83C\uDFFF|\uD83D" + "\uDC73\uD83C\uDFFE|\uD83D\uDC73\uD83C\uDFFD|\uD83D\uDC73\uD83C\uDFFC" + "|\uD83D\uDC73\uD83C\uDFFB|\uD83D\uDC73\u200D\u2640\uFE0F|\uD83D\uDC73" + "|\uD83D\uDC72\uD83C\uDFFF|\uD83D\uDC72\uD83C\uDFFE|\uD83D\uDC72\uD83C" + "\uDFFD|\uD83D\uDC72\uD83C\uDFFC|\uD83D\uDC72\uD83C\uDFFB|\uD83D\uDC72" + "|\uD83D\uDC71\uD83C\uDFFF|\uD83D\uDC71\uD83C\uDFFE|\uD83D\uDC71\uD83C" + "\uDFFD|\uD83D\uDC71\uD83C\uDFFC|\uD83D\uDC71\uD83C\uDFFB|\uD83D\uDC71" + "\u200D\u2640\uFE0F|\uD83D\uDC71|\uD83D\uDC70\uD83C\uDFFF|\uD83D\uDC70" + "\uD83C\uDFFE|\uD83D\uDC70\uD83C\uDFFD|\uD83D\uDC70\uD83C\uDFFC|\uD83D" + "\uDC70\uD83C\uDFFB|\uD83D\uDC70|\uD83D\uDC6F\u200D\u2642\uFE0F|\uD83D" + "\uDC6F|\uD83D\uDC6E\uD83C\uDFFF|\uD83D\uDC6E\uD83C\uDFFE|\uD83D\uDC6E" + "\uD83C\uDFFD|\uD83D\uDC6E\uD83C\uDFFC|\uD83D\uDC6E\uD83C\uDFFB|\uD83D" + "\uDC6E\u200D\u2640\uFE0F|\uD83D\uDC6E|\uD83D\uDC6D|\uD83D\uDC6C|\uD83D" + "\uDC6B|\uD83D\uDC6A|\uD83D\uDC69\uD83C\uDFFF|\uD83D\uDC69\uD83C\uDFFE" + "|\uD83D\uDC69\uD83C\uDFFD|\uD83D\uDC69\uD83C\uDFFC|\uD83D\uDC69\uD83C" + "\uDFFB|\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC67" + "|\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66|\uD83D" + "\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC69" + "\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D" + "\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC67|\uD83D\uDC69" + "\u200D\uD83D\uDC67\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D" + "\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC66" + "|\uD83D\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D\uDC69|\uD83D" + "\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D\uDC68|\uD83D\uDC69" + "\u200D\u2764\uFE0F\u200D\uD83D\uDC69|\uD83D\uDC69\u200D\u2764\uFE0F\u200D" + "\uD83D\uDC68|\uD83D\uDC69|\uD83D\uDC68\uD83C\uDFFF|\uD83D\uDC68\uD83C" + "\uDFFE|\uD83D\uDC68\uD83C\uDFFD|\uD83D\uDC68\uD83C\uDFFC|\uD83D\uDC68" + "\uD83C\uDFFB|\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D" + "\uDC67|\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66" + "|\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC68\u200D\uD83D" + "\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC68\u200D\uD83D\uDC69" + "\u200D\uD83D\uDC66|\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D" + "\uD83D\uDC67|\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D" + "\uDC66|\uD83D\uDC68\u200D\uD83D\uDC68\u200D\uD83D\uDC67|\uD83D\uDC68\u200D" + "\uD83D\uDC68\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC68\u200D\uD83D" + "\uDC68\u200D\uD83D\uDC66|\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC67" + "|\uD83D\uDC68\u200D\uD83D\uDC67\u200D\uD83D\uDC66|\uD83D\uDC68\u200D\uD83D" + "\uDC67|\uD83D\uDC68\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC68\u200D" + "\uD83D\uDC66|\uD83D\uDC68\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D\uD83D" + "\uDC68|\uD83D\uDC68\u200D\u2764\uFE0F\u200D\uD83D\uDC68|\uD83D\uDC68" + "|\uD83D\uDC67\uD83C\uDFFF|\uD83D\uDC67\uD83C\uDFFE|\uD83D\uDC67\uD83C" + "\uDFFD|\uD83D\uDC67\uD83C\uDFFC|\uD83D\uDC67\uD83C\uDFFB|\uD83D\uDC67" + "|\uD83D\uDC66\uD83C\uDFFF|\uD83D\uDC66\uD83C\uDFFE|\uD83D\uDC66\uD83C" + "\uDFFD|\uD83D\uDC66\uD83C\uDFFC|\uD83D\uDC66\uD83C\uDFFB|\uD83D\uDC66" + "|\uD83D\uDC65|\uD83D\uDC64|\uD83D\uDC63|\uD83D\uDC62|\uD83D\uDC61|\uD83D" + "\uDC60|\uD83D\uDC5F|\uD83D\uDC5E|\uD83D\uDC5D|\uD83D\uDC5C|\uD83D\uDC5B" + "|\uD83D\uDC5A|\uD83D\uDC59|\uD83D\uDC58|\uD83D\uDC57|\uD83D\uDC56|\uD83D" + "\uDC55|\uD83D\uDC54|\uD83D\uDC53|\uD83D\uDC52|\uD83D\uDC51|\uD83D\uDC50" + "\uD83C\uDFFF|\uD83D\uDC50\uD83C\uDFFE|\uD83D\uDC50\uD83C\uDFFD|\uD83D" + "\uDC50\uD83C\uDFFC|\uD83D\uDC50\uD83C\uDFFB|\uD83D\uDC50|\uD83D\uDC4F" + "\uD83C\uDFFF|\uD83D\uDC4F\uD83C\uDFFE|\uD83D\uDC4F\uD83C\uDFFD|\uD83D" + "\uDC4F\uD83C\uDFFC|\uD83D\uDC4F\uD83C\uDFFB|\uD83D\uDC4F|\uD83D\uDC4E" + "\uD83C\uDFFF|\uD83D\uDC4E\uD83C\uDFFE|\uD83D\uDC4E\uD83C\uDFFD|\uD83D" + "\uDC4E\uD83C\uDFFC|\uD83D\uDC4E\uD83C\uDFFB|\uD83D\uDC4E|\uD83D\uDC4D" + "\uD83C\uDFFF|\uD83D\uDC4D\uD83C\uDFFE|\uD83D\uDC4D\uD83C\uDFFD|\uD83D" + "\uDC4D\uD83C\uDFFC|\uD83D\uDC4D\uD83C\uDFFB|\uD83D\uDC4D|\uD83D\uDC4C" + "\uD83C\uDFFF|\uD83D\uDC4C\uD83C\uDFFE|\uD83D\uDC4C\uD83C\uDFFD|\uD83D" + "\uDC4C\uD83C\uDFFC|\uD83D\uDC4C\uD83C\uDFFB|\uD83D\uDC4C|\uD83D\uDC4B" + "\uD83C\uDFFF|\uD83D\uDC4B\uD83C\uDFFE|\uD83D\uDC4B\uD83C\uDFFD|\uD83D" + "\uDC4B\uD83C\uDFFC|\uD83D\uDC4B\uD83C\uDFFB|\uD83D\uDC4B|\uD83D\uDC4A" + "\uD83C\uDFFF|\uD83D\uDC4A\uD83C\uDFFE|\uD83D\uDC4A\uD83C\uDFFD|\uD83D" + "\uDC4A\uD83C\uDFFC|\uD83D\uDC4A\uD83C\uDFFB|\uD83D\uDC4A|\uD83D\uDC49" + "\uD83C\uDFFF|\uD83D\uDC49\uD83C\uDFFE|\uD83D\uDC49\uD83C\uDFFD|\uD83D" + "\uDC49\uD83C\uDFFC|\uD83D\uDC49\uD83C\uDFFB|\uD83D\uDC49|\uD83D\uDC48" + "\uD83C\uDFFF|\uD83D\uDC48\uD83C\uDFFE|\uD83D\uDC48\uD83C\uDFFD|\uD83D" + "\uDC48\uD83C\uDFFC|\uD83D\uDC48\uD83C\uDFFB|\uD83D\uDC48|\uD83D\uDC47" + "\uD83C\uDFFF|\uD83D\uDC47\uD83C\uDFFE|\uD83D\uDC47\uD83C\uDFFD|\uD83D" + "\uDC47\uD83C\uDFFC|\uD83D\uDC47\uD83C\uDFFB|\uD83D\uDC47|\uD83D\uDC46" + "\uD83C\uDFFF|\uD83D\uDC46\uD83C\uDFFE|\uD83D\uDC46\uD83C\uDFFD|\uD83D" + "\uDC46\uD83C\uDFFC|\uD83D\uDC46\uD83C\uDFFB|\uD83D\uDC46|\uD83D\uDC45" + "|\uD83D\uDC44|\uD83D\uDC43\uD83C\uDFFF|\uD83D\uDC43\uD83C\uDFFE|\uD83D" + "\uDC43\uD83C\uDFFD|\uD83D\uDC43\uD83C\uDFFC|\uD83D\uDC43\uD83C\uDFFB" + "|\uD83D\uDC43|\uD83D\uDC42\uD83C\uDFFF|\uD83D\uDC42\uD83C\uDFFE|\uD83D" + "\uDC42\uD83C\uDFFD|\uD83D\uDC42\uD83C\uDFFC|\uD83D\uDC42\uD83C\uDFFB" + "|\uD83D\uDC42|\uD83D\uDC41\u200D\uD83D\uDDE8|\uD83D\uDC41|\uD83D\uDC40" + "|\uD83D\uDC3F|\uD83D\uDC3E|\uD83D\uDC3D|\uD83D\uDC3C|\uD83D\uDC3B|\uD83D" + "\uDC3A|\uD83D\uDC39|\uD83D\uDC38|\uD83D\uDC37|\uD83D\uDC36|\uD83D\uDC35" + "|\uD83D\uDC34|\uD83D\uDC33|\uD83D\uDC32|\uD83D\uDC31|\uD83D\uDC30|\uD83D" + "\uDC2F|\uD83D\uDC2E|\uD83D\uDC2D|\uD83D\uDC2C|\uD83D\uDC2B|\uD83D\uDC2A" + "|\uD83D\uDC29|\uD83D\uDC28|\uD83D\uDC27|\uD83D\uDC26|\uD83D\uDC25|\uD83D" + "\uDC24|\uD83D\uDC23|\uD83D\uDC22|\uD83D\uDC21|\uD83D\uDC20|\uD83D\uDC1F" + "|\uD83D\uDC1E|\uD83D\uDC1D|\uD83D\uDC1C|\uD83D\uDC1B|\uD83D\uDC1A|\uD83D" + "\uDC19|\uD83D\uDC18|\uD83D\uDC17|\uD83D\uDC16|\uD83D\uDC15|\uD83D\uDC14" + "|\uD83D\uDC13|\uD83D\uDC12|\uD83D\uDC11|\uD83D\uDC10|\uD83D\uDC0F|\uD83D" + "\uDC0E|\uD83D\uDC0D|\uD83D\uDC0C|\uD83D\uDC0B|\uD83D\uDC0A|\uD83D\uDC09" + "|\uD83D\uDC08|\uD83D\uDC07|\uD83D\uDC06|\uD83D\uDC05|\uD83D\uDC04|\uD83D" + "\uDC03|\uD83D\uDC02|\uD83D\uDC01|\uD83D\uDC00|\uD83C\uDFFF|\uD83C\uDFFE" + "|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB|\uD83C\uDFFA|\uD83C\uDFF9|\uD83C" + "\uDFF8|\uD83C\uDFF7|\uD83C\uDFF5|\uD83C\uDFF4|\uD83C\uDFF3\uFE0F\u200D" + "\uD83C\uDF08|\uD83C\uDFF3|\uD83C\uDFF0|\uD83C\uDFEF|\uD83C\uDFEE|\uD83C" + "\uDFED|\uD83C\uDFEC|\uD83C\uDFEB|\uD83C\uDFEA|\uD83C\uDFE9|\uD83C\uDFE8" + "|\uD83C\uDFE7|\uD83C\uDFE6|\uD83C\uDFE5|\uD83C\uDFE4|\uD83C\uDFE3|\uD83C" + "\uDFE2|\uD83C\uDFE1|\uD83C\uDFE0|\uD83C\uDFDF|\uD83C\uDFDE|\uD83C\uDFDD" + "|\uD83C\uDFDC|\uD83C\uDFDB|\uD83C\uDFDA|\uD83C\uDFD9|\uD83C\uDFD8|\uD83C" + "\uDFD7|\uD83C\uDFD6|\uD83C\uDFD5|\uD83C\uDFD4|\uD83C\uDFD3|\uD83C\uDFD2" + "|\uD83C\uDFD1|\uD83C\uDFD0|\uD83C\uDFCF|\uD83C\uDFCE|\uD83C\uDFCD|\uD83C" + "\uDFCC\uFE0F\u200D\u2640\uFE0F|\uD83C\uDFCC|\uD83C\uDFCB\uFE0F\u200D\u2640" + "\uFE0F|\uD83C\uDFCB\uD83C\uDFFF|\uD83C\uDFCB\uD83C\uDFFE|\uD83C\uDFCB" + "\uD83C\uDFFD|\uD83C\uDFCB\uD83C\uDFFC|\uD83C\uDFCB\uD83C\uDFFB|\uD83C" + "\uDFCB|\uD83C\uDFCA\uD83C\uDFFF|\uD83C\uDFCA\uD83C\uDFFE|\uD83C\uDFCA" + "\uD83C\uDFFD|\uD83C\uDFCA\uD83C\uDFFC|\uD83C\uDFCA\uD83C\uDFFB|\uD83C" + "\uDFCA\u200D\u2640\uFE0F|\uD83C\uDFCA|\uD83C\uDFC9|\uD83C\uDFC8|\uD83C" + "\uDFC7|\uD83C\uDFC6|\uD83C\uDFC5|\uD83C\uDFC4\uD83C\uDFFF|\uD83C\uDFC4" + "\uD83C\uDFFE|\uD83C\uDFC4\uD83C\uDFFD|\uD83C\uDFC4\uD83C\uDFFC|\uD83C" + "\uDFC4\uD83C\uDFFB|\uD83C\uDFC4\u200D\u2640\uFE0F|\uD83C\uDFC4|\uD83C" + "\uDFC3\uD83C\uDFFF|\uD83C\uDFC3\uD83C\uDFFE|\uD83C\uDFC3\uD83C\uDFFD" + "|\uD83C\uDFC3\uD83C\uDFFC|\uD83C\uDFC3\uD83C\uDFFB|\uD83C\uDFC3\u200D" + "\u2640\uFE0F|\uD83C\uDFC3|\uD83C\uDFC2|\uD83C\uDFC1|\uD83C\uDFC0|\uD83C" + "\uDFBF|\uD83C\uDFBE|\uD83C\uDFBD|\uD83C\uDFBC|\uD83C\uDFBB|\uD83C\uDFBA" + "|\uD83C\uDFB9|\uD83C\uDFB8|\uD83C\uDFB7|\uD83C\uDFB6|\uD83C\uDFB5|\uD83C" + "\uDFB4|\uD83C\uDFB3|\uD83C\uDFB2|\uD83C\uDFB1|\uD83C\uDFB0|\uD83C\uDFAF" + "|\uD83C\uDFAE|\uD83C\uDFAD|\uD83C\uDFAC|\uD83C\uDFAB|\uD83C\uDFAA|\uD83C" + "\uDFA9|\uD83C\uDFA8|\uD83C\uDFA7|\uD83C\uDFA6|\uD83C\uDFA5|\uD83C\uDFA4" + "|\uD83C\uDFA3|\uD83C\uDFA2|\uD83C\uDFA1|\uD83C\uDFA0|\uD83C\uDF9F|\uD83C" + "\uDF9E|\uD83C\uDF9B|\uD83C\uDF9A|\uD83C\uDF99|\uD83C\uDF97|\uD83C\uDF96" + "|\uD83C\uDF93|\uD83C\uDF92|\uD83C\uDF91|\uD83C\uDF90|\uD83C\uDF8F|\uD83C" + "\uDF8E|\uD83C\uDF8D|\uD83C\uDF8C|\uD83C\uDF8B|\uD83C\uDF8A|\uD83C\uDF89" + "|\uD83C\uDF88|\uD83C\uDF87|\uD83C\uDF86|\uD83C\uDF85\uD83C\uDFFF|\uD83C" + "\uDF85\uD83C\uDFFE|\uD83C\uDF85\uD83C\uDFFD|\uD83C\uDF85\uD83C\uDFFC" + "|\uD83C\uDF85\uD83C\uDFFB|\uD83C\uDF85|\uD83C\uDF84|\uD83C\uDF83|\uD83C" + "\uDF82|\uD83C\uDF81|\uD83C\uDF80|\uD83C\uDF7F|\uD83C\uDF7E|\uD83C\uDF7D" + "|\uD83C\uDF7C|\uD83C\uDF7B|\uD83C\uDF7A|\uD83C\uDF79|\uD83C\uDF78|\uD83C" + "\uDF77|\uD83C\uDF76|\uD83C\uDF75|\uD83C\uDF74|\uD83C\uDF73|\uD83C\uDF72" + "|\uD83C\uDF71|\uD83C\uDF70|\uD83C\uDF6F|\uD83C\uDF6E|\uD83C\uDF6D|\uD83C" + "\uDF6C|\uD83C\uDF6B|\uD83C\uDF6A|\uD83C\uDF69|\uD83C\uDF68|\uD83C\uDF67" + "|\uD83C\uDF66|\uD83C\uDF65|\uD83C\uDF64|\uD83C\uDF63|\uD83C\uDF62|\uD83C" + "\uDF61|\uD83C\uDF60|\uD83C\uDF5F|\uD83C\uDF5E|\uD83C\uDF5D|\uD83C\uDF5C" + "|\uD83C\uDF5B|\uD83C\uDF5A|\uD83C\uDF59|\uD83C\uDF58|\uD83C\uDF57|\uD83C" + "\uDF56|\uD83C\uDF55|\uD83C\uDF54|\uD83C\uDF53|\uD83C\uDF52|\uD83C\uDF51" + "|\uD83C\uDF50|\uD83C\uDF4F|\uD83C\uDF4E|\uD83C\uDF4D|\uD83C\uDF4C|\uD83C" + "\uDF4B|\uD83C\uDF4A|\uD83C\uDF49|\uD83C\uDF48|\uD83C\uDF47|\uD83C\uDF46" + "|\uD83C\uDF45|\uD83C\uDF44|\uD83C\uDF43|\uD83C\uDF42|\uD83C\uDF41|\uD83C" + "\uDF40|\uD83C\uDF3F|\uD83C\uDF3E|\uD83C\uDF3D|\uD83C\uDF3C|\uD83C\uDF3B" + "|\uD83C\uDF3A|\uD83C\uDF39|\uD83C\uDF38|\uD83C\uDF37|\uD83C\uDF36|\uD83C" + "\uDF35|\uD83C\uDF34|\uD83C\uDF33|\uD83C\uDF32|\uD83C\uDF31|\uD83C\uDF30" + "|\uD83C\uDF2F|\uD83C\uDF2E|\uD83C\uDF2D|\uD83C\uDF2C|\uD83C\uDF2B|\uD83C" + "\uDF2A|\uD83C\uDF29|\uD83C\uDF28|\uD83C\uDF27|\uD83C\uDF26|\uD83C\uDF25" + "|\uD83C\uDF24|\uD83C\uDF21|\uD83C\uDF20|\uD83C\uDF1F|\uD83C\uDF1E|\uD83C" + "\uDF1D|\uD83C\uDF1C|\uD83C\uDF1B|\uD83C\uDF1A|\uD83C\uDF19|\uD83C\uDF18" + "|\uD83C\uDF17|\uD83C\uDF16|\uD83C\uDF15|\uD83C\uDF14|\uD83C\uDF13|\uD83C" + "\uDF12|\uD83C\uDF11|\uD83C\uDF10|\uD83C\uDF0F|\uD83C\uDF0E|\uD83C\uDF0D" + "|\uD83C\uDF0C|\uD83C\uDF0B|\uD83C\uDF0A|\uD83C\uDF09|\uD83C\uDF08|\uD83C" + "\uDF07|\uD83C\uDF06|\uD83C\uDF05|\uD83C\uDF04|\uD83C\uDF03|\uD83C\uDF02" + "|\uD83C\uDF01|\uD83C\uDF00|\uD83C\uDE51|\uD83C\uDE50|\uD83C\uDE3A|\uD83C" + "\uDE39|\uD83C\uDE38|\uD83C\uDE37|\uD83C\uDE36|\uD83C\uDE35|\uD83C\uDE34" + "|\uD83C\uDE33|\uD83C\uDE32|\uD83C\uDE2F|\uD83C\uDE1A|\uD83C\uDE02|\uD83C" + "\uDE01|\uD83C\uDDFF\uD83C\uDDFC|\uD83C\uDDFF\uD83C\uDDF2|\uD83C\uDDFF" + "\uD83C\uDDE6|\uD83C\uDDFE\uD83C\uDDF9|\uD83C\uDDFE\uD83C\uDDEA|\uD83C" + "\uDDFD\uD83C\uDDF0|\uD83C\uDDFC\uD83C\uDDF8|\uD83C\uDDFC\uD83C\uDDEB" + "|\uD83C\uDDFB\uD83C\uDDFA|\uD83C\uDDFB\uD83C\uDDF3|\uD83C\uDDFB\uD83C" + "\uDDEE|\uD83C\uDDFB\uD83C\uDDEC|\uD83C\uDDFB\uD83C\uDDEA|\uD83C\uDDFB" + "\uD83C\uDDE8|\uD83C\uDDFB\uD83C\uDDE6|\uD83C\uDDFA\uD83C\uDDFF|\uD83C" + "\uDDFA\uD83C\uDDFE|\uD83C\uDDFA\uD83C\uDDF8|\uD83C\uDDFA\uD83C\uDDF2" + "|\uD83C\uDDFA\uD83C\uDDEC|\uD83C\uDDFA\uD83C\uDDE6|\uD83C\uDDF9\uD83C" + "\uDDFF|\uD83C\uDDF9\uD83C\uDDFC|\uD83C\uDDF9\uD83C\uDDFB|\uD83C\uDDF9" + "\uD83C\uDDF9|\uD83C\uDDF9\uD83C\uDDF7|\uD83C\uDDF9\uD83C\uDDF4|\uD83C" + "\uDDF9\uD83C\uDDF3|\uD83C\uDDF9\uD83C\uDDF2|\uD83C\uDDF9\uD83C\uDDF1" + "|\uD83C\uDDF9\uD83C\uDDF0|\uD83C\uDDF9\uD83C\uDDEF|\uD83C\uDDF9\uD83C" + "\uDDED|\uD83C\uDDF9\uD83C\uDDEC|\uD83C\uDDF9\uD83C\uDDEB|\uD83C\uDDF9" + "\uD83C\uDDE9|\uD83C\uDDF9\uD83C\uDDE8|\uD83C\uDDF9\uD83C\uDDE6|\uD83C" + "\uDDF8\uD83C\uDDFF|\uD83C\uDDF8\uD83C\uDDFE|\uD83C\uDDF8\uD83C\uDDFD" + "|\uD83C\uDDF8\uD83C\uDDFB|\uD83C\uDDF8\uD83C\uDDF9|\uD83C\uDDF8\uD83C" + "\uDDF8|\uD83C\uDDF8\uD83C\uDDF7|\uD83C\uDDF8\uD83C\uDDF4|\uD83C\uDDF8" + "\uD83C\uDDF3|\uD83C\uDDF8\uD83C\uDDF2|\uD83C\uDDF8\uD83C\uDDF1|\uD83C" + "\uDDF8\uD83C\uDDF0|\uD83C\uDDF8\uD83C\uDDEF|\uD83C\uDDF8\uD83C\uDDEE" + "|\uD83C\uDDF8\uD83C\uDDED|\uD83C\uDDF8\uD83C\uDDEC|\uD83C\uDDF8\uD83C" + "\uDDEA|\uD83C\uDDF8\uD83C\uDDE9|\uD83C\uDDF8\uD83C\uDDE8|\uD83C\uDDF8" + "\uD83C\uDDE7|\uD83C\uDDF8\uD83C\uDDE6|\uD83C\uDDF7\uD83C\uDDFC|\uD83C" + "\uDDF7\uD83C\uDDFA|\uD83C\uDDF7\uD83C\uDDF8|\uD83C\uDDF7\uD83C\uDDF4" + "|\uD83C\uDDF7\uD83C\uDDEA|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF5\uD83C" + "\uDDFE|\uD83C\uDDF5\uD83C\uDDFC|\uD83C\uDDF5\uD83C\uDDF9|\uD83C\uDDF5" + "\uD83C\uDDF8|\uD83C\uDDF5\uD83C\uDDF7|\uD83C\uDDF5\uD83C\uDDF3|\uD83C" + "\uDDF5\uD83C\uDDF2|\uD83C\uDDF5\uD83C\uDDF1|\uD83C\uDDF5\uD83C\uDDF0" + "|\uD83C\uDDF5\uD83C\uDDED|\uD83C\uDDF5\uD83C\uDDEC|\uD83C\uDDF5\uD83C" + "\uDDEB|\uD83C\uDDF5\uD83C\uDDEA|\uD83C\uDDF5\uD83C\uDDE6|\uD83C\uDDF4" + "\uD83C\uDDF2|\uD83C\uDDF3\uD83C\uDDFF|\uD83C\uDDF3\uD83C\uDDFA|\uD83C" + "\uDDF3\uD83C\uDDF7|\uD83C\uDDF3\uD83C\uDDF5|\uD83C\uDDF3\uD83C\uDDF4" + "|\uD83C\uDDF3\uD83C\uDDF1|\uD83C\uDDF3\uD83C\uDDEE|\uD83C\uDDF3\uD83C" + "\uDDEC|\uD83C\uDDF3\uD83C\uDDEB|\uD83C\uDDF3\uD83C\uDDEA|\uD83C\uDDF3" + "\uD83C\uDDE8|\uD83C\uDDF3\uD83C\uDDE6|\uD83C\uDDF2\uD83C\uDDFF|\uD83C" + "\uDDF2\uD83C\uDDFE|\uD83C\uDDF2\uD83C\uDDFD|\uD83C\uDDF2\uD83C\uDDFC" + "|\uD83C\uDDF2\uD83C\uDDFB|\uD83C\uDDF2\uD83C\uDDFA|\uD83C\uDDF2\uD83C" + "\uDDF9|\uD83C\uDDF2\uD83C\uDDF8|\uD83C\uDDF2\uD83C\uDDF7|\uD83C\uDDF2" + "\uD83C\uDDF6|\uD83C\uDDF2\uD83C\uDDF5|\uD83C\uDDF2\uD83C\uDDF4|\uD83C" + "\uDDF2\uD83C\uDDF3|\uD83C\uDDF2\uD83C\uDDF2|\uD83C\uDDF2\uD83C\uDDF1" + "|\uD83C\uDDF2\uD83C\uDDF0|\uD83C\uDDF2\uD83C\uDDED|\uD83C\uDDF2\uD83C" + "\uDDEC|\uD83C\uDDF2\uD83C\uDDEB|\uD83C\uDDF2\uD83C\uDDEA|\uD83C\uDDF2" + "\uD83C\uDDE9|\uD83C\uDDF2\uD83C\uDDE8|\uD83C\uDDF2\uD83C\uDDE6|\uD83C" + "\uDDF1\uD83C\uDDFE|\uD83C\uDDF1\uD83C\uDDFB|\uD83C\uDDF1\uD83C\uDDFA" + "|\uD83C\uDDF1\uD83C\uDDF9|\uD83C\uDDF1\uD83C\uDDF8|\uD83C\uDDF1\uD83C" + "\uDDF7|\uD83C\uDDF1\uD83C\uDDF0|\uD83C\uDDF1\uD83C\uDDEE|\uD83C\uDDF1" + "\uD83C\uDDE8|\uD83C\uDDF1\uD83C\uDDE7|\uD83C\uDDF1\uD83C\uDDE6|\uD83C" + "\uDDF0\uD83C\uDDFF|\uD83C\uDDF0\uD83C\uDDFE|\uD83C\uDDF0\uD83C\uDDFC" + "|\uD83C\uDDF0\uD83C\uDDF7|\uD83C\uDDF0\uD83C\uDDF5|\uD83C\uDDF0\uD83C" + "\uDDF3|\uD83C\uDDF0\uD83C\uDDF2|\uD83C\uDDF0\uD83C\uDDEE|\uD83C\uDDF0" + "\uD83C\uDDED|\uD83C\uDDF0\uD83C\uDDEC|\uD83C\uDDF0\uD83C\uDDEA|\uD83C" + "\uDDEF\uD83C\uDDF5|\uD83C\uDDEF\uD83C\uDDF4|\uD83C\uDDEF\uD83C\uDDF2" + "|\uD83C\uDDEF\uD83C\uDDEA|\uD83C\uDDEE\uD83C\uDDF9|\uD83C\uDDEE\uD83C" + "\uDDF8|\uD83C\uDDEE\uD83C\uDDF7|\uD83C\uDDEE\uD83C\uDDF6|\uD83C\uDDEE" + "\uD83C\uDDF4|\uD83C\uDDEE\uD83C\uDDF3|\uD83C\uDDEE\uD83C\uDDF2|\uD83C" + "\uDDEE\uD83C\uDDF1|\uD83C\uDDEE\uD83C\uDDEA|\uD83C\uDDEE\uD83C\uDDE9" + "|\uD83C\uDDEE\uD83C\uDDE8|\uD83C\uDDED\uD83C\uDDFA|\uD83C\uDDED\uD83C" + "\uDDF9|\uD83C\uDDED\uD83C\uDDF7|\uD83C\uDDED\uD83C\uDDF3|\uD83C\uDDED" + "\uD83C\uDDF2|\uD83C\uDDED\uD83C\uDDF0|\uD83C\uDDEC\uD83C\uDDFE|\uD83C" + "\uDDEC\uD83C\uDDFC|\uD83C\uDDEC\uD83C\uDDFA|\uD83C\uDDEC\uD83C\uDDF9" + "|\uD83C\uDDEC\uD83C\uDDF8|\uD83C\uDDEC\uD83C\uDDF7|\uD83C\uDDEC\uD83C" + "\uDDF6|\uD83C\uDDEC\uD83C\uDDF5|\uD83C\uDDEC\uD83C\uDDF3|\uD83C\uDDEC" + "\uD83C\uDDF2|\uD83C\uDDEC\uD83C\uDDF1|\uD83C\uDDEC\uD83C\uDDEE|\uD83C" + "\uDDEC\uD83C\uDDED|\uD83C\uDDEC\uD83C\uDDEC|\uD83C\uDDEC\uD83C\uDDEB" + "|\uD83C\uDDEC\uD83C\uDDEA|\uD83C\uDDEC\uD83C\uDDE9|\uD83C\uDDEC\uD83C" + "\uDDE7|\uD83C\uDDEC\uD83C\uDDE6|\uD83C\uDDEB\uD83C\uDDF7|\uD83C\uDDEB" + "\uD83C\uDDF4|\uD83C\uDDEB\uD83C\uDDF2|\uD83C\uDDEB\uD83C\uDDF0|\uD83C" + "\uDDEB\uD83C\uDDEF|\uD83C\uDDEB\uD83C\uDDEE|\uD83C\uDDEA\uD83C\uDDFA" + "|\uD83C\uDDEA\uD83C\uDDF9|\uD83C\uDDEA\uD83C\uDDF8|\uD83C\uDDEA\uD83C" + "\uDDF7|\uD83C\uDDEA\uD83C\uDDED|\uD83C\uDDEA\uD83C\uDDEC|\uD83C\uDDEA" + "\uD83C\uDDEA|\uD83C\uDDEA\uD83C\uDDE8|\uD83C\uDDEA\uD83C\uDDE6|\uD83C" + "\uDDE9\uD83C\uDDFF|\uD83C\uDDE9\uD83C\uDDF4|\uD83C\uDDE9\uD83C\uDDF2" + "|\uD83C\uDDE9\uD83C\uDDF0|\uD83C\uDDE9\uD83C\uDDEF|\uD83C\uDDE9\uD83C" + "\uDDEC|\uD83C\uDDE9\uD83C\uDDEA|\uD83C\uDDE8\uD83C\uDDFF|\uD83C\uDDE8" + "\uD83C\uDDFE|\uD83C\uDDE8\uD83C\uDDFD|\uD83C\uDDE8\uD83C\uDDFC|\uD83C" + "\uDDE8\uD83C\uDDFB|\uD83C\uDDE8\uD83C\uDDFA|\uD83C\uDDE8\uD83C\uDDF7" + "|\uD83C\uDDE8\uD83C\uDDF5|\uD83C\uDDE8\uD83C\uDDF4|\uD83C\uDDE8\uD83C" + "\uDDF3|\uD83C\uDDE8\uD83C\uDDF2|\uD83C\uDDE8\uD83C\uDDF1|\uD83C\uDDE8" + "\uD83C\uDDF0|\uD83C\uDDE8\uD83C\uDDEE|\uD83C\uDDE8\uD83C\uDDED|\uD83C" + "\uDDE8\uD83C\uDDEC|\uD83C\uDDE8\uD83C\uDDEB|\uD83C\uDDE8\uD83C\uDDE9" + "|\uD83C\uDDE8\uD83C\uDDE8|\uD83C\uDDE8\uD83C\uDDE6|\uD83C\uDDE7\uD83C" + "\uDDFF|\uD83C\uDDE7\uD83C\uDDFE|\uD83C\uDDE7\uD83C\uDDFC|\uD83C\uDDE7" + "\uD83C\uDDFB|\uD83C\uDDE7\uD83C\uDDF9|\uD83C\uDDE7\uD83C\uDDF8|\uD83C" + "\uDDE7\uD83C\uDDF7|\uD83C\uDDE7\uD83C\uDDF6|\uD83C\uDDE7\uD83C\uDDF4" + "|\uD83C\uDDE7\uD83C\uDDF3|\uD83C\uDDE7\uD83C\uDDF2|\uD83C\uDDE7\uD83C" + "\uDDF1|\uD83C\uDDE7\uD83C\uDDEF|\uD83C\uDDE7\uD83C\uDDEE|\uD83C\uDDE7" + "\uD83C\uDDED|\uD83C\uDDE7\uD83C\uDDEC|\uD83C\uDDE7\uD83C\uDDEB|\uD83C" + "\uDDE7\uD83C\uDDEA|\uD83C\uDDE7\uD83C\uDDE9|\uD83C\uDDE7\uD83C\uDDE7" + "|\uD83C\uDDE7\uD83C\uDDE6|\uD83C\uDDE6\uD83C\uDDFF|\uD83C\uDDE6\uD83C" + "\uDDFD|\uD83C\uDDE6\uD83C\uDDFC|\uD83C\uDDE6\uD83C\uDDFA|\uD83C\uDDE6" + "\uD83C\uDDF9|\uD83C\uDDE6\uD83C\uDDF8|\uD83C\uDDE6\uD83C\uDDF7|\uD83C" + "\uDDE6\uD83C\uDDF6|\uD83C\uDDE6\uD83C\uDDF4|\uD83C\uDDE6\uD83C\uDDF2" + "|\uD83C\uDDE6\uD83C\uDDF1|\uD83C\uDDE6\uD83C\uDDEE|\uD83C\uDDE6\uD83C" + "\uDDEC|\uD83C\uDDE6\uD83C\uDDEB|\uD83C\uDDE6\uD83C\uDDEA|\uD83C\uDDE6" + "\uD83C\uDDE9|\uD83C\uDDE6\uD83C\uDDE8|\uD83C\uDD9A|\uD83C\uDD99|\uD83C" + "\uDD98|\uD83C\uDD97|\uD83C\uDD96|\uD83C\uDD95|\uD83C\uDD94|\uD83C\uDD93" + "|\uD83C\uDD92|\uD83C\uDD91|\uD83C\uDD8E|\uD83C\uDD7F|\uD83C\uDD7E|\uD83C" + "\uDD71|\uD83C\uDD70|\uD83C\uDCCF|\uD83C\uDC04|\u3299|\u3297|\u303D|\u3030" + "|\u2B55|\u2B50|\u2B1C|\u2B1B|\u2B07|\u2B06|\u2B05|\u2935|\u2934|\u27BF" + "|\u27B0|\u27A1|\u2797|\u2796|\u2795|\u2764|\u2763|\u2757|\u2755|\u2754" + "|\u2753|\u274E|\u274C|\u2747|\u2744|\u2734|\u2733|\u2728|\u2721|\u271D" + "|\u2716|\u2714|\u2712|\u270F|\u270D\uD83C\uDFFF|\u270D\uD83C\uDFFE|\u270D" + "\uD83C\uDFFD|\u270D\uD83C\uDFFC|\u270D\uD83C\uDFFB|\u270D|\u270C\uD83C" + "\uDFFF|\u270C\uD83C\uDFFE|\u270C\uD83C\uDFFD|\u270C\uD83C\uDFFC|\u270C" + "\uD83C\uDFFB|\u270C|\u270B\uD83C\uDFFF|\u270B\uD83C\uDFFE|\u270B\uD83C" + "\uDFFD|\u270B\uD83C\uDFFC|\u270B\uD83C\uDFFB|\u270B|\u270A\uD83C\uDFFF" + "|\u270A\uD83C\uDFFE|\u270A\uD83C\uDFFD|\u270A\uD83C\uDFFC|\u270A\uD83C" + "\uDFFB|\u270A|\u2709|\u2708|\u2705|\u2702|\u26FD|\u26FA|\u26F9\uFE0F\u200D" + "\u2640\uFE0F|\u26F9\uD83C\uDFFF|\u26F9\uD83C\uDFFE|\u26F9\uD83C\uDFFD" + "|\u26F9\uD83C\uDFFC|\u26F9\uD83C\uDFFB|\u26F9|\u26F8|\u26F7|\u26F5|\u26F4" + "|\u26F3|\u26F2|\u26F1|\u26F0|\u26EA|\u26E9|\u26D4|\u26D3|\u26D1|\u26CF" + "|\u26CE|\u26C8|\u26C5|\u26C4|\u26BE|\u26BD|\u26B1|\u26B0|\u26AB|\u26AA" + "|\u26A1|\u26A0|\u269C|\u269B|\u2699|\u2697|\u2696|\u2694|\u2693|\u2692" + "|\u267F|\u267B|\u2668|\u2666|\u2665|\u2663|\u2660|\u2653|\u2652|\u2651" + "|\u2650|\u264F|\u264E|\u264D|\u264C|\u264B|\u264A|\u2649|\u2648|\u263A" + "|\u2639|\u2638|\u262F|\u262E|\u262A|\u2626|\u2623|\u2622|\u2620|\u261D" + "\uD83C\uDFFF|\u261D\uD83C\uDFFE|\u261D\uD83C\uDFFD|\u261D\uD83C\uDFFC" + "|\u261D\uD83C\uDFFB|\u261D|\u2618|\u2615|\u2614|\u2611|\u260E|\u2604|\u2603" + "|\u2602|\u2601|\u2600|\u25FE|\u25FD|\u25FC|\u25FB|\u25C0|\u25B6|\u25AB" + "|\u25AA|\u24C2|\u23FA|\u23F9|\u23F8|\u23F3|\u23F2|\u23F1|\u23F0|\u23EF" + "|\u23EE|\u23ED|\u23EC|\u23EB|\u23EA|\u23E9|\u23CF|\u2328|\u231B|\u231A" + "|\u21AA|\u21A9|\u2199|\u2198|\u2197|\u2196|\u2195|\u2194|\u2139|\u2122" + "|\u2049|\u203C|\u00AE|\u00A9|\u0039\uFE0F\u20E3|\u0038\uFE0F\u20E3|\u0037" + "\uFE0F\u20E3|\u0036\uFE0F\u20E3|\u0035\uFE0F\u20E3|\u0034\uFE0F\u20E3" + "|\u0033\uFE0F\u20E3|\u0032\uFE0F\u20E3|\u0031\uFE0F\u20E3|\u0030\uFE0F" + "\u20E3|\u002A\uFE0F\u20E3|\u0023\uFE0F\u20E3)"; private static SpannableString testLongString = new SpannableString ("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"); private static SpannableStringBuilder[] allTestStrings = new SpannableStringBuilder[Util.TEST_LIST_ITEM_COUNT]; public static void init(Context context) { Random random = new Random(); for (int i = 0; i < allTestStrings.length; i++) { int start = i; int len = 50 + random.nextInt(100); len = len > 1 ? len : 1; int end = start + len > testString.length() ? testString.length() : start + len; allTestStrings[i] = new SpannableStringBuilder(i + ":" + testString.subSequence(start, end)); ImageSpan imgSpan = new ImageSpan(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.test)); int spanStart = random.nextInt(len - 1); allTestStrings[i].setSpan(imgSpan, spanStart, spanStart + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE); } for (int i = 0; i < testLongString.length(); i++) { if (i + 1 < testLongString.length()) { ImageSpan imgSpan = new ImageSpan(context, BitmapFactory.decodeResource(context .getResources(), R.drawable.test)); testLongString.setSpan(imgSpan, i, i + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE); } } } public static SpannableStringBuilder getSpanString(int index) { return allTestStrings[index]; } public static SpannableString getLongSpanString() { return testLongString; } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/TestStats.java ================================================ package com.lsjwzh.test; import android.os.SystemClock; /** * Created by wenye on 2017/12/15. */ public class TestStats { private volatile long drawCost = 0; private volatile long drawCount = 0; private volatile long measureCost = 0; private volatile long measureCount = 0; private volatile long layoutCost = 0; private volatile long layoutCount = 0; private long drawStart = 0; private long measureStart = 0; private long layoutStart = 0; @Override public String toString() { return "TestStats{" + "drawCost=" + drawCost + ", drawCount=" + drawCount + ", measureCost=" + measureCost + ", measureCount=" + measureCount + ", layoutCost=" + layoutCost + ", layoutCount=" + layoutCount + '}'; } public void reset() { drawCost = 0; drawCount = 0; measureCost = 0; measureCount = 0; layoutCost = 0; layoutCount = 0; } public long getDrawCost() { return drawCost; } public long getDrawCount() { return drawCount; } public long getMeasureCost() { return measureCost; } public long getMeasureCount() { return measureCount; } public long getLayoutCost() { return layoutCost; } public long getLayoutCount() { return layoutCount; } public void drawStart() { drawStart = SystemClock.elapsedRealtime(); } public void drawEnd() { drawCost += SystemClock.elapsedRealtime() - drawStart; drawCount++; } public void measuretart() { measureStart = SystemClock.elapsedRealtime(); } public void measureEnd() { measureCost += SystemClock.elapsedRealtime() - measureStart; measureCount++; } public void layoutStart() { layoutStart = SystemClock.elapsedRealtime(); } public void layoutEnd() { layoutCost += SystemClock.elapsedRealtime() - layoutStart; layoutCount++; } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/TestTextView.java ================================================ package com.lsjwzh.test; import android.content.Context; import android.graphics.Canvas; import android.os.SystemClock; import android.support.annotation.Nullable; import android.support.annotation.Px; import android.util.AttributeSet; import android.widget.TextView; /** * Created by wenye on 2017/10/12. */ public class TestTextView extends TextView { private static final String TAG = TestTextView.class.getSimpleName(); public static final TestStats TEST_STATS = new TestStats(); public TestTextView(Context context) { super(context); } public TestTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public TestTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { TEST_STATS.measuretart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } TEST_STATS.measureEnd(); } @Override protected void onDraw(Canvas canvas) { TEST_STATS.drawStart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { super.onDraw(canvas); } TEST_STATS.drawEnd(); // Log.d(TAG, TAG + " onDraw cost:" + (end - start)); } @Override public void layout(@Px int l, @Px int t, @Px int r, @Px int b) { TEST_STATS.layoutStart(); for (int i = 0; i < Const.LOOP_COUNT; i++) { // TODO for test super.layout(l, t, r, b); } TEST_STATS.layoutEnd(); } } ================================================ FILE: app/src/main/java/com/lsjwzh/test/TextLineView.java ================================================ //package com.lsjwzh.test; // //import android.content.Context; //import android.graphics.Canvas; //import android.graphics.Color; //import android.graphics.Paint; //import android.os.Build; //import android.os.SystemClock; //import android.support.annotation.Nullable; //import android.support.annotation.RequiresApi; //import android.text.Directions; //import android.text.Layout; //import android.text.TextLineCompat; //import android.text.TextPaint; //import android.util.AttributeSet; //import android.util.Log; //import android.view.View; // ///** // * Just for test. // * Created by wenye on 2017/11/5. // */ //public class TextLineView extends View { // private static final String TAG = "TextLineView"; // private CharSequence mText; // private TextPaint mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); // private final Paint.FontMetricsInt mFontMetric = new Paint.FontMetricsInt(); // TextLineCompat mTextLineCompat; // // public TextLineView(Context context) { // super(context); // } // // public TextLineView(Context context, @Nullable AttributeSet attrs) { // super(context, attrs); // } // // public TextLineView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // } // // @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) // public TextLineView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { // super(context, attrs, defStyleAttr, defStyleRes); // } // // public void setText(CharSequence text) { // mText = text; // mTextPaint.setTextSize(20); // mTextPaint.setColor(Color.RED); // mTextLineCompat = TextLineCompat.obtain(); // mTextLineCompat.set(mTextPaint, mText, 0, mText.length(), Layout.DIR_LEFT_TO_RIGHT, Directions.DIRS_ALL_LEFT_TO_RIGHT, false, null); // mTextPaint.getFontMetricsInt(mFontMetric); // } // // @Override // protected void onDraw(Canvas canvas) { // long start = SystemClock.elapsedRealtime(); // for (int i = 0; i < Const.LOOP_COUNT; i++) { // super.onDraw(canvas); // int offset = getHeight() - (mFontMetric.bottom - mFontMetric.top); // int baseLine = offset / 2 - mFontMetric.top; // mTextLineCompat.draw(canvas, 0, 0, baseLine, baseLine + mFontMetric.bottom); // } // long end = SystemClock.elapsedRealtime(); // Log.d(TAG, TAG + " onDraw cost:" + (end - start)); // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // long start = SystemClock.elapsedRealtime(); // for (int i = 0; i < Const.LOOP_COUNT; i++) { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // } // long end = SystemClock.elapsedRealtime(); // Log.d(TAG, TAG + " measure cost:" + (end - start)); // // } // // //} ================================================ FILE: app/src/main/java/com/lsjwzh/test/Util.java ================================================ package com.lsjwzh.test; import android.content.Context; import android.graphics.Point; import android.view.WindowManager; /** * Created by ragnarok on 15/7/21. */ public class Util { public static final int TEST_LIST_ITEM_COUNT = 500; public static final int TEXT_SIZE_DP = 25; public static final int AUTO_SCROLL_INTERVAL = 1; public static final int AUTO_SCROLL_STEP = 10; public static float fromDPtoPix(Context context, int dp) { return context.getResources().getDisplayMetrics().density * dp; } public static int getScreenWidth(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Point size = new Point(); windowManager.getDefaultDisplay().getSize(size); return size.x; } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/EllipseFragment.java ================================================ package com.wechat.testdemo; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.SystemClock; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.text.Layout; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.StaticLayout; import android.text.StaticLayoutBuilderCompat; import android.text.TextPaint; import android.text.TextUtils; import android.text.style.ImageSpan; import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.lsjwzh.test.TestSingleLineTextView; import com.lsjwzh.widget.text.FastTextLayoutView; import com.lsjwzh.widget.text.FastTextView; import com.lsjwzh.widget.text.ReadMoreTextView; import com.lsjwzh.widget.text.StrokeSpan; /** * A placeholder fragment containing a simple view. */ public class EllipseFragment extends Fragment { private View mRootView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mRootView != null) { return mRootView; } mRootView = inflater.inflate(R.layout.ellipse_demo, container, false); SpannableStringBuilder spannableStringBuilder = getSpannable(); FastTextView fastTextView = (FastTextView) mRootView.findViewById(R.id.fast_tv2); fastTextView.setText(spannableStringBuilder); // fastTextView.setCustomEllipsisSpan(new ImageSpan(drawable)); TextView tv = (TextView) mRootView.findViewById(R.id.system_tv); tv.setText(spannableStringBuilder); // tv.setMovementMethod(LinkMovementMethod.getInstance()); return mRootView; } private StaticLayout getStaticLayout(SpannableStringBuilder spannableStringBuilder, TextPaint textPaint, float textSize, Rect bounds, String text) { long start = SystemClock.elapsedRealtime(); for (int i = 0; i < 1000; i++) { textPaint.getTextBounds(text, 0, spannableStringBuilder.length(), bounds); } long end = SystemClock.elapsedRealtime(); float withWithTextBounds = bounds.width(); Log.d("test", "withWithTextBounds:" + withWithTextBounds + " offset:" + 0.5f * textSize + " cost:" + (end - start)); start = SystemClock.elapsedRealtime(); float withWithMeasureText = 0; for (int i = 0; i < 1000; i++) { withWithMeasureText = textPaint.measureText(spannableStringBuilder, 0, spannableStringBuilder.length()); } end = SystemClock.elapsedRealtime(); Log.d("test", "withWithMeasureText:" + withWithMeasureText + " cost:" + (end - start)); start = SystemClock.elapsedRealtime(); float withWithDesiredWidth = 0; for (int i = 0; i < 1000; i++) { withWithDesiredWidth = Layout.getDesiredWidth(spannableStringBuilder, textPaint); } end = SystemClock.elapsedRealtime(); Log.d("test", "withWithDesiredWidth:" + withWithDesiredWidth + " cost:" + (end - start)); start = SystemClock.elapsedRealtime(); for (int i = 0; i < 1000; i++) { spannableStringBuilder.getSpans(0, spannableStringBuilder.length(), StrokeSpan.class); } end = SystemClock.elapsedRealtime(); Log.d("test", "getSpans cost:" + (end - start)); int width = (int) Math.ceil(Math.max(Math.max(withWithTextBounds, withWithMeasureText), withWithDesiredWidth)); return StaticLayoutBuilderCompat.obtain(spannableStringBuilder, 0, spannableStringBuilder.length(), textPaint, Math.min(width, getResources().getDisplayMetrics().widthPixels)) .setAlignment(Layout.Alignment.ALIGN_NORMAL) .setLineSpacing(0f, 1f) .setEllipsize(TextUtils.TruncateAt.END) .setMaxLines(2).setIncludePad(true).build(); } @NonNull private SpannableStringBuilder getSpannable() { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(getResources().getString(R.string.content_cn)); Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher); drawable.setBounds(0, 0, 35, 35); spannableStringBuilder.setSpan(new ImageSpan(drawable) , 36, 37, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); spannableStringBuilder.setSpan(new ImageSpan(drawable) , 37, 38, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); spannableStringBuilder.setSpan(new ImageSpan(drawable) , 38, 39, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); spannableStringBuilder.setSpan(new ImageSpan(drawable) , 39, 40, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); // ItalicReplacementSpan italicSpan = new ItalicReplacementSpan(-0.25f); // StrokeSpan strokeSpan = new StrokeSpan(Color.BLUE, Color.YELLOW, 20); // spannableStringBuilder.setSpan(strokeSpan, 0, spannableStringBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); return spannableStringBuilder; } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/FastTextViewListTestFragment.java ================================================ package com.wechat.testdemo; import android.content.Context; import android.os.Bundle; import android.os.SystemClock; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.lsjwzh.test.AutoScrollHandler; import com.lsjwzh.test.FastTextView; import com.lsjwzh.test.TestSpan; import com.lsjwzh.test.TestTextView; import com.lsjwzh.test.Util; public class FastTextViewListTestFragment extends Fragment { private ListView listView; private ListAdapter adapter; private AutoScrollHandler autoScrollHandler; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View viewRoot = inflater.inflate(R.layout.normal_layout_ui, container, false); listView = (ListView) viewRoot.findViewById(R.id.test_list); adapter = new ListAdapter(getActivity()); listView.setAdapter(adapter); autoScrollHandler = new AutoScrollHandler(listView, Util.TEST_LIST_ITEM_COUNT); viewRoot.findViewById(R.id.scroll_down_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FastTextView.TEST_STATS.reset(); adapter.bindCost = 0; autoScrollHandler.startAutoScrollDown(new AutoScrollHandler.Callback() { @Override public void callback(int fps) { Toast.makeText(listView.getContext(), "Average FPS: " + fps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "TestFastTextView.avgFps" + fps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("TestFastTextViewStats", FastTextView.TEST_STATS.toString()); } }); } }); viewRoot.findViewById(R.id.scroll_up_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FastTextView.TEST_STATS.reset(); adapter.bindCost = 0; autoScrollHandler.startAutoScrollUp(new AutoScrollHandler.Callback() { @Override public void callback(int fps) { Toast.makeText(listView.getContext(), "Average FPS: " + fps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "TestFastTextView.avgFps" + fps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("TestFastTextViewStats", FastTextView.TEST_STATS.toString()); } }); } }); return viewRoot; } private static class ListAdapter extends TestListAdapter { private ListAdapter(Context context) { super(context); } @Override public View bindView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.fast_list_item, parent, false); ViewHolder viewHolder = new ViewHolder(); viewHolder.textView = (FastTextView) convertView.findViewById(R.id.fast_text_view); convertView.setTag(viewHolder); } ViewHolder holder = (ViewHolder) convertView.getTag(); holder.textView.setText(TestSpan.getSpanString(position)); return convertView; } private class ViewHolder { FastTextView textView; } } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/MainActivity.java ================================================ package com.wechat.testdemo; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.FragmentActivity; import android.view.View; import android.view.Menu; import android.view.MenuItem; import com.lsjwzh.test.FpsCalculator; import com.lsjwzh.test.GhostThread; public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getSupportFragmentManager().popBackStackImmediate(); } }); getSupportFragmentManager().beginTransaction() .replace(R.id.fragment, new MainActivityFragment()) .commit(); // GhostThread.start(); FpsCalculator.instance().start(); } @Override public void onBackPressed() { super.onBackPressed(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override protected void onDestroy() { super.onDestroy(); FpsCalculator.instance().stop(); GhostThread.stop(); } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/MainActivityFragment.java ================================================ package com.wechat.testdemo; import android.graphics.Paint; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.Layout; import android.text.StaticLayout; import android.text.TextLayoutCache; import android.text.TextLayoutWarmer; import android.text.TextPaint; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import com.lsjwzh.test.StaticLayoutManager; import com.lsjwzh.test.TestSpan; import com.lsjwzh.test.Util; /** * A placeholder fragment containing a simple view. */ public class MainActivityFragment extends Fragment { private View mRootView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mRootView != null) { return mRootView; } mRootView = inflater.inflate(R.layout.fragment_main, container, false); mRootView.findViewById(R.id.demo_measure_test).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new EllipseFragment()) .addToBackStack(null) .commit(); } }); mRootView.findViewById(R.id.demo_ellipsis).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new EllipseFragment()) .addToBackStack(null) .commitAllowingStateLoss(); } }); mRootView.findViewById(R.id.demo_read_more).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new ReadMoreFragment()) .addToBackStack(null) .commitAllowingStateLoss(); } }); mRootView.findViewById(R.id.demo_read_more_list).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new ReadMoreListTestFragment()) .addToBackStack(null) .commitAllowingStateLoss(); } }); mRootView.findViewById(R.id.prepare_layout_cache).setOnClickListener(new View.OnClickListener () { @Override public void onClick(View v) { StaticLayoutManager.sLayoutWarmer.setLayoutFactory(new TextLayoutWarmer .LayoutFactory() { @Override public StaticLayout makeLayout(CharSequence text) { // 公用TextPaint会导致fps下降? why final TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(Util.fromDPtoPix(getActivity(), Util.TEXT_SIZE_DP)); int width = (int) Layout.getDesiredWidth(text, textPaint); return new StaticLayout(text, textPaint, Math.min(width, Util.getScreenWidth(getActivity())), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0f, true); } }); StaticLayoutManager.sLayoutWarmer.addListener(new TextLayoutWarmer .WarmListener() { int count = 0; @Override public void onWarmComplete(CharSequence text, TextLayoutWarmer.WarmerTask warmerTask) { TextLayoutCache.STATIC_LAYOUT_CACHE.put(text, warmerTask.mLayout); count++; if (count == Util.TEST_LIST_ITEM_COUNT) { mRootView.post(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), "init layout and span finish", Toast.LENGTH_LONG) .show(); } }); } } }); for (int i = 0; i < Util.TEST_LIST_ITEM_COUNT; i++) { StaticLayoutManager.sLayoutWarmer.addText(TestSpan.getSpanString(i)); } // new Thread(new Runnable() { // @Override // public void run() { // StaticLayoutManager.getInstance().initLayout(getActivity(), TestSpan.getSpanString // (), TestSpan.getLongSpanString()); // getActivity().runOnUiThread(new Runnable() { // @Override // public void run() { // Toast.makeText(getActivity(), "init layout and span finish", Toast.LENGTH_LONG) // .show(); // } // }); // } // }).start(); } }); mRootView.findViewById(R.id.demo_layout_cache).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new StaticLayoutCacheTestFragment()) .addToBackStack(null) .commitAllowingStateLoss(); } }); mRootView.findViewById(R.id.demo_fast_tv).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new FastTextViewListTestFragment()) .addToBackStack(null) .commitAllowingStateLoss(); } }); mRootView.findViewById(R.id.demo_normal_list).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction() .replace(R.id.fragment, new NormalLayoutTestFragment()) .addToBackStack(null) .commitAllowingStateLoss(); } }); TestSpan.init(getActivity()); return mRootView; } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/NormalLayoutTestFragment.java ================================================ package com.wechat.testdemo; import android.content.Context; import android.os.Bundle; import android.os.SystemClock; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.method.LinkMovementMethod; import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.lsjwzh.test.AutoScrollHandler; import com.lsjwzh.test.FastTextView; import com.lsjwzh.test.TestSpan; import com.lsjwzh.test.TestTextView; import com.lsjwzh.test.Util; public class NormalLayoutTestFragment extends Fragment { private ListView listView; private NormalListAdapter adapter; private AutoScrollHandler autoScrollHandler; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View viewRoot = inflater.inflate(R.layout.normal_layout_ui, container, false); listView = (ListView) viewRoot.findViewById(R.id.test_list); adapter = new NormalListAdapter(getActivity()); listView.setAdapter(adapter); autoScrollHandler = new AutoScrollHandler(listView, Util.TEST_LIST_ITEM_COUNT); viewRoot.findViewById(R.id.scroll_down_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TestTextView.TEST_STATS.reset(); adapter.bindCost = 0; autoScrollHandler.startAutoScrollDown(new AutoScrollHandler.Callback() { @Override public void callback(int fps) { Toast.makeText(listView.getContext(), "Average FPS: " + fps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "TestTextView.avgFps" + fps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("TestTextViewStats", TestTextView.TEST_STATS.toString()); } }); } }); viewRoot.findViewById(R.id.scroll_up_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TestTextView.TEST_STATS.reset(); adapter.bindCost = 0; autoScrollHandler.startAutoScrollUp(new AutoScrollHandler.Callback() { @Override public void callback(int fps) { Toast.makeText(listView.getContext(), "Average FPS: " + fps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "TestTextView.avgFps" + fps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("TestTextViewStats", TestTextView.TEST_STATS.toString()); } }); } }); return viewRoot; } private static class NormalListAdapter extends TestListAdapter { private NormalListAdapter(Context context) { super(context); } @Override public View bindView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.normal_list_item, parent, false); ViewHolder viewHolder = new ViewHolder(); viewHolder.textView = (TextView) convertView.findViewById(R.id.normal_text); convertView.setTag(viewHolder); } ViewHolder holder = (ViewHolder) convertView.getTag(); holder.textView.setMovementMethod(LinkMovementMethod.getInstance()); holder.textView.setText(TestSpan.getSpanString(position)); return convertView; } private class ViewHolder { TextView textView; } } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/ReadMoreFragment.java ================================================ package com.wechat.testdemo; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextPaint; import android.text.style.ClickableSpan; import android.text.style.ImageSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import com.lsjwzh.widget.text.ReadMoreTextView; /** * A placeholder fragment containing a simple view. */ public class ReadMoreFragment extends Fragment { private View mRootView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mRootView != null) { return mRootView; } mRootView = inflater.inflate(R.layout.read_more_demo, container, false); SpannableStringBuilder spannableStringBuilder = getSpannable(); final ReadMoreTextView readMoreTextView = mRootView.findViewById(R.id.readmore_tv); readMoreTextView.setText(spannableStringBuilder); readMoreTextView.setCustomEllipsisSpan(new ReadMoreTextView.EllipsisSpan(" Read More") { @Override public void draw(@NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) { int oldColor = paint.getColor(); paint.setColor(Color.RED); super.draw(canvas, text, start, end, x, top, y, bottom, paint); paint.setColor(oldColor); } }); readMoreTextView.setCustomCollapseSpan(new ReadMoreTextView.EllipsisSpan(" Collapse") { @Override public void draw(@NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) { int oldColor = paint.getColor(); paint.setColor(Color.RED); super.draw(canvas, text, start, end, x, top, y, bottom, paint); paint.setColor(oldColor); } }); readMoreTextView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { readMoreTextView.setTextColor(Color.RED); return false; } }); return mRootView; } @NonNull private SpannableStringBuilder getSpannable() { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(getResources().getString(R.string.content_cn)); return spannableStringBuilder; } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/ReadMoreListTestFragment.java ================================================ package com.wechat.testdemo; import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.Toast; import com.lsjwzh.test.AutoScrollHandler; import com.lsjwzh.test.FastTextView; import com.lsjwzh.test.TestSpan; import com.lsjwzh.test.Util; import com.lsjwzh.widget.text.ReadMoreTextView; public class ReadMoreListTestFragment extends Fragment { private ListView listView; private ListAdapter adapter; private AutoScrollHandler autoScrollHandler; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View viewRoot = inflater.inflate(R.layout.normal_layout_ui, container, false); listView = (ListView) viewRoot.findViewById(R.id.test_list); adapter = new ListAdapter(getActivity()); listView.setAdapter(adapter); autoScrollHandler = new AutoScrollHandler(listView, Util.TEST_LIST_ITEM_COUNT); viewRoot.findViewById(R.id.scroll_down_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FastTextView.TEST_STATS.reset(); adapter.bindCost = 0; autoScrollHandler.startAutoScrollDown(new AutoScrollHandler.Callback() { @Override public void callback(int fps) { Toast.makeText(listView.getContext(), "Average FPS: " + fps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "TestFastTextView.avgFps" + fps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("TestFastTextViewStats", FastTextView.TEST_STATS.toString()); } }); } }); viewRoot.findViewById(R.id.scroll_up_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FastTextView.TEST_STATS.reset(); adapter.bindCost = 0; autoScrollHandler.startAutoScrollUp(new AutoScrollHandler.Callback() { @Override public void callback(int fps) { Toast.makeText(listView.getContext(), "Average FPS: " + fps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "TestFastTextView.avgFps" + fps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("TestFastTextViewStats", FastTextView.TEST_STATS.toString()); } }); } }); return viewRoot; } private static class ListAdapter extends TestListAdapter { private ListAdapter(Context context) { super(context); } @Override public View bindView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.readmore_list_item, parent, false); ViewHolder viewHolder = new ViewHolder(); viewHolder.textView = (ReadMoreTextView) convertView.findViewById(R.id.fast_text_view); convertView.setTag(viewHolder); } ViewHolder holder = (ViewHolder) convertView.getTag(); holder.textView.setText(TestSpan.getSpanString(position)); return convertView; } private class ViewHolder { ReadMoreTextView textView; } } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/StaticLayoutCacheTestFragment.java ================================================ package com.wechat.testdemo; import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.Toast; import com.lsjwzh.test.AutoScrollHandler; import com.lsjwzh.test.StaticLayoutManager; import com.lsjwzh.test.Util; import com.lsjwzh.widget.text.FastTextLayoutView; public class StaticLayoutCacheTestFragment extends Fragment { private static final String TAG = "StaticLayoutUI"; private ListView listview; private StaticListAdapter adapter; private AutoScrollHandler autoScrollHandler; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View viewRoot = inflater.inflate(R.layout.static_layout_ui, container, false); listview = (ListView) viewRoot.findViewById(R.id.test_list); adapter = new StaticListAdapter(getActivity()); listview.setAdapter(adapter); autoScrollHandler = new AutoScrollHandler(listview, Util.TEST_LIST_ITEM_COUNT); viewRoot.findViewById(R.id.scroll_down_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { com.lsjwzh.test.FastTextLayoutView.TEST_STATS.reset(); autoScrollHandler.startAutoScrollDown(new AutoScrollHandler.Callback() { @Override public void callback(int avgFps) { Toast.makeText(getActivity(), "Average FPS: " + avgFps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "FastTextLayoutView.avgFps" + avgFps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("FastTextLayoutViewStats", com.lsjwzh.test.FastTextLayoutView.TEST_STATS .toString()); } }); } }); viewRoot.findViewById(R.id.scroll_up_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { com.lsjwzh.test.FastTextLayoutView.TEST_STATS.reset(); autoScrollHandler.startAutoScrollUp(new AutoScrollHandler.Callback() { @Override public void callback(int avgFps) { Toast.makeText(getActivity(), "Average FPS: " + avgFps, Toast.LENGTH_LONG).show(); Log.e("drawFps", "FastTextLayoutView.avgFps" + avgFps); Log.e("bindCost", "bindCost" + adapter.bindCost); Log.e("FastTextLayoutViewStats", com.lsjwzh.test.FastTextLayoutView.TEST_STATS .toString()); } }); } }); return viewRoot; } private static class StaticListAdapter extends TestListAdapter { private StaticListAdapter(Context context) { super(context); } @Override public View bindView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.static_list_item, parent, false); ViewHolder viewHolder = new ViewHolder(); viewHolder.staticLayoutView = (FastTextLayoutView) convertView.findViewById(R.id .static_layout_view); convertView.setTag(viewHolder); } ViewHolder holder = (ViewHolder) convertView.getTag(); holder.staticLayoutView.setTextLayout(StaticLayoutManager.getInstance().getLayout(position)); holder.staticLayoutView.requestLayout(); return convertView; } private class ViewHolder { FastTextLayoutView staticLayoutView; } } } ================================================ FILE: app/src/main/java/com/wechat/testdemo/TestListAdapter.java ================================================ package com.wechat.testdemo; import android.content.Context; import android.os.SystemClock; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import com.lsjwzh.test.Util; public abstract class TestListAdapter extends BaseAdapter { protected Context context; public long bindCost = 0; public TestListAdapter(Context context) { this.context = context; } @Override public int getCount() { return Util.TEST_LIST_ITEM_COUNT; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public final View getView(int position, View convertView, ViewGroup parent) { long start = SystemClock.elapsedRealtime(); convertView = bindView(position, convertView, parent); long end = SystemClock.elapsedRealtime(); bindCost += (end - start); return convertView; } public abstract View bindView(int position, View convertView, ViewGroup parent); } ================================================ FILE: app/src/main/res/anim/popup_enter.xml ================================================ ================================================ FILE: app/src/main/res/anim/popup_exit.xml ================================================ ================================================ FILE: app/src/main/res/drawable/popup_background.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: app/src/main/res/layout/ellipse_demo.xml ================================================ ================================================ FILE: app/src/main/res/layout/fast_layout_ui.xml ================================================