Skip to content

Commit

Permalink
Cleanup code and TodaysTextColor added
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Garcia Alvarado authored and Daniel Garcia Alvarado committed Jan 16, 2017
1 parent 5d3641c commit f067a72
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 58 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

12 changes: 3 additions & 9 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 3 additions & 16 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/encodings.xml → .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath "com.github.dcendents:android-maven-gradle-plugin:1.3"
classpath "com.github.dcendents:android-maven-gradle-plugin:1.4.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Mon Jan 16 16:11:51 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "noman.weekcalendar"
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -22,7 +22,7 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:25.1.0'
//compile 'noman.weekcalendar:weekcalendar:1.0.6'
compile project(':weekcalendar')

Expand Down
9 changes: 5 additions & 4 deletions weekcalendar/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0.1"
}
Expand All @@ -22,7 +23,7 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'joda-time:joda-time:2.9.1'
compile 'com.squareup:otto:1.3.8'
}
Expand Down
16 changes: 11 additions & 5 deletions weekcalendar/src/main/java/noman/weekcalendar/WeekCalendar.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package noman.weekcalendar;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class WeekCalendar extends LinearLayout {
private GridView daysName;
private DayDecorator dayDecorator;
private OnWeekChangeListener onWeekChangeListener;
private TextView monthYearName;


public WeekCalendar(Context context) {
Expand Down Expand Up @@ -74,10 +76,12 @@ private void init(AttributeSet attrs) {
.WeekCalendar_daysTextColor, Color.WHITE);
float daysTextSize = typedArray.getDimension(R.styleable
.WeekCalendar_daysTextSize, -1);

int todayDateTextColor = typedArray.getColor(R.styleable
.WeekCalendar_todaysDateTextColor, ContextCompat.getColor(getContext(), android.R.color.white));
setDayDecorator(new DefaultDayDecorator(getContext(),
selectedDateColor,
todayDateColor,
todayDateTextColor,
daysTextColor,
daysTextSize));
}
Expand Down Expand Up @@ -153,6 +157,7 @@ public long getItemId(int position) {
return 0;
}

@SuppressLint("InflateParams")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
Expand Down Expand Up @@ -212,19 +217,20 @@ public void reset() {
BusProvider.getInstance().post(new Event.ResetEvent());
}

public void setSelectedDate(DateTime selectedDate){
public void setSelectedDate(DateTime selectedDate) {
BusProvider.getInstance().post(new Event.SetSelectedDateEvent(selectedDate));
}
public void setStartDate(DateTime startDate){

public void setStartDate(DateTime startDate) {
BusProvider.getInstance().post(new Event.SetStartDateEvent(startDate));
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
BusProvider.getInstance().register(this);
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package noman.weekcalendar.decorator;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Color;
Expand All @@ -26,17 +27,20 @@ public class DefaultDayDecorator implements DayDecorator {
private Context context;
private final int selectedDateColor;
private final int todayDateColor;
private int todayDateTextColor;
private int textColor;
private float textSize;

public DefaultDayDecorator(Context context,
@ColorInt int selectedDateColor,
@ColorInt int todayDateColor,
@ColorInt int todayDateTextColor,
@ColorInt int textColor,
@DimenRes float textSize) {
float textSize) {
this.context = context;
this.selectedDateColor = selectedDateColor;
this.todayDateColor = todayDateColor;
this.todayDateTextColor = todayDateTextColor;
this.textColor = textColor;
this.textSize = textSize;
}
Expand Down Expand Up @@ -73,9 +77,10 @@ public void decorate(View view, TextView dayTextView,

if (dateTime.toLocalDate().equals(calendarStartDate.toLocalDate())) {
dayTextView.setBackground(solidCircle);
dayTextView.setTextColor(Color.WHITE);
dayTextView.setTextColor(this.todayDateTextColor);
} else {
dayTextView.setTextColor(textColor);
}
dayTextView.setTextColor(textColor);
float size = textSize;
if (size == -1)
size = dayTextView.getTextSize();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package noman.weekcalendar.fragment;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
Expand Down Expand Up @@ -29,13 +30,13 @@
* Created by nor on 12/4/2015.
*/
public class WeekFragment extends Fragment {
private static final String TAG = "WeekFragment";
public static String DATE_KEY = "date_key";
private GridView gridView;
private WeekAdapter weekAdapter;
public static DateTime selectedDateTime = new DateTime();
public static DateTime CalendarStartDate = new DateTime();
private DateTime startDate, endDate, midDate;
private DateTime startDate;
private DateTime endDate;
private boolean isVisible;

@Nullable
Expand All @@ -49,12 +50,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

private void init() {
ArrayList<DateTime> days = new ArrayList<>();
midDate = (DateTime) getArguments().getSerializable(DATE_KEY);
midDate = midDate.withDayOfWeek(DateTimeConstants.THURSDAY);
DateTime midDate = (DateTime) getArguments().getSerializable(DATE_KEY);
if (midDate != null) {
midDate = midDate.withDayOfWeek(DateTimeConstants.THURSDAY);
}
//Getting all seven days

for (int i = -3; i <= 3; i++)
days.add(midDate.plusDays(i));
days.add(midDate != null ? midDate.plusDays(i) : null);

startDate = days.get(0);
endDate = days.get(days.size() - 1);
Expand Down Expand Up @@ -123,7 +126,7 @@ public class WeekAdapter extends BaseAdapter {
private Context context;
private DateTime firstDay;

public WeekAdapter(Context context, ArrayList<DateTime> days) {
WeekAdapter(Context context, ArrayList<DateTime> days) {
this.days = days;
this.context = context;
}
Expand All @@ -143,6 +146,7 @@ public long getItemId(int position) {
return 0;
}

@SuppressLint("InflateParams")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import noman.weekcalendar.fragment.WeekFragment;

/**
* Created by nor on 12/5/2015.
* Created by gokhan on 7/28/16.
*/
public class WeekPager extends ViewPager {
private static final String TAG = "WeekCalendar";
private PagerAdapter adapter;
private int pos;
private boolean check;
Expand Down Expand Up @@ -127,9 +126,10 @@ public void setStartDate(Event.SetStartDateEvent event) {
}

private int idCheck() {

int id = 0;
while (findViewById(++id) != null) ;
while (true) {
if (findViewById(++id) == null) break;
}
return id;
}
}
3 changes: 3 additions & 0 deletions weekcalendar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
<enum name="threeLetters" value="1"/>
</attr>
<attr name="hideNames" format="boolean"/>

<!-- danigarciaalva -->
<attr name="todaysDateTextColor" format="color"/>
</declare-styleable>
</resources>

0 comments on commit f067a72

Please sign in to comment.