Пример #1
0
  public static byte[] getCurrentTimeData() {
    /*
     * org.bluetooth.characteristic.current_time
     * - Exact Time 256: org.bluetooth.characteristic.exact_time_256
     *   - Day Date Time: org.bluetooth.characteristic.day_date_time
     *     - Date Time: org.bluetooth.characteristic.date_time
     *       - Year: uint16
     *       - Month: uint8
     *       - Day: uint8
     *       - Hours: uint8
     *       - Minutes: uint8
     *       - Seconds: uint8
     *     - Day of Week: org.bluetooth.characteristic.day_of_week
     *       - uint8
     *   - Fractions256: uint8
     * - Adjust Reason: 8bit
     */
    Time currentTime = new Time();
    currentTime.setToNow();

    byte[] timeData = new byte[10];
    timeData[0] = (byte) (currentTime.year % 256);
    timeData[1] = (byte) (currentTime.year / 256);
    timeData[2] = (byte) (currentTime.month + 1);
    timeData[3] = (byte) (currentTime.monthDay);
    timeData[4] = (byte) (currentTime.hour);
    timeData[5] = (byte) (currentTime.minute);
    timeData[6] = (byte) (currentTime.second);
    timeData[7] = (byte) (currentTime.weekDay + 1);
    timeData[8] = 0;
    timeData[9] = 0;

    return timeData;
  }
Пример #2
0
 protected void doTakePhoto() {
   try {
     // Launch camera to take photo for selected contact
     PHOTO_DIR.mkdirs(); // 创建照片的存储目录
     Time t = new Time();
     t.setToNow();
     String year = String.valueOf(t.year);
     String month = String.valueOf(t.month + 1);
     String day = String.valueOf(t.monthDay);
     String hour;
     if (t.hour < 10) {
       hour = "0" + String.valueOf(t.hour);
     } else {
       hour = String.valueOf(t.hour);
     }
     String minute;
     if (t.minute < 10) {
       minute = "0" + String.valueOf(t.minute);
     } else {
       minute = String.valueOf(t.minute);
     }
     String second;
     if (t.second < 10) {
       second = "0" + String.valueOf(t.second);
     } else {
       second = String.valueOf(t.second);
     }
     String filenameString = "lily_" + year + month + day + hour + minute + second + ".jpeg";
     File outFile = new File(PHOTO_DIR, filenameString);
     final Intent intent = getTakePickIntent(outFile);
     startActivityForResult(intent, CAMERA_WITH_DATA);
   } catch (ActivityNotFoundException e) {
     Toast.makeText(this, "无法创建图片", Toast.LENGTH_LONG).show();
   }
 }
Пример #3
0
  public static long normalizeDate(long startDate) {

    Time time = new Time();
    time.set(startDate);
    int julianDay = Time.getJulianDay(startDate, time.gmtoff);
    return time.setJulianDay(julianDay);
  }
 public static String getCurYearAndMonth() {
   Time time = new Time();
   time.setToNow();
   int year = time.year;
   int month = time.month + 1;
   return year + "_" + month;
 }
Пример #5
0
  public static String time2String4Trans(long t, Context context) {
    String CURRENT_YEAR = "MM-dd HH:mm";
    String BEFORE_YEAR = "yyyy-MM-dd HH:mm";
    String lRecentDateString = "";
    String lDateTimeFormat = " HH:mm";
    long currTime = System.currentTimeMillis();
    Time time = new Time();
    time.set(currTime);
    int currYear = time.year;
    int currDay = time.yearDay;
    time.set(t);
    int day = time.yearDay;
    if (day == currDay) {
      //            	lRecentDateString= context.getString(R.string.list_today_format);
    } else if (currDay - day == 1) {
      //            	lRecentDateString= context.getString(R.string.list_yesterday_format);
    } else {
      lRecentDateString = "";
      if (time.year < currYear) {
        lDateTimeFormat = BEFORE_YEAR;
      } else {
        lDateTimeFormat = CURRENT_YEAR;
      }
    }

    SimpleDateFormat df = new SimpleDateFormat(lDateTimeFormat);
    return lRecentDateString + df.format(new Date(t));
  }
