use of net.iGap.module.dialog.topsheet.TopSheetDialog in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListFrag method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLeftIcon(R.string.icon_back).setLifecycleOwner(getViewLifecycleOwner()).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
@Override
public void onRightIconClickListener(View view) {
List<Integer> items = new ArrayList<>();
items.add(R.string.elecBill_cell_deleteAccount);
new TopSheetDialog(getContext()).setListDataWithResourceId(items, -1, position -> {
if (position == 0) {
final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteAccount_title).content(R.string.elecBill_deleteAccount_desc).positiveText(R.string.elecBill_deleteAccount_pos).negativeText(R.string.elecBill_deleteAccount_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> viewModel.deleteAccount()).build();
dialog.show();
}
}).show();
}
}).setLogoShown(true);
LinearLayout toolbarLayout = binding.Toolbar;
toolbarLayout.addView(mHelperToolbar.getView());
binding.billRecycler.setHasFixedSize(true);
onDataChangedListener();
viewModel.getBillsList();
}
use of net.iGap.module.dialog.topsheet.TopSheetDialog in project iGap-Android by KianIranian-STDG.
the class FragmentGroupProfile method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
isNeedResume = true;
// because actionbar not in this view do that and not correct in viewModel
imvGroupAvatar = binding.toolbarAvatar;
imvGroupAvatar.setOnClickListener(v -> viewModel.onClickRippleGroupAvatar());
if (currentRoomAccess != null) {
checkRoomAccess(currentRoomAccess);
roomAccessChangeListener = (realmRoomAccess, changeSet) -> checkRoomAccess(realmRoomAccess);
currentRoomAccess.addChangeListener(roomAccessChangeListener);
}
binding.toolbarMore.setOnClickListener(v -> viewModel.onClickRippleMenu());
binding.toolbarBack.setOnClickListener(v -> popBackStackFragment());
binding.toolbarEdit.setOnClickListener(v -> {
if (getActivity() != null && currentRoomAccess != null && currentRoomAccess.isCanModifyRoom()) {
new HelperFragment(getActivity().getSupportFragmentManager(), EditGroupFragment.newInstance(viewModel.roomId)).setReplace(false).load();
}
});
viewModel.groupName.observe(getViewLifecycleOwner(), s -> {
binding.toolbarTxtNameCollapsed.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameCollapsed.getPaint().getFontMetricsInt()));
binding.toolbarTxtNameExpanded.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameExpanded.getPaint().getFontMetricsInt()));
});
viewModel.groupNumber.observe(getViewLifecycleOwner(), s -> binding.toolbarTxtStatusExpanded.setText(String.format("%s %s", s, getString(R.string.member))));
viewModel.showMoreMenu.observe(getViewLifecycleOwner(), isShow -> {
if (isShow != null) {
binding.toolbarMore.setVisibility(isShow ? View.VISIBLE : View.GONE);
}
});
viewModel.goToShearedMediaPage.observe(getViewLifecycleOwner(), model -> {
if (getActivity() != null && model != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShearedMedia.newInstance(model)).setReplace(false).load();
}
});
viewModel.goToShowAvatarPage.observe(getViewLifecycleOwner(), roomId -> {
if (getActivity() != null && roomId != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShowAvatars.newInstance(roomId, FragmentShowAvatars.From.group)).setReplace(false).load();
}
});
viewModel.showMenu.observe(getViewLifecycleOwner(), menuList -> {
if (getActivity() != null && menuList != null) {
new TopSheetDialog(getActivity()).setListDataWithResourceId(menuList, -1, position -> {
if (menuList.get(position) == R.string.clear_history) {
new MaterialDialog.Builder(getActivity()).title(R.string.clear_history).content(R.string.clear_history_content).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
getMessageController().clearHistoryMessage(viewModel.roomId);
}
}).negativeText(R.string.no).show();
} else if (menuList.get(position) == R.string.group_title_convert_to_public || menuList.get(position) == R.string.group_title_convert_to_private) {
viewModel.convertMenuClick();
}
}).show();
}
});
viewModel.goToShowMemberPage.observe(getViewLifecycleOwner(), type -> {
if (getActivity() != null && type != null) {
FragmentShowMember fragment = FragmentShowMember.newInstance2(this, viewModel.roomId, viewModel.role.toString(), AccountManager.getInstance().getCurrentUser().getId(), type, viewModel.isNeedgetContactlist, true);
new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
}
});
viewModel.showDialogConvertToPublic.observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).title(getString(R.string.group_title_convert_to_public)).content(getString(R.string.group_text_convert_to_public)).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
setUsername();
}
}).negativeText(R.string.no).show();
}
});
viewModel.showDialogConvertToPrivate.observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).title(R.string.group_title_convert_to_private).content(R.string.group_text_convert_to_private).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
viewModel.sendRequestRemoveGroupUsername();
}
}).negativeText(R.string.no).show();
}
});
viewModel.showRequestError.observe(getViewLifecycleOwner(), errorMessage -> {
if (errorMessage != null) {
HelperError.showSnackMessage(getString(errorMessage), false);
}
});
viewModel.goToShowCustomListPage.observe(getViewLifecycleOwner(), listItem -> {
if (getActivity() != null && listItem != null) {
ShowCustomList showCustomListFragment = new ShowCustomList();
showCustomListFragment.setFields(ProtoGlobal.Room.Type.GROUP, listItem, (result, message, countForShowLastMessage, list) -> {
for (int i = 0; i < list.size(); i++) {
new RequestGroupAddMember().groupAddMember(viewModel.roomId, list.get(i).peerId, RealmRoomMessage.findCustomMessageId(viewModel.roomId, countForShowLastMessage));
}
});
Bundle bundle = new Bundle();
bundle.putBoolean("DIALOG_SHOWING", true);
bundle.putLong("COUNT_MESSAGE", 0);
showCustomListFragment.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), showCustomListFragment).setReplace(false).load();
}
});
viewModel.goBack.observe(getViewLifecycleOwner(), isGoBack -> {
if (isGoBack != null && isGoBack) {
popBackStackFragment();
}
});
BetterLinkMovementMethod.linkify(Linkify.ALL, binding.description).setOnLinkClickListener((tv, url) -> {
return false;
}).setOnLinkLongClickListener((tv, url) -> {
if (HelperUrl.isTextLink(url)) {
G.isLinkClicked = true;
HelperUrl.openLinkDialog(getActivity(), url);
}
return true;
});
viewModel.groupDescription.observe(getViewLifecycleOwner(), groupDescription -> {
if (getActivity() != null && groupDescription != null) {
binding.description.setText(EmojiManager.getInstance().replaceEmoji(HelperUrl.setUrlLink(getActivity(), groupDescription, true, false, null, true), binding.description.getPaint().getFontMetricsInt()));
}
});
viewModel.goToRoomListPage.observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() instanceof ActivityMain && isGo != null) {
Log.wtf(this.getClass().getName(), "goToRoomListPage observe");
((ActivityMain) getActivity()).removeAllFragmentFromMain();
/*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(2);*/
}
});
viewModel.showDialogEditLink.observe(getViewLifecycleOwner(), link -> {
if (getActivity() != null && link != null) {
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.group_link).positiveText(R.string.array_Copy).customView(createDialogLayout(link), true).widgetColor(new Theme().getPrimaryColor(getContext())).negativeText(R.string.edit).onPositive((dialog1, which) -> {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("LINK_GROUP", link);
clipboard.setPrimaryClip(clip);
}).onNegative((dialog12, which) -> {
if (viewModel.isPrivate) {
viewModel.sendRequestRevokeGroupUsername();
} else {
setUsername();
}
}).build();
dialog.show();
}
});
viewModel.showDialogCopyLink.observe(getViewLifecycleOwner(), link -> {
if (getActivity() != null && link != null) {
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.group_link).positiveText(R.string.array_Copy).customView(createDialogLayout(link), true).widgetColor(new Theme().getPrimaryColor(getContext())).onPositive((dialog1, which) -> {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("LINK_GROUP", link);
clipboard.setPrimaryClip(clip);
Toast.makeText(getActivity(), R.string.copied, Toast.LENGTH_SHORT).show();
}).build();
dialog.show();
}
});
viewModel.goToCustomNotificationPage.observe(getViewLifecycleOwner(), roomId -> {
if (getActivity() != null && roomId != null) {
FragmentNotification fragmentNotification = new FragmentNotification();
Bundle bundle = new Bundle();
bundle.putLong("ID", roomId);
fragmentNotification.setArguments(bundle);
new HelperFragment(getActivity().getSupportFragmentManager(), fragmentNotification).setReplace(false).load();
}
});
viewModel.showDialogLeaveGroup.observe(getViewLifecycleOwner(), isShow -> {
if (isShow != null && isShow) {
groupLeft();
}
});
if (viewModel.role.equals(GroupChatRole.OWNER)) {
binding.editGroupPermission.setVisibility(View.VISIBLE);
binding.editGroupPermission.setOnClickListener(v -> {
openChatEditRightsFragment(viewModel.getRealmRoom());
});
}
initComponent();
attachFile = new AttachFile(getActivity());
G.onGroupAvatarDelete = this;
initialToolbar();
}
use of net.iGap.module.dialog.topsheet.TopSheetDialog in project iGap-Android by KianIranian-STDG.
the class FragmentChatBackground method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewModel.init();
toolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_other_vertical_dots, R.string.icon_sent, R.string.icon_retry).setLogoShown(true).setDefaultTitle(getString(R.string.st_title_Background)).setListener(this);
binding.fcbLayoutToolbar.addView(toolbar.getView());
toolbar.getSecondRightButton().setVisibility(View.GONE);
binding.rcvContent.setAdapter(new AdapterChatBackground(viewModel.getOnImageWallpaperListClick()));
viewModel.getLoadSelectedImage().observe(getViewLifecycleOwner(), wallpaper -> {
if (wallpaper != null) {
binding.stchfFullImage.setBackground(null);
binding.stchfFullImage.setImageDrawable(Drawable.createFromPath(new File(wallpaper.getImagePath()).getAbsolutePath()));
if (wallpaper.isNew()) {
toolbar.getSecondRightButton().setVisibility(View.VISIBLE);
toolbar.getThirdRightButton().setVisibility(View.GONE);
} else {
toolbar.getSecondRightButton().setVisibility(View.GONE);
toolbar.getThirdRightButton().setVisibility(View.VISIBLE);
}
}
});
viewModel.getShowAddImage().observe(getViewLifecycleOwner(), isShow -> {
if (getActivity() != null && isShow != null && isShow) {
new MaterialDialog.Builder(getActivity()).title(R.string.choose_picture).negativeText(R.string.cancel).items(R.array.profile).itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
AttachFile attachFile = new AttachFile(getActivity());
if (text.toString().equals(getString(R.string.from_camera))) {
try {
attachFile.requestTakePicture(FragmentChatBackground.this);
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
attachFile.requestOpenGalleryForImageSingleSelect(FragmentChatBackground.this);
} catch (IOException e) {
e.printStackTrace();
}
}
dialog.dismiss();
}
}).show();
}
});
viewModel.getLoadSelectedColor().observe(getViewLifecycleOwner(), colorValue -> {
if (colorValue != null) {
binding.stchfFullImage.setImageDrawable(null);
binding.stchfFullImage.setBackgroundColor(colorValue.getColor());
if (colorValue.isNew()) {
toolbar.getSecondRightButton().setVisibility(View.VISIBLE);
toolbar.getThirdRightButton().setVisibility(View.GONE);
} else {
toolbar.getSecondRightButton().setVisibility(View.GONE);
toolbar.getThirdRightButton().setVisibility(View.VISIBLE);
}
}
});
viewModel.getMenuList().observe(getViewLifecycleOwner(), menuList -> {
if (getContext() != null && menuList != null) {
new TopSheetDialog(getContext()).setListDataWithResourceId(menuList, -1, position -> viewModel.onMenuItemClicked(position)).show();
}
});
viewModel.getLoadChatBackgroundImage().observe(getViewLifecycleOwner(), isLoad -> {
if (binding.rcvContent.getAdapter() instanceof AdapterChatBackground && isLoad != null) {
((AdapterChatBackground) binding.rcvContent.getAdapter()).wallpaperList(isLoad);
}
});
viewModel.getLoadChatBackgroundSolidColor().observe(getViewLifecycleOwner(), isLoad -> {
if (binding.rcvContent.getAdapter() instanceof AdapterChatBackground && isLoad != null) {
((AdapterChatBackground) binding.rcvContent.getAdapter()).setSolidColor(isLoad);
}
});
viewModel.getGoBack().observe(getViewLifecycleOwner(), isGoBack -> {
if (getActivity() instanceof ActivityMain && isGoBack != null) {
if (isGoBack) {
((ActivityMain) getActivity()).chatBackgroundChanged();
}
getActivity().onBackPressed();
}
});
}
use of net.iGap.module.dialog.topsheet.TopSheetDialog in project iGap-Android by KianIranian-STDG.
the class FragmentiGapMap method initToolbar.
private void initToolbar(View view) {
mHelperToolbar = new Toolbar(getContext());
mHelperToolbar.setTitle(getString(R.string.igap_nearby));
mHelperToolbar.setBackIcon(new BackDrawable(false));
mHelperToolbar.addItem(toolbarDotsTag, R.string.icon_other_vertical_dots, Color.WHITE);
mHelperToolbar.setListener(i -> {
switch(i) {
case -1:
// after return to FragmentMapUsers from FragmentContactsProfile don't execute this block
if (getActivity() != null && getActivity().getSupportFragmentManager().getFragments().get(getActivity().getSupportFragmentManager().getFragments().size() - 1) != null && getActivity().getSupportFragmentManager().getFragments().get(getActivity().getSupportFragmentManager().getFragments().size() - 1).getClass().getName().equals(FragmentContactsProfile.class.getName())) {
return;
}
if (rippleMoreMap.getVisibility() == View.GONE || fabGps.getVisibility() == View.GONE) {
rippleMoreMap.setVisibility(View.VISIBLE);
fabGps.show();
fabStateSwitcher.setVisibility(View.VISIBLE);
}
if (!isBackPress) {
// getActivity().getSupportFragmentManager().popBackStack();
G.fragmentActivity.onBackPressed();
}
closeKeyboard(view);
isBackPress = false;
page = pageiGapMap;
break;
case toolbarDotsTag:
if (getActivity() != null) {
List<Integer> items = new ArrayList<>();
items.add(R.string.list_user_map);
items.add(R.string.nearby);
if (getActivity().getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE).getBoolean(SHP_SETTING.REGISTER_STATUS, false)) {
items.add(R.string.map_registration);
} else {
items.add(R.string.map_registration_enable);
}
dialog = new TopSheetDialog(getActivity()).setListDataWithResourceId(items, -1, new BottomSheetItemClickCallback() {
@Override
public void onClick(int position) {
if (items.get(position) == R.string.list_user_map) {
fabGps.hide();
fabStateSwitcher.setVisibility(View.GONE);
rippleMoreMap.setVisibility(View.GONE);
page = pageUserList;
try {
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentMapUsers.newInstance()).setResourceContainer(R.id.mapContainer_main).setReplace(false).load();
}
} catch (Exception e) {
e.getStackTrace();
}
} else if (items.get(position) == R.string.nearby) {
if (location != null && !isSendRequestGeoCoordinate) {
new RequestGeoGetNearbyCoordinate().getNearbyCoordinate(location.getLatitude(), location.getLongitude());
showProgress(true);
isSendRequestGeoCoordinate = true;
}
} else if (items.get(position) == R.string.map_registration) {
new MaterialDialog.Builder(getActivity()).title(R.string.Visible_Status_title_dialog_invisible).content(R.string.Visible_Status_text_dialog_invisible).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
new RequestGeoRegister().register(false);
}
}).negativeText(R.string.no).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
}
}).show();
} else if (items.get(position) == R.string.map_registration_enable) {
if (!isGpsOn) {
try {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
} else {
new MaterialDialog.Builder(getContext()).title(R.string.Visible_Status_title_dialog).content(R.string.Visible_Status_text_dialog).positiveText(R.string.yes).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
if (getRequestManager().isUserLogin()) {
new RequestGeoRegister().register(true);
} else {
toggleGps.setChecked(false);
showSnackBar(getString(R.string.please_check_your_connenction));
}
}
}).negativeText(R.string.no).onNegative((dialog, which) -> toggleGps.setChecked(false)).show();
}
}
}
});
dialog.show();
}
break;
}
});
ViewGroup layoutToolbar = view.findViewById(R.id.fm_layout_toolbar);
layoutToolbar.addView(mHelperToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
}
use of net.iGap.module.dialog.topsheet.TopSheetDialog 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();
}
Aggregations