extended maptool dir scan
This commit is contained in:
parent
23968b2a5b
commit
52b4dfb028
4 changed files with 336 additions and 5 deletions
|
|
@ -12,7 +12,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeMap;
|
||||
|
|
@ -32,6 +31,7 @@ import android.widget.Toast;
|
|||
import btools.expressions.BExpressionContextGlobal;
|
||||
import btools.expressions.BExpressionMetaData;
|
||||
import btools.mapaccess.OsmNode;
|
||||
import btools.mapaccess.StorageConfigHelper;
|
||||
import btools.router.OsmNodeNamed;
|
||||
import btools.router.OsmTrack;
|
||||
import btools.router.RoutingContext;
|
||||
|
|
@ -66,6 +66,8 @@ public class BRouterView extends View
|
|||
private boolean needsNogoSelection;
|
||||
private boolean needsWaypointSelection;
|
||||
|
||||
private WpDatabaseScanner dataBaseScanner;
|
||||
|
||||
private long lastDataTime = System.currentTimeMillis();
|
||||
|
||||
private CoordinateReader cor;
|
||||
|
|
@ -358,6 +360,19 @@ public class BRouterView extends View
|
|||
}
|
||||
}
|
||||
|
||||
public void startWpDatabaseScan()
|
||||
{
|
||||
dataBaseScanner = new WpDatabaseScanner();
|
||||
dataBaseScanner.start();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void saveMaptoolDir( String dir )
|
||||
{
|
||||
ConfigMigration.saveAdditionalMaptoolDir( segmentDir, dir );
|
||||
( (BRouterActivity) getContext() ).showResultMessage( "Success", "please restart to use new config", -1 );
|
||||
}
|
||||
|
||||
public void finishWaypointSelection()
|
||||
{
|
||||
needsWaypointSelection = false;
|
||||
|
|
@ -390,7 +405,7 @@ public class BRouterView extends View
|
|||
String msg;
|
||||
if ( wpList.size() == 0 )
|
||||
{
|
||||
msg = "no from/to found\n" + sourceHint;
|
||||
msg = "Expecting waypoint selection\n" + sourceHint;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -398,7 +413,7 @@ public class BRouterView extends View
|
|||
for ( int i = 0; i < wpList.size(); i++ )
|
||||
msg += ( i > 0 ? "->" : "" ) + wpList.get( i ).name;
|
||||
}
|
||||
( (BRouterActivity) getContext() ).showResultMessage( "Select Action", msg, wpList.size() );
|
||||
( (BRouterActivity) getContext() ).showResultMessage( "Select Action", msg, cor instanceof CoordinateReaderNone ? -2 : wpList.size() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -580,8 +595,59 @@ public class BRouterView extends View
|
|||
}
|
||||
}
|
||||
|
||||
private void showDatabaseScanning( Canvas canvas )
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep( 100 );
|
||||
}
|
||||
catch (InterruptedException ie)
|
||||
{
|
||||
}
|
||||
Paint paint1 = new Paint();
|
||||
paint1.setColor( Color.WHITE );
|
||||
paint1.setTextSize( 20 );
|
||||
|
||||
Paint paint2 = new Paint();
|
||||
paint2.setColor( Color.WHITE );
|
||||
paint2.setTextSize( 10 );
|
||||
|
||||
String currentDir = dataBaseScanner.getCurrentDir();
|
||||
String bestGuess = dataBaseScanner.getBestGuess();
|
||||
|
||||
if ( currentDir == null ) // scan finished
|
||||
{
|
||||
if ( bestGuess.length() == 0 )
|
||||
{
|
||||
( (BRouterActivity) getContext() ).showErrorMessage( "scan did not find any possible waypoint database" );
|
||||
}
|
||||
else
|
||||
{
|
||||
( (BRouterActivity) getContext() ).showWpDatabaseScanSuccess( bestGuess);
|
||||
}
|
||||
cr = null;
|
||||
dataBaseScanner = null;
|
||||
waitingForSelection = true;
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.drawText( "Scanning:", 10, 30, paint1 );
|
||||
canvas.drawText( currentDir, 0, 60, paint2 );
|
||||
canvas.drawText( "Best Guess:", 10, 90, paint1 );
|
||||
canvas.drawText( bestGuess, 0, 120, paint2 );
|
||||
canvas.drawText( "Last Error:", 10, 150, paint1 );
|
||||
canvas.drawText( dataBaseScanner.getLastError(), 0, 180, paint2 );
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void _onDraw( Canvas canvas )
|
||||
{
|
||||
if ( dataBaseScanner != null )
|
||||
{
|
||||
showDatabaseScanning( canvas );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( waitingForSelection )
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue