GithubHelp home page GithubHelp logo

caldroid's Introduction

Caldroid

Caldroid is a fragment that display calendar with dates in a month. Caldroid can be used as embedded fragment, or as dialog fragment. User can also swipe left/right to navigate to different months.

It's very easy to customize look and feel of Caldroid using your own theme, thanks to @crocodile2u contribution. There are two default themes in Caldroid (Light and Dark). You can provide your own theme based on these default themes as well.

Caldroid is fully localized. You can customize start day of the week for different countries. By default calendar start on Sunday.

Caldroid can be used with Android 2.2 and above. It is extracted from official Roomorama application

If you found bugs specific to Caldroid, please open a new issue on Github. However for general Android questions (about layout, drawable, etc), you probably can find more information on StackOverflow.

Setup

For Android Studio user: add compile 'com.roomorama:caldroid:3.0.1' to your gradle build file.

For Maven user:

<dependency>
    <groupId>com.roomorama</groupId>
    <artifactId>caldroid</artifactId>
    <version>3.0.1</version>
</dependency>

For Eclipse/ADT user: please see tag eclipse_project, download the source codes, check out the CaldroidSample to see how the library works. However you are strongly recommended to use Maven or gradle, because this tag is no longer supported.

To use in your project, reference the child library project as a library. If you see JAR mismatched error, replace your android-support-v4.jar to the jar inside Caldroid. Make sure you compile the project against Android 4.2 and above to allow nested fragment. See more at http://developer.android.com/about/versions/android-4.2.html#NestedFragments

Features

##Flexible setup: can be embedded or shown as dialog If you support Android 2.2 and above, you can embed caldroid fragment in your activity with below code:

CaldroidFragment caldroidFragment = new CaldroidFragment();
Bundle args = new Bundle();
Calendar cal = Calendar.getInstance();
args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
caldroidFragment.setArguments(args);

FragmentTransaction t = getSupportFragmentManager().beginTransaction();
t.replace(R.id.calendar1, caldroidFragment);
t.commit();

If your app only target minSdkVersion 16 and above, you can use Caldroid too. First, you need to change your Activity class to FragmentActivity, and add support library to your project. You don't have to change how you use android.app.Fragment.

CaldroidFragment caldroidFragment = new CaldroidFragment();
Bundle args = new Bundle();
Calendar cal = Calendar.getInstance();
args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
caldroidFragment.setArguments(args);

android.support.v4.app.FragmentTransaction t = getSupportFragmentManager().beginTransaction();
t.replace(R.id.cal, caldroidFragment);
t.commit();

You can also embed caldroid fragment as a child in your fragment.

Caldroid accepts numerous arguments during start up:

public final static String
            DIALOG_TITLE = "dialogTitle",
            MONTH = "month",
            YEAR = "year",
            SHOW_NAVIGATION_ARROWS = "showNavigationArrows",
            DISABLE_DATES = "disableDates",
            SELECTED_DATES = "selectedDates",
            MIN_DATE = "minDate",
            MAX_DATE = "maxDate",
            ENABLE_SWIPE = "enableSwipe",
            START_DAY_OF_WEEK = "startDayOfWeek",
            SIX_WEEKS_IN_CALENDAR = "sixWeeksInCalendar",
            ENABLE_CLICK_ON_DISABLED_DATES = "enableClickOnDisabledDates",
            SQUARE_TEXT_VIEW_CELL = "squareTextViewCell",
            THEME_RESOURCE = "themeResource";

To customize the startDayOfWeek, just use

Bundle args = new Bundle();
args.putInt(CaldroidFragment.START_DAY_OF_WEEK, CaldroidFragment.TUESDAY); // Tuesday
caldroidFragment.setArguments(args);

If you want to know when user clicks on disabled dates:

Bundle args = new Bundle();
args.putBoolean(CaldroidFragment.ENABLE_CLICK_ON_DISABLED_DATES, true);
caldroidFragment.setArguments(args);

By default, Caldroid use square TextView to display date. However when the screen has limited space, user can switch to normal TextView instead:

Bundle args = new Bundle();
args.putBoolean(CaldroidFragment.SQUARE_TEXT_VIEW_CELL, false);
caldroidFragment.setArguments(args);

