Example usage for twitter4j UserList getId

List of usage examples for twitter4j UserList getId

Introduction

In this page you can find the example usage for twitter4j UserList getId.

Prototype

long getId();

Source Link

Document

Returns the id of the list

Usage

From source file:alberapps.java.noticias.tw.tw4j.ProcesarTwitter4j.java

License:Open Source License

/**
 * Recuperar la lista indicada/*  w  w  w . j  a v a 2  s .  c om*/
 *
 * @param twuser
 * @param url
 * @param elementos
 * @return listado
 */
public List<TwResultado> recuperarListaUsuario(String twuser, String url, int elementos) throws Exception {

    List<TwResultado> listaResultados = new ArrayList<>();

    Paging pagina = new Paging(1, 25);

    //pagina.setCount(elementos);

    UserList userList = twitter.showUserList(twuser, "tiempobuslist");

    ResponseList<Status> timeline = twitter.getUserListStatuses(userList.getId(), pagina);

    listaResultados = new ArrayList<>();

    Status linea = timeline.get(0);

    TwResultado resultado = null;

    for (int i = 0; i < timeline.size(); i++) {

        resultado = new TwResultado();

        resultado.setId(Long.toString(timeline.get(i).getId()));
        resultado.setFechaDate(timeline.get(i).getCreatedAt());

        resultado.setFecha(formatearFechaTw(resultado.getFechaDate()));

        resultado.setNombreCompleto(timeline.get(i).getUser().getName());
        resultado.setUsuario("@" + timeline.get(i).getUser().getScreenName());
        resultado.setMensaje(timeline.get(i).getText());
        resultado.setImagen(timeline.get(i).getUser().getBiggerProfileImageURL());

        resultado.setRetweet(timeline.get(i).isRetweet());

        resultado.setUrl(url);

        resultado.setRespuestaId(timeline.get(i).getInReplyToUserId());

        Log.d("twitter", "resp: " + resultado.getRespuestaId());

        listaResultados.add(resultado);

    }

    //throw new Exception("prueba");

    return listaResultados;

}

From source file:com.daiv.android.twitter.adapters.ListsArrayAdapter.java

License:Apache License

public void bindView(final View view, Context mContext, final UserList list) {
    final ViewHolder holder = (ViewHolder) view.getTag();

    final String name = list.getName();
    final String id = list.getId() + "";

    holder.text.setText(name);/* w w w  .  j  a v  a 2 s.  c  om*/

    holder.text.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setItems(R.array.lists_options, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    final int DELETE_LIST = 0;
                    final int VIEW_USERS = 1;
                    switch (i) {
                    case DELETE_LIST:
                        new DeleteList().execute(id + "");
                        break;
                    }

                }
            });

            builder.create();
            builder.show();

            return false;
        }
    });

}

From source file:com.daiv.android.twitter.settings.configure_pages.ListChooserArrayAdapter.java

License:Apache License

@Override
public void bindView(final View view, Context mContext, final UserList list) {
    final ViewHolder holder = (ViewHolder) view.getTag();

    final String name = list.getName();
    final String id = list.getId() + "";

    holder.text.setText(name);//ww  w. j  av a 2 s. c o  m
}

From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java

License:Open Source License

public void changeUserList(final long account_id, final UserList user_list) {
    if (user_list == null || getActivity() == null || !isMyActivatedAccount(getActivity(), account_id))
        return;//from w  w w.jav a 2  s .c  o m
    getLoaderManager().destroyLoader(0);
    final User user = user_list.getUser();
    if (user == null)
        return;
    final boolean is_my_activated_account = isMyActivatedAccount(getActivity(), user_list.getId());
    mErrorRetryContainer.setVisibility(View.GONE);
    mAccountId = account_id;
    mUserListId = user_list.getId();
    mUserName = user.getName();
    mUserId = user.getId();
    mUserScreenName = user.getScreenName();
    mListName = user_list.getName();
    mListSlug = user_list.getSlug();

    final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1;

    mListView.setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0);
    if (is_multiple_account_enabled) {
        final Drawable d = mListView.getBackground();
        if (d != null) {
            d.mutate().setColorFilter(getAccountColor(getActivity(), account_id), PorterDuff.Mode.MULTIPLY);
            mListView.invalidate();
        }
    }

    mListNameView.setText(mListName);
    mUserNameView.setText(mDisplayName ? mUserName : mUserScreenName);
    final String description = user_list.getDescription();
    mDescriptionContainer
            .setVisibility(is_my_activated_account || !isNullOrEmpty(description) ? View.VISIBLE : View.GONE);
    mDescriptionContainer.setOnLongClickListener(this);
    mDescriptionView.setText(description);
    final TwidereLinkify linkify = new TwidereLinkify(mDescriptionView);
    linkify.setOnLinkClickListener(this);
    linkify.addAllLinks();
    mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    final String profile_image_url_string = parseString(user.getProfileImageURL());
    final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image);
    mProfileImageLoader.displayProfileImage(mProfileImageView,
            hires_profile_image ? getBiggerTwitterProfileImage(profile_image_url_string)
                    : profile_image_url_string);
    mUserList = user_list;
    //if (mUserId == mAccountId) {
    mFollowMoreButton.setText(R.string.more);
    mFollowMoreButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.expander_open_holo, 0);
    //} else {
    //   mFollowMoreButton.setText(user_list.isFollowing() ? R.string.unfollow : R.string.follow);
    //   mFollowMoreButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    //}
    mAdapter.notifyDataSetChanged();
}

