-
Notifications
You must be signed in to change notification settings - Fork 129
Examples CustomUI
vineetmobile edited this page Sep 18, 2013
·
3 revisions
This option lets you implement providers in your way. You can show them either in ListView , GridView , Context Menu , Dialog or any way you want.
ListView Example
Here is example how to use custom-ui with listview :
// Adapter initialization
adapter = new SocialAuthAdapter(new ResponseListener());
listview = (ListView)findViewById(R.id.listview);
listview.setAdapter(new CustomAdapter(this, adapter));
On Clicking List item :
holder.text.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// providers array contains name of providers
adapter.authorize(context, providers[position]);
}
});
Single Provider Example
// Adapter initialization
adapter = new SocialAuthAdapter(new ResponseListener());
facebook_button = (Button)findViewById(R.id.fb_btn);
facebook_button.setBackgroundResource(R.drawable.facebook);
facebook_button.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
adapter.authorize(ProviderUI.this, Provider.FACEBOOK);
}
});
==Share Message and Links==
private final class ResponseListener implements DialogListener
{
public void onComplete(Bundle values) {
adapter.updateStatus(edit.getText().toString(), new MessageListener(),false);
}
public void onError(DialogError error) {
Log.d("Custom-UI" , "Error");
}
public void onCancel() {
Log.d("Custom-UI" , "Cancelled");
}
}
// To get status of message after authentication
private final class MessageListener implements SocialAuthListener<Integer> {
@Override
public void onExecute(Integer t) {
Integer status = t;
if (status.intValue() == 200 || status.intValue() == 201 ||status.intValue() == 204)
Toast.makeText(CustomUI.this, "Message posted",Toast.LENGTH_LONG).show();
else
Toast.makeText(CustomUI.this, "Message not posted",Toast.LENGTH_LONG).show();
}
@Override
public void onError(SocialAuthError e) {
}
}
To see the functionality, view custom-ui example from socialauth-android zip on Download Page.