Caldroid uses SQUARE_TEXT_VIEW_CELL parameter internally as well. When the phone is in portrait mode, it will default SQUARE_TEXT_VIEW_CELL to true, and on landscape, SQUARE_TEXT_VIEW_CELL is set to false. If your app provides different value, Caldroid will use your value instead of the default one.

To show the caldroid fragment as a dialog, you might want to set the dialog title. There is a convenient method for that:

CaldroidFragment dialogCaldroidFragment = CaldroidFragment.newInstance("Select a date", 3, 2013);
dialogCaldroidFragment.show(getSupportFragmentManager(),"TAG");

Custom theme

You can define your own theme to change the look and feel of Caldroid without having to subclass it. You should inherit from base theme CaldroidDefault. Here's how to create a dark theme:

    <!-- Dark theme. -->
    <style name="CaldroidDefaultDark" parent="CaldroidDefault">
        <item name="styleCaldroidViewLayout">@style/CaldroidDefaultDarkCalendarViewLayout</item>
        <item name="styleCaldroidMonthName">@style/CaldroidDefaultDarkMonthName</item>
        <item name="styleCaldroidNormalCell">@style/CaldroidDefaultDarkNormalCell</item>
        <item name="styleCaldroidSquareCell">@style/CaldroidDefaultDarkSquareCell</item>
        <item name="styleCaldroidGridView">@style/CaldroidDefaultDarkGridView</item>
    </style>

    <style name="CaldroidDefaultDarkCalendarViewLayout">
        <item name="android:background">@android:color/black</item>
    </style>

    <style name="CaldroidDefaultDarkMonthName" parent="CaldroidDefaultMonthName">
        <item name="android:textColor">@color/caldroid_white</item>
    </style>

    <style name="CaldroidDefaultDarkGridView" parent="CaldroidDefaultGridView">
        <item name="android:background">@color/caldroid_middle_gray</item>
    </style>

    <style name="CaldroidDefaultDarkCell" parent="CaldroidDefaultCell">
        <item name="android:textColor">@color/cell_text_color_dark</item>
        <item name="android:background">@drawable/cell_bg_dark</item>
    </style>

    <style name="CaldroidDefaultDarkNormalCell" parent="CaldroidDefaultDarkCell">
        <item name="android:padding">5dp</item>
    </style>

    <style name="CaldroidDefaultDarkSquareCell" parent="CaldroidDefaultDarkCell" />

After creating your own theme, supply it to your Caldroid fragment:

Bundle args = new Bundle();
args.putInt(CaldroidFragment.THEME_RESOURCE, com.caldroid.R.style.CaldroidDefaultDark);
caldroidFragment.setArguments(args);

Custom backgrounds and text colors for different dates

It is very easy to supply different backgrounds and text colors for different dates:

// You can use any of below methods to set background colors
public void setBackgroundDrawableForDates(HashMap<Date, Drawable> backgroundForDateMap);
public void setBackgroundDrawableForDateTimes(HashMap<DateTime, Drawable> backgroundForDateTimeMap);
public void setBackgroundDrawableForDate(Drawable drawable, Date date);
public void setBackgroundDrawableForDateTime(Drawable drawable, DateTime dateTime);

// Below methods is to set text color
public void setTextColorForDates(HashMap<Date, Integer> textColorForDateMap);
public void setTextColorForDateTimes(HashMap<DateTime, Integer> textColorForDateTimeMap);
public void setTextColorForDate(int textColorRes, Date date);
public void setTextColorForDateTime(int textColorRes, DateTime dateTime);

To use these methods, you can define your colors in color.xml and background in drawable folder:

ColorDrawable blue = new ColorDrawable(getResources().getColor(R.color.blue));
ColorDrawable green = new ColorDrawable(Color.GREEN);
caldroidFragment.setBackgroundDrawableForDate(blue, blueDate);
caldroidFragment.setBackgroundDrawableForDate(green, greenDate);

caldroidFragment.setTextColorForDate(R.color.white, blueDate);
caldroidFragment.setTextColorForDate(R.color.white, greenDate);

You need to call refreshView() after above methods to update calendar appearance.

You can also clear the background and text color:

