fixed indentations

This commit is contained in:
fysx
2014-02-13 14:24:17 +01:00
parent 1703660617
commit 5849e8d369
2 changed files with 49 additions and 49 deletions
+1 -1
View File
@@ -38,7 +38,7 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:mimeType="*/*" /> <data android:mimeType="*/*" />
<data android:pathPattern=".*\\.love" /> <data android:pathPattern=".*\\.love" />
<data android:host="*" /> <data android:host="*" />
+48 -48
View File
@@ -17,11 +17,11 @@ public class GameLauncher extends GameActivity {
protected void onCreate(Bundle bundle) { protected void onCreate(Bundle bundle) {
Uri game = this.getIntent().getData(); Uri game = this.getIntent().getData();
if (game != null) { if (game != null) {
if (game.getScheme().equals ("file")) { if (game.getScheme().equals ("file")) {
gamePath = game.getPath(); gamePath = game.getPath();
} else { } else {
copyGameToCache (game); copyGameToCache (game);
} }
Log.d("GameLauncher", "Selected the file: " + getGamePath()); Log.d("GameLauncher", "Selected the file: " + getGamePath());
} }
super.onCreate(bundle); super.onCreate(bundle);
@@ -30,57 +30,57 @@ public class GameLauncher extends GameActivity {
public static String getGamePath() { public static String getGamePath() {
return gamePath; return gamePath;
} }
void copyGameToCache (Uri sourceuri) void copyGameToCache (Uri sourceuri)
{ {
String destinationFilename = this.getCacheDir().getPath()+"/downloaded.love"; String destinationFilename = this.getCacheDir().getPath()+"/downloaded.love";
gamePath = destinationFilename; gamePath = destinationFilename;
BufferedOutputStream bos = null; BufferedOutputStream bos = null;
try { try {
bos = new BufferedOutputStream(new FileOutputStream(destinationFilename, false)); bos = new BufferedOutputStream(new FileOutputStream(destinationFilename, false));
} catch (IOException e) { } catch (IOException e) {
Log.d ("GameLauncher", "Could not open destination file:" + e.getMessage()); Log.d ("GameLauncher", "Could not open destination file:" + e.getMessage());
} }
int chunk_read = 0; int chunk_read = 0;
int bytes_written = 0; int bytes_written = 0;
BufferedInputStream bis = null; BufferedInputStream bis = null;
if (sourceuri.getScheme().equals("content")) { if (sourceuri.getScheme().equals("content")) {
try { try {
bis = new BufferedInputStream(getContentResolver().openInputStream(sourceuri)); bis = new BufferedInputStream(getContentResolver().openInputStream(sourceuri));
} catch (IOException e) { } catch (IOException e) {
Log.d ("GameLauncher", "Could not open game file:" + e.getMessage()); Log.d ("GameLauncher", "Could not open game file:" + e.getMessage());
} }
} else { } else {
Log.d ("GameLauncher", "Unsupported scheme: " + sourceuri.getScheme()); Log.d ("GameLauncher", "Unsupported scheme: " + sourceuri.getScheme());
} }
if (bis != null) { if (bis != null) {
// actual copying // actual copying
try { try {
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
chunk_read = bis.read(buf); chunk_read = bis.read(buf);
do { do {
bos.write(buf, 0, chunk_read); bos.write(buf, 0, chunk_read);
bytes_written += chunk_read; bytes_written += chunk_read;
chunk_read = bis.read(buf); chunk_read = bis.read(buf);
} while(chunk_read != -1); } while(chunk_read != -1);
} catch (IOException e) { } catch (IOException e) {
Log.d ("GameLauncher", "Copying failed:" + e.getMessage()); Log.d ("GameLauncher", "Copying failed:" + e.getMessage());
} }
} }
// close streams // close streams
try { try {
if (bis != null) bis.close(); if (bis != null) bis.close();
if (bos != null) bos.close(); if (bos != null) bos.close();
} catch (IOException e) { } catch (IOException e) {
Log.d ("GameLauncher", "Copying failed: " + e.getMessage()); Log.d ("GameLauncher", "Copying failed: " + e.getMessage());
} }
Log.d("GameLauncher", "Copied " + bytes_written + " bytes"); Log.d("GameLauncher", "Copied " + bytes_written + " bytes");
} }
} }