use of com.lingtuan.firefly.contact.vo.NewContactVO in project SmartMesh_Android by SmartMeshFoundation.
the class MainContactFragmentUI method onItemLongClick.
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (position < 1 || position >= mContactList.size() + 1) {
return true;
}
NewContactVO vo = (NewContactVO) mContactList.get(position - 1);
ShowDeleteDialog(vo.getLocalId(), ((NewContactVO) mContactList.get(position - 1)).isOffLine());
return true;
}
use of com.lingtuan.firefly.contact.vo.NewContactVO in project SmartMesh_Android by SmartMeshFoundation.
the class MainContactFragmentUI method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position >= mContactList.size() + 1) {
return;
} else if (position == 0) {
// group chat
startActivity(new Intent(getActivity(), DiscussGroupListUI.class));
Utils.openNewActivityAnim(getActivity(), false);
return;
}
NewContactVO baseVo = (NewContactVO) mContactList.get(position - 1);
baseVo.setFriendLog(1);
Utils.intentFriendUserInfo(getActivity(), baseVo, false);
}
use of com.lingtuan.firefly.contact.vo.NewContactVO in project SmartMesh_Android by SmartMeshFoundation.
the class MainContactFragmentUI method deleteFriends.
/**
* Remove buddy
*/
private void deleteFriends(final String uid, final boolean isFriendOffline) {
if (isFriendOffline) {
FinalUserDataBase.getInstance().deleteFriendByUid(uid);
int i = 0;
for (UserBaseVo info : mFriendInfoList) {
if (uid.equals(info.getLocalId())) {
mFriendInfoList.remove(i);
break;
}
i++;
}
mContactList.clear();
for (UserBaseVo voT : mFriendInfoList) {
NewContactVO info = new NewContactVO();
info.setAge(voT.getAge());
info.setDistance(voT.getDistance());
info.setFriendLog(voT.getFriendLog());
info.setGender(voT.getGender());
info.setSightml(voT.getSightml());
info.setThumb(voT.getThumb());
info.setLocalId(voT.getLocalId());
info.setUsername(voT.getUserName());
info.setNote(voT.getNote());
info.setLogintime(voT.getLogintime());
info.setFullName(PinYin.getPinYin(voT.getShowName()));
info.setMid(voT.getMid());
info.setOffLine(voT.isOffLine());
mContactList.add(info);
}
mNewListView.setFastScrollEnabled(true);
Collections.sort(mContactList, new ContactItemComparator());
mNewContactListAdapter.updateList(mContactList);
contactNum.setText(getString(R.string.contact_num, mContactList.size()));
} else {
NetRequestImpl.getInstance().deleteFriends(uid, new RequestListener() {
@Override
public void start() {
}
@Override
public void success(JSONObject response) {
showToast(response.optString("msg"));
FinalUserDataBase.getInstance().deleteFriendByUid(uid);
int i = 0;
for (UserBaseVo info : mFriendInfoList) {
if (uid.equals(info.getLocalId())) {
mFriendInfoList.remove(i);
break;
}
i++;
}
mContactList.clear();
for (UserBaseVo voT : mFriendInfoList) {
NewContactVO info = new NewContactVO();
info.setAge(voT.getAge());
info.setDistance(voT.getDistance());
info.setFriendLog(voT.getFriendLog());
info.setGender(voT.getGender());
info.setSightml(voT.getSightml());
info.setThumb(voT.getThumb());
info.setLocalId(voT.getLocalId());
info.setUsername(voT.getUserName());
info.setNote(voT.getNote());
info.setLogintime(voT.getLogintime());
info.setFullName(PinYin.getPinYin(voT.getShowName()));
info.setMid(voT.getMid());
info.setOffLine(voT.isOffLine());
mContactList.add(info);
}
mNewListView.setFastScrollEnabled(true);
Collections.sort(mContactList, new ContactItemComparator());
mNewContactListAdapter.updateList(mContactList);
contactNum.setText(getString(R.string.contact_num, mContactList.size()));
}
@Override
public void error(int errorCode, String errorMsg) {
showToast(errorMsg);
}
});
}
}
use of com.lingtuan.firefly.contact.vo.NewContactVO in project SmartMesh_Android by SmartMeshFoundation.
the class SelectContactUI method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position >= mContactList.size() + 1) {
return;
} else if (position == 0) {
showSearch();
return;
}
if (isMultipleChoice) {
// multi-select
NewContactVO baseVo = (NewContactVO) mContactList.get(position - 1);
if (baseVo.isCantChecked()) {
return;
}
baseVo.setChecked(!baseVo.isChecked());
mNewContactListAdapter.notifyDataSetChanged();
if (baseVo.isChecked()) {
final ImageView imageView = new ImageView(SelectContactUI.this);
imageView.setTag(baseVo.getLocalId());
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
clickSelectVo(imageView);
}
});
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Utils.dip2px(SelectContactUI.this, 40), Utils.dip2px(SelectContactUI.this, 40));
lp.setMargins(Utils.dip2px(SelectContactUI.this, 10), Utils.dip2px(SelectContactUI.this, 5), 0, 0);
mHorizontalScrollViewContent.addView(imageView, lp);
NextApplication.displayCircleImage(imageView, baseVo.getThumb());
selectList.add(baseVo);
new Handler().postDelayed(new Runnable() {
public void run() {
mHorizontalScrollView.smoothScrollTo(mHorizontalScrollViewContent.getChildCount() * Utils.dip2px(SelectContactUI.this, 50), 0);
}
}, 0);
if (hasSelectList == null && !mFinishBtn.isEnabled()) {
mFinishBtn.setEnabled(true);
}
if (hasSelectList != null) {
hasSelectList.add(baseVo);
}
} else {
for (int i = 0; i < mHorizontalScrollViewContent.getChildCount(); i++) {
View imageView = mHorizontalScrollViewContent.getChildAt(i);
if (baseVo.getLocalId().equals(imageView.getTag())) {
mHorizontalScrollViewContent.removeViewAt(i);
break;
}
}
for (int i = 0; i < selectList.size(); i++) {
if (selectList.get(i).getLocalId().equals(baseVo.getLocalId())) {
selectList.remove(i);
break;
}
}
if (hasSelectList == null && selectList.size() <= 0) {
if (mFinishBtn.isEnabled()) {
mFinishBtn.setEnabled(false);
}
}
if (hasSelectList != null) {
int hasSelectCount = hasSelectList.size();
for (int i = 0; i < hasSelectCount; i++) {
UserBaseVo vo = hasSelectList.get(i);
if (vo.getLocalId().equals(baseVo.getLocalId())) {
hasSelectList.remove(i);
break;
}
}
}
}
} else {
NewContactVO baseVo = (NewContactVO) mContactList.get(position - 1);
clickSingleItem(baseVo);
}
}
use of com.lingtuan.firefly.contact.vo.NewContactVO in project SmartMesh_Android by SmartMeshFoundation.
the class SelectContactUI method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0 && resultCode == RESULT_OK) {
final String uid = data.getStringExtra("uid");
final String avatarUrl = data.getStringExtra("avatarurl");
final String username = data.getStringExtra("username");
final String gender = data.getStringExtra("gender");
UserBaseVo vo = new UserBaseVo();
vo.setLocalId(uid);
vo.setThumb(avatarUrl);
vo.setUsername(username);
vo.setGender(gender);
clickSingleItem(vo);
} else if (requestCode == 10 && resultCode == RESULT_OK) {
final String uid = data.getStringExtra("uid");
final String avatarUrl = data.getStringExtra("avatarurl");
final String username = data.getStringExtra("username");
final String gender = data.getStringExtra("gender");
UserBaseVo vo = new UserBaseVo();
vo.setLocalId(uid);
vo.setThumb(avatarUrl);
vo.setUsername(username);
vo.setGender(gender);
clickSingleItem(vo);
} else if (requestCode == 100 && resultCode == RESULT_OK) {
final String gid = data.getStringExtra("gid");
final String avatarUrl = data.getStringExtra("avatarurl");
final String username = data.getStringExtra("groupName");
final String gender = data.getStringExtra("gender");
UserBaseVo vo = new UserBaseVo();
vo.setLocalId(gid);
vo.setThumb(avatarUrl);
vo.setUsername(username);
vo.setGender(gender);
clickSingleItem(vo);
} else if (requestCode == 1000 && resultCode == RESULT_OK) {
// Choose common contact back
ArrayList<UserBaseVo> selectListT = (ArrayList<UserBaseVo>) data.getSerializableExtra("selectList");
if (selectListT != null) {
selectList.clear();
selectList.addAll(selectListT);
if (selectList.size() <= 0) {
mFinishBtn.setEnabled(false);
} else {
mFinishBtn.setEnabled(true);
}
for (int i = 0; i < mContactList.size(); i++) {
NewContactVO item = (NewContactVO) mContactList.get(i);
boolean found = false;
for (int m = 0; m < selectList.size(); m++) {
if (selectList.get(m).getLocalId().equals(item.getLocalId())) {
item.setChecked(true);
found = true;
break;
}
}
if (!found) {
item.setChecked(false);
}
}
mNewContactListAdapter.notifyDataSetChanged();
mHorizontalScrollViewContent.removeAllViews();
for (int i = 0; i < selectList.size(); i++) {
final ImageView imageView = new ImageView(SelectContactUI.this);
imageView.setTag(selectList.get(i).getLocalId());
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
clickSelectVo(imageView);
}
});
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Utils.dip2px(SelectContactUI.this, 40), Utils.dip2px(SelectContactUI.this, 40));
lp.setMargins(Utils.dip2px(SelectContactUI.this, 10), Utils.dip2px(SelectContactUI.this, 5), 0, 0);
mHorizontalScrollViewContent.addView(imageView, lp);
NextApplication.displayCircleImage(imageView, selectList.get(i).getThumb());
}
new Handler().postDelayed(new Runnable() {
public void run() {
mHorizontalScrollView.smoothScrollTo(mHorizontalScrollViewContent.getChildCount() * Utils.dip2px(SelectContactUI.this, 50), 0);
}
}, 0);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
Aggregations