Fixed WeekView canvas under API 28 (Android P)

This commit is contained in:
Caesar2011
2018-08-11 18:48:50 +02:00
parent 8acac1ee8b
commit f0bd6d1454
6 changed files with 66 additions and 7 deletions

2
.idea/misc.xml generated
View File

@@ -25,5 +25,5 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8 (2)" project-jdk-type="JavaSDK" />
</project>

View File

@@ -88,7 +88,7 @@ class MealAdapter extends BaseExpandableListAdapter {
Meal meal = getGroup(groupPosition);
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_all_items, parent, false);
.inflate(R.layout.list_canteen_items, parent, false);
}
ItemViewHolder itemHolder = new ItemViewHolder(convertView);

View File

@@ -61,7 +61,7 @@ class ModDetailGradebookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return new HeaderViewHolder(view);
case TYPE_GRADE:
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_modetails_gradebook, parent, false);
.inflate(R.layout.list_moddetails_gradebook, parent, false);
return new GradebookViewHolder(view);
default:
//noinspection ConstantConditions

View File

@@ -741,7 +741,8 @@ public class WeekView extends View {
canvas.drawRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight(), mHeaderColumnBackgroundPaint);
// Clip to paint in left column only.
canvas.clipRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight(), Region.Op.REPLACE);
canvas.save();
canvas.clipRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight());
for (int i = 0; i < getNumberOfPeriods(); i++) {
// If we are showing half hours (eg. 5:30am), space the times out by half the hour height
@@ -768,6 +769,7 @@ public class WeekView extends View {
if (top < getHeight())
canvas.drawText(time, mTimeTextWidth + mHeaderColumnPadding, top + mTimeTextHeight, mTimeTextPaint);
}
canvas.restore();
}
private void drawHeaderRowAndEvents(Canvas canvas) {
@@ -852,7 +854,8 @@ public class WeekView extends View {
}
// Clip to paint events only.
canvas.clipRect(mHeaderColumnWidth, mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight / 2, getWidth(), getHeight(), Region.Op.REPLACE);
canvas.save();
canvas.clipRect(mHeaderColumnWidth, mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight / 2, getWidth(), getHeight());
// Iterate through each day.
Calendar oldFirstVisibleDay = mFirstVisibleDay;
@@ -954,13 +957,17 @@ public class WeekView extends View {
// In the next iteration, start from the next day.
startPixel += mWidthPerDay + mColumnGap;
}
canvas.restore();
// Hide everything in the first cell (top left corner).
canvas.clipRect(0, 0, mTimeTextWidth + mHeaderColumnPadding * 2, mHeaderHeight + mHeaderRowPadding * 2, Region.Op.REPLACE);
canvas.save();
canvas.clipRect(0, 0, mTimeTextWidth + mHeaderColumnPadding * 2, mHeaderHeight + mHeaderRowPadding * 2);
canvas.drawRect(0, 0, mTimeTextWidth + mHeaderColumnPadding * 2, mHeaderHeight + mHeaderRowPadding * 2, mHeaderBackgroundPaint);
canvas.restore();
// Clip to paint header row only.
canvas.clipRect(mHeaderColumnWidth, 0, getWidth(), mHeaderHeight + mHeaderRowPadding * 2, Region.Op.REPLACE);
canvas.save();
canvas.clipRect(mHeaderColumnWidth, 0, getWidth(), mHeaderHeight + mHeaderRowPadding * 2);
// Draw the header background.
canvas.drawRect(0, 0, getWidth(), mHeaderHeight + mHeaderRowPadding * 2, mHeaderBackgroundPaint);
@@ -985,6 +992,7 @@ public class WeekView extends View {
drawAllDayEvents(day, startPixel, canvas);
startPixel += mWidthPerDay + mColumnGap;
}
canvas.restore();
}

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:layout_margin="5dip">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="sans"
tools:text="Test this new stuff!" />
<TextView
android:id="@+id/sub_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="5dip"
android:textColor="#343434"
android:textSize="12sp"
tools:text="Peter Bauer" />
<TextView
android:id="@+id/sub_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/sub_left"
android:layout_alignBottom="@id/sub_left"
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="20.03.18 18:42 Uhr" />
<TextView
android:id="@+id/top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/title"
android:layout_alignBottom="@id/title"
android:textColor="#343434"
android:textSize="12sp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:text="Raum 105"
tools:ignore="RelativeOverlap" />
</android.support.v7.widget.CardView>