public void clearBackgroundDrawableForDate(Date date);
public void clearBackgroundDrawableForDates(List<Date> dates);
public void clearTextColorForDates(List<Date> dates);
public void clearTextColorForDate(Date date);

Display user events on Caldroid

Caldroid is simply an UI library and it does not connect to user calendar database or fetch any user's events. If your app wants to display these events on Caldroid:

  • Your app needs to fetch events (from server or from user calendar database, depend on your app)

  • Design a drawable for the date with event. See more here for all types of drawable you can create: http://developer.android.com/guide/topics/resources/drawable-resource.html

  • Use above setBackgroundDrawableForDate method to set the event drawable to correct date

  • Call refreshView() to update calendar appearance

If you need to customize more for the cell, you can supply your own cell design.

Set min / max date

Client can use below methods:

public void setMinDate(Date minDate);
public void setMinDateFromString(String minDateString, String dateFormat);

public void setMaxDate(Date minDate);
public void setMaxDateFromString(String maxDateString, String dateFormat);

To refresh the calendar, just call refreshView()

Set disabled dates

Client can either provide ArrayList or ArrayList to Caldroid.

public void setDisableDates(ArrayList<Date> disableDateList);
public void setDisableDatesFromString(ArrayList<String> disableDateStrings);
public void setDisableDatesFromString(ArrayList<String> disableDateStrings, String dateFormat);

To clear the disabled dates:

public void clearDisableDates();

##Select dates within a range To select dates within a range:

public void setSelectedDates(Date fromDate, Date toDate);
public void setSelectedDateStrings(String fromDateString, String toDateString, String dateFormat);

To clear the selected dates:

public void clearSelectedDates();

##Show / Hide the navigation arrows to move to previous or next month To show/hide the navigation arrows:

public void setShowNavigationArrows(boolean showNavigationArrows);

To enable / disable swipe:

public void setEnableSwipe(boolean enableSwipe);

Client can programmatically move the calendar (with animation) to a specified date:

public void moveToDate(Date date);
public void moveToDateTime(DateTime dateTime);

##Allow user to select a date and inform listener

Caldroid inform clients via CaldroidListener.

final CaldroidListener listener = new CaldroidListener() {

	@Override
	public void onSelectDate(Date date, View view) {
		Toast.makeText(getApplicationContext(), formatter.format(date),
				Toast.LENGTH_SHORT).show();
	}

	@Override
	public void onChangeMonth(int month, int year) {
		String text = "month: " + month + " year: " + year;
		Toast.makeText(getApplicationContext(), text,
				Toast.LENGTH_SHORT).show();
	}

	@Override
	public void onLongClickDate(Date date, View view) {
		Toast.makeText(getApplicationContext(),
				"Long click " + formatter.format(date),
				Toast.LENGTH_SHORT).show();
	}

	@Override
	public void onCaldroidViewCreated() {
		Toast.makeText(getApplicationContext(),
				"Caldroid view is created",
				Toast.LENGTH_SHORT).show();
	}

};

caldroidFragment.setCaldroidListener(listener);

User can also customize the navigation arrows and month title textView: font, size, onClickListener, onLongClickListener, etc. Client can supply different adapter to the weekdayGridView. Make sure you only access these methods after Caldroid has been successfully attached to view, otherwise you will see NullPointerException.

final CaldroidListener listener = new CaldroidListener() {

    @Override
    public void onSelectDate(Date date, View view) {
        // Do something
    }

    @Override
    public void onCaldroidViewCreated() {
        // Supply your own adapter to weekdayGridView (SUN, MON, etc)
        caldroidFragment.getWeekdayGridView().setAdapter(YOUR_ADAPTER);

        Button leftButton = caldroidFragment.getLeftArrowButton();
        Button rightButton = caldroidFragment.getRightArrowButton();
        TextView textView = caldroidFragment.getMonthTitleTextView();

        // Do customization here
    }

};

caldroidFragment.setCaldroidListener(listener);

##Handle screen rotation

To handle rotation properly, Caldroid provides method to get current states of the fragment:

