Lasith-Niro / appinventor-java-translation

Automatically exported from code.google.com/p/appinventor-java-translation
0 stars 0 forks source link

Only last screen is generated #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Your code should be changed from using the project name as key for the screens 
to using the screen name

Change from:

    private void loadSourceFile( String path, InputStream inputStream ) throws IOException
    {
        projectName = getFolder( path );
        AppInventorScreen screen = screens.get( projectName );

        if( screen == null )
            screen = new AppInventorScreen( projectName );

        if( path.endsWith( ".blk" ))
            screen.loadBlocksFile( inputStream );
        else if( path.endsWith( ".scm" ))
            screen.loadComponentFile( inputStream );
        else if( path.endsWith( ".yail" ))
            screen.loadInterfaceFile( inputStream );

        screens.put( projectName, screen );
    }

to:

    private String getScreenName( String path )
    {
        int lastSlash = path.lastIndexOf( '/' );
                path = path.substring(lastSlash);
        int lastDot = path.lastIndexOf( '.' );
                return path.substring(0, lastDot);
    }

    private void loadSourceFile( String path, InputStream inputStream ) throws IOException
    {
        projectName = getFolder( path );
        String screenName = getScreenName( path );
        AppInventorScreen screen = screens.get( screenName );

        if( screen == null )
            screen = new AppInventorScreen( projectName );

        if( path.endsWith( ".blk" ))
            screen.loadBlocksFile( inputStream );
        else if( path.endsWith( ".scm" ))
            screen.loadComponentFile( inputStream );
        else if( path.endsWith( ".yail" ))
            screen.loadInterfaceFile( inputStream );

        screens.put( screenName, screen );
    }

Original issue reported on code.google.com by jacob.nordfalk on 20 Jun 2012 at 8:42

GoogleCodeExporter commented 8 years ago
Fixed in build 72

Original comment by clhod...@crimson.ua.edu on 20 Jul 2012 at 8:00