Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Wire 3.1.0 snapshot feature #215

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.ponycui_home.svgaplayer"
applicationId "com.example.drumge.svgaplayer"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
Expand Down Expand Up @@ -34,3 +34,18 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}


task testGit() {
// testExc("channel_id_test")
}

def testExc(String channelId) {
exec {
workingDir '.'
// commandLine 'git commit -m \'test\''
// commandLine 'git', 'status'
// commandLine 'git', 'commit', '-m', 'test'
commandLine 'git', 'commit', '-am', "${version} ${channelId} 渠道包"
}
}
Binary file added app/src/main/assets/daxiao.svga
Binary file not shown.
Binary file added app/src/main/assets/red_pocket_miss.svga
Binary file not shown.
Binary file added app/src/main/assets/yingbi.svga
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public void onClick(View view) {
}

private void loadAnimation() {
parser.decodeFromAssets(this.randomSample(), new SVGAParser.ParseCompletion() {
parser.decodeFromAssets("roomlist_ranking-2_0.svga", new SVGAParser.ParseCompletion() {
// parser.decodeFromAssets("roomlist_ranking.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity videoItem) {
animationView.setVideoItem(videoItem);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
package com.example.ponycui_home.svgaplayer;

import android.app.Activity;
import android.content.Intent;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAPlayer;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.opensource.svgaplayer.proto.AudioEntity;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import ikxd.cproxy.InnerV2;
import okio.ByteString;

class SampleItem {

Expand All @@ -61,13 +39,52 @@ public class MainActivity extends AppCompatActivity {

ListView listView;
ArrayList<SampleItem> items = new ArrayList();
private byte[] bytes;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setupData();
this.setupListView();
setContentView(listView);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(listView);
setContentView(linearLayout);

Button ser1 = new Button(this);
ser1.setText("序列化");
linearLayout.addView(ser1);
Button ser2 = new Button(this);
ser2.setText("反序列化");
linearLayout.addView(ser2);

ser1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AudioEntity entity = new AudioEntity.Builder().totalTime(33).build();
byte[] payload = entity.encode();
InnerV2 innerV2 = new InnerV2.Builder().payload(ByteString.of(payload)).build();
bytes = innerV2.encode();
Log.i("chenrenzhan-2", "序列化 payload " + payload.length + " , entity" + entity + " , inner2 " + innerV2);
}
});
ser2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InnerV2 innerV2 = null;
try {
innerV2 = InnerV2.ADAPTER.decode(bytes);
AudioEntity entity = AudioEntity.ADAPTER.decode(innerV2.payload);
Log.i("chenrenzhan-2", "反序列化 payload " + innerV2.payload.size() + " , entity" + entity + " , " +
"innerV2" + innerV2);
Log.i("chenrenzhan-2", "反序列化 uri " + innerV2.uri);
Log.i("chenrenzhan-2", "反序列化 startFrame " + entity.startFrame);
} catch (Exception e) {
e.printStackTrace();
Log.i("dd", e.getMessage());
}
}
});
}

