Skip to content

Commit

Permalink
Release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
widavies committed Feb 26, 2018
1 parent 28bf305 commit 1b7be6c
Show file tree
Hide file tree
Showing 19 changed files with 360 additions and 131 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "com.cpjd.roblu"
minSdkVersion 19
targetSdkVersion 27
versionCode 46
versionName "4.0.6"
versionCode 47
versionName "4.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

javaCompileOptions {
Expand Down
Binary file modified app/libs/RobluCloud-API.jar
Binary file not shown.
53 changes: 38 additions & 15 deletions app/src/main/java/com/cpjd/roblu/csv/ExportCSVTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.cpjd.roblu.models.RTeam;
import com.cpjd.roblu.ui.teams.TeamsView;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.usermodel.XSSFSheet;
Expand Down Expand Up @@ -109,11 +108,11 @@ public interface ExportCSVListener {
private HashMap<String, XSSFSheet> sheets;

public static class SHEETS {
public static int MATCH_DATA = 0;
public static int PIT_DATA = 1;
public static int MATCH_LIST = 2;
public static int MATCH_LOOKUP = 3;
public static int OUR_MATCHES = 4;
static int MATCH_DATA = 0;
static int PIT_DATA = 1;
static int MATCH_LIST = 2;
static int MATCH_LOOKUP = 3;
static int OUR_MATCHES = 4;
}

public static class VERBOSENESS {
Expand All @@ -128,8 +127,16 @@ public static class VERBOSENESS {
*/
private int verboseness;

/**
* Specifies the file type
*/
private boolean isXslx;

/**
* Specifies the file name of the file
*/
private String fileName;

/**
* Initializes the ExportCSVTask.
* @param context context object
Expand All @@ -142,6 +149,7 @@ public ExportCSVTask(Context context, ExportCSVListener listener, REvent event,
this.listener = listener;
this.verboseness = verboseness;
this.isXslx = isXslx;
this.fileName = fileName;

/*
*
Expand Down Expand Up @@ -246,18 +254,18 @@ public void run() {
new Thread() {
public void run() {
if(s.isEnabled()) {
try {
// try {
s.setIo(io);
s.setVerboseness(verboseness);
s.setWorkbook(workbook);
Log.d("RBS", "ExportCSVTask: Generating sheet: "+s.getSheetName());
s.setCellStyle(BorderStyle.THIN, IndexedColors.WHITE, IndexedColors.BLACK, false); // sets the default, this may get overrided at any point in time by the user
s.generateSheet(sheets.get(s.getSheetName()), event, form, teams, checkouts);
for(int i = 0; i < sheets.get(s.getSheetName()).getRow(0).getLastCellNum(); i++) sheets.get(s.getSheetName()).setColumnWidth(i, s.getColumnWidth());
} catch(Exception e) {
listener.errorOccurred("Failed to execute "+s.getSheetName()+" sheet generation.");
Log.d("RBS", "Failed to execute "+s.getSheetName()+" sheet generation. Err: "+e.getMessage());
}
// for(int i = 0; i < sheets.get(s.getSheetName()).getRow(0).getLastCellNum(); i++) sheets.get(s.getSheetName()).setColumnWidth(i, s.getColumnWidth());
// } catch(Exception e) {
// listener.errorOccurred("Failed to execute "+s.getSheetName()+" sheet generation.");
// Log.d("RBS", "Failed to execute "+s.getSheetName()+" sheet generation. Err: "+e.getMessage());
// }
threadCompleted(s.getSheetName());
}

Expand All @@ -272,17 +280,32 @@ private void threadCompleted(String name) {

threadsComplete++;
if(threadsComplete == enabledSheets) {
File file = new IO(contextWeakReference.get()).getNewCSVExportFile(name + (isXslx ? ".xslx" : ".csv"));
File file = new IO(contextWeakReference.get()).getNewCSVExportFile(fileName + ".xslx");

try {
FileOutputStream out = new FileOutputStream(file);
workbook.write(out);

Log.d("RBS", "Successfully generated .xslx file: "+file.getAbsolutePath());

try {
if(isXslx) new ToCSV().convertExcelToCSV(file.getPath(), file.getPath());
} catch(InvalidFormatException e) {
if(!isXslx) {
new ToCSV().convertExcelToCSV(file.getPath(), file.getParentFile().getPath());
// Get the new file reference
file = new File(file.getParentFile()+File.separator+fileName+".csv");
Log.d("RBS", "Converted .xslx to .CSV: "+file.getAbsolutePath()+" Check: "+file.exists());
}
} catch(Exception e) {
Log.d("RBS", "Failed to convert the file to .CSV");

listener.errorOccurred("Failed to generate ");
}

// List contents of file
for(File f : file.getParentFile().listFiles()) {
Log.d("RBS", "Exports dir contains "+f.getAbsolutePath());
}

out.close();
listener.csvFileGenerated(file);
} catch(IOException e) {
Expand Down
Loading

0 comments on commit 1b7be6c

Please sign in to comment.