Search in sources :

Example 11 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class BaseViewHolder method handleDiscoveryFieldsClickStatic.

public static void handleDiscoveryFieldsClickStatic(DiscoveryItemField discoveryField, FragmentActivity activity, boolean haveNext) {
    if (activity == null || activity.isFinishing()) {
        return;
    }
    if (discoveryField.agreementSlug != null && discoveryField.agreementSlug.length() > 1) {
        if (!discoveryField.agreement) {
            DiscoveryFragmentAgreement.newInstance(discoveryField, discoveryField.agreementSlug).show(activity.getSupportFragmentManager(), null);
            return;
        }
    }
    new RequestClientSetDiscoveryItemClick().setDiscoveryClicked(discoveryField.id);
    switch(discoveryField.actionType) {
        case PAGE:
            /**
             * tested *
             */
            actionPage(discoveryField.value, activity, haveNext);
            break;
        case JOIN_LINK:
            int index = discoveryField.value.lastIndexOf("/");
            if (index >= 0 && index < discoveryField.value.length() - 1) {
                String token = discoveryField.value.substring(index + 1);
                if (discoveryField.value.toLowerCase().contains("join")) {
                    HelperUrl.checkAndJoinToRoom(activity, token);
                } else {
                    HelperUrl.checkUsernameAndGoToRoom(activity, token, HelperUrl.ChatEntry.profile);
                }
            }
            break;
        case WEB_LINK:
            /**
             * tested *
             */
            SharedPreferences sharedPreferences = activity.getSharedPreferences(SHP_SETTING.FILE_NAME, Context.MODE_PRIVATE);
            int checkedInAppBrowser = sharedPreferences.getInt(SHP_SETTING.KEY_IN_APP_BROWSER, 1);
            if (checkedInAppBrowser == 1 && !HelperUrl.isNeedOpenWithoutBrowser(discoveryField.value)) {
                HelperUrl.openBrowser(discoveryField.value);
            } else {
                HelperUrl.openWithoutBrowser(discoveryField.value);
            }
            break;
        case IVAND:
            new HelperFragment(activity.getSupportFragmentManager(), new FragmentUserScore()).setReplace(false).load();
            break;
        case IVANDQR:
            UserScoreViewModel.scanBarCode(activity);
            break;
        case IVANDLIST:
            new HelperFragment(activity.getSupportFragmentManager(), FragmentIVandActivities.newInstance()).setReplace(false).load();
            break;
        case WEB_VIEW_LINK:
            /**
             * tested title needed*
             */
            if (HelperUrl.isNeedOpenWithoutBrowser(discoveryField.value)) {
                HelperUrl.openWithoutBrowser(discoveryField.value);
            } else {
                new HelperFragment(activity.getSupportFragmentManager(), FragmentWebView.newInstance(discoveryField.value, discoveryField.refresh, discoveryField.param)).setReplace(false).load();
            }
            break;
        case USERNAME_LINK:
            /**
             * tested *
             */
            HelperUrl.checkUsernameAndGoToRoomWithMessageId(activity, discoveryField.value.replace("@", ""), HelperUrl.ChatEntry.chat, 0, 0);
            break;
        case TOPUP_MENU:
            /**
             * tested *
             */
            new HelperFragment(activity.getSupportFragmentManager(), ChargeFragment.newInstance()).setReplace(false).load();
            break;
        case BILL_MENU:
            try {
                JSONObject jsonObject = new JSONObject(discoveryField.value);
                new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills, jsonObject)).setReplace(false).load();
            } catch (JSONException e) {
                new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills)).setReplace(false).load();
            }
            break;
        case TRAFFIC_BILL_MENU:
            /**
             * tested *
             */
            try {
                JSONObject jsonObject = new JSONObject(discoveryField.value);
                new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills_crime, jsonObject)).setReplace(false).load();
            } catch (JSONException e) {
                new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills_crime)).setReplace(false).load();
            }
            break;
        case PHONE_BILL_MENU:
            /**
             * tested *
             */
            new HelperFragment(activity.getSupportFragmentManager(), new FragmentPaymentInquiryTelephone()).setReplace(false).load();
            break;
        case ELECTRIC_BILL_MENU:
            new HelperFragment(activity.getSupportFragmentManager(), new ElectricityBillMainFrag()).setReplace(false).load();
            // new HelperFragment(activity.getSupportFragmentManager(), new MobileBankLoginFragment()).setReplace(false).load();
            break;
        case PARSLAND:
            break;
        case FUN_SERVICE:
            new HelperFragment(activity.getSupportFragmentManager(), new IGashtProvinceFragment()).setReplace(false).load();
            break;
        case BLOCKCHAIN:
            break;
        case VIRTUAL_GIFT_CARD:
            break;
        case NEWS:
            NewsMainFrag frag = new NewsMainFrag();
            if (!discoveryField.value.equals(""))
                frag.setSpecificNewsID(discoveryField.value);
            new HelperFragment(activity.getSupportFragmentManager(), frag).setReplace(false).load();
            break;
        case MOBILE_BILL_MENU:
            /**
             * tested *
             */
            new HelperFragment(activity.getSupportFragmentManager(), new FragmentPaymentInquiryMobile()).setReplace(false).load();
            break;
        case FINANCIAL_MENU:
            /**
             * tested *
             */
            new HelperFragment(activity.getSupportFragmentManager(), FragmentPayment.newInstance()).setReplace(false).load();
            break;
        case NEARBY_MENU:
            /**
             * tested *
             */
            try {
                HelperPermission.getLocationPermission(activity, new OnGetPermission() {

                    @Override
                    public void Allow() throws IOException {
                        try {
                            if (!waitingForConfiguration) {
                                waitingForConfiguration = true;
                                if (mapUrls == null || mapUrls.isEmpty() || mapUrls.size() == 0) {
                                    G.onGeoGetConfiguration = new OnGeoGetConfiguration() {

                                        @Override
                                        public void onGetConfiguration() {
                                            G.handler.postDelayed(new Runnable() {

                                                @Override
                                                public void run() {
                                                    waitingForConfiguration = false;
                                                }
                                            }, 2000);
                                            new HelperFragment(activity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).setReplace(false).load();
                                        }

                                        @Override
                                        public void getConfigurationTimeOut() {
                                            G.handler.postDelayed(new Runnable() {

                                                @Override
                                                public void run() {
                                                    waitingForConfiguration = false;
                                                }
                                            }, 2000);
                                        }
                                    };
                                    new RequestGeoGetConfiguration().getConfiguration();
                                } else {
                                    G.handler.postDelayed(new Runnable() {

                                        @Override
                                        public void run() {
                                            waitingForConfiguration = false;
                                        }
                                    }, 2000);
                                    new HelperFragment(activity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).setReplace(false).load();
                                }
                            }
                        } catch (Exception e) {
                            e.getStackTrace();
                        }
                    }

                    @Override
                    public void deny() {
                        showDeniedPermissionMessage(G.context.getString(R.string.permission_location));
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
            break;
        case REQUEST_PHONE:
            // this item is for bot
            break;
        case REQUEST_LOCATION:
            // this item is for bot
            break;
        case BOT_ACTION:
            // this item is for bot
            break;
        case PAY_BY_WALLET:
            // coming soon
            break;
        case PAY_DIRECT:
            try {
                JSONObject jsonObject = new JSONObject(discoveryField.value);
                DirectPayHelper.directPay(jsonObject);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            break;
        case CALL:
            /**
             * tested *
             */
            dialPhoneNumber(activity, discoveryField.value, activity);
            break;
        case SHOW_ALERT:
            /**
             * tested *
             */
            new MaterialDialog.Builder(activity).content(discoveryField.value).positiveText(R.string.dialog_ok).onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                }
            }).show();
            break;
        case STREAM_PLAY:
            // coming soon
            break;
        case STICKER_SHOP:
            /**
             * tested *
             */
            StickerRepository.getInstance().getUserStickersGroup();
            if (discoveryField.value.isEmpty()) {
                new HelperFragment(activity.getSupportFragmentManager(), FragmentSettingAddStickers.newInstance("ALL")).setReplace(false).load();
            } else {
                try {
                    String title = "";
                    JSONObject jsonObject = new JSONObject(discoveryField.value);
                    if (jsonObject.has("title"))
                        title = jsonObject.getString("title");
                    if (jsonObject.has("group")) {
                        String category = jsonObject.getString("group");
                        if (!category.isEmpty()) {
                            if (jsonObject.has("type")) {
                                String type = jsonObject.getString("type");
                                new HelperFragment(activity.getSupportFragmentManager(), AddStickersFragment.newInstance(category, type, title)).setReplace(false).load();
                            } else {
                                new HelperFragment(activity.getSupportFragmentManager(), AddStickersFragment.newInstance(category, "ALL", title)).setReplace(false).load();
                            }
                        }
                    } else if (jsonObject.has("type")) {
                        String type = jsonObject.getString("type");
                        new HelperFragment(activity.getSupportFragmentManager(), FragmentSettingAddStickers.newInstance(type)).setReplace(false).load();
                    } else if (jsonObject.has("id")) {
                        String id = jsonObject.getString("id");
                        StickerDialogFragment dialogFragment = StickerDialogFragment.getInstance(id);
                        dialogFragment.show(activity.getSupportFragmentManager(), "BaseViewHolder");
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            break;
        case CARD_TO_CARD:
            CardToCardHelper.CallCardToCard(activity);
            break;
        case IVANDSCORE:
            new MaterialDialog.Builder(activity).content(R.string.are_you_sure_request).positiveText(R.string.yes).negativeText(R.string.no).onPositive((dialog, which) -> {
                dialog.dismiss();
                ActivityMain.doIvandScore(discoveryField.value, activity);
            }).onNegative((dialog, which) -> {
                dialog.dismiss();
            }).show();
            break;
        case NONE:
            break;
        case POLL:
            new HelperFragment(activity.getSupportFragmentManager(), PollFragment.newInstance(Integer.parseInt(HelperString.isNumeric(discoveryField.value) ? discoveryField.value : "0"))).setReplace(false).load();
            break;
        case POLL_RESULT:
            new HelperFragment(activity.getSupportFragmentManager(), ChartFragment.newInstance(Integer.parseInt(HelperString.isNumeric(discoveryField.value) ? discoveryField.value : "0"))).setReplace(false).load();
            break;
        case FAVORITE_CHANNEL:
            if (discoveryField.value.equals(""))
                new HelperFragment(activity.getSupportFragmentManager(), new PopularChannelHomeFragment()).setReplace(false).load();
            else {
                PopularMoreChannelFragment popularMoreChannelFragment = new PopularMoreChannelFragment();
                Bundle bundle = new Bundle();
                bundle.putString("id", discoveryField.value);
                popularMoreChannelFragment.setArguments(bundle);
                new HelperFragment(activity.getSupportFragmentManager(), popularMoreChannelFragment).setReplace(false).load();
            }
            break;
        case FINANCIAL_HISTORY:
            new HelperFragment(activity.getSupportFragmentManager(), new MplTransactionFragment()).setReplace(false).load();
            break;
        case INTERNET_PACKAGE_MENU:
            new HelperFragment(activity.getSupportFragmentManager(), InternetFragment.newInstance()).setReplace(false).load();
            break;
        case CHARITY:
            try {
                JSONObject jsonObject = new JSONObject(discoveryField.value);
                if (jsonObject.getInt("price") == 0) {
                    new MaterialDialog.Builder(activity).title(activity.getResources().getString(R.string.insert_amount_in_rial)).customView(R.layout.charity_custom_amount, false).positiveText(activity.getResources().getString(R.string.B_ok)).negativeText(activity.getResources().getString(R.string.B_cancel)).onPositive((dialog, which) -> {
                        EditText editText = dialog.getView().findViewById(R.id.editText);
                        if (editText.getText() != null) {
                            if (editText.getText().toString().length() > 0) {
                                int price = Integer.parseInt(editText.getText().toString());
                                if (price > 10000) {
                                    HelperUrl.showIndeterminateProgressDialog(activity);
                                    try {
                                        dialog.cancel();
                                        sendRequestGetCharityPaymentToken(activity, jsonObject.getString("charityId"), price);
                                    } catch (JSONException e) {
                                        HelperUrl.closeDialogWaiting();
                                        e.printStackTrace();
                                    }
                                } else {
                                    Toast.makeText(activity, activity.getResources().getString(R.string.amount_must_be_greater_10000), Toast.LENGTH_SHORT).show();
                                }
                            }
                        }
                    }).build().show();
                } else {
                    HelperUrl.showIndeterminateProgressDialog(activity);
                    sendRequestGetCharityPaymentToken(activity, jsonObject.getString("charityId"), jsonObject.getInt("price"));
                }
            } catch (JSONException e) {
                HelperUrl.closeDialogWaiting();
                e.printStackTrace();
            }
            break;
        case INVITE_FRIEND:
            try {
                HelperPermission.getContactPermision(activity, new OnGetPermission() {

                    @Override
                    public void Allow() {
                        new HelperFragment(activity.getSupportFragmentManager(), new LocalContactFragment()).setReplace(false).load(true);
                    }

                    @Override
                    public void deny() {
                        showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
            break;
        case QRPAY:
            new HelperFragment(activity.getSupportFragmentManager(), ScanCodeQRCodePaymentFragment.newInstance()).setReplace(false).load();
            break;
        default:
            new MaterialDialog.Builder(activity).content(R.string.install_latest_version).positiveText(R.string.ok).onPositive((dialog, which) -> dialog.dismiss()).show();
            break;
    }
}
Also used : Bundle(android.os.Bundle) DiscoveryFragmentAgreement(net.iGap.fragments.discovery.DiscoveryFragmentAgreement) NonNull(androidx.annotation.NonNull) HandShakeCallback(net.iGap.observers.interfaces.HandShakeCallback) Uri(android.net.Uri) ImageView(android.widget.ImageView) ChargeFragment(net.iGap.fragments.payment.ChargeFragment) UserScoreViewModel(net.iGap.viewmodel.UserScoreViewModel) StickerDialogFragment(net.iGap.fragments.emoji.add.StickerDialogFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) G(net.iGap.G) MciPurchaseResponse(net.iGap.model.paymentPackage.MciPurchaseResponse) RequestClientSetDiscoveryItemClick(net.iGap.request.RequestClientSetDiscoveryItemClick) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) HelperPermission(net.iGap.helper.HelperPermission) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) PollFragment(net.iGap.fragments.poll.PollFragment) View(android.view.View) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) FragmentPayment(net.iGap.fragments.FragmentPayment) HelperFragment(net.iGap.helper.HelperFragment) FragmentIVandActivities(net.iGap.fragments.FragmentIVandActivities) FragmentPaymentInquiryMobile(net.iGap.fragments.inquiryBill.FragmentPaymentInquiryMobile) MplTransactionFragment(net.iGap.fragments.mplTranaction.MplTransactionFragment) IGashtProvinceFragment(net.iGap.fragments.igasht.IGashtProvinceFragment) FragmentSettingAddStickers(net.iGap.fragments.emoji.add.FragmentSettingAddStickers) AddStickersFragment(net.iGap.fragments.emoji.add.AddStickersFragment) DiscoveryItemField(net.iGap.adapter.items.discovery.DiscoveryItemField) SHP_SETTING(net.iGap.module.SHP_SETTING) LocalContactFragment(net.iGap.fragments.LocalContactFragment) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) StickerRepository(net.iGap.repository.StickerRepository) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ResponseCallback(net.iGap.observers.interfaces.ResponseCallback) Context(android.content.Context) ActivityMain(net.iGap.activities.ActivityMain) HelperUrl(net.iGap.helper.HelperUrl) ApiInitializer(net.iGap.api.apiService.ApiInitializer) Intent(android.content.Intent) SystemClock(android.os.SystemClock) FragmentiGapMap.mapUrls(net.iGap.fragments.FragmentiGapMap.mapUrls) InternetFragment(net.iGap.fragments.payment.InternetFragment) FragmentActivity(androidx.fragment.app.FragmentActivity) Toast(android.widget.Toast) ChartFragment(net.iGap.fragments.poll.ChartFragment) ImageLoadingServiceInjector(net.iGap.module.imageLoaderService.ImageLoadingServiceInjector) FragmentUserScore(net.iGap.fragments.FragmentUserScore) PopularMoreChannelFragment(net.iGap.fragments.populaChannel.PopularMoreChannelFragment) FragmentPaymentInquiryTelephone(net.iGap.fragments.FragmentPaymentInquiryTelephone) FragmentiGapMap(net.iGap.fragments.FragmentiGapMap) NewsMainFrag(net.iGap.fragments.news.NewsMainFrag) PopularChannelHomeFragment(net.iGap.fragments.populaChannel.PopularChannelHomeFragment) DialogAction(com.afollestad.materialdialogs.DialogAction) FragmentPaymentBill(net.iGap.fragments.FragmentPaymentBill) IOException(java.io.IOException) ScanCodeQRCodePaymentFragment(net.iGap.fragments.qrCodePayment.fragments.ScanCodeQRCodePaymentFragment) OnGeoGetConfiguration(net.iGap.observers.interfaces.OnGeoGetConfiguration) DiscoveryItem(net.iGap.adapter.items.discovery.DiscoveryItem) CardToCardHelper(net.iGap.helper.CardToCardHelper) RequestGeoGetConfiguration(net.iGap.request.RequestGeoGetConfiguration) RetrofitFactory(net.iGap.api.apiService.RetrofitFactory) ElectricityBillMainFrag(net.iGap.fragments.electricity_bill.ElectricityBillMainFrag) SharedPreferences(android.content.SharedPreferences) HelperString(net.iGap.helper.HelperString) ActivityMain.waitingForConfiguration(net.iGap.activities.ActivityMain.waitingForConfiguration) R(net.iGap.R) DirectPayHelper(net.iGap.helper.DirectPayHelper) EditText(android.widget.EditText) FragmentWebView(net.iGap.fragments.FragmentWebView) PopularChannelHomeFragment(net.iGap.fragments.populaChannel.PopularChannelHomeFragment) FragmentPaymentInquiryTelephone(net.iGap.fragments.FragmentPaymentInquiryTelephone) FragmentUserScore(net.iGap.fragments.FragmentUserScore) ElectricityBillMainFrag(net.iGap.fragments.electricity_bill.ElectricityBillMainFrag) HelperString(net.iGap.helper.HelperString) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) NewsMainFrag(net.iGap.fragments.news.NewsMainFrag) PopularMoreChannelFragment(net.iGap.fragments.populaChannel.PopularMoreChannelFragment) NonNull(androidx.annotation.NonNull) IGashtProvinceFragment(net.iGap.fragments.igasht.IGashtProvinceFragment) RequestGeoGetConfiguration(net.iGap.request.RequestGeoGetConfiguration) EditText(android.widget.EditText) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) SharedPreferences(android.content.SharedPreferences) FragmentPaymentInquiryMobile(net.iGap.fragments.inquiryBill.FragmentPaymentInquiryMobile) Bundle(android.os.Bundle) MplTransactionFragment(net.iGap.fragments.mplTranaction.MplTransactionFragment) JSONException(org.json.JSONException) IOException(java.io.IOException) LocalContactFragment(net.iGap.fragments.LocalContactFragment) JSONException(org.json.JSONException) IOException(java.io.IOException) JSONObject(org.json.JSONObject) DialogAction(com.afollestad.materialdialogs.DialogAction) RequestClientSetDiscoveryItemClick(net.iGap.request.RequestClientSetDiscoveryItemClick) OnGeoGetConfiguration(net.iGap.observers.interfaces.OnGeoGetConfiguration) HelperFragment(net.iGap.helper.HelperFragment) StickerDialogFragment(net.iGap.fragments.emoji.add.StickerDialogFragment)

Example 12 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class Type0ViewHolder method bindView.

@Override
public void bindView(DiscoveryItem item) {
    itemView.setOnClickListener(view -> new HelperFragment(G.currentActivity.getSupportFragmentManager(), new FragmentUserScore()).setReplace(false).load());
    DbManager.getInstance().doRealmTask(realm -> {
        RealmUserInfo userInfo = realm.where(RealmUserInfo.class).findFirst();
        if (userInfo != null)
            tvScore.setText(HelperCalander.isPersianUnicode ? HelperCalander.convertToUnicodeFarsiNumber(String.valueOf(userInfo.getIvandScore())) : String.valueOf(userInfo.getIvandScore()));
    });
    Animation animation = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.shake_mode);
    animation.reset();
    tvContent.clearAnimation();
    tvContent.startAnimation(animation);
}
Also used : RealmUserInfo(net.iGap.realm.RealmUserInfo) FragmentUserScore(net.iGap.fragments.FragmentUserScore) Animation(android.view.animation.Animation) HelperFragment(net.iGap.helper.HelperFragment)

