forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
RobocopAPI.java
50 lines (38 loc) · 1.65 KB
/
RobocopAPI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.mozglue.GeckoLoader;
import org.mozilla.gecko.sqlite.SQLiteBridge;
import org.mozilla.gecko.util.GeckoEventListener;
import android.app.Activity;
import android.database.Cursor;
import android.view.View;
import java.nio.IntBuffer;
public class RobocopAPI {
private final GeckoApp mGeckoApp;
public RobocopAPI(Activity activity) {
mGeckoApp = (GeckoApp)activity;
}
public void registerEventListener(String event, GeckoEventListener listener) {
GeckoAppShell.registerEventListener(event, listener);
}
public void unregisterEventListener(String event, GeckoEventListener listener) {
GeckoAppShell.unregisterEventListener(event, listener);
}
public void broadcastEvent(String subject, String data) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(subject, data));
}
public void setDrawListener(GeckoLayerClient.DrawListener listener) {
mGeckoApp.getLayerView().getLayerClient().setDrawListener(listener);
}
public Cursor querySql(String dbPath, String query) {
GeckoLoader.loadSQLiteLibs(mGeckoApp, mGeckoApp.getApplication().getPackageResourcePath());
return new SQLiteBridge(dbPath).rawQuery(query, null);
}
public IntBuffer getViewPixels(View view) {
return ((LayerView)view).getPixels();
}
}