Пример #6
0
 /**
  * This is a method that should be used across the entire porject to format times so they can be
  * sorted by a TreeMap. If all the Time objects have the same date and seconds then when converted
  * to millis they will be in a natural, easy to sort format.
  *
  * @param hour The hour value of the time object to be returned
  * @param min The minutes value of the time object to be returned
  * @return Time formatted to epoch with custom hour and min.
  */
 public static Time normalizeToScharingTime(int hour, int min) {
   Time t = new Time();
   // epoch day, custom hour and minutes
   // set time to sec, min, hour, day, month, year
   t.set(00, min, hour, 1, 1, 1970);
   return t;
 }
Пример #7
0
  private void setWhenDefaults() {
    // it's possible to have:
    // 1) no times set
    // 2) due time set, but not start time
    // 3) start and due time set

    mShowStart = !Time.isEpoch(mStartTime);
    mShowDue = !Time.isEpoch(mDueTime);

    if (!mShowStart && !mShowDue) {
      mStartTime.setToNow();

      // Round the time to the nearest half hour.
      mStartTime.second = 0;
      int minute = mStartTime.minute;
      if (minute > 0 && minute <= 30) {
        mStartTime.minute = 30;
      } else {
        mStartTime.minute = 0;
        mStartTime.hour += 1;
      }

      long startMillis = mStartTime.normalize(true /* ignore isDst */);
      mDueTime.set(startMillis + DateUtils.HOUR_IN_MILLIS);
    } else if (!mShowStart) {
      // default start to same as due
      mStartTime.set(mDueTime);
    }
  }
Пример #8
0
  private long parse3339(String time) {
    if (time == null || time.length() == 0) {
      return 0;
    }

    if (timestamper != null) {
      try {
        timestamper.parse3339(time);
      } catch (TimeFormatException e) {
        parse_trace("got TimeFormatException parsing timestamp: \"" + time + '"');
        e.printStackTrace();
        return 0;
      }

      return timestamper.normalize(false);
    } else {
      Date timestamp = new Date();

      SimpleDateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
      rfc3339.setLenient(true);

      try {
        timestamp = rfc3339.parse(time);
      } catch (ParseException e) {
        parse_trace("got ParseException parsing timestamp: \"" + time + '"');
        e.printStackTrace();
        return 0;
      }

      return timestamp.getTime();
    }
  }
Пример #9
0
  @Override
  public Time get(ContentSet values) {
    Long timestamp = values.getAsLong(mTimestampField);
    if (timestamp == null) {
      // if the time stamp is null we return null
      return null;
    }
    // create a new Time for the given time zone, falling back to UTC if none is given
    String timezone = mTzField == null ? Time.TIMEZONE_UTC : values.getAsString(mTzField);
    Time value = new Time(timezone == null ? Time.TIMEZONE_UTC : timezone);
    // set the time stamp
    value.set(timestamp);

    // cache mAlldayField locally
    String allDayField = mAllDayField;

    // set the allday flag appropriately
    Integer allDayInt = allDayField == null ? null : values.getAsInteger(allDayField);

    if ((allDayInt != null && allDayInt != 0) || (allDayField == null && mAllDayDefault)) {
      value.set(value.monthDay, value.month, value.year);
      value.timezone = Time.TIMEZONE_UTC;
    }

    return value;
  }
Пример #10
0
 /*
  * Chargement des informations du reveil.
  * Ici pour la sauvegarde on a simplement déserialiser l'objet Alarm.
  */
 public void charger() {
   alarm = null;
   try {
     ObjectInputStream alarmOIS = new ObjectInputStream(context.openFileInput("alarm.serial"));
     try {
       alarm = (Alarm) alarmOIS.readObject();
     } finally {
       try {
         alarmOIS.close();
       } finally {;
       }
     }
   } catch (FileNotFoundException fnfe) {
     alarm = new Alarm();
     alarm.setActive(true);
     Time t = new Time();
     t.hour = 7;
     t.minute = 30;
     alarm.setHeure(t);
   } catch (IOException ioe) {
     ioe.printStackTrace();
   } catch (ClassNotFoundException cnfe) {
     cnfe.printStackTrace();
   }
 }