Example 13 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class CameraStoryFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getEventManager().addObserver(EventManager.ON_VOLUME_DOWN_KEY, this);
    galleryIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            onGalleryIconClicked.onGalleryIconClicked();
        }
    });
    checkFlashMode();
    flashModeButton = new ImageView(context);
    flashModeButton.setScaleType(ImageView.ScaleType.CENTER);
    topToolPanel.addView(flashModeButton, LayoutCreator.createFrame(48, 48, Gravity.LEFT | Gravity.CENTER_VERTICAL));
    flashModeButton.setOnClickListener(currentImage -> {
        if (cameraView == null || !cameraView.isInitied()) {
            return;
        }
        String current = cameraView.getCameraSession().getCurrentFlashMode();
        String next = cameraView.getCameraSession().getNextFlashMode();
        if (current.equals(next)) {
            return;
        }
        cameraView.getCameraSession().setCurrentFlashMode(next);
        setCameraFlashModeIcon(flashModeButton, next);
    });
    flashModeButton.setContentDescription("flash mode ");
    takePicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String fileName = "story_" + HelperString.getRandomFileName(3) + ".jpg";
            File cameraFile = null;
            try {
                cameraFile = new AttachFile(getActivity()).createImageFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            File finalCameraFile = cameraFile;
            CameraController.getInstance().takePicture(cameraFile, cameraView.getCameraSession(), () -> {
                if (finalCameraFile == null || getActivity() == null) {
                    return;
                }
                int orientation = 0;
                try {
                    ExifInterface ei = new ExifInterface(finalCameraFile.getAbsolutePath());
                    int exif = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
                    switch(exif) {
                        case ExifInterface.ORIENTATION_ROTATE_90:
                            orientation = 90;
                            break;
                        case ExifInterface.ORIENTATION_ROTATE_180:
                            orientation = 180;
                            break;
                        case ExifInterface.ORIENTATION_ROTATE_270:
                            orientation = 270;
                            break;
                    }
                } catch (Exception e) {
                    FileLog.e(e);
                }
                // CameraController.getInstance().initCamera(null);
                cameraView.initCamera();
                ImageHelper.correctRotateImage(finalCameraFile.getAbsolutePath(), true);
                FragmentEditImage.checkItemGalleryList();
                FragmentEditImage.insertItemList(finalCameraFile.getAbsolutePath(), true);
                if (getActivity() != null) {
                    new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.newInstance(finalCameraFile.getAbsolutePath(), isForRoom, roomId, listMode, roomTitle)).setReplace(false).load();
                }
            });
        }
    });
    switchCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            cameraView.switchCamera();
            ObjectAnimator animator = ObjectAnimator.ofFloat(switchCamera, View.SCALE_X, 0.0f).setDuration(100);
            animator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animator) {
                    switchCamera.setImageResource(cameraView != null && cameraView.isFrontface() ? R.drawable.camera_revert1 : R.drawable.camera_revert2);
                    ObjectAnimator.ofFloat(switchCamera, View.SCALE_X, 1.0f).setDuration(100).start();
                }
            });
            animator.start();
        }
    });
    if (checkCameraHardware(getContext())) {
        if (allPermissionsGranted()) {
            CameraController.getInstance().initCamera(null);
            // switchCamera.setVisibility(cameraView.hasFrontFaceCamera() ? View.VISIBLE : View.INVISIBLE);
            showCamera();
        } else {
            try {
                HelperPermission.getCameraPermission(getContext(), new OnGetPermission() {

                    @Override
                    public void Allow() throws IOException {
                        HelperPermission.getStoragePermission(getContext(), new OnGetPermission() {

                            @Override
                            public void Allow() throws IOException {
                                if (checkCameraHardware(getContext())) {
                                    CameraController.getInstance().initCamera(null);
                                    // switchCamera.setVisibility(cameraView.hasFrontFaceCamera() ? View.VISIBLE : View.INVISIBLE);
                                    showCamera();
                                }
                            }

                            @Override
                            public void deny() {
                            }
                        });
                    }

                    @Override
                    public void deny() {
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } else {
        Toast.makeText(getContext(), getString(R.string.your_device_does_not_have_a_camera), Toast.LENGTH_LONG).show();
    }
    closeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new HelperFragment(Objects.requireNonNull(getActivity()).getSupportFragmentManager(), CameraStoryFragment.this).popBackStack();
        }
    });
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ExifInterface(androidx.exifinterface.media.ExifInterface) HelperString(net.iGap.helper.HelperString) IOException(java.io.IOException) ImageView(android.widget.ImageView) View(android.view.View) CircleImageView(net.iGap.module.CircleImageView) TextView(android.widget.TextView) IOException(java.io.IOException) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AttachFile(net.iGap.module.AttachFile) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ImageView(android.widget.ImageView) CircleImageView(net.iGap.module.CircleImageView) HelperFragment(net.iGap.helper.HelperFragment) AttachFile(net.iGap.module.AttachFile) File(java.io.File)

Example 14 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class ActivityMain method checkIntent.

private void checkIntent(Intent intent) {
    if (G.isRestartActivity) {
        return;
    }
    if (intent.getAction() != null && intent.getAction().equals("net.iGap.payment")) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment fragment = fragmentManager.findFragmentByTag(PaymentFragment.class.getName());
        if (fragment instanceof PaymentFragment) {
            ((PaymentFragment) fragment).setPaymentResult(new Payment(intent.getStringExtra("status"), intent.getStringExtra("message"), intent.getStringExtra("order_id"), intent.getStringExtra("tax"), intent.getStringExtra("discount")));
        }
    }
    new HelperGetDataFromOtherApp(this, intent);
    // check has shared data if true setup main fragment (room list) ui
    Fragment fragmentBottomNav = getSupportFragmentManager().findFragmentByTag(BottomNavigationFragment.class.getName());
    if (fragmentBottomNav instanceof BottomNavigationFragment) {
        // set true just for checking state
        ((BottomNavigationFragment) fragmentBottomNav).checkHasSharedData(true);
        ((BottomNavigationFragment) fragmentBottomNav).isFirstTabItem();
    }
    if (intent.getAction() != null && intent.getAction().equals("net.iGap.activities.OPEN_ACCOUNT")) {
        new HelperFragment(getSupportFragmentManager(), new FragmentSetting()).load();
    }
    Bundle extras = intent.getExtras();
    if (extras != null) {
        long roomId = extras.getLong(ActivityMain.openChat);
        if (!FragmentLanguage.languageChanged && roomId > 0) {
            // if language changed not need check enter to chat
            // GoToChatActivity goToChatActivity = new GoToChatActivity(roomId);
            // TODO this change is duo to room null bug. if it works server must change routine.
            long peerId = extras.getLong("PeerID");
            long userId = extras.getLong(ActivityMain.userId);
            if (AccountManager.getInstance().getCurrentUser().getId() != userId) {
                new AccountHelper().changeAccount(userId);
                updateUiForChangeAccount();
            }
            HelperUrl.goToActivityFromFCM(this, roomId, peerId);
        }
        FragmentLanguage.languageChanged = false;
        boolean openMediaPlayer = extras.getBoolean(ActivityMain.openMediaPlayer);
        if (openMediaPlayer) {
            if (getSupportFragmentManager().findFragmentByTag(FragmentMediaPlayer.class.getName()) == null) {
                FragmentMediaPlayer fragment = new FragmentMediaPlayer();
                new HelperFragment(getSupportFragmentManager(), fragment).setReplace(false).load();
            }
        }
    }
}
Also used : HelperGetDataFromOtherApp(net.iGap.helper.HelperGetDataFromOtherApp) AccountHelper(net.iGap.module.accountManager.AccountHelper) PaymentFragment(net.iGap.fragments.PaymentFragment) FragmentSetting(net.iGap.fragments.FragmentSetting) Bundle(android.os.Bundle) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) FragmentManager(androidx.fragment.app.FragmentManager) OnPayment(net.iGap.observers.interfaces.OnPayment) Payment(net.iGap.model.payment.Payment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) FragmentMediaPlayer(net.iGap.fragments.FragmentMediaPlayer) HelperFragment(net.iGap.helper.HelperFragment)

