Skip to content

Commit

Permalink
fix a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
c99koder committed May 5, 2017
1 parent 275ac2c commit 68a2027
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ android {
useLibrary 'org.apache.http.legacy'

defaultConfig {
versionCode 117
versionCode 118
versionName "3.22"
minSdkVersion 10
targetSdkVersion 25
Expand Down
14 changes: 7 additions & 7 deletions irccloud-android.iml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@
<sourceFolder url="file://$MODULE_DIR$/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/tests/src" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/tests/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests/src" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/.DS_Store" />
<excludeFolder url="file://$MODULE_DIR$/build/android-profile" />
<excludeFolder url="file://$MODULE_DIR$/build/filtered_resources" />
Expand Down
2 changes: 1 addition & 1 deletion src/com/irccloud/android/NetworkConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -3219,7 +3219,7 @@ public synchronized void notifyHandlers(int message, final Object object, IRCEve
ArrayList<Buffer> buffers = mBuffers.getBuffers();
for (Buffer b : buffers) {
if (b.getTimeout() > 0) {
Crashlytics.log(Log.DEBUG, TAG, "Requesting backlog for timed-out buffer: " + b.getName());
Crashlytics.log(Log.DEBUG, TAG, "Requesting backlog for timed-out buffer: bid" + b.getBid());
request_backlog(b.getCid(), b.getBid(), 0);
}

Expand Down
62 changes: 33 additions & 29 deletions src/com/irccloud/android/data/model/Avatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,41 @@ public class Avatar {

public static Bitmap generateBitmap(String text, int textColor, int bgColor, boolean isDarkTheme, int size, boolean round) {
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setStyle(Paint.Style.FILL);

if(isDarkTheme || !round) {
p.setColor(bgColor);
if(round)
c.drawCircle(size / 2, size / 2, size / 2, p);
else
c.drawColor(bgColor);
} else {
float[] hsv = new float[3];
Color.colorToHSV(bgColor, hsv);
hsv[2] *= 0.8f;
p.setColor(Color.HSVToColor(hsv));
c.drawCircle(size / 2, size / 2, (size / 2) - 2, p);
p.setColor(bgColor);
c.drawCircle(size / 2, (size / 2) - 2, (size / 2) - 2, p);
}
TextPaint tp = new TextPaint(Paint.ANTI_ALIAS_FLAG);
tp.setTextAlign(Paint.Align.CENTER);
tp.setTypeface(font);
tp.setTextSize((int)(size * 0.65));
tp.setColor(textColor);
if (isDarkTheme || !round) {
c.drawText(text, size/2, (size/2) - ((tp.descent() + tp.ascent()) / 2), tp);
if(bitmap != null) {
Canvas c = new Canvas(bitmap);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setStyle(Paint.Style.FILL);

if (isDarkTheme || !round) {
p.setColor(bgColor);
if (round)
c.drawCircle(size / 2, size / 2, size / 2, p);
else
c.drawColor(bgColor);
} else {
float[] hsv = new float[3];
Color.colorToHSV(bgColor, hsv);
hsv[2] *= 0.8f;
p.setColor(Color.HSVToColor(hsv));
c.drawCircle(size / 2, size / 2, (size / 2) - 2, p);
p.setColor(bgColor);
c.drawCircle(size / 2, (size / 2) - 2, (size / 2) - 2, p);
}
TextPaint tp = new TextPaint(Paint.ANTI_ALIAS_FLAG);
tp.setTextAlign(Paint.Align.CENTER);
tp.setTypeface(font);
tp.setTextSize((int) (size * 0.65));
tp.setColor(textColor);
if (isDarkTheme || !round) {
c.drawText(text, size / 2, (size / 2) - ((tp.descent() + tp.ascent()) / 2), tp);
} else {
c.drawText(text, size / 2, (size / 2) - 4 - ((tp.descent() + tp.ascent()) / 2), tp);
}

return bitmap;
} else {
c.drawText(text, size/2, (size/2) - 4 - ((tp.descent() + tp.ascent()) / 2), tp);
return null;
}

return bitmap;
}

public static Bitmap generateBitmap(String text, int textColor, int bgColor, boolean isDarkTheme, int size) {
Expand Down

0 comments on commit 68a2027

Please sign in to comment.