Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
this commit fixes #545
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed May 28, 2017
1 parent 6123e3d commit 8a01f94
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
2 changes: 0 additions & 2 deletions app/src/main/assets/md/github_dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ body {
padding: 10px;
line-height: 1.5;
word-wrap: break-word;
background: #22252A;
color: #ccc;
}

Expand Down Expand Up @@ -85,7 +84,6 @@ body kbd {
line-height: 10px;
color: #656d78;
vertical-align: middle;
background-color: #22252A;
border: solid 1px #656d78;
border-bottom-color: #bbb;
border-radius: 3px;
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/fastaccess/ui/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public abstract class BaseActivity<V extends BaseMvp.FAView, P extends BasePrese
@Nullable @BindView(R.id.appbar) public AppBarLayout appbar;
@Nullable @BindView(R.id.drawer) public DrawerLayout drawer;
@Nullable @BindView(R.id.extrasNav) public NavigationView extraNav;

@State Bundle presenterStateBundle = new Bundle();

private static int REFRESH_CODE = 64;
Expand All @@ -93,8 +92,8 @@ public abstract class BaseActivity<V extends BaseMvp.FAView, P extends BasePrese

@Override protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getPresenter().onSaveInstanceState(outState);
Icepick.saveInstanceState(this, presenterStateBundle);
Icepick.saveInstanceState(this, outState);
getPresenter().onSaveInstanceState(presenterStateBundle);
}

@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class BasePresenter<V extends BaseMvp.FAView> extends TiPresenter<V> impl
}

@Override public void onRestoreInstanceState(Bundle outState) {
Icepick.restoreInstanceState(this, outState);
if (outState != null) Icepick.restoreInstanceState(this, outState);
}

@Override public void manageSubscription(@Nullable Disposable... subscription) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
Expand Down Expand Up @@ -48,6 +50,8 @@ public class GitHubContributionsView extends View {
private List<ContributionsDay> contributionsFilter;
private Rect rect;
private Paint monthTextPaint;
private Matrix matrix = new Matrix();
private Paint paint = new Paint();
private Paint blockPaint;

public GitHubContributionsView(Context context) {
Expand Down Expand Up @@ -77,7 +81,6 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
initAttributes(attributes);

rect = new Rect();

monthTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
blockPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
blockPaint.setStyle(Paint.Style.FILL);
Expand Down Expand Up @@ -258,6 +261,7 @@ public void clearContribution() {

public void onResponse(List<ContributionsDay> contributionsDay) {
this.contributions = contributionsDay;
contributionsFilter = getLastContributions(contributions, lastWeeks);
invalidate();
}

Expand Down Expand Up @@ -292,14 +296,13 @@ public void onResponse(List<ContributionsDay> contributionsDay) {
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (contributions != null) {
contributionsFilter = getLastContributions(contributions, lastWeeks);
drawOnCanvas(canvas);
canvas.drawBitmap(drawOnCanvas(canvas), matrix, paint);
} else {
drawPlaceholder(canvas);
}
}

private void drawOnCanvas(Canvas canvas) {
private Bitmap drawOnCanvas(Canvas canvas) {
canvas.getClipBounds(rect);
int width = rect.width();
int verticalBlockNumber = 7;
Expand All @@ -310,9 +313,11 @@ private void drawOnCanvas(Canvas canvas) {
float topMargin = (displayMonth) ? 7f : 0;
float monthTextHeight = (displayMonth) ? blockWidth * 1.5F : 0;
int height = (int) ((blockWidth + spaceWidth) * 7 + topMargin + monthTextHeight);
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas1 = new Canvas(bitmap);
// Background
blockPaint.setColor(backgroundBaseColor);
canvas.drawRect(0, (topMargin + monthTextHeight), width, height + monthTextHeight, blockPaint);
canvas1.drawRect(0, (topMargin + monthTextHeight), width, height + monthTextHeight, blockPaint);
monthTextPaint.setColor(textColor);
monthTextPaint.setTextSize(monthTextHeight);
// draw the blocks
Expand All @@ -324,15 +329,15 @@ private void drawOnCanvas(Canvas canvas) {
float y = (currentWeekDay - 7) % 7 * (blockWidth + spaceWidth) + (topMargin + monthTextHeight);
for (ContributionsDay day : contributionsFilter) {
blockPaint.setColor(ColorsUtils.calculateLevelColor(baseColor, baseEmptyColor, day.level));
canvas.drawRect(x, y, x + blockWidth, y + blockWidth, blockPaint);
canvas1.drawRect(x, y, x + blockWidth, y + blockWidth, blockPaint);

if (DatesUtils.isFirstDayOfWeek(day.year, day.month, day.day + 1)) {
// another column
x += blockWidth + spaceWidth;
y = topMargin + monthTextHeight;

if (DatesUtils.isFirstWeekOfMount(day.year, day.month, day.day + 1)) {
canvas.drawText(
canvas1.drawText(
DatesUtils.getShortMonthName(day.year, day.month, day.day + 1),
x, monthTextHeight, monthTextPaint);
}
Expand All @@ -342,10 +347,16 @@ private void drawOnCanvas(Canvas canvas) {
}
}

// Resize component
adjustHeight(height);
return bitmap;
}

private void adjustHeight(int height) {
ViewGroup.LayoutParams ll = getLayoutParams();
ll.height = height;
setLayoutParams(ll);
if (height != ll.height) {
ll.height = height;
setLayoutParams(ll);
}
}

private void drawPlaceholder(Canvas canvas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<FrameLayout
android:id="@+id/messageLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?card_background"
android:orientation="vertical">
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -39,9 +39,9 @@
android:id="@+id/prettifyWebView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:webview_background="?card_background"
android:minHeight="200dp"
android:visibility="gone"
app:webview_background="?card_background"/>
android:visibility="gone"/>

<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/message"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
android:id="@+id/contributionView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="200dp"
android:minHeight="100dp"
app:baseColor="?colorAccent"
app:baseEmptyColor="@color/material_grey_400"
app:displayMonth="true"
Expand Down

0 comments on commit 8a01f94

Please sign in to comment.