Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
devgianlu committed Jul 7, 2019
1 parent 451e100 commit 12de80f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CommonUtils
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void onItemCountUpdated(int count) {
recyclerViewLayout.showInfo(R.string.noPeers);
topDownloadCountries.clear();
topUploadCountries.clear();
if (sheet != null && !isDetached()) {
if (sheet != null && getContext() != null) {
sheet.dismiss();
sheet = null;
dismissDialog();
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/gianlu/aria2app/DonutProgress.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import android.util.TypedValue;
import android.view.View;

import java.util.Locale;
import java.util.Random;

import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import java.util.Locale;
import java.util.Random;

public class DonutProgress extends View {
private final Rect textBound = new Rect();
private final Paint arcPaint;
Expand Down Expand Up @@ -97,12 +97,13 @@ protected void onDraw(Canvas canvas) {
}

public void setProgress(float progress) {
if (Float.isNaN(progress)) progress = 0;

sweepAngle = (int) ((progress / 100) * 360);
if (progress == 100) percentage = "100";
else percentage = String.format(Locale.getDefault(), "%.1f", progress);

textPaint.getTextBounds(percentage, 0, percentage.length(), textBound);
invalidate();
}


}

0 comments on commit 12de80f

Please sign in to comment.