void setupData() {
Expand Down
182 changes: 182 additions & 0 deletions app/src/main/java/common/Biz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: common.proto
package common;

import android.os.Parcelable;
import com.squareup.wire.AndroidMessage;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoAdapter;
import com.squareup.wire.WireField;
import com.squareup.wire.internal.Internal;
import java.lang.Long;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.List;
import java.util.Map;
import okio.ByteString;

/**
* BIZ 对应的是Header.biz字段,用于给业务做一些透传信息
* 使用方法:
* 服务器通过biz_actions告诉客户端更新biz信息,客户端将信息保存在内存里面
* 客户端给服务端发包的时候,需要将对应的sname的biz信息填充在biz_infos字段里面
*/
public final class Biz extends AndroidMessage<Biz, Biz.Builder> {
public static final ProtoAdapter<Biz> ADAPTER = ProtoAdapter.newMessageAdapter(Biz.class);

public static final Creator<Biz> CREATOR = AndroidMessage.newCreator(ADAPTER);

private static final long serialVersionUID = 0L;

/**
* see EBizType
*/
@WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#INT64",
label = WireField.Label.REPEATED
)
public final List<Long> types;

/**
* 各列的编号和EBizType保持一致
* 下行包携带,用于给服务端控制客户端的biz信息
*/
@WireField(
tag = 10,
adapter = "common.BizAction#ADAPTER",
label = WireField.Label.REPEATED
)
public final List<BizAction> biz_actions;

/**
* 上行包携带,客户端携带这些信息给对应的sname
*/
@WireField(
tag = 11,
keyAdapter = "com.squareup.wire.ProtoAdapter#STRING",
adapter = "com.squareup.wire.ProtoAdapter#BYTES"
)
public final Map<String, ByteString> biz_infos;

/**
* 一些扩展的字段,上下行都有可能,由业务自行决定怎么用
*/
@WireField(
tag = 12,
keyAdapter = "com.squareup.wire.ProtoAdapter#STRING",
adapter = "com.squareup.wire.ProtoAdapter#BYTES"
)
public final Map<String, ByteString> biz_ext;

public Biz(List<Long> types, List<BizAction> biz_actions, Map<String, ByteString> biz_infos,
Map<String, ByteString> biz_ext) {
this(types, biz_actions, biz_infos, biz_ext, ByteString.EMPTY);
}

public Biz(List<Long> types, List<BizAction> biz_actions, Map<String, ByteString> biz_infos,
Map<String, ByteString> biz_ext, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.types = Internal.immutableCopyOf("types", types);
this.biz_actions = Internal.immutableCopyOf("biz_actions", biz_actions);
this.biz_infos = Internal.immutableCopyOf("biz_infos", biz_infos);
this.biz_ext = Internal.immutableCopyOf("biz_ext", biz_ext);
}

@Override
public Builder newBuilder() {
Builder builder = new Builder();
builder.types = Internal.copyOf(types);
builder.biz_actions = Internal.copyOf(biz_actions);
builder.biz_infos = Internal.copyOf(biz_infos);
builder.biz_ext = Internal.copyOf(biz_ext);
builder.addUnknownFields(unknownFields());
return builder;
}

@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof Biz)) return false;
Biz o = (Biz) other;
return unknownFields().equals(o.unknownFields())
&& types.equals(o.types)
&& biz_actions.equals(o.biz_actions)
&& biz_infos.equals(o.biz_infos)
&& biz_ext.equals(o.biz_ext);
}

@Override
public int hashCode() {
int result = super.hashCode;
if (result == 0) {
result = unknownFields().hashCode();
result = result * 37 + types.hashCode();
result = result * 37 + biz_actions.hashCode();
result = result * 37 + biz_infos.hashCode();
result = result * 37 + biz_ext.hashCode();
super.hashCode = result;
}
return result;
}

public static final class Builder extends Message.Builder<Biz, Builder> {
public List<Long> types;

public List<BizAction> biz_actions;

public Map<String, ByteString> biz_infos;

public Map<String, ByteString> biz_ext;

public Builder() {
types = Internal.newMutableList();
biz_actions = Internal.newMutableList();
biz_infos = Internal.newMutableMap();
biz_ext = Internal.newMutableMap();
}

/**
* see EBizType
*/
public Builder types(List<Long> types) {
Internal.checkElementsNotNull(types);
this.types = types;
return this;
}

/**
* 各列的编号和EBizType保持一致
* 下行包携带,用于给服务端控制客户端的biz信息
*/
public Builder biz_actions(List<BizAction> biz_actions) {
Internal.checkElementsNotNull(biz_actions);
this.biz_actions = biz_actions;
return this;
}

/**
* 上行包携带,客户端携带这些信息给对应的sname
*/
public Builder biz_infos(Map<String, ByteString> biz_infos) {
Internal.checkElementsNotNull(biz_infos);
this.biz_infos = biz_infos;
return this;
}

/**
* 一些扩展的字段,上下行都有可能,由业务自行决定怎么用
*/
public Builder biz_ext(Map<String, ByteString> biz_ext) {
Internal.checkElementsNotNull(biz_ext);
this.biz_ext = biz_ext;
return this;
}

@Override
public Biz build() {
return new Biz(types, biz_actions, biz_infos, biz_ext, super.buildUnknownFields());
}
}
}
Loading