Skip to content

Instantly share code, notes, and snippets.

@eric-wood
Created December 1, 2012 00:40
Show Gist options
  • Save eric-wood/4179786 to your computer and use it in GitHub Desktop.
Save eric-wood/4179786 to your computer and use it in GitHub Desktop.
public void login(View view) {
// Test code only
final class completionCallback implements Callback<Boolean> {
Activity a;
public completionCallback(Activity object) {
a = object;
}
public void onCallback(Boolean data) {
if (data) {
Log.i("login", "Login success");
Intent intent = new Intent(a, HomeActivity.class);
startActivity(intent);
}
else {
Log.i("login", "Login failed");
}
ProgressBar pb = (ProgressBar) findViewById(R.id.spinner);
pb.setVisibility(View.INVISIBLE);
}
}
ProgressBar pb = (ProgressBar) findViewById(R.id.spinner);
pb.setVisibility(View.VISIBLE);
EditText usernameBox = (EditText)findViewById(R.id.editText1);
EditText passwordBox = (EditText)findViewById(R.id.editText2);
Log.i("login", "Login initiated");
GraffitiCom.logIn(usernameBox.getText().toString(), passwordBox.getText().toString(), new completionCallback(this));
}
final class GraffitiCom {
private static GraffitiClient singleton = null;
private GraffitiCom() {
}
public static void setHost(String hostname, boolean devserver) throws MalformedURLException {
singleton = new GraffitiClient(new URL(hostname), devserver);
}
public static void logIn(final String username, final String password,
final Callback<Boolean> completionCallback) {
singleton.logIn(username, password, completionCallback);
}
public static void uploadImage(final File imageFile,
final Callback<String> completionCallback) {
singleton.uploadImage(imageFile, completionCallback);
}
public static void storePositionedSketch(final PositionedSketch posSketch,
final Callback<PositionedSketch> completionCallback) {
singleton.storePositionedSketch(posSketch, completionCallback);
}
public static void getMyImages(final Callback<Collection<Image>> completionCallback) {
singleton.getMyImages(completionCallback);
}
public static void getMyPositionedSketches(
final Callback<Collection<PositionedSketch>> completionCallback) {
singleton.getMyPositionedSketches(completionCallback);
}
public static void getPublicPositionedSketches(
final Callback<Collection<PositionedSketch>> completionCallback) {
singleton.getPublicPositionedSketches(completionCallback);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment