-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shanhong cheng
committed
Mar 24, 2017
1 parent
37877b8
commit 3ed8cf0
Showing
11 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/loganfreeman/utahfishing/common/decorators/EventDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.loganfreeman.utahfishing.common.decorators; | ||
|
||
import android.content.Context; | ||
import android.graphics.drawable.Drawable; | ||
|
||
import com.loganfreeman.utahfishing.R; | ||
import com.loganfreeman.utahfishing.common.PLog; | ||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
import com.prolificinteractive.materialcalendarview.DayViewDecorator; | ||
import com.prolificinteractive.materialcalendarview.DayViewFacade; | ||
import com.prolificinteractive.materialcalendarview.spans.DotSpan; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
|
||
/** | ||
* Created by scheng on 3/23/17. | ||
*/ | ||
|
||
public class EventDecorator implements DayViewDecorator { | ||
|
||
private HashSet<CalendarDay> dates; | ||
private final Drawable drawable; | ||
|
||
public EventDecorator(Context context, Collection<CalendarDay> dates) { | ||
this.dates = new HashSet<>(dates); | ||
|
||
drawable = context.getResources().getDrawable(R.drawable.my_selector); | ||
} | ||
|
||
@Override | ||
public boolean shouldDecorate(CalendarDay day) { | ||
return dates.contains(day); | ||
} | ||
|
||
@Override | ||
public void decorate(DayViewFacade view) { | ||
view.setBackgroundDrawable(drawable); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../main/java/com/loganfreeman/utahfishing/common/decorators/HighlightWeekendsDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.loganfreeman.utahfishing.common.decorators; | ||
|
||
import android.graphics.Color; | ||
import android.graphics.drawable.ColorDrawable; | ||
import android.graphics.drawable.Drawable; | ||
|
||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
import com.prolificinteractive.materialcalendarview.DayViewDecorator; | ||
import com.prolificinteractive.materialcalendarview.DayViewFacade; | ||
|
||
import java.util.Calendar; | ||
|
||
/** | ||
* Created by scheng on 3/23/17. | ||
*/ | ||
|
||
public class HighlightWeekendsDecorator implements DayViewDecorator { | ||
|
||
private final Calendar calendar = Calendar.getInstance(); | ||
private final Drawable highlightDrawable; | ||
private static final int color = Color.parseColor("#228BC34A"); | ||
|
||
public HighlightWeekendsDecorator() { | ||
highlightDrawable = new ColorDrawable(color); | ||
} | ||
|
||
@Override | ||
public boolean shouldDecorate(CalendarDay day) { | ||
day.copyTo(calendar); | ||
int weekDay = calendar.get(Calendar.DAY_OF_WEEK); | ||
return weekDay == Calendar.SATURDAY || weekDay == Calendar.SUNDAY; | ||
} | ||
|
||
@Override | ||
public void decorate(DayViewFacade view) { | ||
view.setBackgroundDrawable(highlightDrawable); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/loganfreeman/utahfishing/common/decorators/MySelectorDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.loganfreeman.utahfishing.common.decorators; | ||
|
||
import android.app.Activity; | ||
import android.graphics.drawable.Drawable; | ||
|
||
import com.loganfreeman.utahfishing.R; | ||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
import com.prolificinteractive.materialcalendarview.DayViewDecorator; | ||
import com.prolificinteractive.materialcalendarview.DayViewFacade; | ||
|
||
/** | ||
* Created by scheng on 3/23/17. | ||
*/ | ||
|
||
public class MySelectorDecorator implements DayViewDecorator { | ||
|
||
private final Drawable drawable; | ||
|
||
public MySelectorDecorator(Activity context) { | ||
drawable = context.getResources().getDrawable(R.drawable.my_selector); | ||
} | ||
|
||
@Override | ||
public boolean shouldDecorate(CalendarDay day) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void decorate(DayViewFacade view) { | ||
view.setSelectionDrawable(drawable); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/loganfreeman/utahfishing/common/decorators/OneDayDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.loganfreeman.utahfishing.common.decorators; | ||
|
||
import android.graphics.Typeface; | ||
import android.text.style.RelativeSizeSpan; | ||
import android.text.style.StyleSpan; | ||
|
||
import com.prolificinteractive.materialcalendarview.CalendarDay; | ||
import com.prolificinteractive.materialcalendarview.DayViewDecorator; | ||
import com.prolificinteractive.materialcalendarview.DayViewFacade; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Created by scheng on 3/23/17. | ||
*/ | ||
|
||
public class OneDayDecorator implements DayViewDecorator { | ||
|
||
private CalendarDay date; | ||
|
||
public OneDayDecorator() { | ||
date = CalendarDay.today(); | ||
} | ||
|
||
@Override | ||
public boolean shouldDecorate(CalendarDay day) { | ||
return date != null && day.equals(date); | ||
} | ||
|
||
@Override | ||
public void decorate(DayViewFacade view) { | ||
view.addSpan(new StyleSpan(Typeface.BOLD)); | ||
view.addSpan(new RelativeSizeSpan(1.4f)); | ||
} | ||
|
||
/** | ||
* We're changing the internals, so make sure to call {@linkplain MaterialCalendarView#invalidateDecorators()} | ||
*/ | ||
public void setDate(Date date) { | ||
this.date = CalendarDay.from(date); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:exitFadeDuration="@android:integer/config_shortAnimTime"> | ||
|
||
<item android:state_checked="true" | ||
android:drawable="@drawable/ic_my_selector" /> | ||
|
||
<item android:state_pressed="true" | ||
android:drawable="@drawable/ic_my_selector" /> | ||
|
||
<item android:drawable="@android:color/transparent" /> | ||
|
||
</selector> |