Пример #11
0
  @Override
  public Time get(Cursor cursor) {
    int tsIdx = cursor.getColumnIndex(mTimestampField);
    int tzIdx = mTzField == null ? -1 : cursor.getColumnIndex(mTzField);
    int adIdx = mAllDayField == null ? -1 : cursor.getColumnIndex(mAllDayField);

    if (tsIdx < 0 || (mTzField != null && tzIdx < 0) || (mAllDayField != null && adIdx < 0)) {
      throw new IllegalArgumentException("At least one column is missing in cursor.");
    }

    if (cursor.isNull(tsIdx)) {
      // if the time stamp is null we return null
      return null;
    }

    Long timestamp = cursor.getLong(tsIdx);

    // create a new Time for the given time zone, falling back to UTC if none is given
    String timezone = mTzField == null ? Time.TIMEZONE_UTC : cursor.getString(tzIdx);
    Time value = new Time(timezone == null ? Time.TIMEZONE_UTC : timezone);
    // set the time stamp
    value.set(timestamp);

    // set the allday flag appropriately
    Integer allDayInt = adIdx < 0 ? null : cursor.getInt(adIdx);

    if ((allDayInt != null && allDayInt != 0) || (mAllDayField == null && mAllDayDefault)) {
      value.set(value.monthDay, value.month, value.year);
    }
    return value;
  }
Пример #12
0
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   super.onPrepareDialog(id, dialog);
   switch (id) {
     case DATE_DIALOG_ID:
       // Handle any DatePickerDialog initialization here
       DatePickerDialog dateDialog = (DatePickerDialog) dialog;
       int iDay, iMonth, iYear;
       // Check for date of birth preference
       if (mGameSettings.contains(GAME_PREFERENCES_DOB)) {
         // Retrieve Birth date setting from preferences
         long msBirthDate = mGameSettings.getLong(GAME_PREFERENCES_DOB, 0);
         Time dateOfBirth = new Time();
         dateOfBirth.set(msBirthDate);
         iDay = dateOfBirth.monthDay;
         iMonth = dateOfBirth.month;
         iYear = dateOfBirth.year;
       } else {
         Calendar cal = Calendar.getInstance();
         // Today’s date fields
         iDay = cal.get(Calendar.DAY_OF_MONTH);
         iMonth = cal.get(Calendar.MONTH);
         iYear = cal.get(Calendar.YEAR);
       }
       // Set the date in the DatePicker to the date of birth OR to the
       // current date
       dateDialog.updateDate(iYear, iMonth, iDay);
       return;
   }
 }
Пример #13
0
 private static void a(Context paramContext, File paramFile) {
   FileOutputStream localFileOutputStream = new FileOutputStream(paramFile);
   byte[] arrayOfByte1 =
       Settings.Secure.getString(paramContext.getContentResolver(), "android_id").getBytes();
   Time localTime = new Time();
   localTime.setToNow();
   byte[] arrayOfByte2 = new byte[6 + arrayOfByte1.length];
   for (int i = 0; ; i++) {
     if (i >= arrayOfByte1.length) {
       int j = i + 1;
       arrayOfByte2[i] = ((byte) localTime.year);
       int k = j + 1;
       arrayOfByte2[j] = ((byte) localTime.month);
       int m = k + 1;
       arrayOfByte2[k] = ((byte) localTime.monthDay);
       int n = m + 1;
       arrayOfByte2[m] = ((byte) localTime.hour);
       int i1 = n + 1;
       arrayOfByte2[n] = ((byte) localTime.minute);
       arrayOfByte2[i1] = ((byte) localTime.second);
       String str = UUID.nameUUIDFromBytes(arrayOfByte2).toString();
       System.out.println("uuid.." + str);
       localFileOutputStream.write(str.getBytes());
       return;
     }
     arrayOfByte2[i] = arrayOfByte1[i];
   }
 }
