Commit 857ecea7 authored by fallenstardust's avatar fallenstardust

copyFile

parent 215be7b2
......@@ -121,6 +121,7 @@ public interface Constants {
int UNSORT_TIMES = 0x80;
int CARD_RESULT_GRAVITY = Gravity.LEFT;
int CARD_SEARCH_GRAVITY = Gravity.RIGHT;
int STRING_LIMIT_START = 1315;
int STRING_CATEGORY_START = 1100;
......@@ -199,4 +200,7 @@ public interface Constants {
//额外的cdb
boolean NETWORK_IMAGE = false;
boolean SHOW_MYCARD = !"core".equals(BuildConfig.FLAVOR);
//打开ydk,是否复制到文件夹
boolean COPY_YDK_FILE = false;
}
......@@ -160,25 +160,25 @@ public abstract class BaseCardsAcitivity extends BaseActivity implements CardLoa
protected abstract void onCardLongClick(View view, Card cardInfo, int pos);
protected void showSearch(boolean autoclose) {
if (mDrawerlayout.isDrawerOpen(Gravity.LEFT)) {
mDrawerlayout.closeDrawer(Gravity.LEFT);
protected void showSearch(boolean autoClose) {
if (mDrawerlayout.isDrawerOpen(Constants.CARD_RESULT_GRAVITY)) {
mDrawerlayout.closeDrawer(Constants.CARD_RESULT_GRAVITY);
}
if (autoclose && mDrawerlayout.isDrawerOpen(Constants.CARD_SEARCH_GRAVITY)) {
if (autoClose && mDrawerlayout.isDrawerOpen(Constants.CARD_SEARCH_GRAVITY)) {
mDrawerlayout.closeDrawer(Constants.CARD_SEARCH_GRAVITY);
} else if (isLoad) {
mDrawerlayout.openDrawer(Constants.CARD_SEARCH_GRAVITY);
}
}
protected void showResult(boolean autoclose) {
protected void showResult(boolean autoClose) {
if (mDrawerlayout.isDrawerOpen(Constants.CARD_SEARCH_GRAVITY)) {
mDrawerlayout.closeDrawer(Constants.CARD_SEARCH_GRAVITY);
}
if (autoclose && mDrawerlayout.isDrawerOpen(Gravity.LEFT)) {
mDrawerlayout.closeDrawer(Gravity.LEFT);
if (autoClose && mDrawerlayout.isDrawerOpen(Constants.CARD_RESULT_GRAVITY)) {
mDrawerlayout.closeDrawer(Constants.CARD_RESULT_GRAVITY);
} else if (isLoad) {
mDrawerlayout.openDrawer(Gravity.LEFT);
mDrawerlayout.openDrawer(Constants.CARD_RESULT_GRAVITY);
}
}
}
......@@ -4,13 +4,27 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class FileUtils {
public static boolean deleteFile(File file){
if(file.isFile()){
try {
file.delete();
}catch (Throwable e){
return false;
}
}
return true;
}
public static List<String> readLines(String file, String encoding) {
InputStreamReader in = null;
FileInputStream inputStream = null;
......@@ -64,20 +78,47 @@ public class FileUtils {
return true;
}
public static void copyFile(String in, FileOutputStream outputStream) {
public static void copyFile(InputStream in, File out) {
FileOutputStream outputStream = null;
try {
File dir = out.getParentFile();
if(!dir.exists()){
dir.mkdirs();
}
outputStream = new FileOutputStream(out);
copy(in, outputStream);
} catch (Throwable e) {
e.printStackTrace();
}finally {
IOUtils.close(outputStream);
IOUtils.close(in);
}
}
public static void copyFile(File in, File out) {
FileOutputStream outputStream = null;
FileInputStream inputStream = null;
byte[] data = new byte[1024 * 8];
try {
inputStream = new FileInputStream(in);
int len;
while ((len = inputStream.read(data)) != -1) {
outputStream.write(data, 0, len);
File dir = out.getParentFile();
if(!dir.exists()){
dir.mkdirs();
}
inputStream = new FileInputStream(in);
outputStream = new FileOutputStream(out);
copy(inputStream, outputStream);
} catch (Throwable e) {
//
} finally {
e.printStackTrace();
}finally {
IOUtils.close(outputStream);
IOUtils.close(inputStream);
}
}
public static void copy(InputStream in, OutputStream out) throws IOException {
byte[] data = new byte[1024 * 8];
int len;
while ((len = in.read(data)) != -1) {
out.write(data, 0, len);
}
}
}
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