use of com.xabber.android.data.extension.bookmarks.BookmarkVO in project xabber-android by redsolution.
the class BookmarksActivity method getBookmarks.
private List<BookmarkVO> getBookmarks(boolean cleanCache) {
final List<BookmarkVO> bookmarksList = new ArrayList<>();
if (cleanCache)
BookmarksManager.getInstance().cleanCache(accountItem.getAccount());
// urls
List<BookmarkedURL> bookmarkedURLs = BookmarksManager.getInstance().getUrlFromBookmarks(accountItem.getAccount());
for (int i = 0; i < bookmarkedURLs.size(); i++) {
BookmarkedURL url = bookmarkedURLs.get(i);
bookmarksList.add(new BookmarkVO(url.getName(), url.getURL()));
}
List<BookmarkedConference> bookmarkedConferences;
try {
bookmarkedConferences = BookmarksManager.getInstance().getConferencesFromBookmarks(accountItem.getAccount());
} catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
LogManager.exception(this, e);
bookmarkedConferences = Collections.emptyList();
}
for (int i = 0; i < bookmarkedConferences.size(); i++) {
BookmarkedConference conference = bookmarkedConferences.get(i);
bookmarksList.add(new BookmarkVO(conference.getName() != null ? conference.getName() : "", conference.getJid() != null ? conference.getJid().toString() : "", conference.getNickname() != null ? conference.getNickname().toString() : "", conference.getPassword() != null ? conference.getPassword() : ""));
}
return bookmarksList;
}
use of com.xabber.android.data.extension.bookmarks.BookmarkVO in project xabber-android by redsolution.
the class BookmarkAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
BookmarkVO bookmark = items.get(position);
View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
BookmarkVO bookmark = items.get(position);
CheckBox checkBox = (CheckBox) v.findViewById(R.id.chbBookmark);
// can't remove xabber url which need for conference sync
if (bookmark.getUrl().equals(BookmarksManager.XABBER_URL))
return;
if (checkedItems.contains(bookmark)) {
checkedItems.remove(bookmark);
checkBox.setChecked(false);
} else {
checkedItems.add(bookmark);
checkBox.setChecked(true);
}
if (listener != null) {
listener.onBookmarkClick();
}
}
};
switch(holder.getItemViewType()) {
case BookmarkVO.TYPE_URL:
UrlHolder urlHolder = (UrlHolder) holder;
urlHolder.tvName.setText(bookmark.getName());
urlHolder.tvUrl.setText(bookmark.getUrl());
urlHolder.chbBookmark.setChecked(checkedItems.contains(bookmark));
urlHolder.chbBookmark.setOnClickListener(onClickListener);
if (bookmark.getUrl().equals(BookmarksManager.XABBER_URL))
urlHolder.chbBookmark.setVisibility(View.INVISIBLE);
else
urlHolder.chbBookmark.setVisibility(View.VISIBLE);
break;
case BookmarkVO.TYPE_CONFERENCE:
ConferenceHolder conferenceHolder = (ConferenceHolder) holder;
conferenceHolder.tvName.setText(bookmark.getName());
conferenceHolder.tvJid.setText(bookmark.getJid());
conferenceHolder.tvNickname.setText(bookmark.getNickname());
conferenceHolder.chbBookmark.setChecked(checkedItems.contains(bookmark));
conferenceHolder.chbBookmark.setOnClickListener(onClickListener);
break;
}
holder.itemView.setOnClickListener(onClickListener);
}
Aggregations