Пример #14
0
  /** Return the time the workout was completed for a given workout id. */
  private Time getTimeForWorkout(int workoutId) {
    Cursor cursor = null;
    try {
      cursor =
          mDatabase.query(
              DATABASE_TABLE_WENDLER_WORKOUT,
              new String[] {KEY_WORKOUT_YEAR, KEY_WORKOUT_MONTH, KEY_WORKOUT_DAY},
              KEY_WORKOUT_ID + "=?",
              new String[] {String.valueOf(workoutId)},
              null,
              null,
              null);

      Time time = new Time();
      time.setToNow();
      if (cursor != null && cursor.moveToFirst()) {
        time.year = Integer.parseInt(cursor.getString(cursor.getColumnIndex(KEY_WORKOUT_YEAR)));
        time.month = Integer.parseInt(cursor.getString(cursor.getColumnIndex(KEY_WORKOUT_MONTH)));
        time.monthDay = Integer.parseInt(cursor.getString(cursor.getColumnIndex(KEY_WORKOUT_DAY)));
      }
      return time;
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.deviations_row);

    Log.d(TAG, "details!?");

    /*Bundle extras = getIntent().getExtras();
    Deviation deviation = extras.getParcelable(EXTRA_DEVIATION);
    if (extras.containsKey(EXTRA_DEVIATION_NOTIFICATION_ID)) {
        int notificationId = extras.getInt(EXTRA_DEVIATION_NOTIFICATION_ID);
        NotificationManager mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        mNotificationManager.cancel(notificationId);
    }*/

    final Uri uri = getIntent().getData();
    String header = uri.getQueryParameter("header");
    String details = uri.getQueryParameter("details");
    String scope = uri.getQueryParameter("scope");
    String reference = uri.getQueryParameter("reference");
    Time created = new Time();
    created.parse3339(uri.getQueryParameter("created"));
    int notificationId = Integer.parseInt(uri.getQueryParameter("notificationId"));

    TextView headerView = (TextView) findViewById(R.id.deviation_header);
    headerView.setText(header);
    TextView detailsView = (TextView) findViewById(R.id.deviation_details);
    detailsView.setText(details);
    TextView createdView = (TextView) findViewById(R.id.deviation_created);
    createdView.setText(created.format("%F %R"));

    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotificationManager.cancel(notificationId);
  }
Пример #16
0
 public int getDueDay() {
   Time time = getTime(taskData.end_date);
   Time now = new Time();
   now.setToNow();
   long diff = time.toMillis(true) - now.toMillis(true);
   return (int) (diff / (1000 * 60 * 60 * 24));
 }
Пример #17
0
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked) {
      if (mDueTime.hour == 0 && mDueTime.minute == 0) {
        mDueTime.monthDay--;

        // Do not allow an event to have an end time before the start time.
        if (mDueTime.before(mStartTime)) {
          mDueTime.set(mStartTime);
        }
      }
    } else {
      if (mDueTime.hour == 0 && mDueTime.minute == 0) {
        mDueTime.monthDay++;
      }
    }

    mShowStart = true;
    long startMillis = mStartTime.normalize(true);
    setDate(mStartDateButton, startMillis, mShowStart);
    setTime(mStartTimeButton, startMillis, mShowStart);

    mShowDue = true;
    long dueMillis = mDueTime.normalize(true);
    setDate(mDueDateButton, dueMillis, mShowDue);
    setTime(mDueTimeButton, dueMillis, mShowDue);

    updateTimeVisibility(!isChecked);
  }
Пример #18
0
 @Override
 protected void onResume() {
   super.onResume();
   AppMeasurementUtils appMeasurementProm = new AppMeasurementUtils(NewLimitbuyActivity.this);
   appMeasurementProm.getUrl(
       getString(R.string.appMeas_actiCenter) + ":" + getString(R.string.appMeas_groupprom),
       getString(R.string.appMeas_actiCenter),
       getString(R.string.appMeas_actiCenter) + ":" + getString(R.string.appMeas_groupprom),
       getString(R.string.appMeas_groupprom),
       "",
       "",
       "",
       "",
       "",
       "",
       "",
       "",
       getString(R.string.appMeas_myprom),
       "",
       "",
       "",
       null);
   Time t2 = new Time();
   t2.setToNow();
   boolean isorNo = t2.after(t);
   if (isorNo) {
     setData(true, true);
     BDebug.d("liuyang", "我也执行了");
     t.set(0, 0, 24, t2.monthDay, t2.month, t2.year);
   }
 }