public Bundle getSavedStates();
public void saveStatesToKey(Bundle outState, String key);
public void restoreStatesFromKey(Bundle savedInstanceState, String key);
public void restoreDialogStatesFromKey(FragmentManager manager, Bundle savedInstanceState, String key, String dialogTag)

Using above method, you can save current state of Caldroid on onSaveInstanceState(Bundle outState) method.

On your activity code:

@Override
protected void onSaveInstanceState(Bundle outState) {
	// TODO Auto-generated method stub
	super.onSaveInstanceState(outState);

	if (caldroidFragment != null) {
		caldroidFragment.saveStatesToKey(outState, "CALDROID_SAVED_STATE");
	}

	if (dialogCaldroidFragment != null) {
		dialogCaldroidFragment.saveStatesToKey(outState,
				"DIALOG_CALDROID_SAVED_STATE");
	}
}

Then you can restore the state in onCreate(Bundle savedInstanceState) of your activity. The algorithm is like below:

// If Activity is created after rotation
if (savedInstanceState != null) {
  caldroidFragment.restoreStatesFromKey(savedInstanceState,
					"CALDROID_SAVED_STATE");
}

// If activity is created from fresh
else {
  Bundle args = new Bundle();
	Calendar cal = Calendar.getInstance();
  args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
  args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
  args.putBoolean(CaldroidFragment.ENABLE_SWIPE, true);
  args.putBoolean(CaldroidFragment.SIX_WEEKS_IN_CALENDAR, false);
  caldroidFragment.setArguments(args);
}

If you use Caldroid as dialog, you can use restoreDialogStatesFromKey

final String dialogTag = "CALDROID_DIALOG_FRAGMENT";
if (savedInstanceState != null) {
  dialogCaldroidFragment.restoreDialogStatesFromKey(getSupportFragmentManager(),
      					savedInstanceState, "DIALOG_CALDROID_SAVED_STATE",
      					dialogTag);
	Bundle args = dialogCaldroidFragment.getArguments();
	args.putString("dialogTitle", "Select a date");
} else {
	// Setup arguments
	Bundle bundle = new Bundle();
	// Setup dialogTitle
	bundle.putString(CaldroidFragment.DIALOG_TITLE, "Select a date");
	dialogCaldroidFragment.setArguments(bundle);
}

Refer to the CaldroidSampleActivity for more detail.

##Allow customized cell for the dates gridView

Caldroid provides flexible API to supply your own cell view. What you have to do is:

  1. Create your own cell view layout in your project

  2. Subclass CaldroidGridAdapter and override getView(int position, View convertView, ViewGroup parent). See CaldroidSampleCustomAdapter.java for more detail. Here you can customize everything: layout, text color, background for different states (normal, disable, selected)

  3. Subclass CaldroidFragment to use your custom adapter instead of the default CaldroidGridAdapter. This is simplest step:

public class CaldroidSampleCustomFragment extends CaldroidFragment {

	@Override
	public CaldroidGridAdapter getNewDatesGridAdapter(int month, int year) {
		// TODO Auto-generated method stub
		return new CaldroidSampleCustomAdapter(getActivity(), month, year, getCaldroidData(), extraData);
	}

}
  1. Use your new customized fragment in your project instead of the default CaldroidFragment.

To see how it works, you can uncomment this line in CaldroidSampleActivity

// final CaldroidSampleCustomFragment caldroidFragment = new CaldroidSampleCustomFragment();

The extraData is a HashMap<String, Object>, is designed to let client injects custom data to CaldroidGridAdapter, so that data can be used to customize the date grid view. Usage is simple:

In your client code:

// To set the extraData:
HashMap<String, Object> extraData = caldroidFragment.getExtraData();
extraData.put("YOUR_CUSTOM_DATA_KEY1", yourCustomData1);
extraData.put("YOUR_CUSTOM_DATA_KEY2", yourCustomData2);

// Refresh view
caldroidFragment.refreshView();

In the CaldroidSampleCustomAdapter:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  // Get your data here
  ArrayList yourCustomData1 = (ArrayList) extraData.get("YOUR_CUSTOM_DATA_KEY1");
  String yourCustomData2 = (String) extraData.get("YOUR_CUSTOM_DATA_KEY2");

  // Continue to build your customized view
}

Basic Structure

