Android-Week-View
Android-Week-View copied to clipboard
OnemptyeventClick need different color
HI, I need to show a different color on onEmptyEventClickLister of an empty event.
Do not get what you want to do... Can you describe it more precisely ?
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.
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?
yes. I am planning to do that.
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.
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.
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)?
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;
}