Пример #19
0
  /**
   * Helper method to convert the database representation of the date into something to display to
   * users. As classy and polished a user experience as "20140102" is, we can do better.
   *
   * @param context Context to use for resource localization
   * @param dateInMillis The date in milliseconds
   * @return a user-friendly representation of the date.
   */
  public static String getFriendlyDayString(Context context, long dateInMillis) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"

    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);

    // If the date we're building the String for is today's date, the format
    // is "Today, June 24"
    if (julianDay == currentJulianDay) {
      String today = context.getString(R.string.today);
      int formatId = R.string.format_full_friendly_date;
      return String.format(
          context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
      // If the input date is less than a week in the future, just return the day name.
      return getDayName(context, dateInMillis);
    } else {
      // Otherwise, use the form "Mon Jun 3"
      SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
      return shortenedDateFormat.format(dateInMillis);
    }
  }
Пример #20
0
 public static int a(long paramLong1, long paramLong2) {
   Time localTime = new Time();
   localTime.set(paramLong1);
   int i = (int) ((paramLong1 + 1000L * localTime.gmtoff) / 86400000L);
   localTime.set(paramLong2);
   return i - (int) ((paramLong2 + 1000L * localTime.gmtoff) / 86400000L);
 }
Пример #21
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
      convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_message, null);
    }

    final Status status = getItem(position);

    ((TextView) convertView.findViewById(R.id.list_item_status)).setText(status.getBody());

    final Time messageTime = status.getCreatedOn();
    if (messageTime != null) {
      ((TextView) convertView.findViewById(R.id.list_item_timestamp))
          .setText(messageTime.format("%B %d %Y, %r"));
    }

    ViewUtils.setVisibility(convertView.findViewById(R.id.status_bar_top), position != 0);
    ViewUtils.setVisibility(
        convertView.findViewById(R.id.status_bar_bottom), position != getCount() - 1);

    final int statusColour = ViewUtils.resolveStatusColour(getContext(), status);

    final View statusIndicator = convertView.findViewById(R.id.status_indicator_circle);
    final Drawable drawable = statusIndicator.getBackground();
    drawable.mutate().setColorFilter(statusColour, PorterDuff.Mode.SRC_ATOP);
    statusIndicator.setBackgroundDrawable(drawable);

    return convertView;
  }
 @Override
 protected void updateQueryParameters(QueryParams params) {
   if (params.getUpdatedMin() == null) {
     // if this is the first sync, only bother syncing starting from
     // one month ago.
     // TODO: remove this restriction -- we may want all of
     // historical calendar events.
     Time lastMonth = new Time(Time.TIMEZONE_UTC);
     lastMonth.setToNow();
     --lastMonth.month;
     lastMonth.normalize(true /* ignore isDst */);
     String startMin = lastMonth.format("%Y-%m-%dT%H:%M:%S.000Z");
     // TODO: move start-min to CalendarClient?
     // or create CalendarQueryParams subclass (extra class)?
     params.setParamValue("start-min", startMin);
     // HACK: specify that we want to expand recurrences ijn the past,
     // so the server does not expand any recurrences.  we do this to
     // avoid a large number of gd:when elements that we do not need,
     // since we process gd:recurrence elements instead.
     params.setParamValue("recurrence-expansion-start", "1970-01-01");
     params.setParamValue("recurrence-expansion-end", "1970-01-01");
   }
   // we want to get the events ordered by last modified, so we can
   // recover in case we cannot process the entire feed.
   params.setParamValue("orderby", "lastmodified");
   params.setParamValue("sortorder", "ascending");
 }