Caldroid fragment includes 4 main parts:

  1. Month title view: show the month and year (e.g MARCH, 2013)

  2. Navigation arrows: to navigate to next month or previous month

  3. Weekday gridview: contains only 1 row and 7 columns. To display "SUN, MON, TUE, WED, THU, FRI, SAT"

  4. An infinite view pager that allow user to swipe left/right to change month. This library is taken from https://github.com/antonyt/InfiniteViewPager

This infinite view pager recycles 4 fragment, each fragment contains a gridview with 7 columns to display the dates in month. Whenever user swipes different screen, the date grid views are updated.

Others

Caldroid code is simple and clean partly because of powerful date4j library!

License

See LICENSE.md

App uses Caldroid

SilentMe

Work Mate

Attendance Register (students)

eDiary

Moon Calendar

Bitdeli Badge

caldroid's People

Contributors

aint avatar ben-j69 avatar bitdeli-chef avatar cashlo avatar coffeeworks avatar crocodile2u avatar dexion avatar jjobes avatar joshkennedy avatar lasprezz avatar lawabidingninja avatar mikepenz avatar nazneenrupawalla avatar nydevel avatar orcchg avatar serggl avatar sh0m1 avatar slavick avatar swolfand avatar theironmarx avatar thomasdao 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  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  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  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

caldroid's Issues

customize the caldroid calendar height?

I have been using the caldroid in my app, so i need to change the height of calendar. how is it possible? Because i didn't see anywhere the size and other specifies.

Background-color of cell

Hello,

Is it possible to define for each cell (day), a different background color ?

For example, I would like to have the 01/07 green, 02/07 red, 03/07 pink, etc ...

Thank you !

Orientation issue

When i change the orientation from Portrait to landscape and then landscape to portrait,
another calendar view gets added at the bottom of the previous view.

Caldroid fragment not taking whole fragment height

I'm injecting Caldroid fragment into my layout.Here is layout code:

    <LinearLayout
        android:id="@+id/left_page"
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:layout_marginBottom="35dp"
        android:layout_marginLeft="75dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="35dp"
        android:layout_weight="0.5"
        android:orientation="vertical" >
    </LinearLayout>

Calendar is properly stretched in width however takes ony like a half of the fragment height making me scroll.

Personnalize each cell

I'm building a a calendar with 3 kinds of cell, normal cells, cells with price and cells with amount in percentage (see the picture).

I added an ArrayList of my cells, order by date in the Adapter.

It's working fine for the selected month, but when i change the month the method getNewDatesGridAdapter is called and i can't figure how to use my array to build the display.

Do you think there is a better way to do this?
device-2013-04-16-100637

Incorrect Caldroid fragment height in ScrollView

Hi,

Tried to reproduce Roomorama's nice Availability page, with multiple, scrollable Caldroid fragments:
https://www.dropbox.com/s/0kpb8435ffv1psp/Screenshot_2013-08-26-18-17-53.png

If I add multiple Caldroid fragments to a LinearLayout that's fine, no problem at all. BUT if I embed it into a ScrollView, height will be messed, and I'll get this:
https://www.dropbox.com/s/g3ntnkrnr8shbbv/Screenshot_2013-08-26-17-57-54.png

Please let me know if you have any idea, or workaround.

Thank you!

Calendar Moves to Next Month On Rotation

When the calendar is viewed as a dialog, on rotation it moves to the next the month. It seems the DatePageChangeListener refreshAdapters is being called each time it rotates causing it to move to the next month.

HoloEverywhere Conflict

Just a note to anyone that may come across it, if you are using the HoloEverywhere library with this, make sure that the Caldroid library comes before the HoloEverywhere library or else you will get some strange layout errors and crashes. Not sure if it was exclusive to me, but it may be beneficial to other developers who cannot find this issue.

fIimBLK

Swipe to change month

Would it be possible for you to implement swipe left and right to change the month?

Gradient in setBackgroundResourceForDates

Is it possible to add a gradient or several colors for one day? I am using to mark holidays blue but there may be a different color from another brand and overlap.

On the other hand, I am implementing a DrawerLayout and get stuck half second it is barely noticeable but it is annoying, I've tried everything but I can not be fluid.

