Android Open Source - twitter-login-button Util






From Project

Back to project page twitter-login-button.

License

The source code is released under:

Copyright (C) 2013 Xavier Balloy https://github.com/xballoy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Soft...

If you think the Android project twitter-login-button 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 2011 Atos Wordline//from  w ww . j  a v a 2s .c  o  m
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package com.awl.tumlabs.twitter.android;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;

import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;

public class Util {

  protected static Bundle parseUrl(String url, String protocol) {
    url = url.replace(protocol, "http://");
    try {
      URL u = new URL(url);
      Bundle b = decodeUrl(u.getQuery());
      b.putAll(decodeUrl(u.getRef()));
      return b;
    } catch (MalformedURLException e) {
      return new Bundle();
    }
  }

  protected static Bundle decodeUrl(String s) {
    Bundle params = new Bundle();
    if (s != null) {
      String array[] = s.split("&");
      for (String parameter : array) {
        String v[] = parameter.split("=");
        params.putString(URLDecoder.decode(v[0]),
            URLDecoder.decode(v[1]));
      }
    }
    return params;
  }
  
  protected static void showAlert(Context context, String title, String text) {
        Builder alertBuilder = new Builder(context);
        alertBuilder.setTitle(title);
        alertBuilder.setMessage(text);
        alertBuilder.create().show();
    }
}




Java Source Code List

com.awl.tumlabs.twitter.android.TwitterAuth.java
com.awl.tumlabs.twitter.android.TwitterDialog.java
com.awl.tumlabs.twitter.android.TwitterLoginButton.java
com.awl.tumlabs.twitter.android.TwitterSessionStore.java
com.awl.tumlabs.twitter.android.Util.java