Пример #23
0
  public static String formatTimeStampString(Context context, long when, boolean fullFormat) {
    Time then = new Time();
    then.set(when);
    Time now = new Time();
    now.setToNow();

    // Basic settings for formatDateTime() we want for all cases.
    int format_flags =
        DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM;

    // If the message is from a different year, show the date and year.
    if (then.year != now.year) {
      format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
      // If it is from a different day than today, show only the date.
      format_flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
      // Otherwise, if the message is from today, show the time.
      format_flags |= DateUtils.FORMAT_SHOW_TIME;
    }

    // If the caller has asked for full details, make sure to show the date
    // and time no matter what we've determined above (but still make showing
    // the year only happen if it is a different year from today).
    if (fullFormat) {
      format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
    }

    return DateUtils.formatDateTime(context, when, format_flags);
  }
Пример #24
0
  @Override
  public NdefMessage createNdefMessage(NfcEvent event) {
    Log.d("ANDROID_LAB", "createNdefMessage thread.name=" + Thread.currentThread().getName());
    StringBuilder sb = new StringBuilder();
    sb.append(Build.MODEL + "("); // 手机型号
    sb.append(Build.VERSION.SDK_INT + ","); // SDK版本号
    sb.append(Build.VERSION.RELEASE + ")"); // Firmware/OS 版本号

    sb.append("发送来一条NFC消息, 时间是");
    Time time = new Time();
    time.setToNow();
    sb.append(time.format("%H:%M:%S"));

    Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.and);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] bmpData = baos.toByteArray();

    NdefRecord[] records = new NdefRecord[2];
    records[0] =
        NdefRecord.createMime("application/lab.sodino.nfc", sb.toString().getBytes()); // 文本消息
    records[1] = NdefRecord.createMime("application/lab.sodino.nfc", bmpData); // 图片消息
    //		records[2] = NdefRecord.createApplicationRecord("com.tencent.mobileqq");

    NdefMessage msg = new NdefMessage(records);

    return msg;
  }
 // To make it easy to query for the exact date, we normalize all dates that go into
 // the database to the start of the the Julian day at UTC.
 public static long normalizeDate(long startDate) {
   // normalize the start date to the beginning of the (UTC) day
   Time time = new Time();
   time.set(startDate);
   int julianDay = Time.getJulianDay(startDate, time.gmtoff);
   return time.setJulianDay(julianDay);
 }
Пример #26
0
 /**
  * Converts db date format to the format "Month day", e.g "June 24".
  *
  * @param context Context to use for resource localization
  * @param dateInMillis The db formatted date string, expected to be of the form specified in
  *     Utility.DATE_FORMAT
  * @return The day in the form of a string formatted "December 6"
  */
 public static String getFormattedMonthDay(Context context, long dateInMillis) {
   Time time = new Time();
   time.setToNow();
   SimpleDateFormat dbDateFormat = new SimpleDateFormat(Utility.DATE_FORMAT);
   SimpleDateFormat monthDayFormat = new SimpleDateFormat("MMMM dd");
   String monthDayString = monthDayFormat.format(dateInMillis);
   return monthDayString;
 }
Пример #27
0
 protected void log(boolean error, String msg) {
   android.text.format.Time time = new android.text.format.Time();
   time.setToNow();
   Log.i(TAG, "log: " + msg);
   log.append(COLOR_TIME, time.format("%H:%M:%S\t"))
       .append(error ? COLOR_ERROR : COLOR_LOG, msg)
       .append("\n");
 }
Пример #28
0
 private void saveListTime() {
   Time curTime = new Time();
   String curDateString = curTime.format("yyyyMMdd");
   SharedPreferences sharedPrefer = PreferenceManager.getDefaultSharedPreferences(mContext);
   Editor edit = sharedPrefer.edit();
   edit.putString(HOT_LIST_DATE, curDateString);
   edit.commit();
 }
Пример #29
0
 @Override
 public void onPause() {
   super.onPause();
   Time tm = new Time();
   tm.setToNow();
   beforeSuspend = tm.minute * 60 + tm.second;
   tm1.append("\nGoto Suspend time: " + beforeSuspend);
 }
Пример #30
0
 // 获得20150926格式的当前日期
 public static int getCurrentTime() {
   Time time = new Time("GMT+8");
   time.setToNow();
   int year = time.year * 10000;
   int month = (time.month + 1) * 100;
   int day = time.monthDay;
   return year + month + day;
 }