use of net.iGap.observers.interfaces.OnComplete in project iGap-Android by KianIranian-STDG.
the class FragmentMediaPlayerViewModel method getInfo.
private void getInfo() {
FragmentMediaPlayer.onComplete = new OnComplete() {
@Override
public void complete(boolean result, String messageOne, final String MessageTwo) {
if (messageOne.equals("play")) {
callBackBtnPlayMusic.set(G.fragmentActivity.getResources().getString(R.string.icon_play));
if (rippleVisualizerView != null) {
rippleVisualizerView.setEnabled(false);
rippleVisualizerView.pauseVisualizer();
}
} else if (messageOne.equals("pause")) {
callBackBtnPlayMusic.set(G.fragmentActivity.getResources().getString(R.string.icon_pause));
if (rippleVisualizerView != null) {
rippleVisualizerView.setEnabled(true);
rippleVisualizerView.startVisualizer();
}
} else if (messageOne.equals("update")) {
G.handler.post(new Runnable() {
@Override
public void run() {
updateUi();
}
});
} else if (messageOne.equals("updateTime")) {
G.handler.post(new Runnable() {
@Override
public void run() {
callBackTxtTimer.set(MessageTwo);
seekBar1.set(MusicPlayer.musicProgress);
}
});
} else if (messageOne.equals("RepeatMode")) {
setReplayButton();
} else if (messageOne.equals("Shuffel")) {
setShuffleButton();
} else if (messageOne.equals("finish")) {
if (FragmentMediaPlayer.onBackFragment != null) {
FragmentMediaPlayer.onBackFragment.onBack();
}
}
}
};
setMusicInfo();
initVisualizer(v);
setShuffleButton();
setReplayButton();
if (HelperCalander.isPersianUnicode) {
callBackTxtTimer.set(HelperCalander.convertToUnicodeFarsiNumber(callBackTxtTimer.get()));
callBackTxtMusicTime.set(HelperCalander.convertToUnicodeFarsiNumber(callBackTxtMusicTime.get()));
}
}
use of net.iGap.observers.interfaces.OnComplete in project iGap-Android by KianIranian-STDG.
the class FragmentChat method initCallbacks.
/**
* initialize some callbacks that used in this page
*/
public void initCallbacks() {
getSendMessageUtil().setOnChatSendMessageResponseChatPage(this);
// G.chatUpdateStatusUtil.setOnChatUpdateStatusResponse(this);
G.onChatSendMessage = new OnChatSendMessage() {
@Override
public void Error(int majorCode, int minorCode, final int waitTime, long messageId) {
if (majorCode == 234) {
G.handler.post(new Runnable() {
@Override
public void run() {
try {
if (G.fragmentActivity.hasWindowFocus()) {
showErrorDialog(waitTime);
}
} catch (Exception e) {
}
}
});
} else if (majorCode == 233 && minorCode == 1) {
G.handler.post(new Runnable() {
@Override
public void run() {
if (getContext() != null && mAdapter != null) {
mAdapter.removeMessage(messageId);
}
}
});
}
}
};
G.onChatEditMessageResponse = new OnChatEditMessageResponse() {
@Override
public void onChatEditMessage(long roomId, final long messageId, long messageVersion, final String message, ProtoResponse.Response response) {
if (mRoomId == roomId && mAdapter != null) {
// I'm in the room
G.handler.post(new Runnable() {
@Override
public void run() {
// update message text in adapter
mAdapter.updateMessageText(messageId, message);
}
});
}
}
@Override
public void onError(int majorCode, int minorCode) {
}
};
onMusicListener = new OnComplete() {
@Override
public void complete(boolean result, String messageID, String MessageTwo) {
if (result) {
updateShowItemInScreen();
} else {
onPlayMusic(messageID);
}
}
};
iUpdateLogItem = new // TODO: 12/29/20 MESSAGE_REFACTOR_NEED_TEST
IUpdateLogItem() {
@Override
public void onUpdate(byte[] log, long messageId) {
if (getActivity() == null || getActivity().isFinishing())
return;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (mAdapter == null) {
return;
}
for (int i = mAdapter.getAdapterItemCount() - 1; i >= 0; i--) {
try {
AbstractMessage item = mAdapter.getAdapterItem(i);
if (item.messageObject != null && item.messageObject.id == messageId) {
// bagi May crash
item.messageObject.log.data = log;
mAdapter.notifyAdapterItemChanged(i);
break;
}
} catch (Exception e) {
e.printStackTrace();
HelperLog.getInstance().setErrorLog(e);
}
}
}
});
}
};
/**
* after get position from gps
*/
complete = new OnComplete() {
@Override
public void complete(boolean result, final String messageOne, String MessageTwo) {
try {
if (getActivity() != null) {
String[] split = messageOne.split(",");
Double latitude = Double.parseDouble(split[0]);
Double longitude = Double.parseDouble(split[1]);
NewFragmentMap fragment = NewFragmentMap.newInstance(latitude, longitude);
new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
}
} catch (Exception e) {
HelperLog.getInstance().setErrorLog(e);
}
}
};
G.onHelperSetAction = new OnHelperSetAction() {
@Override
public void onAction(ProtoGlobal.ClientAction ClientAction) {
HelperSetAction.setActionFiles(mRoomId, messageId, ClientAction, chatType);
}
};
G.onDeleteChatFinishActivity = new OnDeleteChatFinishActivity() {
@Override
public void onFinish() {
G.handler.post(new Runnable() {
@Override
public void run() {
// finish();
finishChat();
}
});
}
};
G.onUpdateUserStatusInChangePage = (peerId, status, lastSeen) -> {
if (chatType == CHAT) {
setUserStatus(status, lastSeen);
new RequestUserInfo().userInfo(peerId);
}
};
}
use of net.iGap.observers.interfaces.OnComplete in project iGap-Android by KianIranian-STDG.
the class FragmentGroupProfile method initComponent.
/**
* ************************************** methods **************************************
*/
private void initComponent() {
AppUtils.setProgresColler(binding.loading);
FragmentShowAvatars.onComplete = new OnComplete() {
@Override
public void complete(boolean result, String messageOne, String MessageTwo) {
long mAvatarId = 0;
if (messageOne != null && !messageOne.equals("")) {
mAvatarId = Long.parseLong(messageOne);
}
avatarHandler.avatarDelete(new ParamWithAvatarType(imvGroupAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM), mAvatarId);
}
};
showAvatar();
}
use of net.iGap.observers.interfaces.OnComplete in project iGap-Android by KianIranian-STDG.
the class FragmentShowAvatars method initComponent.
private void initComponent(View view) {
// ViewGroup rooShowImage = (ViewGroup) view.findViewById(R.id.rooShowImage);
// rooShowImage.setBackgroundColor(G.fragmentActivity.getResources().getColor(R.color.black));
RippleView rippleBack = view.findViewById(R.id.asi_ripple_back);
rippleBack.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
@Override
public void onComplete(RippleView rippleView) {
G.fragmentActivity.onBackPressed();
}
});
RippleView rippleMenu = view.findViewById(R.id.asi_ripple_menu);
rippleMenu.setOnRippleCompleteListener(rippleView -> {
if (getContext() == null)
return;
List<Integer> items = new ArrayList<>();
items.add(R.string.save_to_gallery);
switch(from) {
case setting:
items.add(R.string.array_Delete_photo);
break;
case group:
if (roleGroup == GroupChatRole.OWNER || roleGroup == GroupChatRole.ADMIN) {
items.add(R.string.array_Delete_photo);
}
break;
case channel:
if (roleChannel == ChannelChatRole.OWNER || roleChannel == ChannelChatRole.ADMIN) {
items.add(R.string.array_Delete_photo);
}
break;
}
new TopSheetDialog(getContext()).setListDataWithResourceId(items, -1, position -> {
if (items.get(position) == R.string.save_to_gallery) {
saveToGallery();
} else if (items.get(position) == array_Delete_photo) {
switch(from) {
case setting:
deletePhotoSetting();
break;
case group:
deletePhotoGroup();
break;
case channel:
deletePhotoChannel();
break;
case chat:
deletePhotoChat();
break;
}
}
}).show();
});
viewPager = view.findViewById(R.id.asi_view_pager);
txtImageNumber = view.findViewById(R.id.asi_txt_image_number);
toolbarShowImage = view.findViewById(R.id.showAvatarToolbar);
initViewPager();
}
use of net.iGap.observers.interfaces.OnComplete in project iGap-Android by KianIranian-STDG.
the class FragmentShearedMedia method initComponent.
private void initComponent(View view) {
FrameLayout toolbarLayout = view.findViewById(R.id.frg_shared_media_ll_toolbar_layout);
FragmentMediaContainer mediaContainer = new FragmentMediaContainer(getContext(), this);
mediaContainer.setListener(i -> {
switch(i) {
case FragmentMediaContainer.CALL_TAG:
getActivity().startActivity(new Intent(getContext(), CallActivity.class));
break;
case FragmentMediaContainer.MEDIA_TAG:
if (!MusicPlayer.isVoice) {
Intent intent = new Intent(context, ActivityMain.class);
intent.putExtra(ActivityMain.openMediaPlayer, true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().startActivity(intent);
}
break;
case FragmentMediaContainer.PLAY_TAG:
break;
}
});
sharedMediaToolbar = new Toolbar(getContext());
sharedMediaToolbar.setBackIcon(new BackDrawable(false));
sharedMediaToolbar.createToolbarItems();
sharedMediaToolbar.setTitle(getString(R.string.shared_media));
sharedMediaToolbar.setListener(i -> {
switch(i) {
case -1:
if (isSelectedMode) {
adapter.resetSelected();
sharedMediaToolbar.hideActionToolbar();
return;
}
popBackStackFragment();
break;
case deleteTag:
DbManager.getInstance().doRealmTask(realm -> {
String count = SelectedList.size() + "";
final RealmRoom realmRoom = RealmRoom.getRealmRoom(realm, roomId);
if (roomType == ProtoGlobal.Room.Type.CHAT && bothDeleteMessageId != null && bothDeleteMessageId.size() > 0) {
// TODO: 1/10/21 OPTIMAZE CODE
// show both Delete check box
String delete;
if (HelperCalander.isPersianUnicode) {
delete = HelperCalander.convertToUnicodeFarsiNumber(requireContext().getResources().getString(R.string.st_desc_delete) + count);
} else {
delete = HelperCalander.convertToUnicodeFarsiNumber(requireContext().getResources().getString(R.string.st_desc_delete) + "the");
}
new MaterialDialog.Builder(getContext()).limitIconToDefaultSize().content(delete).title(R.string.message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive((dialog, which) -> {
if (!dialog.isPromptCheckBoxChecked()) {
bothDeleteMessageId = null;
}
if (realmRoom != null) {
ArrayList<Long> selectedListForDel = new ArrayList<>();
ArrayList<Long> selectedDocumentListForDel = new ArrayList<>();
for (StructShearedMedia item : SelectedList) {
selectedListForDel.add(item.messageId);
selectedDocumentListForDel.add(item.documentId);
}
getMessageController().deleteSelectedMessage(roomType.getNumber(), roomId, selectedListForDel, selectedDocumentListForDel, bothDeleteMessageId);
}
resetItems();
}).checkBoxPromptRes(R.string.delete_item_dialog, false, null).show();
} else {
new MaterialDialog.Builder(requireContext()).title(R.string.message).content(getContext().getResources().getString(R.string.st_desc_delete) + count).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
bothDeleteMessageId = null;
if (realmRoom != null) {
ArrayList<Long> messageIds = new ArrayList<>();
ArrayList<Long> documentIds = new ArrayList<>();
for (StructShearedMedia item : SelectedList) {
messageIds.add(item.messageId);
documentIds.add(item.documentId);
}
getMessageController().deleteSelectedMessage(roomType.getNumber(), roomId, messageIds, documentIds, bothDeleteMessageId);
}
resetItems();
}
}).show();
}
});
break;
case forwardTag:
ArrayList<MessageObject> messageInfos = new ArrayList<>(SelectedList.size());
for (StructShearedMedia media : SelectedList) {
messageInfos.add(MessageObject.create(media.item));
}
FragmentChat.mForwardMessages = messageInfos;
adapter.resetSelected();
if (getActivity() instanceof ActivityMain) {
((ActivityMain) getActivity()).setForwardMessage(true);
((ActivityMain) getActivity()).removeAllFragmentFromMain();
/*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(3);*/
}
break;
case seeInChatTag:
if (SelectedList.size() == 1) {
long messageId = SelectedList.get(0).messageId;
long documentId = SelectedList.get(0).documentId;
RealmRoomMessage.setGap(messageId, documentId);
goToPositionFromShardMedia.goToPosition(messageId, documentId);
goToPosition = true;
popBackStackFragment();
adapter.resetSelected();
popBackStackFragment();
}
break;
}
});
createActionMode();
toolbarLayout.addView(mediaContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 39, Gravity.BOTTOM, 0, 60, 0, 0));
toolbarLayout.addView(sharedMediaToolbar);
progressBar = view.findViewById(R.id.asm_progress_bar_waiting);
AppUtils.setProgresColler(progressBar);
mediaTypesLayout = view.findViewById(R.id.asm_ll_media_types_buttons);
complete = new OnComplete() {
@Override
public void complete(boolean result, String messageOne, String MessageTwo) {
int whatAction = 0;
String number = "0";
if (messageOne != null) {
if (messageOne.length() > 0)
whatAction = Integer.parseInt(messageOne);
}
if (MessageTwo != null)
if (MessageTwo.length() > 0)
number = MessageTwo;
callBack(result, whatAction, number);
}
};
recyclerView = view.findViewById(R.id.asm_recycler_view_sheared_media);
recyclerView.setItemViewCacheSize(400);
recyclerView.setItemAnimator(null);
onScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (isThereAnyMoreItemToLoad) {
if (!isSendRequestForLoading) {
int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
if (lastVisiblePosition + 30 >= offset) {
new RequestClientSearchRoomHistory().clientSearchRoomHistory(roomId, nextMessageId, nextDocumentId, mFilter);
isSendRequestForLoading = true;
progressBar.setVisibility(View.VISIBLE);
}
}
}
}
};
recyclerView.addOnScrollListener(onScrollListener);
checkSelectedDefaultTab();
makeSharedTypesViews();
checkSharedButtonsBackgrounds();
}
Aggregations