Example 15 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class ActivityMain method initTabStrip.

// ******************************************************************************************************************************
private void initTabStrip(Intent intent) {
    if (G.twoPaneMode) {
        new HelperFragment(getSupportFragmentManager(), new TabletEmptyChatFragment()).load(true);
    }
    Log.wtf(this.getClass().getName(), "initTabStrip");
    BottomNavigationFragment bottomNavigationFragment = new BottomNavigationFragment();
    if (intent.getExtras() != null && intent.getExtras().getString(DEEP_LINK) != null) {
        bottomNavigationFragment.setCrawlerMap(intent.getExtras().getString(DEEP_LINK, DEEP_LINK_CALL));
    }
    new HelperFragment(getSupportFragmentManager(), bottomNavigationFragment).load();
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) HelperFragment(net.iGap.helper.HelperFragment)

Aggregations

HelperFragment (net.iGap.helper.HelperFragment)93 Bundle (android.os.Bundle)32 View (android.view.View)31 Fragment (androidx.fragment.app.Fragment)25 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)15 RecyclerView (androidx.recyclerview.widget.RecyclerView)14 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)14 ViewGroup (android.view.ViewGroup)13 NonNull (androidx.annotation.NonNull)13 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)13 Theme (net.iGap.module.Theme)13 R (net.iGap.R)12 OnGetPermission (net.iGap.observers.interfaces.OnGetPermission)12 LayoutInflater (android.view.LayoutInflater)11 TextView (android.widget.TextView)11 Nullable (androidx.annotation.Nullable)11 HelperString (net.iGap.helper.HelperString)10 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)10