Java Code Examples for android.text.format.DateFormat#getTimeFormat()

The following examples show how to use android.text.format.DateFormat#getTimeFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseWatchFace.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgoRawBatt();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example 2
Source File: BIGChart.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BIGChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgoRawBatt();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example 3
Source File: BgGraphBuilder.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
	
	String filtered = "";
	try {
		PointValueExtended pve = (PointValueExtended) pointValue;
		if(pve.calculatedFilteredValue != -1) {
			filtered = " (" + Math.round(pve.calculatedFilteredValue*10) / 10d +")";
		}
	} catch (ClassCastException e) {
		Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
	}
    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    Long time = ((long)pointValue.getX())*FUZZER;
    if(tooltip!= null){
        tooltip.cancel();
    }
    tooltip = Toast.makeText(context, timeFormat.format(time)+ ": " + Math.round(pointValue.getY()*10)/ 10d + filtered, Toast.LENGTH_LONG);
    tooltip.show();
}
 
Example 4
Source File: UIHelper.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
private static String readableTimeDifference(Context context, long time,
                                             boolean fullDate) {
    if (time == 0) {
        return context.getString(R.string.just_now);
    }
    Date date = new Date(time);
    long difference = (System.currentTimeMillis() - time) / 1000;
    if (difference < 60) {
        return context.getString(R.string.just_now);
    } else if (difference < 60 * 2) {
        return context.getString(R.string.minute_ago);
    } else if (difference < 60 * 15) {
        return context.getString(R.string.minutes_ago, Math.round(difference / 60.0));
    } else if (today(date)) {
        java.text.DateFormat df = DateFormat.getTimeFormat(context);
        return df.format(date);
    } else {
        if (fullDate) {
            return DateUtils.formatDateTime(context, date.getTime(),
                    FULL_DATE_FLAGS);
        } else {
            return DateUtils.formatDateTime(context, date.getTime(),
                    SHORT_DATE_FLAGS);
        }
    }
}
 
Example 5
Source File: BaseWatchFace.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgoRawBattStatus();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example 6
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
	
	String filtered = "";
	try {
		PointValueExtended pve = (PointValueExtended) pointValue;
		if(pve.calculatedFilteredValue != -1) {
			filtered = " (" + Math.round(pve.calculatedFilteredValue*10) / 10d +")";
		}
	} catch (ClassCastException e) {
		Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
	}
    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    Long time = ((long)pointValue.getX())*FUZZER;
    if(tooltip!= null){
        tooltip.cancel();
    }
    tooltip = Toast.makeText(context, timeFormat.format(time)+ ": " + Math.round(pointValue.getY()*10)/ 10d + filtered, Toast.LENGTH_LONG);
    tooltip.show();
}
 
Example 7
Source File: BIGChart.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BIGChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgeAndStatus();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example 8
Source File: BaseWatchFace.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
public void setDateAndTime() {

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        if (mTime != null) {
            mTime.setText(timeFormat.format(System.currentTimeMillis()));
        }

        Date now = new Date();
        SimpleDateFormat sdfHour = new SimpleDateFormat("HH");
        SimpleDateFormat sdfMinute = new SimpleDateFormat("mm");
        sHour = sdfHour.format(now);
        sMinute = sdfMinute.format(now);

        if (mDate != null && mDay != null && mMonth != null) {
            if (sharedPrefs.getBoolean("show_date", false)) {
                SimpleDateFormat sdfDay = new SimpleDateFormat("dd");
                SimpleDateFormat sdfMonth = new SimpleDateFormat("MMM");
                mDay.setText(sdfDay.format(now));
                mMonth.setText(sdfMonth.format(now));
                mDate.setVisibility(View.VISIBLE);
            } else {
                mDate.setVisibility(View.GONE);
            }
        }
    }
 
Example 9
Source File: NOChart.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(NOChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgeAndStatus();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example 10
Source File: BIGChart.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
    if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
        wakeLock.acquire(50);
        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BIGChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));
        showAgoRawBatt();

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        missedReadingAlert();
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
    }
}
 
