本文整理匯總了Java中com.lqr.wechat.db.model.Friend類的典型用法代碼示例。如果您正苦於以下問題:Java Friend類的具體用法?Java Friend怎麽用?Java Friend使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Friend類屬於com.lqr.wechat.db.model包,在下文中一共展示了Friend類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addGroupMembers
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public void addGroupMembers() {
ArrayList<String> selectedIds = new ArrayList<>(mSelectedData.size());
for (int i = 0; i < mSelectedData.size(); i++) {
Friend friend = mSelectedData.get(i);
selectedIds.add(friend.getUserId());
}
Intent data = new Intent();
data.putStringArrayListExtra("selectedIds", selectedIds);
mContext.setResult(Activity.RESULT_OK, data);
mContext.finish();
}
示例2: changeMyName
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
private void changeMyName() {
showWaitingDialog(UIUtils.getString(R.string.please_wait));
String nickName = mEtName.getText().toString().trim();
ApiRetrofit.getInstance().setName(nickName)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(setNameResponse -> {
hideWaitingDialog();
if (setNameResponse.getCode() == 200) {
Friend friend = DBManager.getInstance().getFriendById(UserCache.getId());
if (friend != null) {
friend.setName(nickName);
friend.setDisplayName(nickName);
DBManager.getInstance().saveOrUpdateFriend(friend);
BroadcastManager.getInstance(ChangeMyNameActivity.this).sendBroadcast(AppConst.CHANGE_INFO_FOR_ME);
BroadcastManager.getInstance(ChangeMyNameActivity.this).sendBroadcast(AppConst.CHANGE_INFO_FOR_CHANGE_NAME);
}
finish();
}
}, this::loadError);
}
示例3: saveFriends
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public synchronized void saveFriends(List<UserRelationshipResponse.ResultEntity> list) {
List<Friend> friends = new ArrayList<>();
for (UserRelationshipResponse.ResultEntity entity : list) {
if (entity.getStatus() == 20) {//已經是好友
Friend friend = new Friend(
entity.getUser().getId(),
entity.getUser().getNickname(),
entity.getUser().getPortraitUri(),
TextUtils.isEmpty(entity.getDisplayName()) ? entity.getUser().getNickname() : entity.getDisplayName(),
null, null, null, null,
PinyinUtils.getPinyin(entity.getUser().getNickname()),
PinyinUtils.getPinyin(TextUtils.isEmpty(entity.getDisplayName()) ? entity.getUser().getNickname() : entity.getDisplayName())
);
if (TextUtils.isEmpty(friend.getPortraitUri())) {
friend.setPortraitUri(getPortrait(friend));
}
friends.add(friend);
}
}
if (friends != null && friends.size() > 0)
DataSupport.saveAll(friends);
}
示例4: sortContacts
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public static void sortContacts(List<Friend> list) {
Collections.sort(list);//排序後由於#號排在上麵,故得把#號的部分集合移動到集合的最下麵
List<Friend> specialList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
//將屬於#號的集合分離開來
if (list.get(i).getNameSpelling().equalsIgnoreCase("#")) {
specialList.add(list.get(i));
}
}
if (specialList.size() != 0) {
list.removeAll(specialList);//先移出掉頂部的#號部分
list.addAll(list.size(), specialList);//將#號的集合添加到集合底部
}
}
示例5: initListener
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
@Override
public void initListener() {
mHeaderView.findViewById(R.id.llNewFriend).setOnClickListener(v -> {
((MainActivity) getActivity()).jumpToActivity(NewFriendActivity.class);
((MainActivity) getActivity()).mTvContactRedDot.setVisibility(View.GONE);
mTvNewFriendUnread.setVisibility(View.GONE);
});
mHeaderView.findViewById(R.id.llGroup).setOnClickListener(v -> ((MainActivity) getActivity()).jumpToActivity(GroupListActivity.class));
mQib.setOnLetterUpdateListener(new QuickIndexBar.OnLetterUpdateListener() {
@Override
public void onLetterUpdate(String letter) {
//顯示對話框
showLetter(letter);
//滑動到第一個對應字母開頭的聯係人
if ("↑".equalsIgnoreCase(letter)) {
mRvContacts.moveToPosition(0);
} else if ("☆".equalsIgnoreCase(letter)) {
mRvContacts.moveToPosition(0);
} else {
List<Friend> data = ((LQRAdapterForRecyclerView) ((LQRHeaderAndFooterAdapter) mRvContacts.getAdapter()).getInnerAdapter()).getData();
for (int i = 0; i < data.size(); i++) {
Friend friend = data.get(i);
String c = friend.getDisplayNameSpelling().charAt(0) + "";
if (c.equalsIgnoreCase(letter)) {
mRvContacts.moveToPosition(i);
break;
}
}
}
}
@Override
public void onLetterCancel() {
//隱藏對話框
hideLetter();
}
});
}
示例6: agreeFriends
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
private void agreeFriends(String friendId, LQRViewHolderForRecyclerView helper) {
if (!NetUtils.isNetworkAvailable(mContext)) {
UIUtils.showToast(UIUtils.getString(R.string.please_check_net));
return;
}
ApiRetrofit.getInstance().agreeFriends(friendId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new Func1<AgreeFriendsResponse, Observable<GetUserInfoByIdResponse>>() {
@Override
public Observable<GetUserInfoByIdResponse> call(AgreeFriendsResponse agreeFriendsResponse) {
if (agreeFriendsResponse != null && agreeFriendsResponse.getCode() == 200) {
helper.setViewVisibility(R.id.tvAdded, View.VISIBLE)
.setViewVisibility(R.id.btnAck, View.GONE);
return ApiRetrofit.getInstance().getUserInfoById(friendId);
}
return Observable.error(new ServerException(UIUtils.getString(R.string.agree_friend_fail)));
}
})
.subscribe(getUserInfoByIdResponse -> {
if (getUserInfoByIdResponse != null && getUserInfoByIdResponse.getCode() == 200) {
GetUserInfoByIdResponse.ResultEntity result = getUserInfoByIdResponse.getResult();
UserInfo userInfo = new UserInfo(UserCache.getId(), result.getNickname(), Uri.parse(result.getPortraitUri()));
if (TextUtils.isEmpty(userInfo.getPortraitUri().toString())) {
userInfo.setPortraitUri(Uri.parse(DBManager.getInstance().getPortraitUri(userInfo)));
}
Friend friend = new Friend(userInfo.getUserId(), userInfo.getName(), userInfo.getPortraitUri().toString());
DBManager.getInstance().saveOrUpdateFriend(friend);
UIUtils.postTaskDelay(() -> {
BroadcastManager.getInstance(UIUtils.getContext()).sendBroadcast(AppConst.UPDATE_FRIEND);
BroadcastManager.getInstance(UIUtils.getContext()).sendBroadcast(AppConst.UPDATE_CONVERSATIONS);
}, 1000);
}
}, this::loadError);
}
示例7: setSelectedAdapter
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
private void setSelectedAdapter() {
if (mSelectedAdapter == null) {
mSelectedAdapter = new LQRAdapterForRecyclerView<Friend>(mContext, mSelectedData, R.layout.item_selected_contact) {
@Override
public void convert(LQRViewHolderForRecyclerView helper, Friend item, int position) {
ImageView ivHeader = helper.getView(R.id.ivHeader);
Glide.with(mContext).load(item.getPortraitUri()).centerCrop().into(ivHeader);
}
};
getView().getRvSelectedContacts().setAdapter(mSelectedAdapter);
}
}
示例8: deleteAllUserInfo
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
/**
* 清除所有用戶數據
*/
public void deleteAllUserInfo() {
// deleteFriends();
// deleteGroups();
// deleteGroupMembers();
DataSupport.deleteAll(Friend.class);
DataSupport.deleteAll(GroupMember.class);
DataSupport.deleteAll(Groups.class);
//TODO:刪除黑名單數據
}
示例9: isMyFriend
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public boolean isMyFriend(String userid) {
Friend friend = getFriendById(userid);
if (friend != null) {
return true;
}
return false;
}
示例10: saveOrUpdateFriend
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public synchronized void saveOrUpdateFriend(Friend friend) {
if (friend != null) {
String portrait = friend.getPortraitUri();
if (TextUtils.isEmpty(portrait)) {
portrait = RongGenerate.generateDefaultAvatar(friend.getName(), friend.getUserId());
friend.setPortraitUri(portrait);
}
friend.saveOrUpdate("userid = ?", friend.getUserId());
//更新過本地好友數據後,清空內存中對應用戶信息緩存
if (mUserInfoCache != null && mUserInfoCache.containsKey(friend.getUserId())) {
mUserInfoCache.remove(friend.getUserId());
}
}
}
示例11: getFriendById
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public synchronized Friend getFriendById(String userid) {
if (!TextUtils.isEmpty(userid)) {
List<Friend> friends = DataSupport.where("userid = ?", userid).find(Friend.class);
if (friends != null && friends.size() > 0)
return friends.get(0);
}
return null;
}
示例12: setAdapter
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
private void setAdapter() {
if (mAdapter == null) {
LQRAdapterForRecyclerView adapter = new LQRAdapterForRecyclerView<Friend>(mContext, mData, R.layout.item_contact) {
@Override
public void convert(LQRViewHolderForRecyclerView helper, Friend item, int position) {
helper.setText(R.id.tvName, item.getDisplayName());
ImageView ivHeader = helper.getView(R.id.ivHeader);
Glide.with(mContext).load(item.getPortraitUri()).centerCrop().into(ivHeader);
String str = "";
//得到當前字母
String currentLetter = item.getDisplayNameSpelling().charAt(0) + "";
if (position == 0) {
str = currentLetter;
} else {
//得到上一個字母
String preLetter = mData.get(position - 1).getDisplayNameSpelling().charAt(0) + "";
//如果和上一個字母的首字母不同則顯示字母欄
if (!preLetter.equalsIgnoreCase(currentLetter)) {
str = currentLetter;
}
}
int nextIndex = position + 1;
if (nextIndex < mData.size() - 1) {
//得到下一個字母
String nextLetter = mData.get(nextIndex).getDisplayNameSpelling().charAt(0) + "";
//如果和下一個字母的首字母不同則隱藏下劃線
if (!nextLetter.equalsIgnoreCase(currentLetter)) {
helper.setViewVisibility(R.id.vLine, View.INVISIBLE);
} else {
helper.setViewVisibility(R.id.vLine, View.VISIBLE);
}
} else {
helper.setViewVisibility(R.id.vLine, View.INVISIBLE);
}
if (position == mData.size() - 1) {
helper.setViewVisibility(R.id.vLine, View.GONE);
}
//根據str是否為空決定字母欄是否顯示
if (TextUtils.isEmpty(str)) {
helper.setViewVisibility(R.id.tvIndex, View.GONE);
} else {
helper.setViewVisibility(R.id.tvIndex, View.VISIBLE);
helper.setText(R.id.tvIndex, str);
}
}
};
adapter.addHeaderView(getView().getHeaderView());
adapter.addFooterView(getView().getFooterView());
mAdapter = adapter.getHeaderAndFooterAdapter();
getView().getRvContacts().setAdapter(mAdapter);
}
((LQRAdapterForRecyclerView) mAdapter.getInnerAdapter()).setOnItemClickListener((lqrViewHolder, viewGroup, view, i) -> {
Intent intent = new Intent(mContext, UserInfoActivity.class);
intent.putExtra("userInfo", DBManager.getInstance().getUserInfo(mData.get(i - 1).getUserId()));//-1是因為有頭部
mContext.jumpToActivity(intent);
});
}
示例13: initListener
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
@Override
public void initListener() {
mBtnToolbarSend.setOnClickListener(v -> {
if (mSelectedTeamMemberAccounts == null) {
mPresenter.createGroup();
} else {
//添加群成員
mPresenter.addGroupMembers();
}
});
mHeaderView.findViewById(R.id.tvSelectOneGroup).setOnClickListener(v -> UIUtils.showToast("選擇一個群"));
mQib.setOnLetterUpdateListener(new QuickIndexBar.OnLetterUpdateListener() {
@Override
public void onLetterUpdate(String letter) {
//顯示對話框
showLetter(letter);
//滑動到第一個對應字母開頭的聯係人
if ("↑".equalsIgnoreCase(letter)) {
mRvContacts.moveToPosition(0);
} else if ("☆".equalsIgnoreCase(letter)) {
mRvContacts.moveToPosition(0);
} else {
List<Friend> data = ((LQRAdapterForRecyclerView) ((LQRHeaderAndFooterAdapter) mRvContacts.getAdapter()).getInnerAdapter()).getData();
for (int i = 0; i < data.size(); i++) {
Friend friend = data.get(i);
String c = friend.getDisplayNameSpelling().charAt(0) + "";
if (c.equalsIgnoreCase(letter)) {
mRvContacts.moveToPosition(i);
break;
}
}
}
}
@Override
public void onLetterCancel() {
//隱藏對話框
hideLetter();
}
});
}
示例14: deleteFriend
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public synchronized void deleteFriend(Friend friend) {
DataSupport.deleteAll(Friend.class, "userid = ?", friend.getUserId());
}
示例15: getFriends
import com.lqr.wechat.db.model.Friend; //導入依賴的package包/類
public synchronized List<Friend> getFriends() {
// return DataSupport.findAll(Friend.class);
return DataSupport.where("userid != ?", UserCache.getId()).find(Friend.class);
}