Landscape mode problem

In CaldroidSample, on changing to landscape mode, the "Customize" and "Show Dialog" button disappear. So I added a scroll view to the whole layout. But after doing so, the calendar grid is no longer visible. Although the calendar arrow and date can be seen, the date grid is vanished. (the buttons are visible). So how to handle the grid when mode is changed to landscape?

Using Caldroid as a photo calendar

Hello,
I'm making photo app, but I'm stuck with a thing that goes like this: when You click on the date I want it to open new activity (or whatever needs to be opened) where You can take a picture of a day and set that picture as a background of that date - just like here: https://play.google.com/store/apps/details?id=pl.pawelbialecki.a365photoapp

Simply put: just want to copy the app above and enhance it with tweaks that I think will be a great feature.

I'm programming Android like for 2 months with no prior experience so please keep it simple :) Thank You in advance for helping out!

Clicking on a Custom Date Grid Cell produces an ANR

I tried the custom cell view for Date Grid. While clicking on the Date cell gives an ANR.
While checking the log there is a problem in casting the type View type to Textview in the onItemClickListener. Please fix it

Today Method

It would be wonderful if there was a method to change the gridview and date to the current day. I'm having a hard time implementing this with the new InfinePager.

First day of week

To select the first day of week can be useful, depends on the country

[HELP] Change background for certain dates .

Hi, I'm trying to highlight certain dates in Caldroid and i'm using a HashMap and A custom Function for parsing a String into a Date variable .. But, it is not working .. What have i done wrong here ?

        // CUSTOM FUNCTION FOR PARSING STRING TO DATA
    public Date ParseDate(String date_str)
    {
        SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
        Date dateStr = null;
        try {
            dateStr = formatter.parse(date_str);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return dateStr;     
    }

        // SETTING THE BACKGROUND
    // Create a hash map
    HashMap hm = new HashMap();
    // Put elements to the map
        hm.put(ParseDate("Jun 14 2013"), R.color.blue);
        hm.put(ParseDate("Jun 16 2013"), R.color.green);
        hm.put(ParseDate("Jun 18 2013"), R.color.blue);
        hm.put(ParseDate("Jun 20 2013"), R.color.green);
        hm.put(ParseDate("Jun 22 2013"), R.color.blue);
    if (caldroidFragment != null) {
            caldroidFragment.setBackgroundResourceForDates(hm);
        }

So, what is wrong here ?? Any help would be greatly appreciated ...

Is there possible to quickly switch years inside dialog?

Hello! At first thank you for great work. Now I will describe issue or maybe the feature which seems to be lack in your lib. I would like to see the way of quick switch between years not only months. So the user wont clik 12 times to get the year he expects.

Please guide me about this :)

Changing month when calendar not visible

Hi there. Caldroid is great, will highly recommend it. I have a question. I want to grab 12 images of the calendar, one for each of the last 12 months. This is invisible to the user and the calendar isn't shown while this happens.

My code to generate the image is as follows:

 public ByteArrayOutputStream getImage() {
    myCalendarView.setBackgroundColor(Color.WHITE);
    myCalendarView.layout(0, 0, 700, 700);
    myCalendarView.buildDrawingCache();
    Bitmap b = calendarView.getDrawingCache();

    ByteArrayOutputStream stream = new ByteArrayOutputStream();

    b = Bitmap.createScaledBitmap(b, 400, 400, true);
    b.compress(Bitmap.CompressFormat.JPEG /* FileType */, 100 /* Ratio */,
            stream);

    myCalendarView.setBackgroundColor(Color.TRANSPARENT);
    myCalendarView.destroyDrawingCache();
    return stream;
}

Then I loop through the last 12 months like this

      for (int i = 0; i < months; i++) {
            ByteArrayOutputStream stream = getImage();

            Image graph = Image.getInstance(stream.toByteArray());
            graph.setAbsolutePosition(xRows, (pdfHeight - topOffset - 550)
                    - (i * 500));
            document.add(graph);

            now.addMonths(-1);
            calendarFrag.moveToDateTime(now.toDateTime());

            Thread.sleep(10);
        }

(I know sleeping the main thread is not good, but otherwise the image gets grabbed half way between transitions on the month change on the calendar).

