From 59b6a9bc9163791bfbe4f61c1c941d02fd3aab66 Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Wed, 26 May 2021 11:15:30 +0800 Subject: [PATCH 1/8] update README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f00d2ef..c1adea7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ 依赖暂无 #### 效果演示 -![效果](https://images.gitee.com/uploads/images/2021/0525/154811_04cd5f34_7918188.gif "826e9023-8391-4085-f8ef-25931f5f4918.gif") +![效果演示](https://images.gitee.com/uploads/images/2021/0526/111504_59461e61_7918188.gif "Stom.gif") #### 使用说明 -- Gitee From 93391a001d4aa6eedcc76234ec483977898dff09 Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Wed, 26 May 2021 11:26:16 +0800 Subject: [PATCH 2/8] first commit --- README.md | 9 ++++++--- .../rxHarmony/OpenHarmonySchedulers.java | 4 ++-- .../rxHarmony/RxHmOSPlugins.java | 2 +- .../slice/MainAbilitySlice.java | 3 ++- .../main/resources/base/layout/ability_main.xml | 15 +++++++++++---- .../java/ua/naiksoftware/stomp/HeartBeatTask.java | 2 ++ .../stomp/pathmatcher/RabbitPathMatcher.java | 8 ++++++-- .../provider/AbstractConnectionProvider.java | 7 ++----- .../stomp/provider/ConnectionProvider.java | 8 ++++++-- .../stomp/provider/OkHttpConnectionProvider.java | 6 +++--- 10 files changed, 41 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c1adea7..e50f8cc 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,10 @@ #### 安装教程 1.在项目根目录下的build.gradle文件中, -2.在entry模块的build.gradle文件中, -依赖暂无 +2.在entry模块的build.gradle文件中, +暂无 +在sdk5,DevEco Studio2.1 beta4下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 效果演示 ![效果演示](https://images.gitee.com/uploads/images/2021/0526/111504_59461e61_7918188.gif "Stom.gif") @@ -145,6 +146,7 @@ CloudTest代码测试无异常 - 0.0.1-SNAPSHOT ## 版权和许可信息 +```` he MIT License (MIT) Copyright (c) 2016 Nickolay Savchenko @@ -165,4 +167,5 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. + diff --git a/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/OpenHarmonySchedulers.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/OpenHarmonySchedulers.java index 3796397..68f4cba 100644 --- a/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/OpenHarmonySchedulers.java +++ b/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/OpenHarmonySchedulers.java @@ -48,8 +48,8 @@ public final class OpenHarmonySchedulers { /** * from 根据 eventRunner 返回 Scheduler * - * @param eventRunner - * @return + * @param eventRunner eventRunner + * @return Scheduler */ public static Scheduler from(EventRunner eventRunner) { if (eventRunner == null) { diff --git a/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/RxHmOSPlugins.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/RxHmOSPlugins.java index d99a248..842082d 100644 --- a/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/RxHmOSPlugins.java +++ b/entry/src/main/java/ua/naiksoftware/stompclientexample/rxHarmony/RxHmOSPlugins.java @@ -21,7 +21,7 @@ public class RxHmOSPlugins { * 创建线程 * * @param scheduler - * @return + * @return Scheduler */ public static Scheduler initMainThreadScheduler(Callable scheduler) { if (scheduler == null) { diff --git a/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java index f319bea..7f138c3 100644 --- a/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java @@ -236,8 +236,9 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL } private void notifyList(int pos) { + mRecyclerView.scrollBy(0,1700); mRecyclerView.scrollTo(pos); - mAdapter.notifyDataChanged(); + mAdapter.notifyDataSetItemChanged(pos); } /** diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml index 826f9c8..f56ee7f 100644 --- a/entry/src/main/resources/base/layout/ability_main.xml +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -1,9 +1,9 @@ - + > @@ -59,14 +61,17 @@ @@ -111,12 +116,14 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/lib/src/main/java/ua/naiksoftware/stomp/HeartBeatTask.java b/lib/src/main/java/ua/naiksoftware/stomp/HeartBeatTask.java index 1c7cc42..3fd6b03 100644 --- a/lib/src/main/java/ua/naiksoftware/stomp/HeartBeatTask.java +++ b/lib/src/main/java/ua/naiksoftware/stomp/HeartBeatTask.java @@ -118,6 +118,8 @@ public class HeartBeatTask { /** * Analise heart-beat sent from server (if any), to adjust the frequency. * Startup the heart-beat logic. + * + * @param heartBeatHeader heartBeatHeader */ private void heartBeatHandshake(final String heartBeatHeader) { if (heartBeatHeader != null) { diff --git a/lib/src/main/java/ua/naiksoftware/stomp/pathmatcher/RabbitPathMatcher.java b/lib/src/main/java/ua/naiksoftware/stomp/pathmatcher/RabbitPathMatcher.java index 1694989..fc28a09 100644 --- a/lib/src/main/java/ua/naiksoftware/stomp/pathmatcher/RabbitPathMatcher.java +++ b/lib/src/main/java/ua/naiksoftware/stomp/pathmatcher/RabbitPathMatcher.java @@ -12,8 +12,12 @@ import java.util.ArrayList; */ public class RabbitPathMatcher implements PathMatcher { /** - * RMQ-style wildcards. - * See more info here. + * RMQ-style wildcards.RabbitPathMatcher + * See more info NUM_16) { + mRecyclerView.setHeight(NUM_1900); + } } - private void notifyList(int pos) { - mRecyclerView.scrollBy(0,1700); + mRecyclerView.scrollBy(0, NUM_1700); mRecyclerView.scrollTo(pos); mAdapter.notifyDataSetItemChanged(pos); } - /** * toast * @@ -275,7 +276,6 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL } super.onStop(); } - /** * debug * @@ -284,4 +284,4 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL private void debug(String msg) { HiLog.error(LABEL, msg, 0); } -} +} \ No newline at end of file -- Gitee From 2bf98a3ebaba823cb860f49d43dea0137c1ea843 Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Wed, 26 May 2021 14:45:48 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20grad?= =?UTF-8?q?le.properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 gradle.properties diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 0daf183..0000000 --- a/gradle.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. DevEco Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# If the Chinese output is garbled, please configure the following parameter. -# org.gradle.jvmargs=-Dfile.encoding=GBK -- Gitee From c2a89c4db913308a8ce2abddbfae5274c43c5307 Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Wed, 26 May 2021 14:45:53 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20grad?= =?UTF-8?q?lew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradlew | 183 -------------------------------------------------------- 1 file changed, 183 deletions(-) delete mode 100755 gradlew diff --git a/gradlew b/gradlew deleted file mode 100755 index 2fe81a7..0000000 --- a/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" -- Gitee From c356cd918e2b9f387bef8a9abf76491dfb63b7c9 Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Wed, 26 May 2021 14:45:58 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20grad?= =?UTF-8?q?lew.bat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradlew.bat | 103 ---------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 gradlew.bat diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 62bd9b9..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,103 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega -- Gitee From 633c70bdf8dd2b928acbb2c66cf99020ef4de9b5 Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Thu, 27 May 2021 14:31:42 +0800 Subject: [PATCH 7/8] update entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java. --- .../slice/MainAbilitySlice.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java index bf61a45..3d4c9bb 100644 --- a/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/ua/naiksoftware/stompclientexample/slice/MainAbilitySlice.java @@ -16,6 +16,8 @@ import ohos.agp.components.Component; import ohos.agp.components.ListContainer; import ohos.agp.components.Text; import ohos.agp.text.Font; +import ohos.agp.window.service.Display; +import ohos.agp.window.service.DisplayManager; import ohos.hiviewdfx.HiLog; import ohos.hiviewdfx.HiLogLabel; import ua.naiksoftware.stomp.Stomp; @@ -42,9 +44,11 @@ import java.util.Locale; public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener { static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, 0x00201, "MainAbilitySlice"); private static final int NUM_1000 = 1000; - private static final int NUM_1900 = 1900; + private static final int NUM_1900 = 1600; private static final int NUM_1700 = 1700; - private static final int NUM_16 = 16; + private static final int NUM_16 = 9; + private static final int NUM_6 = 19; + private static final int NUM_5 = 15; private static final String LOGIN = "login"; private static final String PASSCODE = "passcode"; private SimpleAdapter mAdapter; @@ -60,6 +64,7 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL private Button mBtEchoRest; private Gson mGson = new GsonBuilder().create(); private CompositeDisposable compositeDisposable; + private Display display; @Override public void onStart(Intent intent) { @@ -85,6 +90,7 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL + ":" + RestClient.SERVER_PORT + "/example-endpoint/websocket"); resetSubscriptions(); text.setFont(Font.DEFAULT_BOLD); + display = DisplayManager.getInstance().getDefaultDisplay(this).get(); } private void resetSubscriptions() { @@ -210,6 +216,7 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL toast(throwable.getMessage() + "Message Connect ERROR"); })); } + /** * 重连 */ @@ -225,6 +232,7 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL toast(throwable.getMessage()); }); } + /** * addItem * @@ -234,14 +242,16 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL mDataSet.add(echoModel.getEcho() + " - " + mTimeFormat.format(new Date())); notifyList(mDataSet.size()); if (mDataSet.size() > NUM_16) { - mRecyclerView.setHeight(NUM_1900); + mRecyclerView.setHeight(display.getAttributes().height / NUM_6 * NUM_5); } } + private void notifyList(int pos) { mRecyclerView.scrollBy(0, NUM_1700); mRecyclerView.scrollTo(pos); mAdapter.notifyDataSetItemChanged(pos); } + /** * toast * @@ -276,6 +286,7 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL } super.onStop(); } + /** * debug * @@ -284,4 +295,4 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL private void debug(String msg) { HiLog.error(LABEL, msg, 0); } -} \ No newline at end of file +} -- Gitee From 7f82743da1382bd3b8b8b699c5553481a8f2e4be Mon Sep 17 00:00:00 2001 From: lele <879860859@qq.com> Date: Thu, 27 May 2021 14:32:27 +0800 Subject: [PATCH 8/8] update entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java. --- .../naiksoftware/stompclientexample/SimpleAdapter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java index e0895d3..4bd6c3e 100644 --- a/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java +++ b/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java @@ -5,6 +5,8 @@ import ohos.agp.components.Component; import ohos.agp.components.ComponentContainer; import ohos.agp.components.LayoutScatter; import ohos.agp.components.Text; +import ohos.agp.window.service.Display; +import ohos.agp.window.service.DisplayManager; import ohos.app.Context; import java.util.Collections; @@ -16,9 +18,10 @@ import java.util.List; * @since 2021-04-27 */ public class SimpleAdapter extends BaseItemProvider { + private static int num = 25; private List data; private Context mContext; - + private Display display; /** * 构造函数 @@ -30,6 +33,7 @@ public class SimpleAdapter extends BaseItemProvider { public SimpleAdapter(List list, Context context) { this.data = list; this.mContext = context; + display = DisplayManager.getInstance().getDefaultDisplay(context).get(); } @Override @@ -62,6 +66,7 @@ public class SimpleAdapter extends BaseItemProvider { } else { holder = (ViewHolder) convertComponent.getTag(); } + holder.title.setHeight(display.getAttributes().height / num); holder.title.setText(data.get(position)); return convertComponent; } @@ -74,4 +79,4 @@ public class SimpleAdapter extends BaseItemProvider { private static class ViewHolder { Text title; } -} +} \ No newline at end of file -- Gitee