From source file:com.dwdesign.tweetings.loader.UserListMembersLoader.java

License:Open Source License

@Override
public List<ParcelableUser> getUsers() throws TwitterException {
    final Twitter twitter = getTwitter();
    if (twitter == null)
        return null;
    final PagableResponseList<User> users;
    if (mListId > 0) {
        if (mUserListId <= 0) {
            mUserListId = mListId;/*  www.  j a  v  a  2s  . co  m*/
        }
        if (mOwnerId <= 0) {
            final UserList list = twitter.showUserList(mListId);
            final User owner = list != null ? list.getUser() : null;
            mOwnerId = owner != null ? owner.getId() : -1;
        }
        users = twitter.getUserListMembers(mListId, mCursor);
    } else {
        final UserList list = findUserList(twitter, mUserId, mScreenName, mListName);
        if (list == null)
            return null;
        if (mOwnerId <= 0) {
            final User owner = list.getUser();
            mOwnerId = owner != null ? owner.getId() : -1;
        }
        if (list != null && list.getId() > 0) {
            if (mUserListId <= 0) {
                mUserListId = list.getId();
            }
            users = twitter.getUserListMembers(list.getId(), mCursor);
        } else
            return null;
    }
    mNextCursor = users.getNextCursor();
    mPrevCursor = users.getPreviousCursor();
    final List<ParcelableUser> result = new ArrayList<ParcelableUser>();
    final int size = users.size();
    for (int i = 0; i < size; i++) {
        result.add(new ParcelableUser(users.get(i), mAccountId, (mCursor + 1) * 20 + i));
    }
    return result;
}

From source file:com.dwdesign.tweetings.loader.UserListSubscribersLoader.java

License:Open Source License

@Override
public List<ParcelableUser> getUsers() throws TwitterException {
    final Twitter twitter = getTwitter();
    if (twitter == null)
        return null;
    final PagableResponseList<User> users;
    if (mListId > 0) {
        users = twitter.getUserListSubscribers(mListId, mCursor);
    } else {//from www  .jav  a 2 s. co  m
        final UserList list = findUserList(twitter, mUserId, mScreenName, mListName);
        if (list != null && list.getId() > 0) {
            users = twitter.getUserListSubscribers(list.getId(), mCursor);
        } else
            return null;
    }
    mNextCursor = users.getNextCursor();
    mPrevCursor = users.getPreviousCursor();
    final List<ParcelableUser> result = new ArrayList<ParcelableUser>();
    final int size = users.size();
    for (int i = 0; i < size; i++) {
        result.add(new ParcelableUser(users.get(i), mAccountId, (mCursor + 1) * 20 + i));
    }
    return result;
}

From source file:com.dwdesign.tweetings.loader.UserListTimelineLoader.java

License:Open Source License

@Override
public ResponseList<Status> getStatuses(final Paging paging) throws TwitterException {
    if (mTwitter == null)
        return null;
    if (mListId > 0)
        return mTwitter.getUserListStatuses(mListId, paging);
    else {//w ww. j  av a 2s.  c o  m
        final UserList list = findUserList(mTwitter, mUserId, mScreenName, mListName);
        if (list != null && list.getId() > 0)
            return mTwitter.getUserListStatuses(list.getId(), paging);
    }
    return null;
}

From source file:com.dwdesign.tweetings.model.ParcelableUserList.java

License:Open Source License

public ParcelableUserList(final UserList list, final long account_id, final long position) {
    final User user = list.getUser();
    this.position = position;
    this.account_id = account_id;
    list_id = list.getId();
    is_public = list.isPublic();
    is_following = list.isFollowing();//from ww  w . j av  a  2  s  . co  m
    name = list.getName();
    description = list.getDescription();
    user_id = user.getId();
    user_name = user.getName();
    user_screen_name = user.getScreenName();
    user_profile_image_url = user.getProfileImageURL();
    user_profile_image_url_string = parseString(user_profile_image_url);
}

From source file:com.javielinux.tweettopics2.UserListsActivity.java

License:Apache License

