Commit b3483d52 authored by noname's avatar noname

Fix deck copy/move

parent da056f6b
......@@ -1145,9 +1145,13 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public void onDeckMove(List<DeckFile> deckFileList, DeckType toDeckType) {
String currentDeckPath = mDeckAdapater.getYdkFile().getAbsolutePath();
File ydk = mDeckAdapater.getYdkFile();
if(ydk == null){
return;
}
String currentDeckPath = ydk.getPath();
for (DeckFile deckFile : deckFileList) {
if (deckFile.getPath().equals(currentDeckPath)) {
if (TextUtils.equals(currentDeckPath, deckFile.getPath())) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getName() + ".ydk"));
return;
}
......@@ -1156,9 +1160,13 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public void onDeckCopy(List<DeckFile> deckFileList, DeckType toDeckType) {
String currentDeckPath = mDeckAdapater.getYdkFile().getAbsolutePath();
File ydk = mDeckAdapater.getYdkFile();
if(ydk == null){
return;
}
String currentDeckPath = ydk.getPath();
for (DeckFile deckFile : deckFileList) {
if (deckFile.getPath().equals(currentDeckPath)) {
if (TextUtils.equals(currentDeckPath, deckFile.getPath())) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getName() + ".ydk"));
return;
}
......
......@@ -9,6 +9,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import java.io.File;
......@@ -388,7 +389,7 @@ public class DeckAdapater extends RecyclerView.Adapter<DeckViewHolder> implement
return mLimitList;
}
public File getYdkFile(){
public @Nullable File getYdkFile(){
if(mDeckInfo != null){
return mDeckInfo.source;
}
......
......@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
......@@ -128,6 +129,7 @@ public class YGODialogUtil {
public void onItemSelect(int position, DeckType item) {
clearDeckSelect();
deckList.clear();
Log.d("kk-test", "read path"+item.getPath());
deckList.addAll(DeckUtil.getDeckList(item.getPath()));
if (position == 0) {
if (AppsSettings.get().isReadExpansions()) {
......@@ -237,7 +239,7 @@ public class YGODialogUtil {
List<DeckFile> deckFileList = deckAdp.getSelectList();
for (DeckFile deckFile : deckFileList) {
try {
FileUtils.moveFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getName()).getPath());
FileUtils.moveFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getName() + ".ydk").getPath());
} catch (IOException e) {
e.printStackTrace();
}
......@@ -267,7 +269,7 @@ public class YGODialogUtil {
List<DeckFile> deckFileList = deckAdp.getSelectList();
for (DeckFile deckFile : deckFileList) {
try {
FileUtils.copyFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getName()).getPath());
FileUtils.copyFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getName() + ".ydk").getPath());
} catch (IOException e) {
e.printStackTrace();
}
......
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