android.text.format.DateFormat#getTimeFormat ( )源码实例Demo

下面列出了android.text.format.DateFormat#getTimeFormat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: NightWatch   文件: BIGChart.java
@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());
    }
}
 
源代码2 项目: Pix-Art-Messenger   文件: UIHelper.java
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);
        }
    }
}
 
源代码3 项目: xDrip-plus   文件: BgGraphBuilder.java
@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();
}
 
源代码4 项目: AndroidAPS   文件: BIGChart.java
@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());
    }
}
 
源代码5 项目: AndroidAPS   文件: BaseWatchFace.java
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);
            }
        }
    }
 
源代码6 项目: AndroidAPS   文件: NOChart.java
@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());
    }
}
 
源代码7 项目: xDrip-Experimental   文件: BIGChart.java
@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());
    }
}
 
源代码8 项目: xDrip-Experimental   文件: BaseWatchFace.java
@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());
    }
}
 
源代码9 项目: xDrip-Experimental   文件: BgGraphBuilder.java
@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();
}
 
源代码10 项目: NightWatch   文件: BaseWatchFace.java
@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());
    }
}
 
源代码11 项目: jellyfin-androidtv   文件: BaseItemUtils.java
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();
}
 
源代码12 项目: fitnotifications   文件: AppSettingsActivity.java
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);
        }
    }
}
 
源代码13 项目: fitnotifications   文件: AppSettingsActivity.java
@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);
        }
    }
}
 
源代码14 项目: microMathematics   文件: AdapterBaseImpl.java
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;
}
 
源代码15 项目: NightWatch   文件: BaseWatchFace.java
@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();
}
 
源代码16 项目: NightWatch   文件: BaseWatchFace.java
@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();
}
 
源代码17 项目: xDrip   文件: BgGraphBuilder.java
@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;
    }*/
}
 
源代码18 项目: xDrip-plus   文件: BgGraphBuilder.java
@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;
    }*/
}
 
源代码19 项目: NightWatch   文件: BIGChart.java
@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");
    }
}
 
源代码20 项目: NightWatch   文件: BIGChart.java
@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");
    }
}