This works fine for the current month and the month before, bet any month before that shows blank. I guess this is to do with the buffered page viewer having one month either side buffered, however I have looked and cannot for the life of me work out what is wrong.

If you have any ideas that would be great.

Thanks!
Simon

blank

Request: Caldroid Fragment performClick,performLongClick

Hi I understand there is a CaldroidListener for program to listen to long tap and single tap. This is good but I am wondering can we have a programmatically feature? That is in Android view we have the performClick() method. This allow us to simulate a click on the view programmatically.

So I am requesting for something similar for Caldroid but maybe to programmatically performClick(Date t) and performLongClick(Date t). Then internally it will trigger the existing CaldroidListener methods.

Thanks.

CaldroidFragment Loses Calendar On Rotation

Currently using the FragmentDialog version of the Calendar and on rotation the calendar view pager disappears on rotation. Has anyone seen this issue and no the solution?

JodaTime

JodaTime is great library, but I'm not sure if I want 0.5 MB library only because of datepicker :-(

Allowing dialog without any title

Thanks for sharing this great piece of work.
I wanted to use the dialog fragment without any title so I modified CaldroidFragment to this:

String dialogTitle = args.getString("dialogTitle");
if (dialogTitle != null) {
    getDialog().setTitle(dialogTitle);
} else {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
}

...which makes sense for me, because if I don't provide a title, I probably won't have an empty title bar displayed.

Refreshing only some particular date cells

When refreshView() is called, caldroid updates the date cells for the previous, current and next month. This takes up around 2 seconds to get the dates and refresh. How about adding an extraData (HashMap) parameter inside refreshView() so that dates of some particular cells can be passed and then caldroid would take much less time to refresh these cells?

Updating data in view through AsyncTask

I am loading the calender firstly, then on call of onMonthChange function, I am fetching data (which is basically a count for each day) through Json in asynctask. Thereafter, I have to update the view with count for each day. To do that I am calling notifydatasetchanged in postExecute of the AsynTask.
However, notifydatasetchanged doesn't update view for all months. The pattern is somethign like this:
For example- if we load any month from January, February, or March, view of February is only updated. Then on opening April, no view is updated. Then on calling May, June, or July only view of June is updated each time. This pattern get repeated.
I need to know if I am wrong in calling notifydatasetchanged...Is there any other function I need to call for this purpose?

Display improvement

Change "LUN. MAR. MER. JEU. VEN. SAM. DIM." color, change arrows and red_border without editing the lib itself.

how to add extra text in Gridview

I want to add numbers at the top left corner of the grid views when events are added for a particular date. How can i achieve this?

Cannot be nested within a fragment

Given I add the CaldroidFragment into an existing fragment, I will receive this error message:

java.lang.IllegalStateException: Can't retain fragements that are nested in other fragments

This is how I set things up:

@EFragment(R.layout.frg_analysis)
public class AnalysisFragment extends SherlockFragment {

    @AfterViews
    protected void setupView() {
        CaldroidFragment caldroidFragment = new CaldroidFragment();
        Bundle args = new Bundle();
        Calendar cal = Calendar.getInstance();
        args.putInt("month", cal.get(Calendar.MONTH) + 1);
        args.putInt("year", cal.get(Calendar.YEAR));
        caldroidFragment.setArguments(args);

        FragmentTransaction t = getChildFragmentManager().beginTransaction();
        t.add(R.id.containerCalendar, caldroidFragment);
        t.commit();
    }
}

Stackoverflow has some hints: http://stackoverflow.com/questions/14850573/cant-retain-nested-fragments .

Full stacktrace:

E/AndroidRuntime( 1763): java.lang.IllegalStateException: Can't retain fragements that are nested in other fragments
E/AndroidRuntime( 1763):    at android.support.v4.app.Fragment.setRetainInstance(Fragment.java:742)
E/AndroidRuntime( 1763):    at com.caldroid.CaldroidFragment.onCreate(CaldroidFragment.java:924)
E/AndroidRuntime( 1763):    at android.support.v4.app.Fragment.performCreate(Fragment.java:1437)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:877)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
E/AndroidRuntime( 1763):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
E/AndroidRuntime( 1763):    at android.support.v4.app.Fragment.performStart(Fragment.java:1481)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:941)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
E/AndroidRuntime( 1763):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
E/AndroidRuntime( 1763):    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
E/AndroidRuntime( 1763):    at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime( 1763):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1763):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1763):    at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 1763):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1763):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1763):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 1763):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 1763):    at dalvik.system.NativeStart.main(Native Method)

