diff --git a/README.md b/README.md index f00d2efa49863b629792ca74ccc17bb2628e98a4..e50f8ccd918b5bc4f1e3f45dbdf2a82f713f1389 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,12 @@ #### 安装教程 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/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") #### 使用说明 @@ -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/SimpleAdapter.java b/entry/src/main/java/ua/naiksoftware/stompclientexample/SimpleAdapter.java index e0895d3c6699801f2083d57e884611bf43a847cd..4bd6c3e7ef275990bb540c5970ad87c95aa80e02 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 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 37963975decb0df45a3626d273e1254fb7d1b9bb..68f4cba294c578607ad54ad2ca8c2b66be9e8663 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 d99a248ea781d2e9696a1e182db223fc4b810f84..842082ddd29f46febd7b8432fabe673e95bc0b10 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 f319bea92c8d4bf6d3050e7508e6472f7f425094..3d4c9bbfdcf0961e5738af1969173c4fde9cd282 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,6 +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 = 1600; + private static final int NUM_1700 = 1700; + 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; @@ -57,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) { @@ -82,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() { @@ -208,7 +217,6 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL })); } - /** * 重连 */ @@ -233,11 +241,15 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL private void addItem(EchoModel echoModel) { mDataSet.add(echoModel.getEcho() + " - " + mTimeFormat.format(new Date())); notifyList(mDataSet.size()); + if (mDataSet.size() > NUM_16) { + mRecyclerView.setHeight(display.getAttributes().height / NUM_6 * NUM_5); + } } private void notifyList(int pos) { + mRecyclerView.scrollBy(0, NUM_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 826f9c88e72281f0f43444ba28b0aab997b4d1d8..f56ee7f1ddcec2f977dab4a1df17b0cdfadeea10 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/gradle.properties b/gradle.properties deleted file mode 100644 index 0daf1830fbdef07e50a44d74210c8c82f1b66278..0000000000000000000000000000000000000000 --- 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 diff --git a/gradlew b/gradlew deleted file mode 100755 index 2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3..0000000000000000000000000000000000000000 --- 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" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d..0000000000000000000000000000000000000000 --- 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 diff --git a/lib/src/main/java/ua/naiksoftware/stomp/HeartBeatTask.java b/lib/src/main/java/ua/naiksoftware/stomp/HeartBeatTask.java index 1c7cc42ffccb4fd0c15880b3e4fb4357503f5075..3fd6b03204968a4f0e23d50ec2172999c431c296 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 1694989871fc706bad99f31b8a26d81afa5836f1..fc28a090cb9f644a5f71b70a6da445c48237298f 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