diff --git a/examples/Hackbook/AndroidManifest.xml b/examples/Hackbook/AndroidManifest.xml
index 68f80f362a..afd4c5307a 100644
--- a/examples/Hackbook/AndroidManifest.xml
+++ b/examples/Hackbook/AndroidManifest.xml
@@ -1,49 +1,49 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+ package="com.facebook.android"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/Hackbook/res/layout/connection_item.xml b/examples/Hackbook/res/layout/connection_item.xml
index 4c77b283ff..e556c06852 100644
--- a/examples/Hackbook/res/layout/connection_item.xml
+++ b/examples/Hackbook/res/layout/connection_item.xml
@@ -1,11 +1,11 @@
-
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/fields_connections_list.xml b/examples/Hackbook/res/layout/fields_connections_list.xml
index e5e676fcd5..06b48f89e5 100644
--- a/examples/Hackbook/res/layout/fields_connections_list.xml
+++ b/examples/Hackbook/res/layout/fields_connections_list.xml
@@ -1,45 +1,45 @@
-
-
-
-
-
-
-
-
-
-
-
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@color/black">
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/fields_item.xml b/examples/Hackbook/res/layout/fields_item.xml
index f1569c6a71..c072d7bd2e 100644
--- a/examples/Hackbook/res/layout/fields_item.xml
+++ b/examples/Hackbook/res/layout/fields_item.xml
@@ -1,14 +1,14 @@
-
+
-
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/fql_query.xml b/examples/Hackbook/res/layout/fql_query.xml
index ea0f242f41..ddda019b2f 100644
--- a/examples/Hackbook/res/layout/fql_query.xml
+++ b/examples/Hackbook/res/layout/fql_query.xml
@@ -1,41 +1,41 @@
-
-
-
-
-
-
-
-
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+
+
+
+
+
+
diff --git a/examples/Hackbook/res/layout/friend_item.xml b/examples/Hackbook/res/layout/friend_item.xml
index 08f53627ac..c1c6728edf 100644
--- a/examples/Hackbook/res/layout/friend_item.xml
+++ b/examples/Hackbook/res/layout/friend_item.xml
@@ -1,10 +1,10 @@
-
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/friends_list.xml b/examples/Hackbook/res/layout/friends_list.xml
index 5cb8e19f19..82e565181f 100644
--- a/examples/Hackbook/res/layout/friends_list.xml
+++ b/examples/Hackbook/res/layout/friends_list.xml
@@ -1,11 +1,11 @@
-
+
-
\ No newline at end of file
+ android:layout_height="fill_parent" />
+
diff --git a/examples/Hackbook/res/layout/graph_explorer.xml b/examples/Hackbook/res/layout/graph_explorer.xml
index edf4c71a2e..a7ebee4faa 100644
--- a/examples/Hackbook/res/layout/graph_explorer.xml
+++ b/examples/Hackbook/res/layout/graph_explorer.xml
@@ -1,103 +1,103 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/Hackbook/res/layout/main.xml b/examples/Hackbook/res/layout/main.xml
index d0cb3abd80..2dc8e244a0 100644
--- a/examples/Hackbook/res/layout/main.xml
+++ b/examples/Hackbook/res/layout/main.xml
@@ -1,43 +1,43 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
\ No newline at end of file
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="@color/grey" />
+
diff --git a/examples/Hackbook/res/layout/main_list_item.xml b/examples/Hackbook/res/layout/main_list_item.xml
index 2bccb4a0fd..2ac0fac977 100644
--- a/examples/Hackbook/res/layout/main_list_item.xml
+++ b/examples/Hackbook/res/layout/main_list_item.xml
@@ -4,6 +4,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
- android:layout_alignParentTop="true"
+ android:layout_alignParentTop="true"
android:gravity="center_vertical"
- android:textSize="20sp" />
\ No newline at end of file
+ android:textSize="20sp" />
diff --git a/examples/Hackbook/res/layout/permission_item.xml b/examples/Hackbook/res/layout/permission_item.xml
index e3ae105411..57eb43a8b9 100644
--- a/examples/Hackbook/res/layout/permission_item.xml
+++ b/examples/Hackbook/res/layout/permission_item.xml
@@ -1,8 +1,8 @@
-
-
\ No newline at end of file
+
+
diff --git a/examples/Hackbook/res/layout/permissions_list.xml b/examples/Hackbook/res/layout/permissions_list.xml
index c782f8baf9..f5592c5aef 100644
--- a/examples/Hackbook/res/layout/permissions_list.xml
+++ b/examples/Hackbook/res/layout/permissions_list.xml
@@ -1,59 +1,59 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/place_item.xml b/examples/Hackbook/res/layout/place_item.xml
index a1593e6011..cbc139e429 100644
--- a/examples/Hackbook/res/layout/place_item.xml
+++ b/examples/Hackbook/res/layout/place_item.xml
@@ -1,6 +1,6 @@
-
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/places_list.xml b/examples/Hackbook/res/layout/places_list.xml
index 8de1f660de..f63bb2884d 100644
--- a/examples/Hackbook/res/layout/places_list.xml
+++ b/examples/Hackbook/res/layout/places_list.xml
@@ -1,11 +1,11 @@
-
+
-
\ No newline at end of file
+ android:layout_height="fill_parent" />
+
diff --git a/examples/Hackbook/res/layout/splash.xml b/examples/Hackbook/res/layout/splash.xml
index fa18f95615..2118606393 100644
--- a/examples/Hackbook/res/layout/splash.xml
+++ b/examples/Hackbook/res/layout/splash.xml
@@ -1,5 +1,5 @@
+ android:src="@drawable/splash"
+ android:scaleType="fitXY"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" />
diff --git a/examples/Hackbook/res/layout/update_post_response.xml b/examples/Hackbook/res/layout/update_post_response.xml
index bee656af14..2a0bd90a6c 100644
--- a/examples/Hackbook/res/layout/update_post_response.xml
+++ b/examples/Hackbook/res/layout/update_post_response.xml
@@ -1,67 +1,67 @@
-
+
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/layout/upload_photo_response.xml b/examples/Hackbook/res/layout/upload_photo_response.xml
index 472666bd8c..3b8bd77437 100644
--- a/examples/Hackbook/res/layout/upload_photo_response.xml
+++ b/examples/Hackbook/res/layout/upload_photo_response.xml
@@ -1,71 +1,71 @@
-
+
-
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
\ No newline at end of file
+
diff --git a/examples/Hackbook/res/values/strings.xml b/examples/Hackbook/res/values/strings.xml
index 3f1436f384..81a2138adb 100644
--- a/examples/Hackbook/res/values/strings.xml
+++ b/examples/Hackbook/res/values/strings.xml
@@ -7,74 +7,74 @@
Request!
Upload PhotoWall Post!
Delete Post
- Graph API Explorer
- Get Permissions
- Access Token:
- https://graph.facebook.com/
- Submit
- Output:
- Show metadata
- Show picture
- URL
- Target URL:
- Exception:
- Tip:
- Facebook Error:
- Api Response:
- View Source
- View Post
- Delete Post
- Source Code:
- Please wait...
- View Photo
- Hide Photo
- Tag Photo
- Graph API
- FQL Query
- Source tag:
- Source tag: \"perms_tag\"
- Graph API or FQL Query?
- Get friends using Graph or FQL Query?\n\nWith FQL query you can sort the list by names, whereas with Graph list will be ordered by UID and can\'t be changed.
- Post on friend\'s wall
- Friends list fetched. You can post on friend\'s wall by clicking on the item.
- OK
- Post on Wall?
- Would you like to post on %1$s\'s wall
- Yes
- No
- Save
- Reset
- Get Fields
- Fields
- Connections
- Check-in
- Cancel
- User Data
- Friends Data
- Extended
- Upload from gallery or remote?
- Upload picture from phone\' gallery or remote server?
- Gallery
- Remote
- Get Location?
- Get current location or use Times Square as the location?
- Current Location
- Fetching current permissions...
- Also, checkout the web-version of the Graph API Explorer tool
- Fetching nearby places...
- Times Square
- Check-in?
- Permissions
- Back to parent
- Fields \u0026 Connections
- Select Permissions:
- Checkout permissions reference doc
- Fetching Location...
- Would you like to check-in at %1$s?
- \'read_stream\' permission is required to view and delete the post.\n\nUse SDK dialogs to publish stories or post on friends wall. More info\n\nLike and Comment on a post
- Photos are by default uploaded to the app\'s album. Specify album_id to upload to specific album. E.g. https://graph.facebook.com/{album_id}/photos.\n\nMore Info: https://developers.facebook.com/docs/reference/api/photo
- Enter FQL Query:
- Enable GPS
- Please enable GPS to get nearby places and check-in
- GPS Settings
+ Graph API Explorer
+ Get Permissions
+ Access Token:
+ https://graph.facebook.com/
+ Submit
+ Output:
+ Show metadata
+ Show picture
+ URL
+ Target URL:
+ Exception:
+ Tip:
+ Facebook Error:
+ Api Response:
+ View Source
+ View Post
+ Delete Post
+ Source Code:
+ Please wait...
+ View Photo
+ Hide Photo
+ Tag Photo
+ Graph API
+ FQL Query
+ Source tag:
+ Source tag: \"perms_tag\"
+ Graph API or FQL Query?
+ Get friends using Graph or FQL Query?\n\nWith FQL query you can sort the list by names, whereas with Graph list will be ordered by UID and can\'t be changed.
+ Post on friend\'s wall
+ Friends list fetched. You can post on friend\'s wall by clicking on the item.
+ OK
+ Post on Wall?
+ Would you like to post on %1$s\'s wall
+ Yes
+ No
+ Save
+ Reset
+ Get Fields
+ Fields
+ Connections
+ Check-in
+ Cancel
+ User Data
+ Friends Data
+ Extended
+ Upload from gallery or remote?
+ Upload picture from phone\' gallery or remote server?
+ Gallery
+ Remote
+ Get Location?
+ Get current location or use Times Square as the location?
+ Current Location
+ Fetching current permissions...
+ Also, checkout the web-version of the Graph API Explorer tool
+ Fetching nearby places...
+ Times Square
+ Check-in?
+ Permissions
+ Back to parent
+ Fields \u0026 Connections
+ Select Permissions:
+ Checkout permissions reference doc
+ Fetching Location...
+ Would you like to check-in at %1$s?
+ \'read_stream\' permission is required to view and delete the post.\n\nUse SDK dialogs to publish stories or post on friends wall. More info\n\nLike and Comment on a post
+ Photos are by default uploaded to the app\'s album. Specify album_id to upload to specific album. E.g. https://graph.facebook.com/{album_id}/photos.\n\nMore Info: https://developers.facebook.com/docs/reference/api/photo
+ Enter FQL Query:
+ Enable GPS
+ Please enable GPS to get nearby places and check-in
+ GPS Settings
diff --git a/examples/Hackbook/src/com/facebook/android/BaseDialogListener.java b/examples/Hackbook/src/com/facebook/android/BaseDialogListener.java
index 6b4b9453d0..dbd5b33608 100644
--- a/examples/Hackbook/src/com/facebook/android/BaseDialogListener.java
+++ b/examples/Hackbook/src/com/facebook/android/BaseDialogListener.java
@@ -3,21 +3,23 @@
import com.facebook.android.Facebook.DialogListener;
/**
- * Skeleton base class for RequestListeners, providing default error
- * handling. Applications should handle these error conditions.
- *
+ * Skeleton base class for RequestListeners, providing default error handling.
+ * Applications should handle these error conditions.
*/
public abstract class BaseDialogListener implements DialogListener {
+ @Override
public void onFacebookError(FacebookError e) {
e.printStackTrace();
}
+ @Override
public void onError(DialogError e) {
- e.printStackTrace();
+ e.printStackTrace();
}
- public void onCancel() {
+ @Override
+ public void onCancel() {
}
-
-}
+
+}
\ No newline at end of file
diff --git a/examples/Hackbook/src/com/facebook/android/BaseRequestListener.java b/examples/Hackbook/src/com/facebook/android/BaseRequestListener.java
index bd0f80f998..0e7809f075 100644
--- a/examples/Hackbook/src/com/facebook/android/BaseRequestListener.java
+++ b/examples/Hackbook/src/com/facebook/android/BaseRequestListener.java
@@ -9,32 +9,33 @@
import com.facebook.android.AsyncFacebookRunner.RequestListener;
/**
- * Skeleton base class for RequestListeners, providing default error
- * handling. Applications should handle these error conditions.
- *
+ * Skeleton base class for RequestListeners, providing default error handling.
+ * Applications should handle these error conditions.
*/
public abstract class BaseRequestListener implements RequestListener {
+ @Override
public void onFacebookError(FacebookError e, final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
- public void onFileNotFoundException(FileNotFoundException e,
- final Object state) {
+ @Override
+ public void onFileNotFoundException(FileNotFoundException e, final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
+ @Override
public void onIOException(IOException e, final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
- public void onMalformedURLException(MalformedURLException e,
- final Object state) {
+ @Override
+ public void onMalformedURLException(MalformedURLException e, final Object state) {
Log.e("Facebook", e.getMessage());
e.printStackTrace();
}
-
+
}
diff --git a/examples/Hackbook/src/com/facebook/android/FQLQuery.java b/examples/Hackbook/src/com/facebook/android/FQLQuery.java
index 7594b7f421..1c2e92b3cb 100644
--- a/examples/Hackbook/src/com/facebook/android/FQLQuery.java
+++ b/examples/Hackbook/src/com/facebook/android/FQLQuery.java
@@ -4,7 +4,6 @@
import org.json.JSONException;
import org.json.JSONObject;
-
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
@@ -18,92 +17,96 @@
import android.widget.EditText;
import android.widget.TextView;
-
public class FQLQuery extends Dialog {
- private EditText mFQLQuery;
- private TextView mFQLOutput;
- private Button mSubmitButton;
- private Activity activity;
- private Handler mHandler;
- private ProgressDialog dialog;
-
+ private EditText mFQLQuery;
+ private TextView mFQLOutput;
+ private Button mSubmitButton;
+ private Activity activity;
+ private Handler mHandler;
+ private ProgressDialog dialog;
+
public FQLQuery(Activity activity) {
super(activity);
- this.activity = activity;
+ this.activity = activity;
setTitle(R.string.fqlquery);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
mHandler = new Handler();
-
+
setContentView(R.layout.fql_query);
- LayoutParams params = getWindow().getAttributes();
- params.width = LayoutParams.FILL_PARENT;
- params.height = LayoutParams.FILL_PARENT;
+ LayoutParams params = getWindow().getAttributes();
+ params.width = LayoutParams.FILL_PARENT;
+ params.height = LayoutParams.FILL_PARENT;
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
-
+
mFQLQuery = (EditText) findViewById(R.id.fqlquery);
mFQLOutput = (TextView) findViewById(R.id.fqlOutput);
mSubmitButton = (Button) findViewById(R.id.submit_button);
-
+
mSubmitButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mFQLQuery.getWindowToken(), 0);
- dialog = ProgressDialog.show(FQLQuery.this.activity, "", FQLQuery.this.activity.getString(R.string.please_wait), true, true);
- /*
- * Source tag: fql_query_tag
- */
- String query = mFQLQuery.getText().toString();
- Bundle params = new Bundle();
- params.putString("method", "fql.query");
- params.putString("query", query);
- Utility.mAsyncRunner.request(null, params, new FQLRequestListener());
- }
+ @Override
+ public void onClick(View v) {
+ ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
+ .hideSoftInputFromWindow(mFQLQuery.getWindowToken(), 0);
+ dialog = ProgressDialog.show(FQLQuery.this.activity, "",
+ FQLQuery.this.activity.getString(R.string.please_wait), true, true);
+ /*
+ * Source tag: fql_query_tag
+ */
+ String query = mFQLQuery.getText().toString();
+ Bundle params = new Bundle();
+ params.putString("method", "fql.query");
+ params.putString("query", query);
+ Utility.mAsyncRunner.request(null, params, new FQLRequestListener());
+ }
});
}
-
+
public class FQLRequestListener extends BaseRequestListener {
+ @Override
public void onComplete(final String response, final Object state) {
- dialog.dismiss();
- /*
- * Output can be JSONArray or JSONObject
- * try JSONArray and if there JSONException, parse to JSONObject
- */
- try {
- JSONArray json = new JSONArray(response);
- setText(json.toString(2));
- } catch (JSONException e) {
- try {
- /*
- * JSONObject probably indicates there was some error
- * Display that error, but for end user you should parse the error
- * and show appropriate message
- */
- JSONObject json = new JSONObject(response);
- setText(json.toString(2));
- } catch (JSONException e1) {
- setText(activity.getString(R.string.exception) + e1.getMessage());
- }
- }
+ dialog.dismiss();
+ /*
+ * Output can be a JSONArray or a JSONObject.
+ * Try JSONArray and if there's a JSONException, parse to JSONObject
+ */
+ try {
+ JSONArray json = new JSONArray(response);
+ setText(json.toString(2));
+ } catch (JSONException e) {
+ try {
+ /*
+ * JSONObject probably indicates there was some error
+ * Display that error, but for end user you should parse the
+ * error and show appropriate message
+ */
+ JSONObject json = new JSONObject(response);
+ setText(json.toString(2));
+ } catch (JSONException e1) {
+ setText(activity.getString(R.string.exception) + e1.getMessage());
+ }
+ }
}
-
+
public void onFacebookError(FacebookError error) {
- dialog.dismiss();
- setText(activity.getString(R.string.facebook_error) + error.getMessage());
- }
+ dialog.dismiss();
+ setText(activity.getString(R.string.facebook_error) + error.getMessage());
+ }
}
-
+
public void setText(final String txt) {
- mHandler.post(new Runnable() {
+ mHandler.post(new Runnable() {
+ @Override
public void run() {
- mFQLOutput.setText(txt);
- mFQLOutput.setVisibility(View.VISIBLE);
+ mFQLOutput.setText(txt);
+ mFQLOutput.setVisibility(View.VISIBLE);
}
});
}
-}
\ No newline at end of file
+}
diff --git a/examples/Hackbook/src/com/facebook/android/FieldsConnectionsDialog.java b/examples/Hackbook/src/com/facebook/android/FieldsConnectionsDialog.java
index 530d340b5b..9308301d41 100644
--- a/examples/Hackbook/src/com/facebook/android/FieldsConnectionsDialog.java
+++ b/examples/Hackbook/src/com/facebook/android/FieldsConnectionsDialog.java
@@ -9,7 +9,6 @@
import org.json.JSONException;
import org.json.JSONObject;
-
import android.app.Dialog;
import android.os.Bundle;
import android.text.SpannableString;
@@ -25,285 +24,282 @@
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
-import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
+import android.widget.TextView;
import android.widget.Toast;
-
public class FieldsConnectionsDialog extends Dialog {
-
- private final int TAB_HEIGHT = 50;
-
+
+ private final static int TAB_HEIGHT = 50;
+
private Button mGetFieldsButton;
private ListView fieldsList, connectionsList;
private BaseAdapter fieldsAdapter, connectionsAdapter;
-
- private GraphExplorer explorerActivity;
-
- protected Vector fieldsVector;
- private ArrayList fieldsArray;
- private ArrayList connectionsArray;
-
- public FieldsConnectionsDialog(GraphExplorer explorerActivity, JSONObject metadata) {
+
+ private GraphExplorer explorerActivity;
+
+ protected Vector fieldsVector;
+ private ArrayList fieldsArray;
+ private ArrayList connectionsArray;
+
+ public FieldsConnectionsDialog(GraphExplorer explorerActivity, JSONObject metadata) {
super(explorerActivity);
- this.explorerActivity = explorerActivity;
-
- /*
- * Sort the fields and connections
- */
- try {
- sortFields(metadata.getJSONArray("fields"));
- sortConnections(metadata.getJSONObject("connections").names());
- } catch (JSONException e) {
- Toast.makeText(explorerActivity.getBaseContext(), "Fields/Connections could not be fetched.", Toast.LENGTH_SHORT).show();
-
- }
-
+ this.explorerActivity = explorerActivity;
+
+ /*
+ * Sort the fields and connections
+ */
+ try {
+ sortFields(metadata.getJSONArray("fields"));
+ sortConnections(metadata.getJSONObject("connections").names());
+ } catch (JSONException e) {
+ Toast.makeText(explorerActivity.getBaseContext(),
+ "Fields/Connections could not be fetched.", Toast.LENGTH_SHORT).show();
+ }
+
setTitle(explorerActivity.getString(R.string.fields_and_connections));
fieldsVector = new Vector();
}
- /*
- * Sort fields which are returned as JSONObject in the JSONArray
- */
-
- public void sortFields(JSONArray jsonFieldsArray) {
- this.fieldsArray = new ArrayList(jsonFieldsArray.length());
- for (int i=0; i() {
- @Override
- public int compare(JSONObject object1, JSONObject object2) {
- try {
- return object1.getString("name").compareToIgnoreCase(object2.getString("name"));
- } catch (JSONException e) {
- e.printStackTrace();
- }
- return 0;
- }
- });;
- }
-
- /*
- * Sort the Connections returned in the JSONArray
- */
-
- public void sortConnections(JSONArray jsonConnectionsArray) {
- this.connectionsArray = new ArrayList(jsonConnectionsArray.length());
- for (int i=0; i(jsonFieldsArray.length());
+ for (int i = 0; i < jsonFieldsArray.length(); i++) {
+ try {
+ this.fieldsArray.add(jsonFieldsArray.getJSONObject(i));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ Collections.sort(this.fieldsArray, new Comparator() {
+ @Override
+ public int compare(JSONObject object1, JSONObject object2) {
+ try {
+ return object1.getString("name").compareToIgnoreCase(object2.getString("name"));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
+ });
+ }
+
+ /*
+ * Sort the Connections returned in the JSONArray
+ */
+ public void sortConnections(JSONArray jsonConnectionsArray) {
+ this.connectionsArray = new ArrayList(jsonConnectionsArray.length());
+ for (int i = 0; i < jsonConnectionsArray.length(); i++) {
+ try {
+ this.connectionsArray.add(jsonConnectionsArray.get(i).toString());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ Collections.sort(this.connectionsArray);
+ }
+
+ /*
+ * Layout the dialog
+ */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
setContentView(R.layout.fields_connections_list);
- LayoutParams params = getWindow().getAttributes();
- params.width = LayoutParams.FILL_PARENT;
- params.height = LayoutParams.FILL_PARENT;
+ LayoutParams params = getWindow().getAttributes();
+ params.width = LayoutParams.FILL_PARENT;
+ params.height = LayoutParams.FILL_PARENT;
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
-
-
- fieldsList = (ListView)findViewById(R.id.fields_list);
- connectionsList = (ListView)findViewById(R.id.connections_list);
-
+
+ fieldsList = (ListView) findViewById(R.id.fields_list);
+ connectionsList = (ListView) findViewById(R.id.connections_list);
+
fieldsAdapter = new FieldsListAdapter();
- if(this.fieldsArray == null) {
- fieldsList.setAdapter(new ArrayAdapter(explorerActivity,
- android.R.layout.simple_list_item_1, new String[]{"No fields available"}));
+ if (this.fieldsArray == null) {
+ fieldsList.setAdapter(new ArrayAdapter(explorerActivity,
+ android.R.layout.simple_list_item_1, new String[] { "No fields available" }));
} else {
- fieldsList.setAdapter(fieldsAdapter);
+ fieldsList.setAdapter(fieldsAdapter);
}
-
+
connectionsAdapter = new ConnectionsListAdapter();
- if(this.connectionsArray == null) {
- connectionsList.setAdapter(new ArrayAdapter(explorerActivity,
- android.R.layout.simple_list_item_1, new String[]{"No connections available"}));
+ if (this.connectionsArray == null) {
+ connectionsList.setAdapter(new ArrayAdapter(explorerActivity,
+ android.R.layout.simple_list_item_1,
+ new String[] { "No connections available" }));
} else {
- connectionsList.setAdapter(connectionsAdapter);
+ connectionsList.setAdapter(connectionsAdapter);
}
-
- TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
+
+ TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
tabHost.setup();
-
- TabSpec spec1=tabHost.newTabSpec("Tab 1");
+
+ TabSpec spec1 = tabHost.newTabSpec("Tab 1");
spec1.setIndicator(explorerActivity.getString(R.string.fields));
spec1.setContent(R.id.fields_layout);
-
- TabSpec spec2=tabHost.newTabSpec("Tab 2");
+
+ TabSpec spec2 = tabHost.newTabSpec("Tab 2");
spec2.setIndicator(explorerActivity.getString(R.string.connections));
spec2.setContent(R.id.connections_list);
-
+
tabHost.addTab(spec1);
tabHost.addTab(spec2);
tabHost.setCurrentTab(0);
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = TAB_HEIGHT;
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = TAB_HEIGHT;
-
+
mGetFieldsButton = (Button) findViewById(R.id.get_fields_button);
-
mGetFieldsButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- /*
- * Source Tag:
- */
- FieldsConnectionsDialog.this.dismiss();
- if(!fieldsVector.isEmpty()) {
- explorerActivity.getFields(fieldsVector);
- } else {
- Toast.makeText(explorerActivity.getBaseContext(), "No Fields selected.", Toast.LENGTH_SHORT).show();
- }
- }
+ @Override
+ public void onClick(View v) {
+ /*
+ * Source Tag:
+ */
+ FieldsConnectionsDialog.this.dismiss();
+ if (!fieldsVector.isEmpty()) {
+ explorerActivity.getFields(fieldsVector);
+ } else {
+ Toast.makeText(explorerActivity.getBaseContext(), "No Fields selected.",
+ Toast.LENGTH_SHORT).show();
+ }
+ }
});
-
+
connectionsList.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView> arg0, View v, int position, long arg3) {
- FieldsConnectionsDialog.this.dismiss();
- explorerActivity.getConnection(connectionsArray.get(position));
+ @Override
+ public void onItemClick(AdapterView> arg0, View v, int position, long arg3) {
+ FieldsConnectionsDialog.this.dismiss();
+ explorerActivity.getConnection(connectionsArray.get(position));
}
});
}
-
+
/**
* Definition of the list adapter
*/
- public class FieldsListAdapter extends BaseAdapter {
- private LayoutInflater mInflater;
- boolean []isChecked;
-
- public FieldsListAdapter() {
- mInflater = LayoutInflater.from(explorerActivity.getBaseContext());
- isChecked = new boolean[fieldsArray.size()];
- }
-
- @Override
- public int getCount() {
- return fieldsArray.size();
- }
-
- @Override
- public Object getItem(int position) {
- return null;
- }
-
- @Override
- public long getItemId(int position) {
- return 0;
- }
-
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
-
- View hView = convertView;
- ViewHolder holder;
- JSONObject fieldObject = null;
- fieldObject = (JSONObject)fieldsArray.get(position);
-
- if(hView == null) {
- hView = mInflater.inflate(R.layout.fields_item, null);
- holder = new ViewHolder();
- holder.checkbox = (CheckBox) hView.findViewById(R.id.fields_checkbox);
- holder.fieldsInfo = (TextView) hView.findViewById(R.id.fields_info);
- hView.setTag(holder);
- } else {
- holder = (ViewHolder) hView.getTag();
- }
- try {
- holder.checkbox.setText(fieldObject.getString("name"));
- } catch (JSONException e) {
- holder.checkbox.setText("");
- }
- try {
- holder.fieldsInfo.setText(fieldObject.getString("description"));
- } catch (JSONException e) {
- holder.fieldsInfo.setText("");
- }
- holder.checkbox.setId(position);
- holder.checkbox.setChecked(isChecked[position]);
- holder.checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton button, boolean checked) {
- isChecked[button.getId()] = checked;
- String field = button.getText().toString();
- if(checked) {
- fieldsVector.add(field);
- } else if (fieldsVector.contains(field)) {
- fieldsVector.remove(field);
- }
- }
- });
-
- return hView;
- }
- }
-
- class ViewHolder {
- CheckBox checkbox;
- TextView fieldsInfo;
- }
-
+ public class FieldsListAdapter extends BaseAdapter {
+ private LayoutInflater mInflater;
+ boolean[] isChecked;
+
+ public FieldsListAdapter() {
+ mInflater = LayoutInflater.from(explorerActivity.getBaseContext());
+ isChecked = new boolean[fieldsArray.size()];
+ }
+
+ @Override
+ public int getCount() {
+ return fieldsArray.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public View getView(final int position, View convertView, ViewGroup parent) {
+
+ View hView = convertView;
+ ViewHolder holder;
+ JSONObject fieldObject = null;
+ fieldObject = fieldsArray.get(position);
+
+ if (hView == null) {
+ hView = mInflater.inflate(R.layout.fields_item, null);
+ holder = new ViewHolder();
+ holder.checkbox = (CheckBox) hView.findViewById(R.id.fields_checkbox);
+ holder.fieldsInfo = (TextView) hView.findViewById(R.id.fields_info);
+ hView.setTag(holder);
+ } else {
+ holder = (ViewHolder) hView.getTag();
+ }
+ try {
+ holder.checkbox.setText(fieldObject.getString("name"));
+ } catch (JSONException e) {
+ holder.checkbox.setText("");
+ }
+ try {
+ holder.fieldsInfo.setText(fieldObject.getString("description"));
+ } catch (JSONException e) {
+ holder.fieldsInfo.setText("");
+ }
+ holder.checkbox.setId(position);
+ holder.checkbox.setChecked(isChecked[position]);
+ holder.checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton button, boolean checked) {
+ isChecked[button.getId()] = checked;
+ String field = button.getText().toString();
+ if (checked) {
+ fieldsVector.add(field);
+ } else if (fieldsVector.contains(field)) {
+ fieldsVector.remove(field);
+ }
+ }
+ });
+
+ return hView;
+ }
+ }
+
+ class ViewHolder {
+ CheckBox checkbox;
+ TextView fieldsInfo;
+ }
+
/**
* Definition of the list adapter
*/
- public class ConnectionsListAdapter extends BaseAdapter {
- private LayoutInflater mInflater;
-
- public ConnectionsListAdapter() {
- mInflater = LayoutInflater.from(explorerActivity.getBaseContext());
- }
-
- @Override
- public int getCount() {
- return connectionsArray.size();
- }
-
- @Override
- public Object getItem(int position) {
- return null;
- }
-
- @Override
- public long getItemId(int position) {
- return 0;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
-
- View hView = convertView;
- TextView connection;
- if(hView == null) {
- hView = mInflater.inflate(R.layout.connection_item, null);
- connection = (TextView) hView.findViewById(R.id.connection_name);
- hView.setTag(connection);
- } else {
- connection = (TextView) hView.getTag();
- }
- SpannableString name;
- name = new SpannableString(connectionsArray.get(position));
- name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
- connection.setText(name);
- return hView;
- }
- }
-}
+ public class ConnectionsListAdapter extends BaseAdapter {
+ private LayoutInflater mInflater;
+
+ public ConnectionsListAdapter() {
+ mInflater = LayoutInflater.from(explorerActivity.getBaseContext());
+ }
+
+ @Override
+ public int getCount() {
+ return connectionsArray.size();
+ }
+ @Override
+ public Object getItem(int position) {
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View hView = convertView;
+ TextView connection;
+ if (hView == null) {
+ hView = mInflater.inflate(R.layout.connection_item, null);
+ connection = (TextView) hView.findViewById(R.id.connection_name);
+ hView.setTag(connection);
+ } else {
+ connection = (TextView) hView.getTag();
+ }
+ SpannableString name;
+ name = new SpannableString(connectionsArray.get(position));
+ name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
+ connection.setText(name);
+ return hView;
+ }
+ }
+}
diff --git a/examples/Hackbook/src/com/facebook/android/FriendsGetProfilePics.java b/examples/Hackbook/src/com/facebook/android/FriendsGetProfilePics.java
index e2f251baa1..b2bbd046ca 100644
--- a/examples/Hackbook/src/com/facebook/android/FriendsGetProfilePics.java
+++ b/examples/Hackbook/src/com/facebook/android/FriendsGetProfilePics.java
@@ -10,99 +10,101 @@
/*
* Fetch friends profile pictures request via AsyncTask
*/
+public class FriendsGetProfilePics {
-public class FriendsGetProfilePics
-{
- Hashtable friendsImages;
- Hashtable positionRequested;
- BaseAdapter listener;
- int runningCount = 0;
- Stack queue;
-
- /*
- * 15 max async tasks at any given time.
- */
- final int MAX_ALLOWED_TASKS = 15;
-
- public FriendsGetProfilePics() {
- friendsImages = new Hashtable();
- positionRequested = new Hashtable();
- queue = new Stack();
- }
-
- /*
- * Inform the listener when the image has been downloaded.
- * listener is FriendsList here.
- */
- public void setListener(BaseAdapter listener) {
- this.listener = listener;
- reset();
- }
-
- public void reset() {
- positionRequested.clear();
- runningCount = 0;
- queue.clear();
- }
-
- /*
- * If the profile pictore has already been downloaded and cached, return it
- * else excecute a new async task to fetch it -
- * if total async tasks >15, queue the request.
- */
- public Bitmap getImage(String uid, String url) {
- Bitmap image = (Bitmap)friendsImages.get(uid);
- if(image != null) {
- return image;
- }
- if(!positionRequested.containsKey(uid)) {
- positionRequested.put(uid, "");
- if (runningCount >= MAX_ALLOWED_TASKS) {
- queue.push(new ItemPair(uid, url));
- } else {
- runningCount++;
- new GetProfilePicAsyncTask().execute(uid, url);
- }
- }
- return null;
- }
-
- public void getNextImage() {
- if(!queue.isEmpty()) {
- ItemPair item = (ItemPair)queue.pop();
- new GetProfilePicAsyncTask().execute(item.uid, item.url);
- }
- }
-
- /*
- * Start a AsyncTask to fetch the request
- */
- private class GetProfilePicAsyncTask extends AsyncTask