From eb424d24e39bab4a245725f35deab3f234ea0f13 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 13 十二月 2019 10:48:50 +0800
Subject: [PATCH] 2019.12.13
---
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs | 375 ++++++++++++++++++++++-------------------------------
1 files changed, 158 insertions(+), 217 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
index 7b5c669..a0f8318 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
@@ -22,82 +22,26 @@
FrameLayout bottomFrameLayout;
string currentType = string.Empty;
List<Shared.Phone.UserCenter.MemberInfoRes> localAccountList;
- VerticalScrolViewLayout bodyView;
+ VerticalRefreshLayout bodyView;
+ Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj> oldLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>();
#endregion
void ReadDoorLockUserInfo()
{
System.Threading.Tasks.Task.Run(async () =>
{
- Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
try
{
- var getDoorLockInfo = await doorLock.GetDoorlockUserInfoAsync();
- if (getDoorLockInfo != null && getDoorLockInfo.doorLockUserDetailData != null)
+ var list = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockAllAcountUserlist(doorLock);
+ if (oldLocalDoorLockUserList.Count != 0)
{
- var dataList = getDoorLockInfo.doorLockUserDetailData.UserObjList;
- foreach (var doorData in dataList)
+ if (list.Count == 0)
{
- var localDoorLockObj1 = new ZigBee.Device.DoorLock.LocaDoorLockObj()
+ Application.RunOnMainThread(() =>
{
- UserID = doorData.UserId,
- UnlockType = doorData.UserType
- };
- if ((doorLock.localDoorLockUserList.ContainsKey(localDoorLockObj1.UserID)) == false)
- {
- doorLock.localDoorLockUserList.Add(localDoorLockObj1.UserID, localDoorLockObj1);
- }
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+ });
}
-
- // 璇诲彇浜戠闂ㄩ攣璁惧涓殑淇℃伅
- var localDoorLockObj = new ZigBee.Device.DoorLock.GetDoorLockData() { };
-
- foreach (var curAccountObj in doorLock.localAllAccountList)
- {
- if (UserCenterResourse.UserInfo.AuthorityNo != 1)
- {
- localDoorLockObj.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
- localDoorLockObj.IsOtherAccountCtrl = true;
- }
- localDoorLockObj.CloudAccountId = curAccountObj.SubAccountDistributedMark;
- if (doorLock.DeviceAddr != null)
- {
- localDoorLockObj.DoorLockId = doorLock.DeviceAddr + "_" + doorLock.DeviceEpoint;
- }
- var getDoorLockInfoList = await ZigBee.Device.DoorLock.GetDoorLockInfoFromServer("DoorLock/GetDoorLockPager", localDoorLockObj);
- if (getDoorLockInfoList != null)
- {
- foreach (var curDoorLockUser in getDoorLockInfoList.PageData)
- {
- if (doorLock.localDoorLockUserList.ContainsKey(int.Parse(curDoorLockUser.DoorLockLocalUserId)))
- {
- doorLock.localDoorLockUserList.Remove(int.Parse(curDoorLockUser.DoorLockLocalUserId));
- }
- var doorLockObj = new ZigBee.Device.DoorLock.LocaDoorLockObj() { };
- doorLockObj.UserID = int.Parse(curDoorLockUser.DoorLockLocalUserId);
- doorLockObj.UnlockType = curDoorLockUser.OpenLockMode;
- doorLockObj.PrimaryId = curDoorLockUser.Id;
- doorLockObj.EntryTime = curDoorLockUser.EntryTime;
- doorLockObj.UserName = curDoorLockUser.UserIdRemarks;
- doorLockObj.ConnectedAccount = curDoorLockUser.CloudAccountId;
- doorLock.localDoorLockUserList.Add(int.Parse(curDoorLockUser.DoorLockLocalUserId), doorLockObj);
- }
- }
- else
- {
- Application.RunOnMainThread(() =>
- {
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
- });
- }
- }
- }
- else
- {
- Application.RunOnMainThread(() =>
- {
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
- });
}
}
catch { }
@@ -105,7 +49,7 @@
{
Application.RunOnMainThread(() =>
{
- MidFrameLayoutContent();
+ TypeRefresh();
CommonPage.Loading.Hide();
});
}
@@ -117,18 +61,26 @@
/// </summary>
public void Show()
{
+ doorLock.currentUserDisplayMethod = "";
this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.UndistributedUnlockMethod));
this.btnTitleLine.Visible = false;
EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
{
RemoveFromParent();
- this.btnTip.Visible = false;
};
this.btnBack.MouseUpEventHandler += eHandlerBack;
this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
this.MidFrameLayout(this);
-
- ReadDoorLockUserInfo();
+ MidFrameLayoutContent();
+ if (doorLock.localDoorLockUserList.Count == 0)
+ {
+ CommonPage.Loading.Start("Loading...");
+ ReadDoorLockUserInfo();
+ }
+ else
+ {
+ RefreshList();
+ }
}
public void MidFrameLayoutContent()
@@ -146,12 +98,32 @@
Width = Application.GetRealWidth(141 + 100),
Y = Application.GetRealHeight(35),
X = Application.GetRealWidth(812 - 100),
- TextAlignment = TextAlignment.Center,
- Text = Language.StringByID(R.MyInternationalizationString.LockMethod),
+ TextAlignment = TextAlignment.CenterRight,
TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
TextSize = 12,
};
midTopFrameLayout.AddChidren(btnAllMethod);
+ // 绫诲瀷鍖哄垎
+ if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod))
+ {
+ btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
+ }
+ else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock))
+ {
+ btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.PasswordUnlock);
+ }
+ else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock))
+ {
+ btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.FingerprintUnlock);
+ }
+ else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock))
+ {
+ btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock);
+ }
+ else
+ {
+ btnAllMethod.Text = Language.StringByID(R.MyInternationalizationString.AllMethod);
+ }
var btnNext = new Button()
{
@@ -168,18 +140,35 @@
SideslipFramelayout();
};
- bodyView = new VerticalScrolViewLayout()
+ var btnLine = new Button
{
Y = midTopFrameLayout.Bottom,
+ Height = 1,
+ BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
+ };
+ this.midFrameLayout.AddChidren(btnLine);
+
+ bodyView = new VerticalRefreshLayout()
+ {
+ Y = btnLine.Bottom,
+ Height = Application.GetRealHeight(1921 - 184 - 115 - 1),
};
this.midFrameLayout.AddChidren(bodyView);
-
- RefreshList();
+ bodyView.BeginHeaderRefreshingAction += () =>
+ {
+ bodyView.BeginHeaderRefreshing();
+ ReadDoorLockUserInfo();
+ bodyView.EndHeaderRefreshing();
+ };
}
- void RefreshList()
+ void RefreshList(int unlockMethod = -1)
{
+ this.midFrameLayout.RemoveAll();
+ MidFrameLayoutContent();
bodyView.RemoveAll();
+ var curLocalDoorLockUserList = new Dictionary<int, DoorLockCommonInfo.LocaDoorLockObj>();
+
foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
{
var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
@@ -191,12 +180,43 @@
{
continue;
}
- var RowView = new FrameLayout()
+ curLocalDoorLockUserList.Add(curUserId, curDoorLockUser);
+ }
+
+ int i = 0;
+ foreach (var curUserId in curLocalDoorLockUserList.Keys)
+ {
+ oldLocalDoorLockUserList = curLocalDoorLockUserList;
+ var curDoorLockUser = curLocalDoorLockUserList[curUserId];
+ switch (unlockMethod)
{
- Height = Application.GetRealHeight(161),
+ case 0:
+ if (curDoorLockUser.UnlockType != unlockMethod)
+ {
+ continue;
+ }
+ break;
+ case 3:
+ if (curDoorLockUser.UnlockType != unlockMethod)
+ {
+ continue;
+ }
+ break;
+ case 15:
+ if (curDoorLockUser.UnlockType != unlockMethod)
+ {
+ continue;
+ }
+ break;
+ default:
+ break;
+ }
+ var rowFrameLayout = new FrameLayout()
+ {
+ Height = Application.GetRealHeight(127 + 23),
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
};
- bodyView.AddChidren(RowView);
+ bodyView.AddChidren(rowFrameLayout);
var btnDistributeUnlockIconFrameLayout = new FrameLayout()
{
@@ -205,7 +225,7 @@
X = Application.GetRealWidth(58),
Y = Application.GetRealHeight(43),
};
- RowView.AddChidren(btnDistributeUnlockIconFrameLayout);
+ rowFrameLayout.AddChidren(btnDistributeUnlockIconFrameLayout);
var btnDistributeUnlockIcon = new Button()
{
@@ -224,19 +244,24 @@
TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
Gravity = Gravity.CenterVertical,
};
- RowView.AddChidren(btnText);
+ rowFrameLayout.AddChidren(btnText);
var line2 = new Button()
{
- Y = RowView.Height - 1,
+ Y = rowFrameLayout.Height - 1,
X = Application.GetRealWidth(58),
Width = Application.GetRealWidth(965),
Height = 1,
BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
};
- RowView.AddChidren(line2);
+ rowFrameLayout.AddChidren(line2);
#region 鏁版嵁澶勭悊
+ int currentIndex = i;
+ if (currentIndex == curLocalDoorLockUserList.Keys.Count - 1)
+ {
+ line2.Visible = false;
+ }
switch (curDoorLockUser.UnlockType)
{
case 0:
@@ -277,9 +302,10 @@
};
btnDistributeUnlockIcon.MouseUpEventHandler += eHandler;
btnDistributeUnlockIconFrameLayout.MouseUpEventHandler += eHandler;
- RowView.MouseUpEventHandler += eHandler;
+ rowFrameLayout.MouseUpEventHandler += eHandler;
btnText.MouseUpEventHandler += eHandler;
#endregion
+ i++;
}
}
@@ -441,7 +467,7 @@
if (doorLock.IsFreezeAccount[currentAccount.SubAccountDistributedMark] == true)
{
- new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+ new Tip() { MaxWidth = 150, Text = btnUserName.Text + Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
return;
}
@@ -537,35 +563,42 @@
addLockInfo.EntryTime = curDoorLockUser.EntryTime;
var result = await ZigBee.Device.DoorLock.SendDoorLockToServer("DoorLock/AddDoorLock", addLockInfo);
- if (result != null && result.StateCode == "Success")
+ if (result != null)
{
- //瀛樿处鎴蜂俊鎭�
- //var resultList1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalAccountlist(doorLock, curAccountId);
- //瀛橀棬閿佷俊鎭�
- var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId);
- var uList = new List<int> { };
- if (resultList != null)
+ if (result.StateCode == "Success")
{
- foreach (var a in resultList.Keys)
+ //瀛橀棬閿佷俊鎭�
+ var resultList = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetCloudLocalDoorLocklist(doorLock, curAccountId);
+ var uList = new List<int> { };
+ if (resultList != null)
{
- uList.Add(a);
+ foreach (var a in resultList.Keys)
+ {
+ uList.Add(a);
+ }
}
- }
- var d = uList.Find((value) => { return value == doorLock.doorLockProgrammingEventNotificationCommand.UserID; });
- if (d != null)
- {
- RefreshList();
- flMain.RemoveFromParent();
- bottomFrameLayout.RemoveAll();
+ var d = uList.Find((value) => { return value == curDoorLockUser.UserID; });
+ if (d != null)
+ {
+ TypeRefresh();
+ flMain.RemoveFromParent();
+ bottomFrameLayout.RemoveAll();
+ }
+ else
+ {
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+ }
}
else
{
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+ flMain.RemoveFromParent();
+ bottomFrameLayout.RemoveAll();
}
}
else
{
- new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
+ new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CloudServerResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
flMain.RemoveFromParent();
bottomFrameLayout.RemoveAll();
}
@@ -652,24 +685,7 @@
doorLock.currentUserDisplayMethod = btnMethodText.Text;
btnAllMethod.IsSelected = true;
oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-
- // 绫诲瀷鍖哄垎
- if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod))
- {
- RefreshList();
- }
- if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock))
- {
- DisplayByType(0);
- }
- if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock))
- {
- DisplayByType(15);
- }
- if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock))
- {
- DisplayByType(3);
- }
+ TypeRefresh();
}
dialog.Close();
};
@@ -701,6 +717,13 @@
break;
}
+ if (doorLock.currentUserDisplayMethod == "" && i == 0)
+ {
+ btnAllMethod.IsSelected = true;
+ btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+ oldbutton = btnAllMethod;
+ oldbuttonText = btnMethodText;
+ }
if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.AllMethod) && i == 0)
{
btnAllMethod.IsSelected = true;
@@ -732,106 +755,24 @@
}
}
- // 閫氳繃绫诲瀷绛涢�夋樉绀�
- void DisplayByType(int unlockMethod)
+ //绫诲瀷鍖哄垎
+ void TypeRefresh()
{
- bodyView.RemoveAll();
- foreach (var curUserId in doorLock.localDoorLockUserList.Keys)
+ if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.PasswordUnlock))
{
- var curDoorLockUser = doorLock.localDoorLockUserList[curUserId];
- if (curDoorLockUser.ConnectedAccount != "" || curDoorLockUser.UnlockType != unlockMethod)
- {
- continue;
- }
- var RowView = new FrameLayout()
- {
- Height = Application.GetRealHeight(161),
- BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
- };
- bodyView.AddChidren(RowView);
-
- var btnDistributeUnlockIconFrameLayout = new FrameLayout()
- {
- Height = Application.GetRealHeight(84),
- Width = Application.GetRealWidth(84),
- X = Application.GetRealWidth(58),
- Y = Application.GetRealHeight(43),
- };
- RowView.AddChidren(btnDistributeUnlockIconFrameLayout);
-
- var btnDistributeUnlockIcon = new Button()
- {
- Height = Application.GetRealHeight(84),
- Width = Application.GetRealWidth(84),
- UnSelectedImagePath = "DoorLock/DistributeUnlockIcon.png",
- };
- btnDistributeUnlockIconFrameLayout.AddChidren(btnDistributeUnlockIcon);
-
- var btnText = new Button()
- {
- X = Application.GetRealWidth(176),
- Width = Application.GetRealWidth(300),
- Height = Application.GetRealHeight(300),
- TextAlignment = TextAlignment.CenterLeft,
- TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
- Gravity = Gravity.CenterVertical,
- };
- RowView.AddChidren(btnText);
-
- var line2 = new Button()
- {
- Y = RowView.Height - 1,
- X = Application.GetRealWidth(58),
- Width = Application.GetRealWidth(965),
- Height = 1,
- BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
- };
- RowView.AddChidren(line2);
-
- #region 鏁版嵁澶勭悊
- switch (curDoorLockUser.UnlockType)
- {
- case 0:
- if (curDoorLockUser.UserName != "")
- {
- btnText.Text = curDoorLockUser.UserName;
- }
- else
- {
- btnText.Text = Language.StringByID(R.MyInternationalizationString.Password) + "ID" + curDoorLockUser.UserID;
- }
- break;
- case 3:
- if (curDoorLockUser.UserName != "")
- {
- btnText.Text = curDoorLockUser.UserName;
- }
- else
- {
- btnText.Text = Language.StringByID(R.MyInternationalizationString.IcCard) + "ID" + curDoorLockUser.UserID;
- }
- break;
- case 15:
- if (curDoorLockUser.UserName != "")
- {
- btnText.Text = curDoorLockUser.UserName;
- }
- else
- {
- btnText.Text = Language.StringByID(R.MyInternationalizationString.Fingerprint) + "ID" + +curDoorLockUser.UserID;
- }
- break;
- }
-
- EventHandler<MouseEventArgs> eHandler = (sender, e) =>
- {
- MatchUsersFrameLayout(curDoorLockUser);
- };
- btnDistributeUnlockIcon.MouseUpEventHandler += eHandler;
- btnDistributeUnlockIconFrameLayout.MouseUpEventHandler += eHandler;
- RowView.MouseUpEventHandler += eHandler;
- btnText.MouseUpEventHandler += eHandler;
- #endregion
+ RefreshList(0);
+ }
+ else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.FingerprintUnlock))
+ {
+ RefreshList(15);
+ }
+ else if (doorLock.currentUserDisplayMethod == Language.StringByID(R.MyInternationalizationString.ProximithCardUnlock))
+ {
+ RefreshList(3);
+ }
+ else
+ {
+ RefreshList();
}
}
#region 鈼� 鎺ュ彛瀹炵幇__________________________
--
Gitblit v1.8.0