Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: samples/android_sample/src/com/google/dartndk/DummyActivity.java

Issue 11467028: Migrate files to embedder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge and lint fixes Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 package com.google.dartndk; 1 package com.google.dartndk;
2 2
3 import java.io.File; 3 import java.io.File;
4 import java.io.FileOutputStream; 4 import java.io.FileOutputStream;
5 import java.io.InputStream; 5 import java.io.InputStream;
6 import java.io.IOException; 6 import java.io.IOException;
7 import java.io.OutputStream; 7 import java.io.OutputStream;
8 8
9 import android.app.NativeActivity; 9 import android.app.NativeActivity;
10 import android.content.res.AssetManager; 10 import android.content.res.AssetManager;
11 import android.os.Bundle; 11 import android.os.Bundle;
12 import android.util.Log; 12 import android.util.Log;
13 13
14 public class DummyActivity extends NativeActivity { 14 public class DummyActivity extends NativeActivity {
15 static { 15 static {
16 System.loadLibrary("android_embedder"); 16 System.loadLibrary("android_embedder");
17 System.loadLibrary("DartNDK");
gram 2013/01/09 17:51:36 I don't think we need to worry about this right no
vsm 2013/01/09 18:41:24 I actually tried to get rid of this and ran into a
18 } 17 }
19 18
20 @Override 19 @Override
21 public void onCreate(Bundle savedInstanceState) { 20 public void onCreate(Bundle savedInstanceState) {
22 super.onCreate(savedInstanceState); 21 super.onCreate(savedInstanceState);
23 try { 22 try {
24 File localDir = getApplicationContext().getDir("dart", 0); 23 File localDir = getApplicationContext().getDir("dart", 0);
25 String fileSystemPath = localDir.toString(); 24 String fileSystemPath = localDir.toString();
26 String assetPath = "dart"; 25 String assetPath = "dart";
27 AssetManager assetManager = getAssets(); 26 AssetManager assetManager = getAssets();
28 String[] files = assetManager.list(assetPath); 27 String[] files = assetManager.list(assetPath);
29 byte[] buffer = new byte[1024]; 28 byte[] buffer = new byte[1024];
30 int read; 29 int read;
31 for (String filename : files) { 30 for (String filename : files) {
32 String dest = fileSystemPath + "/" + filename; 31 String dest = fileSystemPath + "/" + filename;
33 Log.w("Dart", "Copying " + dest); 32 Log.w("Dart", "Copying " + dest);
34 InputStream in = assetManager.open(assetPath + "/" + filename); 33 InputStream in = assetManager.open(assetPath + "/" + filename);
35 OutputStream out = new FileOutputStream(dest); 34 OutputStream out = new FileOutputStream(dest);
36 while((read = in.read(buffer)) != -1){ 35 while((read = in.read(buffer)) != -1){
37 out.write(buffer, 0, read); 36 out.write(buffer, 0, read);
38 } 37 }
39 in.close(); 38 in.close();
40 out.flush(); 39 out.flush();
41 ((FileOutputStream)out).getFD().sync(); 40 ((FileOutputStream)out).getFD().sync();
42 out.close(); 41 out.close();
43 } 42 }
44 } catch (IOException ex) { 43 } catch (IOException ex) {
45 } 44 }
46 } 45 }
47 } 46 }
OLDNEW
« runtime/embedders/android/input_service.cc ('K') | « samples/android_sample/jni/vm_glue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698