Kaydet (Commit) 2550cb01 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

android: introduce TileProviderFactory

Change-Id: I98ba16b4d1537ddeb2f8a29d15a803d527ccafe3
üst ef2b36f8
......@@ -26,6 +26,7 @@ public class LOKitThread extends Thread {
private boolean mCheckboardImageSet = false;
public LOKitThread() {
TileProviderFactory.initialize();
}
private RectF normlizeRect(ImmutableViewportMetrics metrics) {
......@@ -35,9 +36,9 @@ public class LOKitThread extends Thread {
}
private Rect roundToTileSize(RectF input, int tileSize) {
int minX = (Math.round(input.left) / tileSize) * tileSize;
int minY = (Math.round(input.top) / tileSize) * tileSize;
int maxX = ((Math.round(input.right) / tileSize) + 1) * tileSize;
int minX = (Math.round(input.left) / tileSize) * tileSize;
int minY = (Math.round(input.top) / tileSize) * tileSize;
int maxX = ((Math.round(input.right) / tileSize) + 1) * tileSize;
int maxY = ((Math.round(input.bottom) / tileSize) + 1) * tileSize;
return new Rect(minX, minY, maxX, maxY);
}
......@@ -136,7 +137,7 @@ public class LOKitThread extends Thread {
if (mTileProvider != null) {
mTileProvider.close();
}
mTileProvider = new LOKitTileProvider(mApplication.getLayerController(), filename);
mTileProvider = TileProviderFactory.create(mApplication.getLayerController(), filename);
boolean isReady = mTileProvider.isReady();
if (isReady) {
updateCheckbardImage();
......@@ -191,4 +192,8 @@ public class LOKitThread extends Thread {
Log.i(LOGTAG, "Event: " + event.getTypeString());
mEventQueue.add(event);
}
public void clearQueue() {
mEventQueue.clear();
}
}
......@@ -13,7 +13,6 @@ import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import org.libreoffice.kit.LibreOfficeKit;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerController;
......@@ -111,19 +110,18 @@ public class LibreOfficeMainActivity extends Activity {
mDrawerList.setOnItemClickListener(new DocumentPartClickListener());
}
LibreOfficeKit.loadStatic();
if (sLOKitThread == null) {
sLOKitThread = new LOKitThread();
sLOKitThread.start();
} else {
sLOKitThread.clearQueue();
}
mLayerController = new LayerController(this);
mLayerClient = new GeckoLayerClient(this);
mLayerController.setLayerClient(mLayerClient);
mGeckoLayout.addView(mLayerController.getView(), 0);
if (sLOKitThread == null) {
sLOKitThread = new LOKitThread();
sLOKitThread.start();
}
sLOKitThread.mEventQueue.clear();
LOKitShell.sendEvent(LOEvent.load(inputFile));
Log.w(LOGTAG, "UI almost up");
......
package org.libreoffice;
import org.libreoffice.kit.LibreOfficeKit;
import org.mozilla.gecko.gfx.LayerController;
public class TileProviderFactory {
private static TileProviderID currentTileProvider = TileProviderID.LOKIT;
private TileProviderFactory() {
}
public static void initialize() {
if (currentTileProvider == TileProviderID.LOKIT) {
LibreOfficeKit.loadStatic();
}
}
public static TileProvider create(LayerController layerController, String filename) {
if (currentTileProvider == TileProviderID.LOKIT) {
return new LOKitTileProvider(layerController, filename);
} else {
return new MockTileProvider(layerController, filename);
}
}
private static enum TileProviderID {
MOCK, LOKIT
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment