Skip to content

Commit

Permalink
更新内容动态长度
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxudong committed May 13, 2020
1 parent e19a347 commit b3f3682
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions seriallibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 5
versionName "1.2"
versionCode 6
versionName "1.2.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ private static void parseFieldParameter(byte[] message, Object object, Field fie
byte[] value = rules.value();
boolean decode = rules.decode();


if (end <= -100) {
end = message.length + 100 + end;
}

int length = end - begin;

if (length <= 0 || message.length < end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
// 开始字节
int begin() default 0;

// 结束字节
// 结束字节 若结果内容是-100代表到结尾 依次减少代表从当前末尾为减少n个字节
// 例如 byte[] {0x11,0x22,0x33,0x44}
// -100 代表都需要
// -101 代表只需要3个
int end() default 0;

// 没有数据默认填充数据
Expand Down

0 comments on commit b3f3682

Please sign in to comment.