Search in sources :

Example 1 with TopSheetDialog

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();
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) NonNull(androidx.annotation.NonNull) ProtoMplGetBillToken(net.iGap.proto.ProtoMplGetBillToken) Theme(net.iGap.module.Theme) ElectricityBillListVM(net.iGap.viewmodel.electricity_bill.ElectricityBillListVM) ArrayList(java.util.ArrayList) MobileDebit(net.iGap.model.bill.MobileDebit) FragmentElecBillListBinding(net.iGap.databinding.FragmentElecBillListBinding) Toast(android.widget.Toast) Map(java.util.Map) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) BillList(net.iGap.model.bill.BillList) DataBindingUtil(androidx.databinding.DataBindingUtil) Debit(net.iGap.model.bill.Debit) LayoutInflater(android.view.LayoutInflater) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) ViewGroup(android.view.ViewGroup) BaseAPIViewFrag(net.iGap.api.apiService.BaseAPIViewFrag) BillInfo(net.iGap.model.bill.BillInfo) ElectricityBillListAdapter(net.iGap.adapter.electricity_bill.ElectricityBillListAdapter) List(java.util.List) Nullable(androidx.annotation.Nullable) R(net.iGap.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) HelperToolbar(net.iGap.helper.HelperToolbar) ServiceDebit(net.iGap.model.bill.ServiceDebit) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ArrayList(java.util.ArrayList) Theme(net.iGap.module.Theme) HelperToolbar(net.iGap.helper.HelperToolbar) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 2 with TopSheetDialog

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();
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) OnGroupAvatarDelete(net.iGap.observers.interfaces.OnGroupAvatarDelete) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) AttachFile(net.iGap.module.AttachFile) Theme(net.iGap.module.Theme) OnGroupCheckUsername(net.iGap.observers.interfaces.OnGroupCheckUsername) Selection(android.text.Selection) G(net.iGap.G) GroupChatRole(net.iGap.module.enums.GroupChatRole) RequestGroupUpdateUsername(net.iGap.request.RequestGroupUpdateUsername) Fragment(androidx.fragment.app.Fragment) ActivityGroupProfileBinding(net.iGap.databinding.ActivityGroupProfileBinding) ClipboardManager(android.content.ClipboardManager) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) RequestGroupAddMember(net.iGap.request.RequestGroupAddMember) Log(android.util.Log) DataBindingUtil(androidx.databinding.DataBindingUtil) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) OnComplete(net.iGap.observers.interfaces.OnComplete) MEditText(net.iGap.module.MEditText) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) RealmRoom(net.iGap.realm.RealmRoom) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ProtoGroupCheckUsername(net.iGap.proto.ProtoGroupCheckUsername) AlphaAnimation(android.view.animation.AlphaAnimation) CLIPBOARD_SERVICE(android.content.Context.CLIPBOARD_SERVICE) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) EventManager(net.iGap.observers.eventbus.EventManager) NotNull(org.jetbrains.annotations.NotNull) TextWatcher(android.text.TextWatcher) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) Context(android.content.Context) Config(net.iGap.Config) ResourcesCompat(androidx.core.content.res.ResourcesCompat) ActivityMain(net.iGap.activities.ActivityMain) HelperUrl(net.iGap.helper.HelperUrl) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AccountManager(net.iGap.module.accountManager.AccountManager) Linkify(android.text.util.Linkify) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) ClipData(android.content.ClipData) Toast(android.widget.Toast) RequestGroupCheckUsername(net.iGap.request.RequestGroupCheckUsername) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) Build(android.os.Build) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) LayoutInflater(android.view.LayoutInflater) FragmentGroupProfileViewModel(net.iGap.viewmodel.FragmentGroupProfileViewModel) DialogAction(com.afollestad.materialdialogs.DialogAction) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) CircleImageView(net.iGap.module.CircleImageView) Gravity(android.view.Gravity) CountDownTimer(android.os.CountDownTimer) TypedValue(android.util.TypedValue) HelperString(net.iGap.helper.HelperString) OnGroupUpdateUsername(net.iGap.observers.interfaces.OnGroupUpdateUsername) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) BetterLinkMovementMethod(me.saket.bettermovementmethod.BetterLinkMovementMethod) DbManager(net.iGap.module.accountManager.DbManager) ClipboardManager(android.content.ClipboardManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Bundle(android.os.Bundle) RequestGroupAddMember(net.iGap.request.RequestGroupAddMember) ActivityMain(net.iGap.activities.ActivityMain) DialogAction(com.afollestad.materialdialogs.DialogAction) AttachFile(net.iGap.module.AttachFile) NonNull(androidx.annotation.NonNull) Theme(net.iGap.module.Theme) HelperFragment(net.iGap.helper.HelperFragment) ClipData(android.content.ClipData)

Example 3 with TopSheetDialog

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();
        }
    });
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) ImageHelper(net.iGap.helper.ImageHelper) Context(android.content.Context) Bundle(android.os.Bundle) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) ActivityMain(net.iGap.activities.ActivityMain) NonNull(androidx.annotation.NonNull) ViewModel(androidx.lifecycle.ViewModel) Intent(android.content.Intent) AttachFile(net.iGap.module.AttachFile) Drawable(android.graphics.drawable.Drawable) ChatBackgroundViewModel(net.iGap.viewmodel.ChatBackgroundViewModel) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperSaveFile.getPrivateDirectory(net.iGap.helper.HelperSaveFile.getPrivateDirectory) Build(android.os.Build) DataBindingUtil(androidx.databinding.DataBindingUtil) ActivityChatBackgroundBinding(net.iGap.databinding.ActivityChatBackgroundBinding) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) ViewGroup(android.view.ViewGroup) File(java.io.File) Nullable(androidx.annotation.Nullable) AdapterChatBackground(net.iGap.adapter.AdapterChatBackground) SHP_SETTING(net.iGap.module.SHP_SETTING) R(net.iGap.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) Activity(android.app.Activity) HelperToolbar(net.iGap.helper.HelperToolbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ActivityMain(net.iGap.activities.ActivityMain) AttachFile(net.iGap.module.AttachFile) IOException(java.io.IOException) AttachFile(net.iGap.module.AttachFile) File(java.io.File) View(android.view.View) AdapterChatBackground(net.iGap.adapter.AdapterChatBackground)

Example 4 with TopSheetDialog

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));
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) BottomSheetItemClickCallback(net.iGap.module.dialog.BottomSheetItemClickCallback) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) Intent(android.content.Intent) RequestGeoRegister(net.iGap.request.RequestGeoRegister) ActivityNotFoundException(android.content.ActivityNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) RequestGeoGetNearbyCoordinate(net.iGap.request.RequestGeoGetNearbyCoordinate)

