Android Open Source - getrest Main Activity






From Project

Back to project page getrest.

License

The source code is released under:

Apache License

If you think the Android project getrest listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright//from w w w . jav  a  2 s . c  om
 */
package getrest.android.testapp;

import android.app.Activity;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import getrest.android.RestfulClient;
import getrest.android.client.RequestCallback;
import getrest.android.client.RequestFuture;
import getrest.android.core.Method;
import getrest.android.core.Request;
import getrest.android.core.Response;

/**
 * @author aha
 * @since 2012-01-16
 */
public class MainActivity extends Activity {

    private RestfulClient restfulClient;

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        restfulClient = RestfulClient.getInstance(this);

        setContentView(R.layout.main);

        final Button postRequestButton = (Button) findViewById(R.id.Main_CreatePostRequestButton);
        postRequestButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                final ContentValues values = new ContentValues();
                values.put("title", "Groceries");
                values.put("note", "Tomatoes\nMeat\nFish\n");

                final RequestFuture future = restfulClient.request(Uri.parse("http://10.0.2.2:8080/note"))
                        .method(Method.POST)
                        .entity(values)
                        .execute();

                future.setRequestCallback(new RequestCallback() {
                    public void onPending(final Request request) {
                        Toast.makeText(MainActivity.this, "Pending...", Toast.LENGTH_SHORT).show();
                    }

                    public void onExecuting(final Request request) {
                        Toast.makeText(MainActivity.this, "Executing...", Toast.LENGTH_SHORT).show();
                    }

                    public void onError(final Request request) {
                        Toast.makeText(MainActivity.this, "Error :(\n" + request.getError(), Toast.LENGTH_SHORT).show();
                    }

                    public void onFinished(final Response request) {
                        Toast.makeText(MainActivity.this, "Finished :)", Toast.LENGTH_SHORT).show();
                    }
                });

            }
        });
        restfulClient.replay();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        restfulClient.detach();
    }
}




Java Source Code List

getrest.android.RestfulClient.java
getrest.android.client.InMemoryRequestManager.java
getrest.android.client.RequestCallbackFactory.java
getrest.android.client.RequestCallback.java
getrest.android.client.RequestExecutor.java
getrest.android.client.RequestFuture.java
getrest.android.client.RequestRegistry.java
getrest.android.client.impl.RequestEventRecord.java
getrest.android.client.impl.RequestFutureImpl.java
getrest.android.client.impl.RequestRegistryEditorImpl.java
getrest.android.client.impl.RequestRegistryEntryFactory.java
getrest.android.client.impl.RequestRegistryPreferencesImpl.java
getrest.android.client.impl.RestfulClientImpl.java
getrest.android.client.impl.TransactionalRequestEntryStorage.java
getrest.android.config.ConfigResolver.java
getrest.android.config.Config.java
getrest.android.config.DefaultContributor.java
getrest.android.config.HasConfig.java
getrest.android.config.ResourceContextContribution.java
getrest.android.config.ResourceContextContributor.java
getrest.android.config.ResourceNode.java
getrest.android.config.ResourcePath.java
getrest.android.core.BaseRequest.java
getrest.android.core.ErrorState.java
getrest.android.core.Error.java
getrest.android.core.HandlerException.java
getrest.android.core.HasHeaders.java
getrest.android.core.Header.java
getrest.android.core.HeadersHelper.java
getrest.android.core.Headers.java
getrest.android.core.Method.java
getrest.android.core.Pack.java
getrest.android.core.Request.java
getrest.android.core.Response.java
getrest.android.core.Status.java
getrest.android.exception.GetrestException.java
getrest.android.exception.GetrestRuntimeException.java
getrest.android.executor.Handler.java
getrest.android.executor.PostMethodPipeline.java
getrest.android.executor.RequestHandlerFactory.java
getrest.android.executor.RequestHandlerImpl.java
getrest.android.executor.RequestHandler.java
getrest.android.executor.RequestPipeline.java
getrest.android.http.HttpEntityRepresentation.java
getrest.android.http.HttpServiceRequestExecutor.java
getrest.android.http.RepresentationHttpEntity.java
getrest.android.request.RequestContext.java
getrest.android.request.RequestLifecycle.java
getrest.android.request.RequestManager.java
getrest.android.request.RequestStatus.java
getrest.android.resource.Marshaller.java
getrest.android.resource.Packer.java
getrest.android.resource.ResourceContextImpl.java
getrest.android.resource.ResourceContext.java
getrest.android.service.Broadcaster.java
getrest.android.service.Representation.java
getrest.android.service.RequestEventBus.java
getrest.android.service.RequestJob.java
getrest.android.service.RequestStateChangeEventWrapper.java
getrest.android.service.RequestWrapper.java
getrest.android.service.RestService.java
getrest.android.service.ServiceRequestExecutor.java
getrest.android.service.ServiceRequest.java
getrest.android.service.ServiceResponse.java
getrest.android.testapp.GetrestTestApplication.java
getrest.android.testapp.MainActivity.java
getrest.android.util.LoggerFactory.java
getrest.android.util.Logger.java
getrest.android.util.WorkerQueue.java