Permalink
Browse files

initial

  • Loading branch information...
0 parents commit 80653305754b9ebbd9dc520edcf08559c3ea2cf6 @sugree committed Oct 31, 2010
@@ -0,0 +1,12 @@
+*~
+*.DS_Store
+*.class
+*java#
+*.classpath
+*.project
+*.settings
+.gradle
+twitter/local.properties
+twitter/build/
+twitter/bin/
+twitter/gen/
@@ -0,0 +1,28 @@
+buildscript {
+ repositories {
+ mavenRepo urls: 'http://jvoegele.com/maven2/'
+ }
+ dependencies {
+ classpath 'com.jvoegele.gradle.plugins:android-plugin:0.9.3'
+ }
+}
+
+dependsOnChildren()
+
+subprojects {
+ apply plugin: 'java'
+ apply plugin: 'eclipse'
+ apply plugin: com.jvoegele.gradle.plugins.android.AndroidPlugin
+
+ proguard.enabled = false
+
+ repositories {
+ flatDir name: 'localRepository', dirs: "${projectDir}/libs"
+ mavenCentral()
+ }
+
+ eclipseClasspath {
+ downloadSources = false
+ downloadJavadoc = false
+ }
+}
@@ -0,0 +1 @@
+include "twitter"
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.sugree.twitter"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application />
+</manifest>
@@ -0,0 +1,4 @@
+dependencies {
+ compile 'oauth.signpost:signpost-core:1.2.1.1'
+ compile 'oauth.signpost:signpost-commonshttp4:1.2.1.1'
+}
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="twitter-android-sdk" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked in in Version
+ Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the default property values
+ used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ application.package
+ the name of your application package as defined in the manifest. Used by the
+ 'uninstall' rule.
+ source.dir
+ the name of the source directory. Default is 'src'.
+ out.dir
+ the name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should be updated
+ using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android' tool, as well
+ as ADT.
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+ <!-- Execute the Android Setup task that will setup some properties specific to the target,
+ and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/templates/android_rules.xml
+
+ To customize some build steps for your project:
+ - copy the content of the main node <project> from android_rules.xml
+ - paste it in this build.xml below the <setup /> task.
+ - disable the import by changing the setup task below to <setup import="false" />
+
+ This will ensure that the properties are setup correctly but that your customized
+ build steps are used.
+ -->
+ <setup />
+
+ <target name="jar" depends="compile">
+ <xpath input="AndroidManifest.xml" expression="/manifest/@android:versionName"
+ output="project.version" />
+ <delete file="${out.absolute.dir}/${ant.project.name}-${project.version}.jar" />
+ <jar destfile="${out.absolute.dir}/${ant.project.name}-${project.version}.jar">
+ <fileset dir="${out.classes.absolute.dir}" />
+ </jar>
+ </target>
+
+</project>
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+android.library=true
+# Project target.
+target=android-3
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2010 Facebook, Inc.
+ *
+ * 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.sugree.twitter;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import android.content.Context;
+import android.os.Bundle;
+
+/**
+ * A sample implementation of asynchronous API requests. This class provides
+ * the ability to execute API methods and have the call return immediately,
+ * without blocking the calling thread. This is necessary when accessing the
+ * API in the UI thread, for instance. The request response is returned to
+ * the caller via a callback interface, which the developer must implement.
+ *
+ * This sample implementation simply spawns a new thread for each request,
+ * and makes the API call immediately. This may work in many applications,
+ * but more sophisticated users may re-implement this behavior using a thread
+ * pool, a network thread, a request queue, or other mechanism. Advanced
+ * functionality could be built, such as rate-limiting of requests, as per
+ * a specific application's needs.
+ *
+ * @see RequestListener
+ * The callback interface.
+ *
+ * @author ssoneff@facebook.com
+ *
+ */
+public class AsyncTwitterRunner {
+
+ Twitter tw;
+
+ public AsyncTwitterRunner(Twitter tw) {
+ this.tw = tw;
+ }
+
+ /**
+ * Invalidate the current user session by removing the access token in
+ * memory, clearing the browser cookies, and calling auth.expireSession
+ * through the API. The application will be notified when logout is
+ * complete via the callback interface.
+ *
+ * Note that this method is asynchronous and the callback will be invoked
+ * in a background thread; operations that affect the UI will need to be
+ * posted to the UI thread or an appropriate handler.
+ *
+ * @param context
+ * The Android context in which the logout should be called: it
+ * should be the same context in which the login occurred in
+ * order to clear any stored cookies
+ * @param listener
+ * Callback interface to notify the application when the request
+ * has completed.
+ */
+ public void logout(final Context context, final RequestListener listener) {
+ new Thread() {
+ @Override public void run() {
+ try {
+ String response = tw.logout(context);
+ if (response.length() == 0 || response.equals("false")){
+ listener.onTwitterError(new TwitterError(
+ "auth.expireSession failed"));
+ return;
+ }
+ listener.onComplete(response);
+ } catch (FileNotFoundException e) {
+ listener.onFileNotFoundException(e);
+ } catch (MalformedURLException e) {
+ listener.onMalformedURLException(e);
+ } catch (IOException e) {
+ listener.onIOException(e);
+ }
+ }
+ }.start();
+ }
+
+ public static interface RequestListener {
+ public void onComplete(String response);
+ public void onIOException(IOException e);
+ public void onFileNotFoundException(FileNotFoundException e);
+ public void onMalformedURLException(MalformedURLException e);
+ public void onTwitterError(TwitterError e);
+
+ }
+
+}
@@ -0,0 +1,24 @@
+package com.sugree.twitter;
+
+public class DialogError extends Throwable {
+
+ private static final long serialVersionUID = -992704825747001028L;
+
+ private int mErrorCode;
+ private String mFailingUrl;
+
+ public DialogError(String message, int errorCode, String failingUrl) {
+ super(message);
+ mErrorCode = errorCode;
+ mFailingUrl = failingUrl;
+ }
+
+ public int getErrorCode() {
+ return mErrorCode;
+ }
+
+ public String getFailingUrl() {
+ return mFailingUrl;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 8065330

Please sign in to comment.