Ejemplo n.º 1
0
 @Override
 public void onResume() {
   super.onResume();
   if (sm != null) {
     if (sm.getCurrentSpace() != null) {
       Toast toast =
           Toast.makeText(
               getApplicationContext(), sm.getCurrentSpace().getName(), Toast.LENGTH_LONG);
       toast.show();
     } else {
       Toast toast2 = Toast.makeText(getApplicationContext(), "Its empty!", Toast.LENGTH_LONG);
       toast2.show();
     }
   } else if (sm == null) {
     Toast toast3 =
         Toast.makeText(getApplicationContext(), "Space manager is empty", Toast.LENGTH_LONG);
     toast3.show();
   }
 }
Ejemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) throws NullPointerException {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_debug);

    Spinner spinner = (Spinner) findViewById(R.id.debug_spinner);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.planets_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    try {
      frontController = FrontController.getInstance(getApplicationContext());
    } catch (AuthorizationException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    try {
      sm = frontController.getSpaceManager();
    } catch (AuthorizationException e) {
      // If not authorized, force the user to login.
      frontController.startLoginActivity();
    }

    if (sm != null) {
      if (sm.getCurrentSpace() != null) {
        Toast toast =
            Toast.makeText(
                getApplicationContext(), sm.getCurrentSpace().getName(), Toast.LENGTH_LONG);
        toast.show();
      } else {
        Toast toast2 = Toast.makeText(getApplicationContext(), "Its empty!", Toast.LENGTH_LONG);
        toast2.show();
      }
    } else if (sm == null) {
      Toast toast3 =
          Toast.makeText(getApplicationContext(), "Space manager is empty", Toast.LENGTH_LONG);
      toast3.show();
    }
  }
Ejemplo n.º 3
0
  public void generateSpaces(View v) {

    for (int i = 0; i < 3; i++) {
      Random r = new Random();
      String token = Long.toString(Math.abs(r.nextLong()), 36);

      Space s = new Space(null, null, null, token, token, "string", null, false, null, null);

      SpaceManager.getInstance(getApplicationContext()).createNewSpace(s);
    }
  }