Search in sources :

Example 1 with UserList

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();
}
Also used : Twitter(twitter4j.Twitter) DrawerActivity(com.klinker.android.twitter.activities.drawer_activities.DrawerActivity) LoginActivity(com.klinker.android.twitter.activities.setup.LoginActivity) Activity(android.app.Activity) UserList(twitter4j.UserList) ListsArrayAdapter(com.klinker.android.twitter.adapters.ListsArrayAdapter) LinearLayout(android.widget.LinearLayout)

Example 2 with UserList

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) UserList(twitter4j.UserList) TwitterException(twitter4j.TwitterException)

Example 3 with UserList

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) UserList(twitter4j.UserList) TwitterException(twitter4j.TwitterException)

Example 4 with UserList

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) UserList(twitter4j.UserList) TwitterException(twitter4j.TwitterException)

Example 5 with UserList

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();
}
Also used : Intent(android.content.Intent) AdapterView(android.widget.AdapterView) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AdapterView(android.widget.AdapterView) UserList(twitter4j.UserList)

Aggregations

UserList (twitter4j.UserList)5 Twitter (twitter4j.Twitter)4 TwitterException (twitter4j.TwitterException)3 TwitterFactory (twitter4j.TwitterFactory)3 Activity (android.app.Activity)1 Intent (android.content.Intent)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 LinearLayout (android.widget.LinearLayout)1 DrawerActivity (com.klinker.android.twitter.activities.drawer_activities.DrawerActivity)1 LoginActivity (com.klinker.android.twitter.activities.setup.LoginActivity)1 ListsArrayAdapter (com.klinker.android.twitter.adapters.ListsArrayAdapter)1 AsyncListView (org.lucasr.smoothie.AsyncListView)1