Android-Week-View icon indicating copy to clipboard operation
Android-Week-View copied to clipboard

Fork that addresses crashes on API 28

Open thellmund opened this issue 6 years ago • 24 comments

Hi guys,

I’ve experienced some problems with the library when using API 28 in our app (deprecated canvas methods). Because the library seems to be no longer maintained, I’ve forked the repository and implemented a fix.

You can find it at https://github.com/thellmund/Android-Week-View. Hope this helps anyone who’s had similar problems 😊

thellmund avatar Sep 09 '18 07:09 thellmund

Thank you :D

marcoscgdev avatar Sep 20 '18 11:09 marcoscgdev

Que cambios has hecho para que funcione? Gracias!

fersical avatar Oct 16 '18 16:10 fersical

Thanks :)

fabien-ml avatar Oct 17 '18 11:10 fabien-ml

I have made another fork that solves this problem. This time, it supports API 14+

marcoscgdev/Android-Week-View

This is what I have done:

I have replaced this

canvas.clipRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight(), Region.Op.REPLACE);

with this

canvas.save();
canvas.clipRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight());
canvas.restore();

So basically I have removed Region.Op.REPLACE and I have added canvas.save(); and canvas.restore();

marcoscgdev avatar Oct 17 '18 12:10 marcoscgdev

@fersical I’ve done exactly what @marcoscgdev has described above. In the future, I want to make more changes, such as improving the scrolling behavior and tweaking the design a little.

thellmund avatar Oct 17 '18 13:10 thellmund

@thellmund Can you update your readme for your release 2.0 with new interfaces and attributes ?

wallforfry avatar Oct 23 '18 11:10 wallforfry

@wallforfry I hope to have some time this weekend to work on the library. This will include updating the readme.

thellmund avatar Oct 26 '18 11:10 thellmund

@wallforfry I finally just pushed a new version of the library and an update to the readme. Let me know if there's anything missing or if you have any improvement ideas.

thellmund avatar Nov 04 '18 22:11 thellmund

@thellmund Thanks for your work ! I've got improvement ideas :

  • add minTime and maxTime attributes in WeekView to constraint calendar display to specific range of hours
  • allow to change nowLine circle size like for the line thickness

wallforfry avatar Nov 05 '18 14:11 wallforfry

@wallforfry Great suggestions – I’ll keep them in mind for the next versions 👍

thellmund avatar Nov 05 '18 18:11 thellmund

@thellmund this method won't work if I compile my app with API 28

canvas.save(); canvas.clipRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight()); canvas.restore();

I am getting the same issue .

nivritgupta avatar Dec 04 '18 13:12 nivritgupta

@nivritgupta You’re referencing @marcoscgdev’s fork.

thellmund avatar Dec 04 '18 14:12 thellmund

@thellmund I think @nivritgupta is implementing his own fork. Your fork and also my fork are correctly working.

marcoscgdev avatar Dec 04 '18 14:12 marcoscgdev

@marcoscgdev 🤷‍♂️

thellmund avatar Dec 04 '18 14:12 thellmund

@marcoscgdev in the last 2 years I customised this library according to my requirements but now I am using your fork in my app and do some changes according to my requirements but I am getting another issue , single event showing 3 times on same time slot , screen shot 2018-12-05 at 12 33 04 am

nivritgupta avatar Dec 04 '18 19:12 nivritgupta

@nivritgupta Everything is working fine for me 🤔

Screenshot

marcoscgdev avatar Dec 04 '18 19:12 marcoscgdev

@marcoscgdev I understand your code is working fine , I am trying to find the exact cause of this issue in my code .

nivritgupta avatar Dec 04 '18 19:12 nivritgupta

@nivritgupta You are likely not implementing the MonthChangeListener (or WeekViewLoader) correctly. It requests 3 periods (eg. previous month, current month, next month). If you return the same event each time then it will display 3 times. Make sure you are correctly constraining the events to the arguments passed into whatever method you've implemented to fetch the events.

tylermarien avatar Dec 05 '18 19:12 tylermarien

Hey there, First of all i must appreciate your work, my developer use this library and he's no more with me so i have to do the changes but the changes i need wasnt in the real library but your updates really save my day. And now im having a little problem like @nivritgupta dose and i have read your suggestion to check MonthChangeListener but i dont find the issue. That would be really helpful if you can help me to make this right. The picture and the code of MonthChangeListener is mentioned below to better explain my problem.

override fun onMonthChange(startDate: Calendar?, endDate: Calendar?): ArrayList<WeekViewDisplayable<Event>>? { return events }

screenshot_2018-12-26-20-42-45-2

WasifNadeem90 avatar Dec 26 '18 15:12 WasifNadeem90

@WasifNadeem90 You need to filter out events that don't exist between the startDate and endDate.

Something like the following should work.

override fun onMonthChange(startDate: Calendar?, endDate: Calendar?): List<WeekViewDisplayable<Event>>? { 
  return events.filter { event ->
    (event.startTime >= startDate && event.startTime <= endDate) 
      || (event.endTime >= startDate && event.endTime <= endDate) 
  }
}

The reason is that the onMonthChange method will get called 3 times (once with the previous month, once with the current month and once with the next month). If you return the same set of events each time, each event will be returned 3 times. This will cause it to show 3 times.

tylermarien avatar Dec 26 '18 21:12 tylermarien

@marcoscgdev hope you are doing well , any ideas how we can implement drag and drop events features in this library ?

nivritgupta avatar Mar 19 '19 05:03 nivritgupta

@nivritgupta Probably by adding a touch listener when long-pressing an item that listens for user drag events and changes the item position based on that events.

marcoscgdev avatar Mar 22 '19 12:03 marcoscgdev

how to disable horizontal scrolling

rahulpateel avatar May 02 '20 07:05 rahulpateel

thanks u work as expected

fukemy avatar Dec 22 '20 08:12 fukemy