WeekView warnings fixed

This commit is contained in:
Caesar2011
2018-07-13 20:51:17 +02:00
parent e40743df93
commit 75683960ca
3 changed files with 27 additions and 75 deletions

View File

@@ -21,7 +21,7 @@ public class Conversion {
}
public static String getModifiedDateTime(Context context, long modified) {
return getModifiedDate(context, Locale.getDefault(), modified, "MM/dd/yy hh:mm");
return getModifiedDate(context, modified, "dd.MM.yy hh:mm");
}
@Deprecated
@@ -30,7 +30,7 @@ public class Conversion {
}
public static String getModifiedTime(Context context, long modified) {
return getModifiedDate(context, Locale.getDefault(), modified, "hh:mm");
return getModifiedDate(context, modified, "hh:mm");
}
@Deprecated
@@ -39,7 +39,11 @@ public class Conversion {
}
public static String getModifiedDate(Context context, long modified) {
return getModifiedDate(context, Locale.getDefault(), modified, "dd.MM.yy");
return getModifiedDate(context, modified, "dd.MM.yy");
}
public static String getModifiedDate(Context context, long modified, String skeleton) {
return getModifiedDate(context, Locale.getDefault(), modified, skeleton);
}
@SuppressLint("SimpleDateFormat")
@@ -49,7 +53,7 @@ public class Conversion {
if (context != null && DateFormat.is24HourFormat(context))
skeleton = skeleton.replaceAll("h", "H");
else if (context == null)
log.w("No context spplied for conversion!");
log.w("No context applied for conversion!");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
dateFormat = new SimpleDateFormat(getDateFormat(locale, skeleton));
} else {

View File

@@ -43,11 +43,11 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.tools.Conversion;
import static de.sebse.fuplanner.tools.ui.weekview.WeekViewUtil.daysBetween;
import static de.sebse.fuplanner.tools.ui.weekview.WeekViewUtil.getPassedMinutesInDay;
@@ -155,8 +155,6 @@ public class WeekView extends View {
private boolean mIsFirstDraw = true;
private boolean mAreDimensionsInvalid = true;
@Deprecated
private int mDayNameLength = LENGTH_LONG;
private int mOverlappingEventGap = 0;
private int mEventMarginVertical = 0;
private float mXScrollingSpeed = 1f;
@@ -471,14 +469,11 @@ public class WeekView extends View {
mEventTextColor = a.getColor(R.styleable.WeekView_eventTextColor, mEventTextColor);
mNewEventColor = a.getColor(R.styleable.WeekView_newEventColor, mNewEventColor);
mNewEventIconDrawable = a.getDrawable(R.styleable.WeekView_newEventIconResource);
// For backward compatibility : Set "mNewEventIdentifier" if the attribute is "WeekView_newEventId" of type int
setNewEventId(a.getInt(R.styleable.WeekView_newEventId, Integer.parseInt(mNewEventIdentifier)));
mNewEventIdentifier = (a.getString(R.styleable.WeekView_newEventIdentifier) != null) ? a.getString(R.styleable.WeekView_newEventIdentifier) : mNewEventIdentifier;
mNewEventLengthInMinutes = a.getInt(R.styleable.WeekView_newEventLengthInMinutes, mNewEventLengthInMinutes);
mNewEventTimeResolutionInMinutes = a.getInt(R.styleable.WeekView_newEventTimeResolutionInMinutes, mNewEventTimeResolutionInMinutes);
mEventPadding = a.getDimensionPixelSize(R.styleable.WeekView_eventPadding, mEventPadding);
mHeaderColumnBackgroundColor = a.getColor(R.styleable.WeekView_headerColumnBackground, mHeaderColumnBackgroundColor);
mDayNameLength = a.getInteger(R.styleable.WeekView_dayNameLength, mDayNameLength);
mOverlappingEventGap = a.getDimensionPixelSize(R.styleable.WeekView_overlappingEventGap, mOverlappingEventGap);
mEventMarginVertical = a.getDimensionPixelSize(R.styleable.WeekView_eventMarginVertical, mEventMarginVertical);
mXScrollingSpeed = a.getFloat(R.styleable.WeekView_xScrollingSpeed, mXScrollingSpeed);
@@ -561,6 +556,7 @@ public class WeekView extends View {
// Prepare hour separator color paint.
mHourSeparatorPaint = new Paint();
mHourSeparatorPaint.setStyle(Paint.Style.STROKE);
//noinspection SuspiciousNameCombination
mHourSeparatorPaint.setStrokeWidth(mHourSeparatorHeight);
mHourSeparatorPaint.setColor(mHourSeparatorColor);
@@ -879,7 +875,7 @@ public class WeekView extends View {
boolean isToday = isSameDay(day, today);
// Don't draw days which are outside requested range
if (!dateIsValid(day)) {
if (dateIsInvalid(day)) {
continue;
}
@@ -967,7 +963,7 @@ public class WeekView extends View {
boolean isToday = isSameDay(day, today);
// Don't draw days which are outside requested range
if (!dateIsValid(day))
if (dateIsInvalid(day))
continue;
// Draw the day labels.
@@ -1258,7 +1254,7 @@ public class WeekView extends View {
* @param originalEvent The original event that was passed by the user.
* @param rectF The rectangle.
*/
public EventRect(WeekViewEvent event, WeekViewEvent originalEvent, RectF rectF) {
EventRect(WeekViewEvent event, WeekViewEvent originalEvent, RectF rectF) {
this.event = event;
this.rectF = rectF;
this.originalEvent = originalEvent;
@@ -1371,19 +1367,16 @@ public class WeekView extends View {
* @param eventRects The events to be sorted.
*/
private void sortEventRects(List<EventRect> eventRects) {
Collections.sort(eventRects, new Comparator<EventRect>() {
@Override
public int compare(EventRect left, EventRect right) {
Collections.sort(eventRects, (left, right) -> {
long start1 = left.event.getStartTime().getTimeInMillis();
long start2 = right.event.getStartTime().getTimeInMillis();
int comparator = start1 > start2 ? 1 : (start1 < start2 ? -1 : 0);
int comparator = Long.compare(start1, start2);
if (comparator == 0) {
long end1 = left.event.getEndTime().getTimeInMillis();
long end2 = right.event.getEndTime().getTimeInMillis();
comparator = end1 > end2 ? 1 : (end1 < end2 ? -1 : 0);
comparator = Long.compare(end1, end2);
}
return comparator;
}
});
}
@@ -1626,8 +1619,7 @@ public class WeekView extends View {
@Override
public String interpretDate(Calendar date) {
try {
SimpleDateFormat sdf = mDayNameLength == LENGTH_SHORT ? new SimpleDateFormat("EEEEE M/dd", Locale.getDefault()) : new SimpleDateFormat("EEE M/dd", Locale.getDefault());
return sdf.format(date.getTime()).toUpperCase();
return Conversion.getModifiedDate(getContext(), date.getTimeInMillis(), "EEE dd.M").toUpperCase();
} catch (Exception e) {
e.printStackTrace();
return "";
@@ -1855,6 +1847,7 @@ public class WeekView extends View {
public void setHourSeparatorHeight(int hourSeparatorHeight) {
mHourSeparatorHeight = hourSeparatorHeight;
//noinspection SuspiciousNameCombination
mHourSeparatorPaint.setStrokeWidth(mHourSeparatorHeight);
invalidate();
}
@@ -1968,35 +1961,6 @@ public class WeekView extends View {
this.mNewEventTimeResolutionInMinutes = newEventTimeResolutionInMinutes;
}
/**
* <b>Note:</b> Use {@link #setDateTimeInterpreter(DateTimeInterpreter)} and
* {@link #getDateTimeInterpreter()} instead.
*
* @return Either long or short day name is being used.
*/
@Deprecated
public int getDayNameLength() {
return mDayNameLength;
}
/**
* Set the length of the day name displayed in the header row. Example of short day names is
* 'M' for 'Monday' and example of long day names is 'Mon' for 'Monday'.
* <p>
* <b>Note:</b> Use {@link #setDateTimeInterpreter(DateTimeInterpreter)} instead.
* </p>
*
* @param length Supported values are {@link WeekView#LENGTH_SHORT} and
* {@link WeekView#LENGTH_LONG}.
*/
@Deprecated
public void setDayNameLength(int length) {
if (length != LENGTH_LONG && length != LENGTH_SHORT) {
throw new IllegalArgumentException("length parameter must be either LENGTH_LONG or LENGTH_SHORT");
}
this.mDayNameLength = length;
}
public int getOverlappingEventGap() {
return mOverlappingEventGap;
}
@@ -2600,12 +2564,7 @@ public class WeekView extends View {
* @return true if scrolling should be stopped before reaching the end of animation.
*/
private boolean forceFinishScroll() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// current velocity only available since api 14
return mScroller.getCurrVelocity() <= mMinimumFlingVelocity;
} else {
return false;
}
}
@@ -2697,14 +2656,8 @@ public class WeekView extends View {
* @see #setMinDate(Calendar)
* @see #setMaxDate(Calendar)
*/
public boolean dateIsValid(Calendar day) {
if (mMinDate != null && day.before(mMinDate)) {
return false;
}
if (mMaxDate != null && day.after(mMaxDate)) {
return false;
}
return true;
public boolean dateIsInvalid(Calendar day) {
return mMinDate != null && day.before(mMinDate) || mMaxDate != null && day.after(mMaxDate);
}
/////////////////////////////////////////////////////////////////

View File

@@ -5,10 +5,6 @@
<attr name="autoLimitTime" format="boolean" />
<attr name="columnGap" format="dimension" />
<attr name="dayBackgroundColor" format="color" />
<attr name="dayNameLength" format="enum">
<enum name="length_short" value="1" />
<enum name="length_long" value="2" />
</attr>
<attr name="eventCornerRadius" format="dimension" />
<attr name="eventMarginVertical" format="dimension" />
<attr name="eventPadding" format="dimension" />
@@ -40,7 +36,6 @@
<attr name="minTime" format="integer" />
<attr name="minOverlappingMinutes" format="integer" />
<attr name="newEventColor" format="color" />
<attr name="newEventId" format="integer" />
<attr name="newEventIdentifier" format="string" />
<attr name="newEventIconResource" format="integer" />
<attr name="newEventLengthInMinutes" format="integer" />