Giter Club home page Giter Club logo

calendar-day-view's Introduction

Calendar-Day-View

Calendar Day View

install:

via Jcenter

compile 'com.framgia.library.calendardayview:library:1.0.4'

or via JitPack (to get current code)

project/build.gradle

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

module/build.gradle

compile 'com.github.khacpv:Calendar-Day-View:master-SNAPSHOT'

How to use:

<!-- If you want the calendar scrollable -->
<ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >
      <com.framgia.library.calendardayview.CalendarDayView
          android:id="@+id/dayView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:eventPaddingLeft="10dp"
          app:dayHeight="@dimen/dayHeight"/>
  </ScrollView>

Create your model Event.java class by implement IEvent & IPopupEvent

Event implements IEvent, IPopupEvent {

    @Override
    public IPopupEvent getPopup() {...}
    
    ...
}

See MainActivity.java to know how to add events into calendar-day-view

{
      int eventColor = getResources().getColor(R.color.eventColor4);
      Calendar timeStart = Calendar.getInstance();
      timeStart.set(Calendar.HOUR_OF_DAY,16);
      timeStart.set(Calendar.MINUTE,15);
      Calendar timeEnd = (Calendar) timeStart.clone();
      timeEnd.add(Calendar.HOUR_OF_DAY, 1);
      timeEnd.add(Calendar.MINUTE,30);
      Event event = new Event(3, timeStart, timeEnd, "event 6", "house", eventColor);
      event.setBitmap(BitmapFactory.decodeResource(getResources(),R.drawable.avatar));
      event.setTitle("event 2 this is test");
      event.setDescription("Yuong alsdf");
      event.setQuote("Google map");
      events.add(event);
  }

  CalendarDayView.setEvents(events);

Contribution

If you've found an error, please file an issue.

Patches and new samples are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

calendar-day-view's People

Contributors

khacpv avatar mdb694 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

calendar-day-view's Issues

License?

I've looked through your project but I can't seem to find any documentation on it's licensing. Would love to verify if it had an MIT or Apache 2.0 license so that I could know whether or not I could use this project. Great project btw!

Event color doesn't change

Hello, i'm adding three events to the dayView, giving them different colors, but it shows the same color for all the events.
I'm doing like this:

events.add(createEvent(1, entranceTime, jobTime1, R.color.entranceOrExitColor, "Entrata"));
events.add(createEvent(2, jobTime1, jobTime2, R.color.jobColor, "Al lavoro"));
events.add(createEvent(3, jobTime2, exitTime, R.color.entranceOrExitColor, "Uscita"));
dayView.setEvents(events);

private MyEvent createEvent(long id,Date timbTime1, Date timbTime2, int color, String eventType){
Calendar timeStart = Calendar.getInstance();
timeStart.set(Calendar.HOUR_OF_DAY, parseInt((DateFormat.format("HH", timbTime1).toString())));
timeStart.set(Calendar.MINUTE, parseInt((DateFormat.format("mm", timbTime1).toString())));
Calendar timeEnd = Calendar.getInstance();
timeEnd.set(Calendar.HOUR_OF_DAY, parseInt((DateFormat.format("HH", timbTime2).toString())));
timeEnd.set(Calendar.MINUTE, parseInt((DateFormat.format("mm", timbTime2).toString())));
return new MyEvent(id, timeStart, timeEnd, eventType, color);
}

Event color change

Hello!
It seems I am unable the set a color of the event to be created. I also need to change the color after an action has been performed on an event(on click). How do I achieve this? Thank you!
I even tried your example, I logged the values parsed to the Event constructor and it prints the int representation (example: -49023 ), but I can't get to sort it out.

Global OnClickListener

How do I apply a single OnClickListener to all events without having to loop into all of them?

Thanks!

onEventClick and onEventViewClick not fired

Hello !
I'm trying to use your component in a Kotlin project but I cannot have these events fired when I click anywhere in the visible control...
Here is the Kotlin code :

package com.reuniware.beautylogic

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.framgia.library.calendardayview.EventView
import com.framgia.library.calendardayview.EventView.OnEventClickListener
import com.framgia.library.calendardayview.data.IEvent
import com.framgia.library.calendardayview.decoration.CdvDecorationDefault
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {

    val events = ArrayList<IEvent>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        (dayView.decoration as CdvDecorationDefault).setOnEventClickListener(
            object : OnEventClickListener {
                override fun onEventClick(view: EventView, data: IEvent) {
                    Log.e("TAG", "onEventClick:" + data.name)
                }

                override fun onEventViewClick(
                    view: View,
                    eventView: EventView,
                    data: IEvent
                ) {
                    Log.e("TAG", "onEventViewClick:" + data.name)
                    if (data is IEvent) { // change event (ex: set event color)
                        dayView.setEvents(events)
                    }
                }
            })

        dayView.setEvents(events)
    }
}