Multiple license files

There is a second license file located here.
Caldroid/src/com/antonyt/infiniteviewpager/LICENSE.txt.

implement in fragment

hi! i have a problem with your code... i have a fragment where i want to display your calendar... i tried from your wiki but it doesnt work... can you help me?

Caldroid RefreshView

Hi I am a new user of Caldroid. I don't know if this is a bug but just want to list down something that does not seem to allow refresh.

HashMap<Date, Integer> map = new HashMap<Date,Integer>();
//put in values etc
m_fragCaldroid.setBackgroundResourceForDates(map);
m_fragCaldroid.refreshView();

Upon calling refreshView below error occurs

org.joda.time.IllegalFieldValueException: Value -1 for monthOfYear must be in the range [1,12]

Trace to below code in refreshView method
// Refresh title view
monthTitleTextView.setText(new DateTime(year, month, 1, 0, 0, 0, 0)
.monthOfYear().getAsText().toUpperCase()
+ " " + year);

Basically I am calling setBackgroundResourceForDates for different map so I want to re-use the Caldroid fragment by doing a refresh every time I set a new map. Is this supported or whenever I change the map, I need to instantiate a new Caldroid fragment ?

Setting text on custom grid view, also set text on wrong grids

Hi, I am using CaldroidSampleCustomAdapter to customize cell layout. I am putting some text on few textview on few dates. It sets data fine, but when i scroll the layout it also sets the text on wrong grids which i don't want. Please check attached image to see the duplicate text on wrong grids. Can you please look into this issue? Because i find this tutorial very helpful and useful, so it can help others perfectly.
caldroid

[Help]how to store daily record with SQLite?

Hello.
First, Thank you so much for the great work what I ve been looking for, for many days.
I am a student, and studying android development beginner.
Could I ask how to store daily schedule with SQLite?
I ve tried to make an sqlite db and a column of date to integrate db with each date.

i.e. I want to make an input and saving daily record app, just like "Work Mate" app.

Please give me some hints.

Thank you.

Sincerely S.

Unable to start activity Null Pointer Exception

Hello Sir,

 I Have followed the procedure to setup the application and i successfully seted up. The problem is when i run the application in my log its showing Null Pointer exception. I don't know whats happening. Can you please guide me regarding this issue.

Thanxs

client injects arraylist to CaldroidGridAdapter using extraData

first i inject an arraylist by extraData to CaldroidGridAdapter, and then i get the arraylist in getView function of CaldroidGridAdapter to Iterate through this arraylist, checking whether current date is in the arraylist, but it always causes Null Pointer Exception.am i doing something wrong because i can inject simple string but arraylist seems not work, please help

[GUIDE]Caldroid with ActionbarSherlock

To all those trying to make Caldroid work along with ActionbarSherlock (without any errors).

  • Import ActionbarSherlock Library and Caldroid Library.
  • Then delete the support v4 jar from the libs folder of ActionbarSherlock
  • Add caldroid as a dependency to ActionbarSherlock.
  • Add ActionbarSherlock as a dependency to your app.

Now, everything will work without any errors !

NoClassDefFoundError: com.caldroid.R$layout

I'm attempting to use the Caldroid library, and have added all the source files to my current project. However, upon deployment, I receive a fatal error every time I try to show a calendar (using the CaldroidFragment).

The error is java.lang.NoClassDefFoundError: com.caldroid.R$layout
at com.caldroid.CaldroidFragment.onCreateView(CaldroidFragment.java:683).

Does anyone know of a possible fix? I can provide any other info if needed.

Thanks.

< & > buttons are not responding all the time

The 2 red arrows on top left and right are sometimes not responding well and seem to cancel the touch event.
This happens when pressing these buttons repeatedly & sometimes when just using it for regular switching.

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.