Commit 892fec01 authored by wangfugui's avatar wangfugui

修复删除我的在线卡组功能、修复卡组广场刷新功能

parent 7afcada0
......@@ -42,7 +42,12 @@ public class DeckSquareFragment extends Fragment {
binding.listDeckInfo.setAdapter(deckSquareListAdapter);
deckSquareListAdapter.loadData();
binding.refreshData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deckSquareListAdapter.loadData();
}
});
deckSquareListAdapter.setOnItemLongClickListener((adapter, view, position) -> {
OnlineDeckDetail item = (OnlineDeckDetail) adapter.getItem(position);
......
......@@ -29,7 +29,7 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<OnlineDeckDetail, Ba
}
public void loadData() {
final DialogPlus dialog_read_ex = DialogPlus.show(getContext(), null, getContext().getString(R.string.fetch_ex_card));
final DialogPlus dialog_read_ex = DialogPlus.show(getContext(), null, getContext().getString(R.string.fetch_online_deck));
VUiKit.defer().when(() -> {
SquareDeckResponse result = DeckSquareApiUtil.getSquareDecks();
if (result == null) {
......
......@@ -50,19 +50,19 @@ public class MyDeckDetailDialog extends Dialog {
Button deleteMyOnlineDeckBtn = findViewById(R.id.delete_my_online_deck_btn);
Button btnPush = findViewById(R.id.dialog_my_deck_btn_push);
LinearLayout downloadLayout = findViewById(R.id.server_download_layout);
LinearLayout deleteMyDeck = findViewById(R.id.delete_my_deck);
LinearLayout uploadLayout = findViewById(R.id.server_upload_layout);
if (mItem.getDeckSouce() == 0) {//来自本地
downloadLayout.setVisibility(View.GONE);
deleteMyDeck.setVisibility(View.GONE);
uploadLayout.setVisibility(View.VISIBLE);
//btnDownload.setBackground(R.id.ic);
} else if (mItem.getDeckSouce() == 1) {//来自服务器
downloadLayout.setVisibility(View.VISIBLE);
deleteMyDeck.setVisibility(View.VISIBLE);
uploadLayout.setVisibility(View.GONE);
previewDeckCard();
} else if (mItem.getDeckSouce() == 2) {//本地、服务器均存在
downloadLayout.setVisibility(View.VISIBLE);
deleteMyDeck.setVisibility(View.VISIBLE);
uploadLayout.setVisibility(View.VISIBLE);
previewDeckCard();
}
......@@ -118,7 +118,11 @@ public class MyDeckDetailDialog extends Dialog {
LogUtil.i(TAG, "square deck detail fail" + e.getMessage());
}).done(data -> {
if (data.isData()) {
YGOUtil.showTextToast("delete success!");
//服务器的api有问题:获取指定用户的卡组列表(无已删卡组)
//删除成功后,通过http://rarnu.xyz:38383/api/mdpro3/sync/795610/nodel接口查询用户卡组时
//要等待2~3秒api响应内容才会对应更新
YGOUtil.showTextToast("删除成功,3秒后服务器将完成同步");
dismiss();
} else {
YGOUtil.showTextToast("delete fail " + data.getMessage());
......
......@@ -15,9 +15,9 @@ import cn.garymb.ygomobile.deck_square.api_response.MyDeckResponse;
import cn.garymb.ygomobile.deck_square.api_response.MyOnlineDeckDetail;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.ui.plus.VUiKit;
import cn.garymb.ygomobile.utils.LogUtil;
import cn.garymb.ygomobile.utils.SharedPreferenceUtil;
//提供“我的”卡组数据,打开后先从sharePreference查询,没有则从服务器查询,然后缓存到sharePreference
public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHolder> {
......@@ -31,13 +31,13 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
}
public void loadData() {
List<MyDeckItem> localDecks = new ArrayList<>();
List<MyDeckItem> myOnlieDecks = new ArrayList<>();
// final DialogPlus dialog_read_ex = DialogPlus.show(getContext(), null, getContext().getString(R.string.fetch_ex_card));
final DialogPlus dialog_read_ex = DialogPlus.show(getContext(), null, getContext().getString(R.string.fetch_online_deck));
LoginToken loginToken = DeckSquareApiUtil.getLoginData();
if(loginToken==null){
if (loginToken == null) {
return;
}
......@@ -53,21 +53,16 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
}).fail((e) -> {
Log.e(TAG, e + "");
// if (dialog_read_ex.isShowing()) {//关闭异常
// try {
// dialog_read_ex.dismiss();
// } catch (Exception ex) {
//
// }
// }
if (dialog_read_ex.isShowing()) {//关闭异常
try {
dialog_read_ex.dismiss();
} catch (Exception ex) {
}
}
LogUtil.i(TAG, "load mycard from server fail");
//只展示本地卡组
getData().clear();
addData(localDecks);
notifyDataSetChanged();
}).done((serverDecks) -> {
// List<MyDeckItem> serverItems = new ArrayList<>();
}).done((serverDecks) -> {
if (serverDecks != null) {//将服务端的卡组也放到LocalDecks中
for (MyOnlineDeckDetail detail : serverDecks) {
MyDeckItem item = new MyDeckItem();
......@@ -76,23 +71,21 @@ public class MyDeckListAdapter extends BaseQuickAdapter<MyDeckItem, BaseViewHold
item.setDeckId(detail.getDeckId());
item.setUserId(detail.getUserId());
item.setUpdateDate(detail.getDeckUpdateDate());
localDecks.add(item);
myOnlieDecks.add(item);
}
}
LogUtil.i(TAG, "load mycard from server done");
//展示本地卡组和服务器上的卡组
getData().clear();
addData(localDecks);
addData(myOnlieDecks);
notifyDataSetChanged();
// if (dialog_read_ex.isShowing()) {
// try {
// dialog_read_ex.dismiss();
// } catch (Exception ex) {
// }
// }
if (dialog_read_ex.isShowing()) {
try {
dialog_read_ex.dismiss();
} catch (Exception ex) {
}
}
});
}
......
......@@ -6,7 +6,7 @@
android:padding="16dp">
<LinearLayout
android:id="@+id/server_download_layout"
android:id="@+id/delete_my_deck"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
......@@ -14,13 +14,13 @@
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_server_download" />
android:src="@drawable/delete" />
<Button
android:id="@+id/delete_my_online_deck_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Download" />
android:text="@string/delete" />
</LinearLayout>
......
......@@ -38,6 +38,9 @@
<string name="quit_tip">退出游戏?</string>
<string name="back_tip">请再按一次返回键退出</string>
<string name="string_help_text">当前应用缺少必要权限。\n请点击 设置-权限 打开所需权限。</string>
<string name="fetch_online_deck">通过网络获取在线卡组</string>
<string name="fetch_ex_card">通过网络获取先行卡</string>
<string name="ex_card_list_title">超先行服☆专用☆</string>
<string name="ex_card_log_title">更新日志</string>
......
......@@ -45,6 +45,9 @@
<string name="back_tip">Press back key again to exit.</string>
<string name="string_help_text">The current application lacks the necessary permissions. \n
please click Settings - permissions - open the required permissions.</string>
<string name="fetch_online_deck">Fetching online decks via web</string>
<string name="fetch_ex_card">Fetching pre-cards via web</string>
<string name="ex_card_list_title">Card List</string>
<string name="ex_card_log_title">update log</string>
......
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