mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-19 04:02:23 +01:00
DroidFish: Moved error message to strings.xml.
This commit is contained in:
@@ -29,8 +29,13 @@ import java.nio.channels.FileChannel;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.petero.droidfish.R;
|
||||
import android.content.Context;
|
||||
|
||||
/** Engine running as a process started from an external resource. */
|
||||
public class ExternalEngine extends UCIEngineBase {
|
||||
protected final Context context;
|
||||
|
||||
private File engineFileName;
|
||||
protected static final String intSfPath = "/data/data/org.petero.droidfish/internal_sf";
|
||||
private static final String exePath = "/data/data/org.petero.droidfish/engine.exe";
|
||||
@@ -42,7 +47,8 @@ public class ExternalEngine extends UCIEngineBase {
|
||||
private List<String> inLines;
|
||||
private boolean startedOk;
|
||||
|
||||
public ExternalEngine(String engine, Report report) {
|
||||
public ExternalEngine(Context context, String engine, Report report) {
|
||||
this.context = context;
|
||||
this.report = report;
|
||||
engineFileName = new File(engine);
|
||||
engineProc = null;
|
||||
@@ -68,7 +74,7 @@ public class ExternalEngine extends UCIEngineBase {
|
||||
try {
|
||||
engineProc.waitFor();
|
||||
if (!startedOk)
|
||||
report.reportError("Failed to start engine");
|
||||
report.reportError(context.getString(R.string.failed_to_start_engine));
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,9 @@ import android.os.Build;
|
||||
|
||||
/** Stockfish engine running as process, started from assets resource. */
|
||||
public class InternalStockFish extends ExternalEngine {
|
||||
private Context context;
|
||||
|
||||
public InternalStockFish(Context context, Report report) {
|
||||
super("", report);
|
||||
this.context = context;
|
||||
|
||||
super(context, "", report);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class UCIEngineBase implements UCIEngine {
|
||||
else if ("stockfish".equals(engine))
|
||||
return new InternalStockFish(context, report);
|
||||
else
|
||||
return new ExternalEngine(engine, report);
|
||||
return new ExternalEngine(context, engine, report);
|
||||
}
|
||||
|
||||
protected UCIEngineBase() {
|
||||
|
||||
Reference in New Issue
Block a user