Giter Site home page Giter Site logo

Comments (10)

empeusz avatar empeusz commented on July 29, 2024 1

@jhoobergs understood. I've just made all necesary changes - works like a charm! :) THANK YOU! And thanks again for keeping the library alive! Cheers! πŸ‘

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@empeusz The stars (**) in the constructor you show here, are they also in you code ?

from android-week-view.

empeusz avatar empeusz commented on July 29, 2024

@jhoobergs ohh sorry - just wanted do bold the text.. so no stars in the code :)
Just to make thing clear I'm pasting the code below:
`public class WeekViewEvent {
private long mId;
private Calendar mStartTime;
private Calendar mEndTime;
private String mName;
private String mLocation;
private int mColor;
private boolean mAllDay;
private Shader mShader;
private int number;

public WeekViewEvent(){}

public WeekViewEvent(long id, int number, String name, int startYear, int startMonth, int startDay, int startHour, int startMinute, int endYear, int endMonth, int endDay, int endHour, int endMinute) {
    this.mId = id;
    this.number=number;
    this.mStartTime = Calendar.getInstance();
    this.mStartTime.set(Calendar.YEAR, startYear);
    this.mStartTime.set(Calendar.MONTH, startMonth-1);
    this.mStartTime.set(Calendar.DAY_OF_MONTH, startDay);
    this.mStartTime.set(Calendar.HOUR_OF_DAY, startHour);
    this.mStartTime.set(Calendar.MINUTE, startMinute);
    this.mEndTime = Calendar.getInstance();
    this.mEndTime.set(Calendar.YEAR, endYear);
    this.mEndTime.set(Calendar.MONTH, endMonth-1);
    this.mEndTime.set(Calendar.DAY_OF_MONTH, endDay);
    this.mEndTime.set(Calendar.HOUR_OF_DAY, endHour);
    this.mEndTime.set(Calendar.MINUTE, endMinute);
    this.mName = name;
    this.number=number;}

public WeekViewEvent(long id, int number, String name, String location, Calendar startTime, Calendar endTime, boolean allDay, Shader shader) {
    this.mId = id;
    this.number=number;
    this.mName = name;
    this.mLocation = location;
    this.mStartTime = startTime;
    this.mEndTime = endTime;
    this.mAllDay = allDay;
    this.mShader = shader;}

public WeekViewEvent(long id, int number,String name, String location, Calendar startTime, Calendar endTime, boolean allDay) {
    this(id, number, name, location, startTime, endTime, allDay, null);}

public WeekViewEvent(long id, int number, String name, String location, Calendar startTime, Calendar endTime) {
    this(id, number, name, location, startTime, endTime, false);}

public WeekViewEvent(long id, int number, String name, Calendar startTime, Calendar endTime) {
    this(id, number, name, null, startTime, endTime);}

... //hidden setters&getters
@OverRide
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

    WeekViewEvent that = (WeekViewEvent) o;

    return mId == that.mId;

}

@Override
public int hashCode() {
    return (int) (mId ^ (mId >>> 32));
}

public List<WeekViewEvent> splitWeekViewEvents(){
    //This function splits the WeekViewEvent in WeekViewEvents by day
    List<WeekViewEvent> events = new ArrayList<WeekViewEvent>();
    // The first millisecond of the next day is still the same day. (no need to split events for this).
    Calendar endTime = (Calendar) this.getEndTime().clone();
    endTime.add(Calendar.MILLISECOND, -1);
    if (!isSameDay(this.getStartTime(), endTime)) {
        endTime = (Calendar) this.getStartTime().clone();
        endTime.set(Calendar.HOUR_OF_DAY, 23);
        endTime.set(Calendar.MINUTE, 59);
        WeekViewEvent event1 = new WeekViewEvent(this.getId(), this.getNumber(), this.getName(), this.getLocation(), this.getStartTime(), endTime, this.isAllDay());
        event1.setColor(this.getColor());
        events.add(event1);

        // Add other days.
        Calendar otherDay = (Calendar) this.getStartTime().clone();
        otherDay.add(Calendar.DATE, 1);
        while (!isSameDay(otherDay, this.getEndTime())) {
            Calendar overDay = (Calendar) otherDay.clone();
            overDay.set(Calendar.HOUR_OF_DAY, 0);
            overDay.set(Calendar.MINUTE, 0);
            Calendar endOfOverDay = (Calendar) overDay.clone();
            endOfOverDay.set(Calendar.HOUR_OF_DAY, 23);
            endOfOverDay.set(Calendar.MINUTE, 59);
            WeekViewEvent eventMore = new WeekViewEvent(this.getId(), this.getNumber(), this.getName(),null, overDay, endOfOverDay, this.isAllDay());
            eventMore.setColor(this.getColor());
            events.add(eventMore);
            // Add next day.
            otherDay.add(Calendar.DATE, 1);}

        // Add last day.
        Calendar startTime = (Calendar) this.getEndTime().clone();
        startTime.set(Calendar.HOUR_OF_DAY, 0);
        startTime.set(Calendar.MINUTE, 0);
        WeekViewEvent event2 = new WeekViewEvent(this.getId(), this.getNumber(), this.getName(), this.getLocation(), startTime, this.getEndTime(), this.isAllDay());
        event2.setColor(this.getColor());
        events.add(event2);
    } else{events.add(this);
    }return events;}}

By the way - splitWeekViewEvents() has also been modified by adding this.getNumber() method.

Any help much appreciated! :)

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@empeusz Are you sure that you are referencing to the class with the changes ? Don't see anything wrong a first sight, except that you set number twice in you first constructor (which wouldn't break anything)

from android-week-view.

empeusz avatar empeusz commented on July 29, 2024

@jhoobergs to tell the truth I'm not really sure what you mean by referencing to the calss with the changes (still a beginner in Android/Java). The only way I create event object is by programatically using WeekViewEvent ( WeekViewEvent event = new WeekViewEvent() ) and then set all necessary fields (event.setName (); event.setId() ) and so on. I've just found out, that when I'm trying to create new event inside WeekViewEvent.class new construcotr is shown and I can use setter&getter for in number. But when I'm trying to create event object in MainActivity.clas - the constructor "disappears" and there's nothing I can do.

Jesse, would you be so kind as to take a look at attached .png file ? I've captured constructor hints.
Thank you in advance! :)

constructor

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

I think that you have 2 conflicting WeekViewEvent.java classes. So to one you are changing isn't the one you are using.

from android-week-view.

empeusz avatar empeusz commented on July 29, 2024

@jhoobergs thank you for your reply! Unfortunately there's only one WeekViewEvent.java class, so I'll check whole code class by class today.
By the way do you have any tutorials or general hints/tips what I should do to save&load events using Room Persistence Library? :)

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@empeusz Did you clone this repo and made your changes or how did you do it ? Make sure you are not using both a local version and the version from gradle (in your build.gradle)
I have no experience with room persistency library πŸ˜„

from android-week-view.

empeusz avatar empeusz commented on July 29, 2024

Ohhh right - I've made a clone (downloaded and imported to the project as I needed to access the library) as well as adding compile 'com.github.quivr:android-week-view:2.2.1' to my gradle file :) @jhoobergs my last question - what's the best way to get rid of this problem? Should I update my gradle file and remove 'compile....' line? I want to keep the library and work with it locally :)

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@empeusz You can't use both at the same time. The best thing would be that you don't use your local version. So use the gradle version and then create your own class CustomWeekViewEvent that extends the WeekViewEvent class (public class CustomWeekViewEvent extends WeekViewEvent) and add the extra parameters there and override the necessairy constructors and methods. After that, you can always use objects of class CustomWeekViewEvent.

from android-week-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.