use of twitter4j.UserList in project Talon-for-Twitter by klinker24.
the class ListsActivity method getLists.
public void getLists() {
new Thread(new Runnable() {
@Override
public void run() {
try {
Twitter twitter = Utils.getTwitter(context, settings);
final ResponseList<UserList> lists;
try {
lists = twitter.getUserLists(settings.myScreenName);
} catch (OutOfMemoryError e) {
return;
}
Collections.sort(lists, new Comparator<UserList>() {
public int compare(UserList result1, UserList result2) {
return result1.getName().compareTo(result2.getName());
}
});
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
if (lists.size() > 0) {
listView.setAdapter(new ListsArrayAdapter(context, lists));
listView.setVisibility(View.VISIBLE);
} else {
LinearLayout nothing = (LinearLayout) findViewById(R.id.no_content);
try {
nothing.setVisibility(View.VISIBLE);
} catch (Exception e) {
}
listView.setVisibility(View.GONE);
}
LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
spinner.setVisibility(View.GONE);
}
});
} catch (Exception e) {
e.printStackTrace();
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
LinearLayout nothing = (LinearLayout) findViewById(R.id.no_content);
nothing.setVisibility(View.VISIBLE);
listView.setVisibility(View.GONE);
LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
spinner.setVisibility(View.GONE);
}
});
}
}
}).start();
}
use of twitter4j.UserList in project twitter4j by yusuke.
the class CreateUserList method main.
/**
* Usage: java twitter4j.examples.list.CreateUserList [list name] [list description]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.CreateUserList [list name] [list description]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
String description = null;
if (args.length >= 2) {
description = args[1];
}
UserList list = twitter.createUserList(args[0], true, description);
System.out.println("Successfully created a list (id:" + list.getId() + ", slug:" + list.getSlug() + ").");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to create a list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.UserList in project twitter4j by yusuke.
the class DestroyUserList method main.
/**
* Usage: java twitter4j.examples.list.DestroyUserList [list id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.DestroyUserList [list id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
UserList list = twitter.destroyUserList(Integer.parseInt(args[0]));
System.out.println("Successfully deleted the list (id:" + list.getId() + ", slug:" + list.getSlug() + ").");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to delete a list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.UserList in project twitter4j by yusuke.
the class ShowUserList method main.
/**
* Usage: java twitter4j.examples.list.ShowUserList [list id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.ShowUserList [list id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
UserList list = twitter.showUserList(Integer.parseInt(args[0]));
System.out.println("id:" + list.getId() + ", name:" + list.getName() + ", description:" + list.getDescription() + ", slug:" + list.getSlug() + "");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to show the list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.UserList in project Talon-for-Twitter by klinker24.
the class ListChooser method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;
sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
settings = AppSettings.getInstance(this);
Utils.setUpTheme(context, settings);
setContentView(R.layout.list_chooser);
actionBar = getActionBar();
actionBar.setTitle(getResources().getString(R.string.lists));
if (!settings.isTwitterLoggedIn) {
Intent login = new Intent(context, LoginActivity.class);
startActivity(login);
finish();
}
listView = (AsyncListView) findViewById(R.id.listView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
UserList list = arrayAdapter.getItem(i);
Intent returnIntent = new Intent();
returnIntent.putExtra("listId", list.getId());
returnIntent.putExtra("listName", list.getName());
setResult(RESULT_OK, returnIntent);
finish();
}
});
new GetLists().execute();
}
Aggregations