Example 11
Source File: BaseWatchFace.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    DataMap dataMap = DataMap.fromBundle(intent.getBundleExtra("data"));
    if (layoutSet) {
        wakeLock.acquire(50);
        sgvLevel = dataMap.getLong("sgvLevel");
        batteryLevel = dataMap.getInt("batteryLevel");
        datetime = dataMap.getDouble("timestamp");
        rawString = dataMap.getString("rawString");
        sgvString = dataMap.getString("sgvString");
        batteryString = dataMap.getString("battery");
        mSgv.setText(dataMap.getString("sgvString"));

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));

        showAgoRawBatt();

        mDirection.setText(dataMap.getString("slopeArrow"));
        mDelta.setText(dataMap.getString("delta"));

        if (chart != null) {
            addToWatchSet(dataMap);
            setupCharts();
        }
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
        invalidate();
    } else {
        Log.d("ERROR: ", "DATA IS NOT YET SET");
    }
    setColor();
}
 
Example 12
Source File: BaseItemUtils.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
public static String getProgramSubText(BaseItemDto baseItem) {
    StringBuilder builder = new StringBuilder();
    // Add the channel name if set
    if (baseItem.getChannelName() != null) {
        builder.append(baseItem.getChannelName())
                .append(" - ");
    }
    // Add the episode title if set
    if (baseItem.getEpisodeTitle() != null) {
        builder.append(baseItem.getEpisodeTitle())
                .append(" ");
    }

    Calendar startTime = Calendar.getInstance();
    startTime.setTime(TimeUtils.convertToLocalDate(baseItem.getStartDate()));
    // If the start time is on a different day, add the date
    if (startTime.get(Calendar.DAY_OF_YEAR) != Calendar.getInstance().get(Calendar.DAY_OF_YEAR)) {
        builder.append(TimeUtils.getFriendlyDate(startTime.getTime()))
                .append(" ");
    }
    // Add the start and end time
    java.text.DateFormat dateFormat = DateFormat.getTimeFormat(TvApp.getApplication());
    builder.append(dateFormat.format(startTime.getTime()))
            .append("-")
            .append(dateFormat.format(TimeUtils.convertToLocalDate(baseItem.getEndDate())));

    return builder.toString();
}
 
Example 13
Source File: BaseWatchFace.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    DataMap dataMap = DataMap.fromBundle(intent.getBundleExtra("data"));
    if (layoutSet) {
        wakeLock.acquire(50);
        sgvLevel = dataMap.getLong("sgvLevel");
        batteryLevel = dataMap.getInt("batteryLevel");
        datetime = dataMap.getDouble("timestamp");
        rawString = dataMap.getString("rawString");
        sgvString = dataMap.getString("sgvString");
        batteryString = dataMap.getString("battery");
        mSgv.setText(dataMap.getString("sgvString"));

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));

        showAgoRawBatt();

        mDirection.setText(dataMap.getString("slopeArrow"));
        mDelta.setText(dataMap.getString("delta"));

        if (chart != null) {
            addToWatchSet(dataMap);
            setupCharts();
        }
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
        invalidate();
    } else {
        Log.d("ERROR: ", "DATA IS NOT YET SET");
    }
    setColor();
}
 
Example 14
Source File: AdapterBaseImpl.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
protected AdapterBaseImpl(Context ctx_, int mode_)
{
    ctx = ctx_;
    mode = mode_;
    mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    localeDateFormat = DateFormat.getDateFormat(ctx);
    localeTimeFormat = DateFormat.getTimeFormat(ctx);
    density = ctx.getResources().getDisplayMetrics().density;
}
 
Example 15
Source File: AppSettingsActivity.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult2(int requestCode, Intent data) {
    int hour = data.getIntExtra(TimePickerFragment.EXTRA_HOUR, 0);
    int minute = data.getIntExtra(TimePickerFragment.EXTRA_MINUTE, 0);

    java.text.DateFormat timeFormat = DateFormat.getTimeFormat(this);
    String formattedTime = timeFormat.format(Func.convertHourMinute2Date(hour, minute));
    int time = hour * 60 + minute;

    if (requestCode == START_TIME_REQUEST) {
        mStartTimeHour = hour;
        mStartTimeMinute = minute;
        mStartTimeButton.setText(formattedTime);
        int stopTime = mStopTimeHour * 60 + mStopTimeMinute;
        if (time > stopTime) {
            mNextDay.setVisibility(View.VISIBLE);
        } else {
            mNextDay.setVisibility(View.INVISIBLE);
        }

    } else if (requestCode == STOP_TIME_REQUEST) {
        mStopTimeHour = hour;
        mStopTimeMinute = minute;
        mStopTimeButton.setText(formattedTime);
        int startTime = mStartTimeHour * 60 + mStartTimeMinute;
        if (time < startTime) {
            mNextDay.setVisibility(View.VISIBLE);
        } else {
            mNextDay.setVisibility(View.INVISIBLE);
        }
    }
}
 
