Skip to content

Commit 6a88c5e

Browse files
author
Mihail Slavchev
committed
use __onLiveSync on the global instead of the app object
1 parent 73dd662 commit 6a88c5e

File tree

3 files changed

+4
-47
lines changed

3 files changed

+4
-47
lines changed

src/src/com/tns/NativeScriptSyncService.java

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.tns;
22

3-
import java.io.BufferedReader;
43
import java.io.Closeable;
54
import java.io.DataInputStream;
65
import java.io.File;
@@ -10,13 +9,6 @@
109
import java.io.FileOutputStream;
1110
import java.io.IOException;
1211
import java.io.InputStream;
13-
import java.io.InputStreamReader;
14-
import java.io.UnsupportedEncodingException;
15-
import java.net.ServerSocket;
16-
import java.net.Socket;
17-
import java.util.ArrayList;
18-
import java.util.NoSuchElementException;
19-
import java.util.Scanner;
2012

2113
import android.content.Context;
2214
import android.content.pm.ApplicationInfo;
@@ -154,7 +146,7 @@ public void run()
154146
input.readFully(new byte[length]); //ignore the payload
155147
executePartialSync(context, syncDir);
156148

157-
Platform.callJSMethod(NativeScriptApplication.getInstance(), "onLiveSync", Void.class);
149+
Platform.runScript(new File(NativeScriptSyncService.this.context.getFilesDir(), "internal/livesync.js"));
158150

159151
socket.close();
160152
}
@@ -411,35 +403,4 @@ private boolean copyFile(String sourceFile, String destinationFile)
411403

412404
return true;
413405
}
414-
415-
// private static String getSyncThumb(String syncThumbFilePath)
416-
// {
417-
// try
418-
// {
419-
// File syncThumbFile = new File(syncThumbFilePath);
420-
// if (syncThumbFile.exists())
421-
// {
422-
// return null;
423-
// }
424-
//
425-
// FileInputStream in = new FileInputStream(syncThumbFile);
426-
// BufferedReader reader = new BufferedReader(new InputStreamReader(in));
427-
// String syncThumb = reader.readLine();
428-
// reader.close();
429-
// in.close();
430-
// return syncThumb;
431-
// }
432-
// catch (FileNotFoundException e)
433-
// {
434-
// Log.e(Platform.DEFAULT_LOG_TAG, "Error while reading sync command");
435-
// e.printStackTrace();
436-
// }
437-
// catch (IOException e)
438-
// {
439-
// Log.e(Platform.DEFAULT_LOG_TAG, "Error while reading sync command");
440-
// e.printStackTrace();
441-
// }
442-
//
443-
// return null;
444-
// }
445406
}

test-app/assets/app/mainpage.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,7 @@ app.init({
6464
return MainActivity;
6565
},
6666

67-
6867
onCreate: function() {
6968
__log("Application on create called");
70-
},
71-
72-
onLiveSync: function() {
73-
__enableVerboseLogging();
74-
__log("LiveSync called");
75-
__disableVerboseLogging();
7669
}
7770
});

test-app/assets/internal/livesync.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (global.__onLiveSync) {
2+
global.__onLiveSync();
3+
}

0 commit comments

Comments
 (0)