And here is the code of the XML layout file :

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="24dp"
        android:layout_marginBottom="24dp"
        android:layout_marginStart="24dp"
        android:layout_marginEnd="24dp">
        <com.framgia.library.calendardayview.CalendarDayView
            android:id="@+id/dayView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

Thanks in advance !

Japanese text on event

I tried using this library and added a simple event just like the example, but it has some sort of foreign text next to it. I would like to remove this text but I don't know how.
Added screenshot:
screenshot from 2017-06-03 20-26-10

Rendering wrong intervals

Hello! I'm encountering a problem, the library does not render the correct intervals of time marked by events.

Start time console Log:
D/Event: startTime = java.util.GregorianCalendar[time=?,areFieldsSet=false,lenient=true,zone=Europe/Athens,firstDayOfWeek=2,minimalDaysInFirstWeek=1,ERA=1,YEAR=2017,MONTH=9,WEEK_OF_YEAR=41,WEEK_OF_MONTH=2,DAY_OF_MONTH=2,DAY_OF_YEAR=275,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=2,HOUR_OF_DAY=8,MINUTE=30,SECOND=41,MILLISECOND=763,ZONE_OFFSET=7200000,DST_OFFSET=3600000]

@khacpv
End time console Log:
D/Event: java.util.GregorianCalendar[time=?,areFieldsSet=false,lenient=true,zone=Europe/Athens,firstDayOfWeek=2,minimalDaysInFirstWeek=1,ERA=1,YEAR=2017,MONTH=9,WEEK_OF_YEAR=41,WEEK_OF_MONTH=2,DAY_OF_MONTH=2,DAY_OF_YEAR=275,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=2,HOUR_OF_DAY=9,MINUTE=30,SECOND=41,MILLISECOND=763,ZONE_OFFSET=7200000,DST_OFFSET=3600000]

And during runtime, the app shows this:
device-2017-10-02-142305

(Usually using a CustomDecorator, but for relevance I included the default one).

Overlapping events

Two-event overlap solution?

e.g.

            int eventColor = ContextCompat.getColor(this, R.color.eventColor);
            Calendar timeStart = Calendar.getInstance();
            timeStart.set(Calendar.HOUR_OF_DAY, 11);
            timeStart.set(Calendar.MINUTE, 0);
            Calendar timeEnd = (Calendar) timeStart.clone();
            timeEnd.set(Calendar.HOUR_OF_DAY, 15);
            timeEnd.set(Calendar.MINUTE, 30);
            Event event = new Event(1, timeStart, timeEnd, "11", "11", eventColor);

            events.add(event);
        
        
            int eventColor = ContextCompat.getColor(this, R.color.eventColor);
            Calendar timeStart = Calendar.getInstance();
            timeStart.set(Calendar.HOUR_OF_DAY, 11);
            timeStart.set(Calendar.MINUTE, 0);
            Calendar timeEnd = (Calendar) timeStart.clone();
            timeEnd.set(Calendar.HOUR_OF_DAY, 15);
            timeEnd.set(Calendar.MINUTE, 30);
            Event event = new Event(1, timeStart, timeEnd, "22", "22", eventColor);

            events.add(event);
        

CalendarDayView Customization

Hello!
I am trying to change some colours in your app so it matches the design I want to achieve.
fabiz-orar-v2

I have found no information about this in the documentation, where should I begin editing?
PS: To remove the line I tried to paint it white with app:lineColor="@android:color/white" but it fails to change any colour.
I am willing to fork and edit if needed, if you put me on the right track! Thank you!

Null Pointer Error

Hi there, I'm trying to implement this library in my code, however, whenever I do so, my code crashes telling me that I'm pointing to a null object. Mainly, the day view object is inside a fragment. How can I successfully implement this and add events in a fragment?

Cusotm Events

I've created a new public class (CalendarEvent) that implements IEvent, but am unable to call

List<CalendarEvent> events = new ArrayList<>();
dayView.setEvents(events);

it doesn't recognize my list as an appoicable argument.

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.