浏览代码

update

/main
siyao 3 年前
当前提交
d518c8c8
共有 13 个文件被更改,包括 106 次插入53 次删除
  1. 20
      Assets/HuaweiService/Android/huawei-cloudfunction.aar
  2. 25
      Assets/HuaweiService/Editor/cloud_db/GenCode.cs
  3. 2
      Assets/HuaweiService/cloud_db/CloudDBZone.cs
  4. 12
      Assets/HuaweiService/cloud_db/ObjectTypeInfo.cs
  5. 21
      Assets/HuaweiService/cloud_db/OnSnapshotListener.cs
  6. 13
      Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Plugins/BookInfo.java
  7. 17
      Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Plugins/ObjectTypeInfoHelper.java
  8. 7
      Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBSnapshotListener.cs
  9. 2
      Assets/Plugins/Android/mainTemplate.gradle
  10. 16
      Assets/HuaweiService/cloud_db/DBListener.cs
  11. 13
      Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/model/ObjectTypeInfoHelper.cs
  12. 11
      Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBListener.cs.meta
  13. 0
      /Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBSnapshotListener.cs

20
Assets/HuaweiService/Android/huawei-cloudfunction.aar


AR.txtPK
A���2uAndroidManifest.xmluR�n�0 ���v[ �����ԥC[t X���A��4_�q�N8�w�Ӊ��W�����4lY.X�F�V�C�b�+�Yg�#��C���W`Zge۰.�8��C �������ܡ�S�ey*���eሲ�F�S��F�d⌛H���Ŷ���9{����8��"�k RR��9��
�*_9$"�.JR\�^��R��� GjXp琁ذ�����;��9T�7�����lS:�3���l4��=��8��|$�.����� ��ptpRȟ�>���9�����}��~&���h���cY�������7d5����PK
A���=c� classes.jar �ffaEE&��ϟed`8���� M����(M,O��/��,��O+�K.����w*��Iq��K�L�K�I,.��t7ﲃ@��'��
3���LeZ�91GKo��G*!�j+'�U ����55[�8�Ljnq�V�媝Gx�w��ﳝ�q�}�:��Vq6��%ɗ$��N<.��oj��d��� �[x����j�䇉{?��� U��}tˤjE;�����;>�Km=�v���cJ������6=��~�هO6,}lyPfK�߲��9%�{�M;{!�����"�B<2o��j��D�a�PX�� �"�I'J����s���Ǝ�U�'����i�N<����*S���\;�%n͡eBO�o~������y��]��|br~�W|�����s��S� �w^ 0 <����*��~��g�J�^l������V{��3˿^W�O�q?��{C�^�5�]s �,��Q)�b2�8r�?�9�4�Ua}W&7�����HbCA�c�k�޿�^��9{�z��i�� y��k|���i�~ʧ�����L(��=3����{vXP����|���~ I��eo�?���ӂ�Uv���c @I+�#_��XV}��� �/J,(H-����laG��z9���m�,Pڷ��Ъ'�Y'~0� ^|�[���w�v���>�#�Qx���g�i�:,8{��N�����͹���_6���V�
:sx����XY�u�DDmޫ
1g���VW����O9�P5�� �1[doNjq�O�d̽���w������,O�>�9��w�˛YwK�����q������j���E&�r.���I���3_�}<9yj�S]����'wDoR2�wC�T�%���>���}��r;�z碩�%�D�b]��{ӫ�{�;S�R�i�������"g�86����sШ ��69��Fv�ݘ@A;�kM�7:k{;K��ߧ0׏)3�U���6z����g���
{��a:�޻M����^u��y�����uۢJ�zû�����rl��07�����f��`y���NXV�ʄJ����3Z_2��v�z͋�r�L'��;m�Ō湞���k]n���ƾ�Ξ
��i&4�Nٽ�:��<y��6�{o��Q���[>�4Uu¬������=��i͒UK��h\������V��b����b[R��ڴ��IV4t~�ު�Gk�|�^X�ȱT��9f���}����)?w@��@��Bs��^��f���w���*o��<�e{��Ҍ�+W�볲z�5�m�ku%��"�k�C�'�Z<;Xֶ�K�b��n?|��E��.�r��+�����y�yŸu�N��/�u��H��s0����=��L~���S�7/�)��M�Q�/�����E/��������7#�L�bL$gt���aT@B�������ۀ�&+�PK
A���� classes.jar��y4z���4�Œ��0��2�.J�R���XB�1Cd̂�Y�PF3"����Rٷd�e-$�X�dIԸ�y���s;�����������{�����=�-�w`G` o� � w^�_���� �y�BX<��C�0$�;���8ed�M$y�y�c�"���6�^��d��dR��}X�
���k���|��I��{��&����I������B�.���J�u(���-u���*N�Vҷ�ծO��K�7��׺~8��.R#��c�>��b��R�| �r�{��"a8�^ݺegS�y�����O��SvMkuf��.A��\[�n�Hfe  ���h���� E�]���YUϘ-�.i7��i����˴�47�����w ���8Ʋ9��7��
M�� c�O��K?v��³�{�OV���b��p����ż�|&.�tS��ѕ†Z���#�����GA��%������8Q�t-����b��#��(��Y��r���\�듾rxI�:R�ͫ�-;����ƥ���� ���
�$�Tp�Żd��+�,���T�8-LP\�OK�Tи�R��>��n� ��x�Asbm
�dzX���s��i���r ��*�h���Ma�����5�������4o`���<u��\Wٻj
���r�\�<zYa\��]l#��>^�Z��k�ٛa�T�R&G�~�4�_������M��o�#�u�-�T7��ج�Ԉve� =��c�aC5]<��$U���d?,ɛ��0"{�q�?O���"1�1�C�>j�T-����r��ls:��z�� ��"�� -�P1�T���M�e��=�$t{��Y�녴+��A�z�傱�׀�T �@p����қĄl4uL��q6ndE
�,��Wŏc����u���/�D2B�����?5� �Ub�I��Q��l2h����%�3�g�
ٓ�_I����RrOJ��NI����oX�C��iڑ��ZrS�ǝDܠ�ց�=t�o��e釾�E��)�/�p��?�/q�'zC!�!��󫉻����RD���~N��[�b^�����O@[\p)�d?»�z��F��jڽ����l���3�ɣ=�Uw#**O��@{���!��iK�V��*�\D�C�*\"{���s>�D�;���z�OXB�
������PAm*.�s;���'v��e�V.��k-��TV�~7(X���72=TY^��Ky$A谾ᮼ"󶠙 ��=�\[&��DE6�y�q�7>��0���1������=�c#f��Uǻ$���M��.���<i>��Fz�a�e.]�G=+����f����-�+S �::Gʎ~}O��:Z�}��&�s�OC�l�i9o�b�D�(2��ō!-`��E� �^����sI�Y�2�����<��jN���b��`����f�h&�J�r�{{i�t�[�Mi�� �(ָ;cˍ�%3SW���k��-� 1�j�S�у-�.E�H��j+፪��.�-��G5�a�e��J�9 ��e���(�wyoX��બ$�͵�.B�M�ϵs�� �B�C�x���u��ND��@8|(:����Yʀ���˸�����>GDg����m '�O�9���DUh"y�9���Zy7$Kî�#o>�(T٘j0�V��m�
��%��a�Wu�D��#H'�'Q�4x �jO��:i~��[|T¢uQ�G��[Q��}��Z5v��Ǿ��?By��z-�W���*:W�⻈��'{��`,?"�/�Kݹ(7#'�Q��c���dr��璅\W�����8(E?���s����2*�̖���&��qh��(�W�rM��R�����"��7�O�m3�
��`#K���^���\���%f�k�����@��1�-z+匌y5�%��4ٰ0���l ��Xwrv�O�OlE�NŠ-R"]ψuQp��[cӷ;��7M5L:�L��q�W�`��� !�a�²��DR��۶( ��M��ػ~�"?7�9��V��R���?��ԯn�(>�_�xwdg���UPK
A���=c� ���classes.jarPK�
A���� ���classes.jarPK��

25
Assets/HuaweiService/Editor/cloud_db/GenCode.cs


using (StreamReader r = new StreamReader (ObjectTypeFilePath)) {
string json = r.ReadToEnd ();
template = JsonConvert.DeserializeObject<ClassTemplate> (json);
GenerateObjectTypeInfoHelper ();
foreach (ObjectType objectType in template.objectTypes) {
GenerateModels (objectType);
}

}
}
public void GenerateObjectTypeInfoHelper () {
string objectTypeName = "ObjectTypeInfoHelper";
string path = ExportFileDir + $"/{objectTypeName}.cs";
if (System.IO.File.Exists (path) == false) { // do not overwrite
try {
using (StreamWriter fs = new StreamWriter (path)) {
GenerateHeader (fs);
fs.WriteLine ($"\tpublic class {objectTypeName}_Data : IHmsBaseClass" + " {");
fs.WriteLine ($"\t\tpublic string name => \"{PackageName}.{objectTypeName}\";");
fs.WriteLine ("\t}");
fs.WriteLine ($"\tpublic class {objectTypeName} : HmsClass<{objectTypeName}_Data>" + " {");
GenerateInitializer (fs, objectTypeName);
fs.WriteLine ($"\t\tpublic static ObjectTypeInfo getObjectTypeInfo() {{");
fs.WriteLine ($"\t\treturn CallStatic<ObjectTypeInfo>(\"getObjectTypeInfo\");");
fs.WriteLine ("\t\t}");
fs.WriteLine ("\t}");
fs.WriteLine ("}");
}
} catch (System.Exception e) {
Debug.Log ("Generate Error: " + e.Message);
}
}
}

2
Assets/HuaweiService/cloud_db/CloudDBZone.cs


return Call<Task>("runTransaction", arg0);
}
public ListenerHandler subscribeSnapshot(CloudDBZoneQuery arg0, CloudDBZoneQuery.CloudDBZoneQueryPolicy arg1, OnSnapshotListener arg2) {
return Call<ListenerHandler>("subscribeSnapshot", arg0, arg1, arg2);
return Call<ListenerHandler>("subscribeSnapshot", arg0, arg1, new DBListener(arg2));
}
}
}

12
Assets/HuaweiService/cloud_db/ObjectTypeInfo.cs


{
public ObjectTypeInfo (): base() { }
}
public class ObjectTypeInfoHelper_Data : IHmsBaseClass{
public string name => "com.huawei.agc.clouddb.quickstart.model.ObjectTypeInfoHelper";
}
public class ObjectTypeInfoHelper :HmsClass<ObjectTypeInfoHelper_Data>
{
public ObjectTypeInfoHelper (): base() { }
public static ObjectTypeInfo getObjectTypeInfo() {
return CallStatic<ObjectTypeInfo>("getObjectTypeInfo");
}
}
}

21
Assets/HuaweiService/cloud_db/OnSnapshotListener.cs


using System.Collections.Generic;
using HuaweiServiceDemo;
using UnityEngine;
namespace HuaweiService.CloudDB {

public virtual void onSnapshot (CloudDBZoneSnapshot arg0, AGConnectCloudDBException arg1) {
Call ("onSnapshot", arg0, arg1);
}
public void onSnapshot(AndroidJavaObject arg0, AndroidJavaObject arg1) {
onSnapshot(HmsUtil.GetHmsBase<CloudDBZoneSnapshot>(arg0),
HmsUtil.GetHmsBase<AGConnectCloudDBException>(arg1));
public void onSnapshot (AndroidJavaObject arg0, AndroidJavaObject arg1) {
onSnapshot (HmsUtil.GetHmsBase<CloudDBZoneSnapshot> (arg0),
HmsUtil.GetHmsBase<AGConnectCloudDBException> (arg1));
public class OnSnapshotListener<T> : OnSnapshotListener where T : IDatabaseModel, new(){
public class OnSnapshotListener<T> : OnSnapshotListener where T : IDatabaseModel, new () {
public void onSnapshot(AndroidJavaObject arg0, AndroidJavaObject arg1) {
onSnapshot(HmsUtil.GetHmsBase<CloudDBZoneSnapshot<T>>(arg0),
HmsUtil.GetHmsBase<AGConnectCloudDBException>(arg1));
public void onSnapshot (AndroidJavaObject arg0, AndroidJavaObject arg1) {
string msg = "";
int code = 0;
if (arg1 != null) {
msg = arg1.Call<string> ("getMessage");
code = arg1.Call<int> ("getCode");
}
onSnapshot (HmsUtil.GetHmsBase<CloudDBZoneSnapshot<T>> (arg0),
new AGConnectCloudDBException (msg, code));
}
}

13
Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Plugins/BookInfo.java


import com.huawei.agconnect.cloud.database.annotations.DefaultValue;
import com.huawei.agconnect.cloud.database.Text;
import com.huawei.agconnect.cloud.database.annotations.NotNull;
import com.huawei.agconnect.cloud.database.annotations.IsIndex;
import com.huawei.agconnect.cloud.database.annotations.PrimaryKey;
import com.huawei.agconnect.cloud.database.annotations.Indexes;
import com.huawei.agconnect.cloud.database.annotations.PrimaryKeys;
import java.util.Date;

* @since 2020-12-04
* @since 2021-01-28
@PrimaryKeys({"id"})
@Indexes({"bookName:bookName"})
@PrimaryKey
@IsIndex(indexName = "bookName")
private String bookName;
private String author;

private Boolean shadowFlag;
public BookInfo() {
super();
super(BookInfo.class);
public void setId(Integer id) {
this.id = id;
}

17
Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Plugins/ObjectTypeInfoHelper.java


*/
package com.huawei.agc.clouddb.quickstart.model;
import com.huawei.agconnect.cloud.database.CloudDBZoneObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
* @since 2020-12-04
* @since 2021-01-28
public class ObjectTypeInfoHelper {
private final static int FORMAT_VERSION = 1;
private final static int OBJECT_TYPE_VERSION = 6;
public final class ObjectTypeInfoHelper {
private final static int FORMAT_VERSION = 2;
private final static int OBJECT_TYPE_VERSION = 8;
objectTypeInfo.setObjectTypes(Arrays.asList(BookInfo.class));
List<Class<? extends CloudDBZoneObject>> objectTypeList = new ArrayList<>();
Collections.addAll(objectTypeList, BookInfo.class);
objectTypeInfo.setObjectTypes(objectTypeList);
return objectTypeInfo;
}
}

7
Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBSnapshotListener.cs


using UnityEngine;
namespace HuaweiServiceDemo {
public delegate void SnapShotCb<T> (CloudDBZoneSnapshot<T> arg0, AGConnectCloudDBException arg1) where T : IDatabaseModel, new();
public delegate void SnapShotCb<T> (CloudDBZoneSnapshot<T> arg0, AGConnectCloudDBException arg1) where T : IDatabaseModel, new ();
public class DBSnapshotListener<T> : OnSnapshotListener<T> where T : IDatabaseModel, new(){
public class DBSnapshotListener<T> : OnSnapshotListener<T> where T : IDatabaseModel, new () {
private SnapShotCb<T> cb;
public DBSnapshotListener (SnapShotCb<T> cb) {

TestTip.Inst.ShowText ("OnSnapshot success.");
var exception = new AGConnectCloudDBException();
exception.obj = arg1.obj;
cb.Invoke (arg0, arg1);
}
}

2
Assets/Plugins/Android/mainTemplate.gradle


implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
// clouddb
implementation 'com.huawei.agconnect:agconnect-database:1.2.2.301'
implementation 'com.huawei.agconnect:agconnect-database:1.2.3.301'
**DEPS**}
android {

16
Assets/HuaweiService/cloud_db/DBListener.cs


using System.Collections.Generic;
using HuaweiServiceDemo;
using UnityEngine;
namespace HuaweiService.CloudDB {
public class DBListener_Data : IHmsBaseClass {
public string name => "com.huawei.unity.cloud.database.DBListener";
}
public class DBListener : HmsClass<DBListener_Data> {
public DBListener (OnSnapshotListener arg0) : base (arg0) { }
}
public class DBListener<T> : DBListener where T : IDatabaseModel, new () {
public DBListener (DBSnapshotListener<T> arg0) : base (arg0) { }
}
}

13
Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/model/ObjectTypeInfoHelper.cs


using HuaweiService;
using HuaweiService.CloudDB;
namespace HuaweiServiceDemo {
public class ObjectTypeInfoHelper_Data : IHmsBaseClass {
public string name => "com.huawei.agc.clouddb.quickstart.model.ObjectTypeInfoHelper";
}
public class ObjectTypeInfoHelper : HmsClass<ObjectTypeInfoHelper_Data> {
public ObjectTypeInfoHelper () : base () { }
public static ObjectTypeInfo getObjectTypeInfo() {
return CallStatic<ObjectTypeInfo>("getObjectTypeInfo");
}
}
}

11
Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBListener.cs.meta


fileFormatVersion: 2
guid: 2780fc05a9fd64fbe9a9c53bef015a36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

/Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBListener.cs → /Assets/HuaweiServiceDemo/HuaweiCloudDBDemo/Scripts/DBSnapshotListener.cs

正在加载...
取消
保存