Closed oneroman closed 7 years ago
Yes, the same problem. If I use this library with DialogFragment I get the same cast error.
@oneroman Thanks! I'm going to investigate it :D @JustTrust I'll see if the proposed solution by @oneroman fix the problem :) Thx!
@Nescafemix thanks for your attention to that issue! really appreciate it. would you like to get a pull request from me?
@oneroman every help is welcome, but please, if you do, do it against develop branch 👍
@Nescafemix looks good?
@Nescafemix any dates for 1.0.4 release?
@oneoman thanks. Looks good! Please, give me some time (1-2 days) to check if I need to add some extra case to fix the problem with DialogFragment that has @JustTrust
on the other hand, @JustTrust, could you show me the code that you use to call your Hint?
@Nescafemix yes, with pleasure
void showHint(ImageView view, String text) {
if (mHintCase != null) return;
CustomHintContentHolder blockInfo = new CustomHintContentHolder.Builder(view.getContext())
.setContentText(text)
.setBorder(R.dimen.bubble_border, R.color.colorPrimaryDark)
.setArrowSize(R.dimen.arrow_width, R.dimen.arrow_height)
.setBackgroundColor(Color.WHITE)
.setMarginByResourcesId(R.dimen.side_margin,
R.dimen.activity_horizontal_margin,
R.dimen.side_margin,
R.dimen.activity_horizontal_margin)
.setContentPaddingByResourcesId(R.dimen.small_margin,
R.dimen.small_margin,
R.dimen.small_margin,
R.dimen.small_margin)
.setContentStyle(R.style.InformationHint)
.build();
if (getView()==null) return;
mHintCase = new HintCase(getView())
.setTarget(view, R.dimen.zero_margin)
.setOnClosedListener(new HintCase.OnClosedListener() {
@Override
public void onClosed() {
hideHintCase();
}
})
.setBackgroundColor(0x00000000)
.setHintBlock(blockInfo, new FadeInContentHolderAnimator(),
new FadeOutContentHolderAnimator())
.setCloseOnTouchView(true);
mHintCase.show();
}
where getView()
we call in DialogFragment
.
I try to write getActivity()
instead of getView()
and it works, but hint was showing under DialogFragment
in activity )
Thx @JustTrust . I found the problem, and I need to perform a deep refactor to enable the use of the library from Dialogs, so I'm going to launch the fix for @oneroman in the next 2 days and then I'm going to start with the necessary changes to enable the library for dialogs. (version 1.0.5 or maybe even 1.1 or 2.0 XD)
Maybe, that refactor will fix the other bug that you told us on https://github.com/Nescafemix/hintcase/issues/9 Thx again!
@Nescafemix you mean my fix is not enough to make your lib to work with Dialogs. Except my patch you need to implement something else, am I right?
@oneroman Exactly. I'm going to launch 1.0.4 (with your fix) in next 2 days :)
@Nescafemix let me know if I can help u to fix Dialog issue, se we could release it faster
@Nescafemix when we are could see the 1.0.4 version of your awesome library?
Sorry @JustTrust , my children took all my free time 😭 . I will try to do it today.
@JustTrust published! @oneroman I'm going to begin the next version of the library fixing the problem with dialogs/dialogsfragments and the hint appearing under the dialog. it is gonna take me some time, cause i need to refactor some things.
@JustTrust hey.Just want to clarify the following. using 1.0.4 version are you able to show hint above a Dialog? or that functionality still does not work for you?
@oneroman No, the problem with the hint under the dialog is still on the last version. I need to refactor the place where I add the view of the hint. Currently, I'm using the Decorview of the activity to put the hintcaseView, but the Dialog is showed in an upper layer so, I need to add the hint in other place with the WindowManager. I know what i need to do (I checked some hardcoded code and I could show the hint above the dialog) but i need some time to do it in a clean way.
Hi @oneroman. How @Nescafemix said above problem with DialogFragment is still present. I need 1.0.4 for one reason, that my application doesn't crashed. But I am still waiting for fixed version.
Yes, the same problem. If I use this library with DialogFragment I get the same cast error.
code.txt Hello there!
I wish to use the library inside the android.support.design.widget.BottomSheetDialogFragment. And I am passing the proper view into constructor for HintCase, but for Nexus 6 L OS I do have the following issue:
AndroidRuntime: FATAL EXCEPTION: main java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity at com.joanfuentes.hintcase.utils.DimenUtils.getRealScreenSize(DimenUtils.java:81) at com.joanfuentes.hintcase.utils.DimenUtils.getNavigationBarSizeIfExistAtTheBottom(DimenUtils.java:42) at com.joanfuentes.hintcase.HintCaseView.init(HintCaseView.java:81) at com.joanfuentes.hintcase.HintCaseView.(HintCaseView.java:63) at com.joanfuentes.hintcase.HintCase.(HintCase.java:40)
Therefore, I am suggesting to modify the code slightly in the following manner. Please consider it because it shall work perfectly.
public static Point getRealScreenSize(Context context) { Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); display.getRealSize(size); } else { View decorView = null; if(context instanceof Activity) { decorView = ((Activity) context).getWindow().getDecorView(); } else if(context instanceof ContextThemeWrapper) { Context baseContext = ((ContextThemeWrapper) context).getBaseContext(); if(baseContext instanceof Activity) { decorView = ((Activity) baseContext).getWindow().getDecorView(); } } if(decorView != null) { size.x = decorView.getWidth(); size.y = decorView.getHeight(); } } return size; }
You are great, Thanks in my case .. if(context instanceOf Activity) worked
code.txt Hello there!
I wish to use the library inside the android.support.design.widget.BottomSheetDialogFragment. And I am passing the proper view into constructor for HintCase, but for Nexus 6 L OS I do have the following issue:
Therefore, I am suggesting to modify the code slightly in the following manner. Please consider it because it shall work perfectly.