Skip to content

Commit

Permalink
- fix small bug if fragment not attached to an activity
Browse files Browse the repository at this point in the history
- update version to 1.3
  • Loading branch information
oliexdev committed Aug 15, 2015
1 parent 7d7e04c commit cae5216
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions android_app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.health.openscale"
android:versionCode="5"
android:versionName="1.2" >
android:versionCode="6"
android:versionName="1.3" >

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.health.openscale.core;

import android.support.v4.app.Fragment;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
Expand Down Expand Up @@ -433,7 +434,9 @@ public void updateScaleData()

for(FragmentUpdateListener fragment : fragmentList) {
if (fragment != null) {
fragment.updateOnView(scaleDataList);
if (((Fragment)fragment).isAdded()) {
fragment.updateOnView(scaleDataList);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,9 @@ private void updateLastLineChart(ArrayList<ScaleData> scaleDataList) {
Calendar histDate = Calendar.getInstance();
Calendar lastDate = Calendar.getInstance();

lastDate.setTime(lastScaleData.date_time);
if (!scaleDataList.isEmpty()) {
lastDate.setTime(scaleDataList.get(0).date_time);
}

scaleDataLastDays = new ArrayList<ScaleData>();

Expand All @@ -713,8 +715,8 @@ private void updateLastLineChart(ArrayList<ScaleData> scaleDataList) {

long days = 0 - daysBetween(lastDate, histDate);

if (days == 0) {
axisValues.add(new AxisValue(i, DateFormat.getDateInstance(DateFormat.SHORT).format(lastScaleData.date_time).toCharArray()));
if (days == 0 && !scaleDataList.isEmpty()) {
axisValues.add(new AxisValue(i, DateFormat.getDateInstance(DateFormat.SHORT).format(scaleDataList.get(0).date_time).toCharArray()));
} else {
axisValues.add(new AxisValue(i, String.format("%d " + getResources().getString(R.string.label_days), days).toCharArray()));
}
Expand Down Expand Up @@ -820,11 +822,10 @@ private void updateLastPieChart() {


if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
pieChartData.setCenterText1FontSize(25);
pieChartData.setCenterText2FontSize(14);
} else
{
} else {
pieChartData.setCenterText1FontSize(20);
pieChartData.setCenterText2FontSize(12);
pieChartData.setValueLabelTextSize(12);
Expand Down

0 comments on commit cae5216

Please sign in to comment.