Example 16
Source File: AppSettingsActivity.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
private void setupScheduleSettings() {
    if (mAllDaySchedule) {
        mStartTimeButton.setEnabled(false);
        mStartTimeButton.setBackgroundColor(0x649e9e9e);
        mStartTimeButton.setText(R.string.schedule_disabled);
        mStopTimeButton.setEnabled(false);
        mStopTimeButton.setBackgroundColor(0x649e9e9e);
        mStopTimeButton.setText(R.string.schedule_disabled);
        mNextDay.setVisibility(View.INVISIBLE);
    } else {
        mStartTimeButton.setEnabled(true);
        mStopTimeButton.setEnabled(true);

        mStartTimeButton.setBackgroundColor(0xffff4081);
        mStopTimeButton.setBackgroundColor(0xffff4081);

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(this);

        mStartTimeButton.setText(timeFormat.format(
                Func.convertHourMinute2Date(mStartTimeHour, mStartTimeMinute)));

        mStopTimeButton.setText(timeFormat.format(
                Func.convertHourMinute2Date(mStopTimeHour, mStopTimeMinute)));

        int startTime = mStartTimeHour * 60 + mStartTimeMinute;
        int stopTime = mStopTimeHour * 60 + mStopTimeMinute;

        if (startTime > stopTime) {
            mNextDay.setVisibility(View.VISIBLE);
        } else {
            mNextDay.setVisibility(View.INVISIBLE);
        }
    }
}
 
Example 17
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {

    Log.d(TAG, "onValueSelected pointValue=" + pointValue.getX() + "," + pointValue.getY());
    String filtered = "";
    String alternate = "";
    String uuid = "";
    int type = 0;
    long real_timestamp = 0;
    try {
        PointValueExtended pve = (PointValueExtended) pointValue;
        type = pve.type;
        if (pve.calculatedFilteredValue != -1) {
            filtered = " (" + Math.round(pve.calculatedFilteredValue * 10) / 10d + ")";
        }
        if (pve.note != null) {
            alternate = pve.note;
        }
        if (pve.uuid != null) {
            uuid = pve.uuid;
        }
        real_timestamp = pve.real_timestamp;

    } catch (ClassCastException e) {
        Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
    }

    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    final Long time = (real_timestamp > 0) ? real_timestamp : ((long) pointValue.getX()) * FUZZER;
    final double ypos = pointValue.getY();

    final String message;

    if (alternate.length() > 0) {
        message = timeFormat.format(time) + "    " + alternate;
    } else {
        message = timeFormat.format(time) + "      " + (Math.round(pointValue.getY() * 10) / 10d) + " " + unit() + filtered;
    }
    Log.d(TAG, "onValueSelected message=" + message);
    JoH.static_toast(xdrip.getAppContext(), message, Toast.LENGTH_SHORT);

    /*switch (type) {
        case com.eveningoutpost.dexdrip.UtilityModels.PointValueExtended.BloodTest:
            final String fuuid = uuid;
            final View.OnClickListener mBtOnClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Home.startHomeWithExtra(xdrip.getAppContext(), Home.BLOOD_TEST_ACTION, time.toString(), fuuid);
                }
            };
            Home.snackBar(R.string.blood_test, message, mBtOnClickListener, callerActivity);
            break;
        default:
            final View.OnClickListener mOnClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, time.toString(), Double.toString(ypos));
                }
            };
            Home.snackBar(R.string.add_note, message, mOnClickListener, callerActivity);
            break;
    }*/
}
 
