Search in sources :

Example 1 with DBInspectorException

use of com.noser.neo4j.android.dbinspector.base.DBInspectorException in project neo4j-mobile-android by neo4j-contrib.

the class MainActivity method askCreationOfNeo4jDatabase.

private void askCreationOfNeo4jDatabase() {
    AlertDialog dialog = new AlertDialog.Builder(this).create();
    dialog.setTitle(R.string.main_create_database_title);
    View mainCreateDatabaseView = inflater.inflate(R.layout.main_activity_createdatabase, null);
    final EditText mainCreateDatabaseEdit = (EditText) mainCreateDatabaseView.findViewById(R.id.mainCreateDatabaseEdit);
    dialog.setView(mainCreateDatabaseView);
    dialog.setButton(getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String databaseName = mainCreateDatabaseEdit.getText().toString();
            if (!databaseName.isEmpty()) {
                try {
                    if (dbManager.neo4jDatabaseExists(databaseName)) {
                        showDatabaseAlreadyExistsDialog(databaseName);
                    } else {
                        if (dbManager.isCurrentNeo4jDatabaseOpen()) {
                            shutdownNeo4jDatabase(dbManager.getCurrentNeo4jDatabaseName());
                        }
                        openOrCreateNeo4jDatabase(databaseName);
                    }
                } catch (DBInspectorException e) {
                    Ln.e(e, "failed to check for existing database '" + databaseName + "'.");
                    showErrorDialog();
                }
            }
        }
    });
    dialog.setButton2(getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) DBInspectorException(com.noser.neo4j.android.dbinspector.base.DBInspectorException) ContentView(roboguice.inject.ContentView) ImageView(android.widget.ImageView) View(android.view.View) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView)

Example 2 with DBInspectorException

use of com.noser.neo4j.android.dbinspector.base.DBInspectorException in project neo4j-mobile-android by neo4j-contrib.

the class DBManager method openOrCreateNeo4jDatabase.

@Override
public void openOrCreateNeo4jDatabase(String databaseName) throws DBInspectorException {
    try {
        doShutdownNeo4jDatabase(databaseName);
        this.database = neo4jService.openOrCreateDatabase(databaseName);
        this.databaseName = databaseName;
    } catch (Neo4jServiceException e) {
        throw new DBInspectorException(e);
    } catch (RemoteException e) {
        throw new DBInspectorException(e);
    }
}
Also used : Neo4jServiceException(org.neo4j.android.client.Neo4jServiceException) DBInspectorException(com.noser.neo4j.android.dbinspector.base.DBInspectorException) RemoteException(android.os.RemoteException)

Aggregations

DBInspectorException (com.noser.neo4j.android.dbinspector.base.DBInspectorException)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 RemoteException (android.os.RemoteException)1 View (android.view.View)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Neo4jServiceException (org.neo4j.android.client.Neo4jServiceException)1 ContentView (roboguice.inject.ContentView)1 InjectView (roboguice.inject.InjectView)1