Skip to content

Commit

Permalink
add some setters and getters
Browse files Browse the repository at this point in the history
Fixes Quivr#43
  • Loading branch information
jhoobergs committed Sep 9, 2017
1 parent 0dea50e commit d12f518
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.1.0
VERSION_NAME=2.1.1
GROUP=com.github.quivr

POM_DESCRIPTION=An android library to show day view, week view, 3 day view etc. in your app.
Expand Down
121 changes: 112 additions & 9 deletions library/src/main/java/com/alamkanak/weekview/WeekView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2070,23 +2070,66 @@ public void setAutoLimitTime(boolean isAuto){
invalidate();
}

private void recalculateHourHeight(){
int height = (int) ((getHeight() - (mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight/2 + mHeaderMarginBottom)) / (this.mMaxTime - this.mMinTime));
if(height > mHourHeight){
if(height > mMaxHourHeight)
mMaxHourHeight = height;
mNewHourHeight = height;
}
}

/**
* set fix visible time.
* Set visible time span.
* @param startHour limit time display on top (between 0~24)
* @param endHour limit time display at bottom (between 0~24 and > startHour)
* @param endHour limit time display at bottom (between 0~24 and larger than startHour)
* */
public void setLimitTime(int startHour, int endHour){
if(endHour <= startHour || startHour < 0 || endHour > 24){
throw new IllegalArgumentException("endHour must larger startHour");
if(endHour <= startHour){
throw new IllegalArgumentException("endHour must larger startHour.");
}
else if(startHour < 0){
throw new IllegalArgumentException("startHour must be at least 0.");
}
else if(endHour > 24){
throw new IllegalArgumentException("endHour can't be higher than 24.");
}
this.mMinTime = startHour;
this.mMaxTime = endHour;
int height = (int) ((getHeight() - (mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight/2 + mHeaderMarginBottom)) / (this.mMaxTime - this.mMinTime));
if(height > mHourHeight){
if(height > mMaxHourHeight)
mMaxHourHeight = height;
mNewHourHeight = height;
recalculateHourHeight();
invalidate();
}

/**
* Set minimal shown time
*
* @param startHour limit time display on top (between 0~24) and smaller than endHour
* */
public void setMinTime(int startHour){
if(mMaxTime <= startHour){
throw new IllegalArgumentException("startHour must smaller than endHour");
}
else if(startHour < 0){
throw new IllegalArgumentException("startHour must be at least 0.");
}
this.mMinTime = startHour;
recalculateHourHeight();
}

/**
* Set highest shown time
*
* @param endHour limit time display at bottom (between 0~24 and larger than startHour)
* */
public void setMaxTime(int endHour){
if(endHour <= mMinTime){
throw new IllegalArgumentException("endHour must larger startHour.");
}
else if(endHour > 24){
throw new IllegalArgumentException("endHour can't be higher than 24.");
}
this.mMaxTime = endHour;
recalculateHourHeight();
invalidate();
}

Expand Down Expand Up @@ -2274,6 +2317,66 @@ public void setScrollDuration(int scrollDuration) {
mScrollDuration = scrollDuration;
}

public int getMaxHourHeight() {
return mMaxHourHeight;
}

public void setMaxHourHeight(int maxHourHeight) {
mMaxHourHeight = maxHourHeight;
}

public int getMinHourHeight() {
return mMinHourHeight;
}

public void setMinHourHeight(int minHourHeight) {
this.mMinHourHeight = minHourHeight;
}

public int getPastBackgroundColor() {
return mPastBackgroundColor;
}

public void setPastBackgroundColor(int pastBackgroundColor) {
this.mPastBackgroundColor = pastBackgroundColor;
mPastBackgroundPaint.setColor(mPastBackgroundColor);
}

public int getFutureBackgroundColor() {
return mFutureBackgroundColor;
}

public void setFutureBackgroundColor(int futureBackgroundColor) {
this.mFutureBackgroundColor = futureBackgroundColor;
mFutureBackgroundPaint.setColor(mFutureBackgroundColor);
}

public int getPastWeekendBackgroundColor() {
return mPastWeekendBackgroundColor;
}

public void setPastWeekendBackgroundColor(int pastWeekendBackgroundColor) {
this.mPastWeekendBackgroundColor = pastWeekendBackgroundColor;
this.mPastWeekendBackgroundPaint.setColor(mPastWeekendBackgroundColor);
}

public int getFutureWeekendBackgroundColor() {
return mFutureWeekendBackgroundColor;
}

public void setFutureWeekendBackgroundColor(int futureWeekendBackgroundColor) {
this.mFutureWeekendBackgroundColor = futureWeekendBackgroundColor;
this.mFutureWeekendBackgroundPaint.setColor(mFutureWeekendBackgroundColor);
}

public Drawable getNewEventIconDrawable() {
return mNewEventIconDrawable;
}

public void setNewEventIconDrawable(Drawable newEventIconDrawable) {
this.mNewEventIconDrawable = newEventIconDrawable;
}

/////////////////////////////////////////////////////////////////
//
// Functions related to scrolling.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.alamkanak.weekview.sample;

import android.graphics.Color;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Bundle;
Expand Down Expand Up @@ -79,12 +80,25 @@ protected void onCreate(Bundle savedInstanceState) {
//mWeekView.setAutoLimitTime(true);
//mWeekView.setLimitTime(4, 16);

//mWeekView.setMinTime(10);
//mWeekView.setMaxTime(20);

// Set up a date time interpreter to interpret how the date and time will be formatted in
// the week view. This is optional.
setupDateTimeInterpreter(false);
}

@Override
protected void onResume() {
super.onResume();
/*mWeekView.setShowDistinctPastFutureColor(true);
mWeekView.setShowDistinctWeekendColor(true);
mWeekView.setFutureBackgroundColor(Color.rgb(24,85,96));
mWeekView.setFutureWeekendBackgroundColor(Color.rgb(255,0,0));
mWeekView.setPastBackgroundColor(Color.rgb(85,189,200));
mWeekView.setPastWeekendBackgroundColor(Color.argb(50, 0,255,0));
*/
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down

0 comments on commit d12f518

Please sign in to comment.