Example usage for com.badlogic.gdx.net HttpStatus HttpStatus

List of usage examples for com.badlogic.gdx.net HttpStatus HttpStatus

Introduction

In this page you can find the example usage for com.badlogic.gdx.net HttpStatus HttpStatus.

Prototype

public HttpStatus(int statusCode) 

Source Link

Usage

From source file:de.tomgrill.gdxtwitter.desktop.DesktopTwitterAPI.java

License:Apache License

public void sendDenied() {
    responseListener.apiError(new HttpStatus(400), "Bad Request");
}

From source file:de.tomgrill.gdxtwitter.ios.IOSTwitterAPI.java

License:Apache License

private void runGUILogin(final TwitterResponseListener responseListener) {
    if (rootViewController == null) {
        rootViewController = new UIViewController();
    }/*from   ww w.  java2s  .c  om*/

    if (window == null) {
        window = new UIWindow(UIScreen.getMainScreen().getApplicationFrame());
        window.setRootViewController(rootViewController);
        window.addSubview(rootViewController.getView());
    }

    if (webView == null) {

        CGRect buttonFrame = new CGRect(10f, 0.0, 106.0f, 55f);

        CGRect fullScreen = rootViewController.getView().getFrame();
        UIView topBackground = new UIView(new CGRect(0f, 0f, fullScreen.getWidth(), 55f));
        topBackground.setBackgroundColor(UIColor.white());

        UIView topDivider = new UIView(new CGRect(0f, 55f, fullScreen.getWidth(), 1f));
        topDivider.setBackgroundColor(UIColor.white());
        topDivider.setBackgroundColor(UIColor.darkGray());

        UIButton cancelButton = new UIButton(buttonFrame);

        cancelButton.setTitle("cancel", UIControlState.Normal);
        cancelButton.setContentVerticalAlignment(UIControlContentVerticalAlignment.Center);
        cancelButton.setContentHorizontalAlignment(UIControlContentHorizontalAlignment.Left);
        cancelButton.setTitleColor(UIColor.darkGray(), UIControlState.Normal);
        cancelButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {

            @Override
            public void onTouchUpInside(UIControl control, UIEvent event) {
                responseListener.cancelled();
                window.setHidden(true);

            }

        });

        topBackground.addSubview(cancelButton);

        window.addSubview(topBackground);
        window.addSubview(topDivider);

        CGRect webFrame = rootViewController.getView().getFrame();
        webFrame.getOrigin().setY(webFrame.getOrigin().getY() + 56f);

        webFrame.getSize().setHeight(webFrame.getSize().getHeight() - 40.0);

        webView = new UIWebView(webFrame);
        webView.setBackgroundColor(UIColor.white());
        webView.setScalesPageToFit(true);
        webView.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth);
    }

    webView.setDelegate(new UIWebViewDelegateAdapter() {

        @Override
        public void didStartLoad(UIWebView webView) {
            UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(true);
        }

        @Override
        public void didFinishLoad(UIWebView webView) {
            UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);

        }

        @Override
        public void didFailLoad(UIWebView webView, NSError error) {
            UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);
        }

        @Override
        public boolean shouldStartLoad(UIWebView webView, NSURLRequest request,
                UIWebViewNavigationType navigationType) {

            String urlToCall = request.getURL().toString();

            // System.out.println(urlToCall);

            if (urlToCall.contains(config.TWITTER_CALLBACK_URL)) {
                if (urlToCall.contains("oauth_verifier=")) {
                    String oauthIdentifier = "oauth_verifier=";

                    int amperIndex = 0;
                    amperIndex = urlToCall.indexOf("&", amperIndex);
                    String verifier = urlToCall.substring(
                            urlToCall.lastIndexOf(oauthIdentifier) + oauthIdentifier.length(),
                            urlToCall.length());

                    webView.stopLoading();
                    window.setHidden(true);

                    receiveAccessToken(verifier, responseListener);

                }

                if (urlToCall.contains("denied=")) {
                    webView.stopLoading();
                    window.setHidden(true);
                    responseListener.cancelled();
                }

            }
            return true;
        }

    });
    window.addSubview(webView);

    String authUrl = null;
    ;
    try {
        authUrl = provider.retrieveRequestToken(consumer, config.TWITTER_CALLBACK_URL);

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (authUrl == null) {
        responseListener.apiError(new HttpStatus(400), "Bad Request");
        return;
    }

    window.makeKeyAndVisible();
    webView.loadRequest(new NSURLRequest(new NSURL(authUrl)));

}

From source file:es.eucm.gleaner.tracker.http.SimpleHttpResponse.java

License:Apache License

public SimpleHttpResponse(String data, int status) {
    this.data = data;
    this.status = new HttpStatus(status);
}