package org.pestrada.android_tdd_playground;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;

import com.cloudant.p2p.listener.HttpListener;
import com.cloudant.sync.datastore.Datastore;
import com.cloudant.sync.datastore.DatastoreManager;

import org.restlet.Component;
import org.restlet.data.Protocol;

import java.io.File;


public class MainActivity extends FragmentActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    File path = getApplicationContext().getDir("datastores", MODE_PRIVATE);
    DatastoreManager manager = new DatastoreManager(path.getAbsolutePath());

    Datastore ds = manager.openDatastore("mydb");
    ds.close();

    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8182);
    component.getDefaultHost().attachDefault(HttpListener.class);

    try {
        component.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
  }

  public void changeText(View view) {
    TextView textView = (TextView) findViewById(R.id.textView1);
    textView.setText("new text");
  }

}

@@ -613,20 +613,35 @@
 main);%0A%0A
+%0A    try %7B%0A  
     
+  
 File pat
@@ -704,24 +704,28 @@
 IVATE);%0A    
+  
+  
 DatastoreMan
@@ -786,24 +786,28 @@
 th());%0A%0A    
+ 
+   
 Datastore ds
@@ -844,16 +844,20 @@
 %22);%0A    
+   
+ 
 ds.close
@@ -857,24 +857,28 @@
 s.close();%0A%0A
+    
     Componen
@@ -908,24 +908,28 @@
 nent();%0A    
+  
+  
 component.ge
@@ -965,16 +965,20 @@
  8182);%0A
+    
     comp
@@ -1034,27 +1034,16 @@
 .class);
-%0A%0A    try %7B
 %0A       
@@ -1058,24 +1058,25 @@
 nt.start();%0A
+%0A
     %7D catch 

handle exception