Example 5 with TopSheetDialog

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();
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) OnGroupAvatarDelete(net.iGap.observers.interfaces.OnGroupAvatarDelete) RequestGroupAvatarGetList(net.iGap.request.RequestGroupAvatarGetList) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) MessageProgress(net.iGap.messageprogress.MessageProgress) OnUserAvatarDelete(net.iGap.observers.interfaces.OnUserAvatarDelete) G(net.iGap.G) GroupChatRole(net.iGap.module.enums.GroupChatRole) DialogAnimation(net.iGap.module.DialogAnimation) R.string.array_Delete_photo(net.iGap.R.string.array_Delete_photo) View(android.view.View) Log(android.util.Log) HelperImageBackColor(net.iGap.helper.HelperImageBackColor) RequestUserAvatarGetList(net.iGap.request.RequestUserAvatarGetList) HelperCalander(net.iGap.helper.HelperCalander) Status(net.iGap.module.downloader.Status) OnComplete(net.iGap.observers.interfaces.OnComplete) RealmRoom(net.iGap.realm.RealmRoom) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Downloader(net.iGap.module.downloader.Downloader) RealmStory(net.iGap.realm.RealmStory) ViewGroup(android.view.ViewGroup) HelperLog(net.iGap.helper.HelperLog) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) Sort(io.realm.Sort) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) DownloadObject(net.iGap.module.downloader.DownloadObject) RealmChangeListener(io.realm.RealmChangeListener) Context(android.content.Context) AttachmentObject(net.iGap.structs.AttachmentObject) RippleView(net.iGap.libs.rippleeffect.RippleView) AndroidUtils(net.iGap.module.AndroidUtils) PagerAdapter(androidx.viewpager.widget.PagerAdapter) AccountManager(net.iGap.module.accountManager.AccountManager) ViewPager(androidx.viewpager.widget.ViewPager) ArrayList(java.util.ArrayList) Toast(android.widget.Toast) LayoutCreator(net.iGap.helper.LayoutCreator) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RequestChannelAvatarGetList(net.iGap.request.RequestChannelAvatarGetList) RequestChannelAvatarDelete(net.iGap.request.RequestChannelAvatarDelete) HelperDownloadFile(net.iGap.helper.HelperDownloadFile) LayoutInflater(android.view.LayoutInflater) PhotoView(com.github.chrisbanes.photoview.PhotoView) RealmResults(io.realm.RealmResults) RequestUserAvatarDelete(net.iGap.request.RequestUserAvatarDelete) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) RequestGroupAvatarDelete(net.iGap.request.RequestGroupAvatarDelete) File(java.io.File) OnChannelAvatarDelete(net.iGap.observers.interfaces.OnChannelAvatarDelete) Color(android.graphics.Color) RealmAvatar(net.iGap.realm.RealmAvatar) Glide(com.bumptech.glide.Glide) HelperSaveFile(net.iGap.helper.HelperSaveFile) ProtoGlobal(net.iGap.proto.ProtoGlobal) R(net.iGap.R) ChannelChatRole(net.iGap.module.enums.ChannelChatRole) DbManager(net.iGap.module.accountManager.DbManager) RealmAttachment(net.iGap.realm.RealmAttachment) ArrayList(java.util.ArrayList) RippleView(net.iGap.libs.rippleeffect.RippleView)

Aggregations

ViewGroup (android.view.ViewGroup)6 TopSheetDialog (net.iGap.module.dialog.topsheet.TopSheetDialog)6 Bundle (android.os.Bundle)5 LayoutInflater (android.view.LayoutInflater)5 View (android.view.View)5 NonNull (androidx.annotation.NonNull)5 Nullable (androidx.annotation.Nullable)5 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)5 R (net.iGap.R)5 LinearLayout (android.widget.LinearLayout)4 Toast (android.widget.Toast)4 Intent (android.content.Intent)3 DataBindingUtil (androidx.databinding.DataBindingUtil)3 ViewModelProviders (androidx.lifecycle.ViewModelProviders)3 ArrayList (java.util.ArrayList)3 Context (android.content.Context)2 Build (android.os.Build)2 TextView (android.widget.TextView)2 PhotoView (com.github.chrisbanes.photoview.PhotoView)2 Sort (io.realm.Sort)2