Example 18
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {

    Log.d(TAG, "onValueSelected pointValue=" + pointValue.getX() + "," + pointValue.getY());
    String filtered = "";
    String alternate = "";
    String uuid = "";
    int type = 0;
    long real_timestamp = 0;
    try {
        PointValueExtended pve = (PointValueExtended) pointValue;
        type = pve.type;
        if (pve.calculatedFilteredValue != -1) {
            filtered = " (" + Math.round(pve.calculatedFilteredValue * 10) / 10d + ")";
        }
        if (pve.note != null) {
            alternate = pve.note;
        }
        if (pve.uuid != null) {
            uuid = pve.uuid;
        }
        real_timestamp = pve.real_timestamp;

    } catch (ClassCastException e) {
        Log.e(TAG, "Error casting a point from pointValue to PointValueExtended", e);
    }

    final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
    //Won't give the exact time of the reading but the time on the grid: close enough.
    final Long time = (real_timestamp > 0) ? real_timestamp : ((long) pointValue.getX()) * FUZZER;
    final double ypos = pointValue.getY();

    final String message;

    if (alternate.length() > 0) {
        message = timeFormat.format(time) + "    " + alternate;
    } else {
        message = timeFormat.format(time) + "      " + (Math.round(pointValue.getY() * 10) / 10d) + " " + unit() + filtered;
    }
    Log.d(TAG, "onValueSelected message=" + message);
    JoH.static_toast(xdrip.getAppContext(), message, Toast.LENGTH_SHORT);

    /*switch (type) {
        case com.eveningoutpost.dexdrip.UtilityModels.PointValueExtended.BloodTest:
            final String fuuid = uuid;
            final View.OnClickListener mBtOnClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Home.startHomeWithExtra(xdrip.getAppContext(), Home.BLOOD_TEST_ACTION, time.toString(), fuuid);
                }
            };
            Home.snackBar(R.string.blood_test, message, mBtOnClickListener, callerActivity);
            break;
        default:
            final View.OnClickListener mOnClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, time.toString(), Double.toString(ypos));
                }
            };
            Home.snackBar(R.string.add_note, message, mOnClickListener, callerActivity);
            break;
    }*/
}
 
Example 19
Source File: BIGChart.java    From NightWatch with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    DataMap dataMap = DataMap.fromBundle(intent.getBundleExtra("data"));
    if (layoutSet) {
        wakeLock.acquire(50);
        sgvLevel = dataMap.getLong("sgvLevel");
        batteryLevel = dataMap.getInt("batteryLevel");
        datetime = dataMap.getDouble("timestamp");
        rawString = dataMap.getString("rawString");
        sgvString = dataMap.getString("sgvString");
        batteryString = dataMap.getString("battery");
        mSgv.setText(dataMap.getString("sgvString"));

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BIGChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));

        showAgoRawBatt();

        String delta = dataMap.getString("delta");

        if (delta.endsWith(" mg/dl")) {
            mDelta.setText(delta.substring(0, delta.length() - 6));
        } else if (delta.endsWith(" mmol")) {
            mDelta.setText(delta.substring(0, delta.length() - 5));
        }

        if (chart != null) {
            addToWatchSet(dataMap);
            setupCharts();
        }
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
        invalidate();
        setColor();

        //start animation?
        // dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
        if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5"))) {
            startAnimation();
        }


    } else {
        Log.d("ERROR: ", "DATA IS NOT YET SET");
    }
}
 
Example 20
Source File: BIGChart.java    From NightWatch with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    DataMap dataMap = DataMap.fromBundle(intent.getBundleExtra("data"));
    if (layoutSet) {
        wakeLock.acquire(50);
        sgvLevel = dataMap.getLong("sgvLevel");
        batteryLevel = dataMap.getInt("batteryLevel");
        datetime = dataMap.getDouble("timestamp");
        rawString = dataMap.getString("rawString");
        sgvString = dataMap.getString("sgvString");
        batteryString = dataMap.getString("battery");
        mSgv.setText(dataMap.getString("sgvString"));

        if(ageLevel()<=0) {
            mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
        }

        final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BIGChart.this);
        mTime.setText(timeFormat.format(System.currentTimeMillis()));

        showAgoRawBatt();

        String delta = dataMap.getString("delta");

        if (delta.endsWith(" mg/dl")) {
            mDelta.setText(delta.substring(0, delta.length() - 6));
        } else if (delta.endsWith(" mmol")) {
            mDelta.setText(delta.substring(0, delta.length() - 5));
        }

        if (chart != null) {
            addToWatchSet(dataMap);
            setupCharts();
        }
        mRelativeLayout.measure(specW, specH);
        mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
                mRelativeLayout.getMeasuredHeight());
        invalidate();
        setColor();

        //start animation?
        // dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
        if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5"))) {
            startAnimation();
        }


    } else {
        Log.d("ERROR: ", "DATA IS NOT YET SET");
    }
}