uknownothingsnow / CircleProgress

CircleProgress, DonutProgress, ArcProgress
3.81k stars 921 forks source link

Bottom text cut on ArcProgress when use Fragment #11

Open csechuan opened 9 years ago

csechuan commented 9 years ago

As per title, I found this issue happens only when using Fragment. I simulate the same thing on Activity, it works perfect.

\ There are 3 posts regarding this issue. So I don't know which should I post into.

sp574 commented 9 years ago

I have the same issue

xbassols commented 9 years ago

Same here.

uknownothingsnow commented 9 years ago

I will check this bug this weekend, please wait

ferozsho commented 9 years ago

In Fragment the arcBottomHeight = 0 after reload.

on first load: -- /ArcProgress﹕ arcBottomHeight: 14.323726 -- /ArcProgress﹕ onDraw -> getBottomText : 142.5122

on reload: * /ArcProgress﹕ arcBottomHeight: 0.0 * /ArcProgress﹕ onDraw -> getBottomText : 142.5122

uknownothingsnow commented 9 years ago

@ferozsho thanks a lot, I will fix it

uknownothingsnow commented 9 years ago

@ferozsho would you mind give more detail about fragment reload, so I can reproduce this bug.

ferozsho commented 9 years ago

@lzyzsd Thanks for response.

please check when i reuse the code its working. onfrag

uknownothingsnow commented 9 years ago

@ferozsho I still can not reproduce this bug, would you mind giving more detail about your code? I use show and hide to switch fragments and can not reproduce it.How do you reload your fragments?

ferozsho commented 9 years ago

@lzyzsd Please add this below code on ArcProgress.java under onDraw method after 297 line and its working fine with below code.

        if(arcBottomHeight == 0) {
            float radius = getWidth() / 2f;
            float angle = (360 - arcAngle) / 2f;
            arcBottomHeight = radius * (float) (1 - Math.cos(angle / 180 * Math.PI));
        }

because the arcBottomHeight is getting to zero. after reload the fragment.

For calling multiples time on Activity:

FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.overviewFragment, OverviewFragment .newInstance(selectedPeriod, sDate, eDate)); fragmentTransaction.commit();

1

Hope this help.

akshaylive commented 9 years ago

I have the same problem. Please release with the fix. Thank you so much!

ngalongc commented 9 years ago

@ferozsho u are my hero, I solved this by using ur solution, I wish I can kiss u. And of cause thank you author of this package! Which is very good looking and nice!

Lir10 commented 9 years ago

can you push this commit and release a new fixed version please? :)

Lir10 commented 9 years ago

Looks like we can fix this from the fragment it self with :

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.status, container, false);
            // Initialise your layout here
        } else {
            container.removeView(rootView);
        }
return rootView;
}
b0wter commented 8 years ago

The same issue also happens when using the control in a regular activity inside a PercentFrameLayout.