private void createUserListsColumn(UserList userList) {

    ArrayList<Entity> created_column_list = DataFramework.getInstance().getEntityList("columns",
            "userlist_id=" + userList.getId());
    int position = 0;

    if (created_column_list.size() == 0) {
        position = ColumnsUtils.nextPositionColumn();

        Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_LIST_USER);
        Entity user_list = new Entity("columns");
        user_list.setValue("description", userList.getName());
        user_list.setValue("type_id", type);
        user_list.setValue("user_id", user_id);
        user_list.setValue("position", position);
        user_list.setValue("userlist_id", userList.getId());
        user_list.save();//w w w .java  2s. co m
        Toast.makeText(this, getString(R.string.column_created, userList.getName()), Toast.LENGTH_LONG).show();
    } else {
        position = created_column_list.get(0).getInt("position");
    }

    Intent intent = getIntent();
    intent.putExtra("position", position);

    setResult(RESULT_OK, intent);
    finish();

    /*ArrayList<Entity> created_column_list = DataFramework.getInstance().getEntityList("columns", "userlist_id=" + userList.getId());
            
    int position = 0;
            
    if (created_column_list.size() == 0) {
    position = DBUtils.nextPositionColumn();
            
    Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_LIST_USER);
    Entity user_list = new Entity("columns");
    user_list.setValue("description", type.getString("description"));
    user_list.setValue("type_id", type);
    user_list.setValue("position", position);
    user_list.setValue("userlist_id", userList.getId());
    user_list.save();
    Toast.makeText(this, getString(R.string.column_created, userList.getString("name")), Toast.LENGTH_LONG).show();
    } else {
    position = created_column_list.get(0).getInt("position");
    }
            
    Intent intent = getIntent();
    intent.putExtra("position", position);
            
    setResult(RESULT_OK, intent);
    finish();*/
}

From source file:com.javielinux.tweettopics2.UserListsSelectorActivity.java

License:Apache License

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    userEntity = null;/*from ww  w .  j  a  v a2 s .  c  o  m*/

    try {
        DataFramework.getInstance().open(this, Utils.packageName);
        userEntity = DataFramework.getInstance().getTopEntity("users", "", "");
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (userEntity == null) {
        Utils.showMessage(this, R.string.error_general);
        finish();
    }

    nextCursor = -1;
    loadingMoreUserList = false;

    themeManager = new ThemeManager(this);
    themeManager.setTheme();

    setContentView(R.layout.userlistsselector_activity);

    mLayoutBackgroundApp = (LinearLayout) this.findViewById(R.id.user_lists_parent);
    layoutActionBar = (RelativeLayout) findViewById(R.id.user_list_bar_action);
    titlePage = (TextView) this.findViewById(R.id.user_list_bar_title);

    refreshTheme();

    viewNoLists = (LinearLayout) this.findViewById(R.id.user_lists_view_no_lists);
    viewLoading = (LinearLayout) this.findViewById(R.id.user_lists_view_loading);
    viewNoInternet = (LinearLayout) this.findViewById(R.id.user_lists_view_no_internet);
    viewUserLists = (GridView) this.findViewById(R.id.grid_userlist);
    viewUserInfo = (RelativeLayout) this.findViewById(R.id.user_info);

    userIcon = (ImageView) this.findViewById(R.id.user_icon);
    userFullname = (TextView) this.findViewById(R.id.user_fullname);
    userName = (TextView) this.findViewById(R.id.user_name);

    viewUserInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ArrayList<Entity> userEntityList = DataFramework.getInstance().getEntityList("users",
                    "service is null or service = \"twitter.com\"");

            final UsersAdapter adapter = new UsersAdapter(UserListsSelectorActivity.this, userEntityList);

            AlertDialog builder = new AlertDialog.Builder(UserListsSelectorActivity.this).setCancelable(true)
                    .setTitle(R.string.users).setAdapter(adapter, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            userEntity = adapter.getItem(which);
                            loadUserInfo();
                            reload();
                        }

                    }).setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }).create();
            builder.show();
        }
    });

    findViewById(R.id.user_list_bar_icon).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            UserListsSelectorActivity.this.finish();
        }
    });

    userListArrayList = new ArrayList<UserList>();
    userListsAdapter = new RowUserListsAdapter(this, userListArrayList);

    GridView gridUserList = (GridView) this.findViewById(R.id.grid_userlist);
    gridUserList.setAdapter(userListsAdapter);

    gridUserList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {
            UserList userList = userListsAdapter.getItem(pos);
            Intent intent = getIntent();
            intent.putExtra(KEY_ACTIVE_USER_ID, userEntity.getId());
            intent.putExtra(KEY_LIST_ID, userList.getId());
            setResult(RESULT_OK, intent);
            finish();
        }
    });

    gridUserList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            return true;
        }
    });

    loadUserInfo();
    reload();
}