Commit 9680f33b authored by fallenstardust's avatar fallenstardust

将在线备份排序在回调时执行,使得各处调用保持统一

parent 2a9ff9ce
package cn.garymb.ygomobile.ui.cards.deck_square; package cn.garymb.ygomobile.ui.cards.deck_square;
import static cn.garymb.ygomobile.ui.cards.DeckManagerFragment.getOriginalData;
import static cn.garymb.ygomobile.ui.cards.DeckManagerFragment.originalData; import static cn.garymb.ygomobile.ui.cards.DeckManagerFragment.originalData;
import static cn.garymb.ygomobile.ui.cards.deck_square.DeckSquareFileUtil.toDeckItemList; import static cn.garymb.ygomobile.ui.cards.deck_square.DeckSquareFileUtil.toDeckItemList;
...@@ -240,7 +241,7 @@ public class DeckSquareApiUtil { ...@@ -240,7 +241,7 @@ public class DeckSquareApiUtil {
if (deckIdList == null) { if (deckIdList == null) {
return null; return null;
} else { } else {
LogUtil.i(TAG,"requestIdAndPushNewDecks deckIdList"+ deckIdList); LogUtil.i(TAG, "requestIdAndPushNewDecks deckIdList" + deckIdList);
} }
return pushDecks(deckDataList, loginToken, deckIdList); return pushDecks(deckDataList, loginToken, deckIdList);
...@@ -275,7 +276,7 @@ public class DeckSquareApiUtil { ...@@ -275,7 +276,7 @@ public class DeckSquareApiUtil {
deckContent = DeckSquareFileUtil.setDeckId(item.getDeckPath(), loginToken.getUserId(), item.getDeckId()); deckContent = DeckSquareFileUtil.setDeckId(item.getDeckPath(), loginToken.getUserId(), item.getDeckId());
} }
data.setDeckYdk(deckContent); data.setDeckYdk(deckContent);
LogUtil.w(TAG, "syncMyDecks *要上传的* 本地卡组: \n是否删除?: " + data.isDelete() + "\n卡组分类:"+data.getDeckType() +"\n卡组名称: " + data.getDeckName()+"\n封面id: "+data.getDeckCoverCard1()+"\n卡组id: "+ data.getDeckId()); LogUtil.w(TAG, "syncMyDecks *要上传的* 本地卡组: \n是否删除?: " + data.isDelete() + "\n卡组分类:" + data.getDeckType() + "\n卡组名称: " + data.getDeckName() + "\n封面id: " + data.getDeckCoverCard1() + "\n卡组id: " + data.getDeckId());
dataList.add(data); dataList.add(data);
} }
return pushMultiDecks(dataList, loginToken); return pushMultiDecks(dataList, loginToken);
...@@ -470,7 +471,7 @@ public class DeckSquareApiUtil { ...@@ -470,7 +471,7 @@ public class DeckSquareApiUtil {
} }
// 剩余的在线卡组都是新卡组(云端独有,需要下载) // 剩余的在线卡组都是新卡组(云端独有,需要下载)
LogUtil.i(TAG,"看看剩余onlineDecks:"+onlineDecks); LogUtil.i(TAG, "看看剩余onlineDecks:" + onlineDecks);
for (MyOnlineDeckDetail onlineDeck : onlineDecks) { for (MyOnlineDeckDetail onlineDeck : onlineDecks) {
LogUtil.d(TAG, "synchronizeDecks +要下载的 云备份卡组: \n卡组分类:" + onlineDeck.getDeckType() + "\n卡组名:" + onlineDeck.getDeckName() + "\n卡组id:" + onlineDeck.getDeckId()); LogUtil.d(TAG, "synchronizeDecks +要下载的 云备份卡组: \n卡组分类:" + onlineDeck.getDeckType() + "\n卡组名:" + onlineDeck.getDeckName() + "\n卡组id:" + onlineDeck.getDeckId());
// 确保文件名包含.ydk扩展名 // 确保文件名包含.ydk扩展名
...@@ -481,7 +482,7 @@ public class DeckSquareApiUtil { ...@@ -481,7 +482,7 @@ public class DeckSquareApiUtil {
String fileFullPath = AppsSettings.get().getDeckDir() + "/" + fileName; String fileFullPath = AppsSettings.get().getDeckDir() + "/" + fileName;
if (!onlineDeck.getDeckType().equals("")) if (!onlineDeck.getDeckType().equals(""))
fileFullPath = AppsSettings.get().getDeckDir() + "/" + onlineDeck.getDeckType()+ "/" + fileName; fileFullPath = AppsSettings.get().getDeckDir() + "/" + onlineDeck.getDeckType() + "/" + fileName;
// 保存在线卡组到本地 // 保存在线卡组到本地
boolean saved = DeckSquareFileUtil.saveFileToPath(fileFullPath, onlineDeck.getDeckYdk(), onlineDeck.getDeckUpdateDate()); boolean saved = DeckSquareFileUtil.saveFileToPath(fileFullPath, onlineDeck.getDeckYdk(), onlineDeck.getDeckUpdateDate());
...@@ -500,7 +501,7 @@ public class DeckSquareApiUtil { ...@@ -500,7 +501,7 @@ public class DeckSquareApiUtil {
LogUtil.w(TAG, "+上传新增的 本地卡组newPushDecks: " + newPushDecks); LogUtil.w(TAG, "+上传新增的 本地卡组newPushDecks: " + newPushDecks);
if (!newPushDecks.isEmpty()) { if (!newPushDecks.isEmpty()) {
PushMultiResponse result = requestIdAndPushNewDecks(newPushDecks, loginToken); PushMultiResponse result = requestIdAndPushNewDecks(newPushDecks, loginToken);
LogUtil.w(TAG, "上传结果数:"+ result.getData()); LogUtil.w(TAG, "上传结果数:" + result.getData());
} }
} }
......
...@@ -72,17 +72,6 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyOnlineDeckDetail, Base ...@@ -72,17 +72,6 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyOnlineDeckDetail, Base
LogUtil.i(TAG, "load mycard from server failed:" + e); LogUtil.i(TAG, "load mycard from server failed:" + e);
}).done((serverDecks) -> { }).done((serverDecks) -> {
if (serverDecks != null) {//将服务端的卡组也放到缓存中 if (serverDecks != null) {//将服务端的卡组也放到缓存中
//根据deckType排序,提高观感
serverDecks.sort((o1, o2) -> {
String type1 = o1.getDeckType();
String type2 = o2.getDeckType();
if (type1 == null && type2 == null) return 0;
if (type1 == null) return 1;
if (type2 == null) return -1;
return type1.compareTo(type2);
});
DeckManagerFragment.getOriginalData().clear();//虽然判断originalData是空的才会执行到这里,但还是写上保险 DeckManagerFragment.getOriginalData().clear();//虽然判断originalData是空的才会执行到这里,但还是写上保险
DeckManagerFragment.getOriginalData().addAll(serverDecks); // 保存原始数据 DeckManagerFragment.getOriginalData().addAll(serverDecks); // 保存原始数据
} }
......
...@@ -24,6 +24,16 @@ public class MyDeckResponse { ...@@ -24,6 +24,16 @@ public class MyDeckResponse {
} }
public List<MyOnlineDeckDetail> getData() { public List<MyOnlineDeckDetail> getData() {
//根据deckType排序,提高观感
data.sort((o1, o2) -> {
String type1 = o1.getDeckType();
String type2 = o2.getDeckType();
if (type1 == null && type2 == null) return 0;
if (type1 == null) return 1;
if (type2 == null) return -1;
return type1.compareTo(type2);
});
return data; return data;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment