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

OnemptyeventClick need different color

Open subbuboyapati opened this issue 9 years ago • 8 comments

HI, I need to show a different color on onEmptyEventClickLister of an empty event.

subbuboyapati avatar May 22 '15 05:05 subbuboyapati

Do not get what you want to do... Can you describe it more precisely ?

lolobosse avatar May 30 '15 14:05 lolobosse

Currently on clicking on empty event area, just returning the time of the particular clicked area. I need to fill the clicked region with different colour.

subbuboyapati avatar May 30 '15 14:05 subbuboyapati

Ok, I understand more or less, yet. But how big is this clicked region supposed to be? You want to do something like Google Calendar (Web Version) when you click it automatically creates a one hour long appmt?

lolobosse avatar May 30 '15 15:05 lolobosse

yes. I am planning to do that.

subbuboyapati avatar May 30 '15 15:05 subbuboyapati

What I would do for that is creating a method which draws a rectangle of your favorite color directly in the lib and change a bit the setEmptyViewClickListener() method by creating another EmptyViewClickListener which calls your draw method first and then the original onEmptyViewClicked(Calendar time). I think it works and allows not to change to much code of the lib. I don't think we're able to do it out of the box.

lolobosse avatar May 30 '15 15:05 lolobosse

I could able to do that initially. But where i am getting problem is when i scroll from top to bottom at the time facing an issue. could you please provide the scrolling with the fixed size like the dates. Sorry for my bad english.

subbuboyapati avatar May 30 '15 15:05 subbuboyapati

Is there Any progress on this issue? i did override onEmptyViewClicked(Calendar time) of library but by calling super.getView().setBackgroundDrawable(Drawable d); it changes the back ground of whole View instead of only empty View. how to Change the Color of empty View when clicked (Or HighLight it)?

dhavalocked avatar Feb 06 '16 05:02 dhavalocked

For anyone who is still looking, I found an easy way to do this without changing the source and avoiding rendering problems.

1: create a “temporary” event when the first click on an empty cell is performed

WeekViewEvent proxyEvent;   //My Temp event

@Override
public void onEmptyViewClicked(Calendar time) {

//This checks to see if there is already a temp event and if so removes it because we clicked somewhere else
    if (proxyEvent!=null) {
        events.remove(findProxy("proxy"));
        proxyEvent = null;
    }

//This sets the temp Event to the beginning of the hour which was chosen
    time.set(Calendar.MINUTE,0);
    time.set(Calendar.SECOND,0);

    Calendar endTime = (Calendar) time.clone();
    endTime.add(Calendar.HOUR_OF_DAY, 1);

//Adds the details to the temp event
    WeekViewEvent proxy = new WeekViewEvent("proxy", "Add New Event?", time, endTime);
    proxy.setColor(getResources().getColor(R.color.material_blue_300));
    proxyEvent = proxy;
    events.add(proxyEvent);
    mWeekView.notifyDatasetChanged();


}

2: then in On event click, see if the temp event was clicked, if it was - use it, if not - remove it

@Override
public void onEventClick(WeekViewEventTwo event, RectF eventRect) {
    Toast.makeText(getContext(), "Clicked " + event.getName(), Toast.LENGTH_SHORT).show();


    if(proxyEvent!=null && event==proxyEvent){

	//If the clicked event was the temp event edit and create the new event here

        
    }
    else{
	//If the clicked event was not the temp event, remove the temp event and use the event clicked

        if (proxyEvent!=null) {
            events.remove(findProxy("proxy"));
            proxyEvent = null;
            mWeekView.notifyDatasetChanged();
        }

        //Edit the clicked event


    }
}

3:This method is to find the temp event in the list of events

WeekViewEvent findProxy(String id) {
    for(WeekViewEvent event : events) {
        if(event.getId().equals(id)) {
            return event;
        }
    }
    return null;
}

JojoGogo9 avatar Jul 31 '18 14:07 JojoGogo9