use of com.lingtuan.firefly.util.MyDialogFragment in project SmartMesh_Android by SmartMeshFoundation.
the class MainMessageFragmentUI method onItemLongClick.
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
int itemArrayId;
final ChatMsg msg = mList.get(position);
if (msg.getChatId().equals("everyone")) {
itemArrayId = mList.get(position).isTop() ? R.array.delete_clear_top_chat_array : R.array.clear_to_top_chat_array;
} else {
itemArrayId = mList.get(position).isTop() ? R.array.delete_remove_top_chat_array : R.array.delete_to_top_chat_array;
}
MyDialogFragment mdf = new MyDialogFragment(MyDialogFragment.DIALOG_LIST, itemArrayId);
mdf.setItemClickCallback(new MyDialogFragment.ItemClickCallback() {
@Override
public void itemClickCallback(int which) {
switch(which) {
case // Placed at the top, cancel placed at the top
0:
{
long topTime = System.currentTimeMillis() / 1000;
msg.setTop(!msg.isTop());
if (msg.isTop()) {
msg.setTopTime(topTime);
}
Collections.sort(mList, new ChatMsgComparable());
mAdapter.updateList(mList);
FinalUserDataBase.getInstance().updateChatEventTop(msg.getChatId(), msg.isTop(), topTime);
for (int i = 0; i < mList.size(); i++) {
if (msg.equals(mList.get(i))) {
mListView.setSelection(i);
break;
}
}
}
break;
case 1:
{
Bundle bundle = new Bundle();
bundle.putInt("unread", -msg.getUnread());
Utils.intentAction(getActivity(), XmppAction.ACTION_MESSAGE_EVENT_LISTENER, bundle);
if (msg.getChatId().equals("everyone")) {
FinalUserDataBase.getInstance().clearChatMsgByChatId(msg.getChatId(), msg);
msg.setContent("");
msg.setUnread(0);
mAdapter.updateList(mList);
} else {
FinalUserDataBase.getInstance().deleteChatMsgByChatId(msg.getChatId());
mList.remove(position);
mAdapter.updateList(mList);
}
}
break;
}
}
});
mdf.show(getFragmentManager(), "mdf");
return true;
}
use of com.lingtuan.firefly.util.MyDialogFragment in project SmartMesh_Android by SmartMeshFoundation.
the class MsgAddContactListUI method onItemLongClick.
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
MyDialogFragment mdf = new MyDialogFragment(MyDialogFragment.DIALOG_LIST, R.array.delete_chat_array);
mdf.setItemClickCallback(new MyDialogFragment.ItemClickCallback() {
@Override
public void itemClickCallback(int which) {
ChatMsg msg = mList.get(position);
FinalUserDataBase.getInstance().deleteChatEventAddContactByMessageId(msg.getMessageId());
MyToast.showToast(MsgAddContactListUI.this, getString(R.string.delete_success));
mList.remove(position);
mAdapter.updateList(mList);
}
});
mdf.show(getSupportFragmentManager(), "mdf");
return true;
}
use of com.lingtuan.firefly.util.MyDialogFragment in project SmartMesh_Android by SmartMeshFoundation.
the class MyProfileUI method addGenderMethod.
/**
* 添加修改性别方法
*/
private void addGenderMethod() {
MyDialogFragment mdf = new MyDialogFragment(MyDialogFragment.DIALOG_LIST, R.array.sex_list);
mdf.setItemClickCallback(new MyDialogFragment.ItemClickCallback() {
@Override
public void itemClickCallback(int which) {
if (which == 0) {
// See a larger head
gender = "1";
addGender.setText(getString(R.string.man));
} else if (which == 1) {
// Photo modified head
gender = "2";
addGender.setText(getString(R.string.woman));
}
}
});
mdf.show(getSupportFragmentManager(), "mdf");
}
use of com.lingtuan.firefly.util.MyDialogFragment in project SmartMesh_Android by SmartMeshFoundation.
the class ChatAdapter method onLongClickLogic.
/**
* Long press event
*/
private boolean onLongClickLogic(final ChatMsg msg) {
String title = msg.getUsername();
int itemArrayId = 0;
if (msg.getType() == 0) {
// The text
itemArrayId = R.array.copy_del_text;
} else if (msg.getType() == 1009) {
// The text
if (// On the cross and upload fail, cancel the upload Can't collect
msg.getInviteType() == 0 || msg.getInviteType() == 1 || msg.getInviteType() == 3) {
itemArrayId = R.array.copy_del_only_text;
} else if (msg.getDatingSOSId() == 1) {
// Already collected
itemArrayId = R.array.cancel_fav_del_list_file;
} else {
itemArrayId = R.array.fav_del_list_file;
}
} else if (msg.getType() == 2) {
boolean is_mode_in_call = MySharedPrefs.readBooleanNormal(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.AUDIO_MODE);
if (is_mode_in_call) {
itemArrayId = R.array.speaker_mode_list;
} else {
itemArrayId = R.array.receiver_mode_list;
}
} else {
itemArrayId = R.array.copy_del_only_text;
}
MyDialogFragment mdf = new MyDialogFragment(MyDialogFragment.DIALOG_LIST, itemArrayId);
mdf.setItemClickCallback(new MyDialogFragment.ItemClickCallback() {
@Override
public void itemClickCallback(int position) {
selectedList.clear();
switch(position) {
case // copy
0:
if (// Document collection or cancel the collection
msg.getType() == 1009) {
if (// On the cross and upload fail, cancel the upload Can't collect
msg.getInviteType() == 0 || msg.getInviteType() == 1 || msg.getInviteType() == 3) {
forwarding = false;
delete = true;
selectedItem(msg);
notifyDataSetChanged();
} else {
requestFavFile(msg);
}
return;
} else if (msg.getType() == 2) {
boolean is_mode_in_call = MySharedPrefs.readBooleanNormal(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.AUDIO_MODE);
if (is_mode_in_call) {
MySharedPrefs.writeBoolean(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.AUDIO_MODE, false);
MyToast.showToast(mContext, mContext.getString(R.string.change_speaker_mode));
} else {
MySharedPrefs.writeBoolean(mContext, MySharedPrefs.FILE_USER, MySharedPrefs.AUDIO_MODE, true);
MyToast.showToast(mContext, mContext.getString(R.string.change_receiver_mode));
}
return;
} else if (msg.getType() == 0) {
ClipboardManager cmb = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText(msg.getContent().concat(" "));
MyToast.showToast(mContext, mContext.getString(R.string.copy_success));
return;
} else {
forwarding = false;
delete = true;
selectedItem(msg);
notifyDataSetChanged();
}
break;
case // Delete
1:
forwarding = false;
delete = true;
selectedItem(msg);
notifyDataSetChanged();
break;
}
if (listener != null) {
listener.onSceneListener(delete);
}
}
});
mdf.show(((FragmentActivity) mContext).getSupportFragmentManager(), "mdf");
return true;
}
use of com.lingtuan.firefly.util.MyDialogFragment in project SmartMesh_Android by SmartMeshFoundation.
the class MyProfileUI method scanOrEditAvatar.
/**
* View the big picture or edit avatar
*/
private void scanOrEditAvatar() {
MyDialogFragment mdf = new MyDialogFragment(MyDialogFragment.DIALOG_LIST, R.array.scan_edit_avatar);
mdf.setItemClickCallback(new MyDialogFragment.ItemClickCallback() {
@Override
public void itemClickCallback(int which) {
if (which == 0) {
// See a larger head
if (NextApplication.myInfo != null) {
Intent intent = new Intent(MyProfileUI.this, ScanLargePic.class);
ArrayList<String> picList = new ArrayList<>();
picList.add(NextApplication.myInfo.getPic());
intent.putStringArrayListExtra("picList", picList);
startActivity(intent);
Utils.openNewActivityAnim(MyProfileUI.this, false);
}
} else if (which == 1) {
// Photo modified head
// Call system camera
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(SDCardCtrl.getUploadPath(), BitmapUtils.getPhotoFileName());
if (!file.exists()) {
try {
file.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
cameraUri = Uri.fromFile(file);
camera.putExtra(MediaStore.EXTRA_OUTPUT, cameraUri);
startActivityForResult(camera, Constants.CAMERA_WITH_DATA);
} else {
// From the album revision
try {
Intent photo = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(photo, Constants.PHOTO_PICKED_WITH_DATA);
} catch (ActivityNotFoundException e) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, Constants.PHOTO_PICKED_WITH_DATA);
}
}
}
});
mdf.show(getSupportFragmentManager(), "mdf");
}
Aggregations