Example usage for android.text.format Time Time

List of usage examples for android.text.format Time Time

Introduction

In this page you can find the example usage for android.text.format Time Time.

Prototype

public Time(Time other) 

Source Link

Document

A copy constructor.

Usage

From source file:ti.android.ble.devicemonitor.ServiceView.java

private String timeNowStr() {
    Time now = new Time(Time.getCurrentTimezone());
    now.setToNow();//from   w  w w . j  a  v a2 s . co m
    return now.format("%k:%M:%S") + ": ";
}

From source file:com.jogden.spunkycharts.traditionalchart.TraditionalChartFragmentAdapter.java

@Override
public void update(DataClientInterface dataClient, DataConsumerInterface.InsertCallback iCallback) {

    Pair<OHLC, Time> pricePair = dataClient.getLast(_symbol, DataClientLocalDebug.DATA_PRICE_DEF);
    Pair<Integer, Time> volPair = dataClient.getLast(_symbol, DataClientLocalDebug.DATA_VOL_DEF);

    OHLC price = new OHLC(pricePair.first);
    int vol = volPair.first.intValue();
    Time time = new Time(pricePair.second);

    /* if we've rolled past TIME_GRANULARITY */
    if (_hasSegment.get() && _segHasRolled(_lastGranularSegTime, time, DataClientInterface.TIME_GRANULARITY)) {
        /* cache penultimate values */
        _penultGranularPriceSeg = new OHLC(_lastGranularPriceSeg);
        _penultGranularVolSeg = _lastGranularVolSeg;
        _penultGranularSegTime.set(_lastGranularSegTime);

        iCallback.insertRow(//from w  w w  .  j  a va 2 s  .co m
                _createContentValues(_lastGranularPriceSeg, _lastGranularVolSeg, _lastGranularSegTime), _symbol,
                (DataConsumerInterface) this);
        _lastVolPartialCummulative += _lastGranularVolSeg;
        _lastGranularSegTime = _truncateTime(time, GMS, true, false); /*
                                                                      Log.d("Data-Consumer-Update-DB", 
                                                                      _lastGranularSegTime.format("%H:%M:%S")
                                                                      );   */
    }
    _lastGranularPriceSeg = new OHLC(price);
    _lastGranularVolSeg = vol;

    /* BE SURE TO CALLBACK TO DATABASE and
     * SET _lastGranular... CACHE VALS, REGARDLESS; */
    /* then we can leave if necessary */
    try {
        if (!_updateLtch.await(ApplicationPreferences.getShortTimeout(), TimeUnit.MILLISECONDS)
                || _myCursor == null)
            return;
    } catch (InterruptedException e) {
        return;
    }

    /* if everything else is shut down bail so we don't
     *  block on the synchronous queue  */
    if (!_streamReady.get()) {
        _updateTime.set(time);
        return;
    }

    /* value depends on if we've rolled to a new full seg */
    int fullSegVol = 0;

    /* if we've rolled past Chart Frequency Value */
    if (_segHasRolled(_lastSegTime, time, _chartFreq.value) || !_hasSegment.get()) {
        try {
            fullSegVol = vol;
            _lastVolPartialCummulative = 0;
            Time tTime = _truncateTime(time, MSPM * _chartFreq.value, true, false);
            _lastSegTime.set(tTime);

            // _timeStampQueue.put( tTime.format("%H:%M") );      
            /* time must come first since it may fill gaps in price/vol */
            try {
                _populateLck.lock();
                _putTime(tTime);
                _ohlcQueue.put(new OHLC(price));
                _volumeQueue.put(fullSegVol);
            } finally {
                _populateLck.unlock();
            }
            /*                            
            Log.d("Data-Consumer-Update-New", 
                price.toString() + "   " +
                String.valueOf(vol) + "   " +
                tTime.format("%H:%M:%S")); */
        } catch (InterruptedException e) {
        }
    } else {
        fullSegVol = vol + _lastVolPartialCummulative;
        _priceSgmnt.update(price.close);
        _volumeSgmnt.update(fullSegVol);
        _lastPriceSeg.close = price.close;
        if (price.high > _lastPriceSeg.high)
            _lastPriceSeg.high = price.high;
        if (price.low < _lastPriceSeg.low)
            _lastPriceSeg.low = price.low;
        _lastVolSeg = fullSegVol; /*
                                  Log.d("Data-Consumer-Update-Current", 
                                  _lastPriceSeg.toString() + "    "
                                  + String.valueOf(_lastVolSeg) + "   " 
                                  +time.format("%H:%M:%S"));            */
    }

    if (price.high > _highPrice) {
        Intent iii = new Intent(HighLowChange.NEW_HIGH_PRICE);
        iii.putExtra(HighLowChange.EXTRA_VALUE, price.high);
        iii.putExtra(HighLowChange.FRAGMENT_ID, _myId);
        _localBcastMngr.sendBroadcast(iii);
    }
    if (price.low < _lowPrice) {
        Intent iii = new Intent(HighLowChange.NEW_LOW_PRICE);
        iii.putExtra(HighLowChange.EXTRA_VALUE, price.low);
        iii.putExtra(HighLowChange.FRAGMENT_ID, _myId);
        _localBcastMngr.sendBroadcast(iii);
    }
    if (fullSegVol > _highVolume) {
        Intent iii = new Intent(HighLowChange.NEW_HIGH_VOL);
        iii.putExtra(HighLowChange.EXTRA_VALUE, fullSegVol);
        iii.putExtra(HighLowChange.FRAGMENT_ID, _myId);
        _localBcastMngr.sendBroadcast(iii);
        ;
    }
    _updateTime.set(time);
}

From source file:com.bookkos.bircle.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    _context = getApplicationContext();/*from  w w  w  . j a v a  2s .co m*/
    _activity = this;

    currentTime = new Time("Asia/Tokyo");

    //      exceptionHandler = new ExceptionHandler(_context);   
    //      Thread.setDefaultUncaughtExceptionHandler(exceptionHandler);

    // sharedPreference???, user_id?group_id?registration_id??
    getUserData();

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // ??
    WindowManager window_manager = getWindowManager();
    Display display = window_manager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    displayWidth = point.x;
    displayHeight = point.y;

    displayInch = getInch();
    // ??4???????
    textSize = 17 * (displayInch / 4);

    actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    String title_text = "";
    subGroupText = "";
    groupText = groupName;

    if (displayInch < 4.7) {
        title_text = "<small><small><small>??: </small></small></small>";
        resizeTitleSizeTooSmall();
    } else if (displayInch >= 4.7 && displayInch < 5.5) {
        title_text = "<small><small>??: </small></small>";
        resizeTitleSizeSmall();
    } else if (displayInch >= 5.5 && displayInch < 6.5) {
        title_text = "<small>??: </small>";
        resizeTitleSizeMiddle();
    } else if (displayInch >= 6.5 && displayInch < 8) {
        title_text = "<small>??: </small>";
        resizeTitleSizeLarge();
    } else {
        title_text = "??: ";
    }
    String modify_group_text = title_text + "<font color=#FF0000>" + groupName + "</font>";
    actionBar.setTitle(Html.fromHtml(modify_group_text));

    Resources resources = _context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    titleBarHeight = resources.getDimensionPixelSize(resourceId);

    setContentView(R.layout.capture);

    returnBorrowHelpView = (ImageView) findViewById(R.id.return_borrow_help_view);
    returnBorrowHelpView.setImageResource(R.drawable.return_borrow_help);
    returnBorrowHelpView.setTranslationY(displayHeight / 5 + titleBarHeight);
    returnBorrowHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth,
            displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER));

    registHelpView = (ImageView) findViewById(R.id.regist_help_view);
    registHelpView.setImageResource(R.drawable.regist_help);
    registHelpView.setTranslationY(displayHeight / 5 + titleBarHeight);
    registHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth,
            displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER));
    registHelpView.setVisibility(View.GONE);

    leftDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    leftDrawer = (ListView) findViewById(R.id.left_drawer);
    textView = (TextView) findViewById(R.id.textView);

    modeText = (TextView) findViewById(R.id.mode_text);
    modeText.setTextColor(Color.rgb(56, 234, 123));
    modeText.setTextSize(textSize);
    modeText.setTypeface(Typeface.SERIF.MONOSPACE, Typeface.BOLD);
    strokeColor = Color.rgb(56, 234, 123);

    borrowReturnButton = (Button) findViewById(R.id.borrowReturnButton);
    registButton = (Button) findViewById(R.id.registButton);
    returnHistoryButton = (Button) findViewById(R.id.return_history_button);
    helpViewButton = (Button) findViewById(R.id.help_view_button);

    registSelectShelfRelativeLayout = (RelativeLayout) findViewById(R.id.regist_select_shelf_relative_layout);
    textViewLinearLayout = (LinearLayout) findViewById(R.id.text_view_linear_layout);
    buttonLinearLayout = (LinearLayout) findViewById(R.id.button_linear_layout);
    listViewLinearLayout = (LinearLayout) findViewById(R.id.list_view_linear_layout);
    decisionButton = (Button) findViewById(R.id.decision_button);
    cancelButton = (Button) findViewById(R.id.cancel_button);
    shelfListView = (ListView) findViewById(R.id.shelf_list_view);
    tempTextView = (TextView) findViewById(R.id.temp_text_view);
    //      bookListViewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    bookListViewAdapter = new BookListViewAdapter(_context, R.layout.book_list_row, this);

    bookRegistRelativeLayout = (RelativeLayout) findViewById(R.id.book_regist_relative_layout);
    bookRegistLinearLayout = (LinearLayout) findViewById(R.id.book_regist_linear_layout);
    bookRegistListViewLinearLayout = (LinearLayout) findViewById(R.id.book_regist_list_view_linear_layout);
    bookRegistListView = (ListView) findViewById(R.id.book_regist_list_view);
    bookRegistTextView = (TextView) findViewById(R.id.book_regist_text_view);
    bookRegistCancelButton = (Button) findViewById(R.id.book_regist_cancel_button);

    registFlag = 0;

    int borrowReturnButton_width = displayWidth / 5 * 2;
    int borrowReturnButton_height = displayHeight / 10;
    int borrowReturnButton_x = ((displayWidth / 2) - borrowReturnButton_width) / 2;
    int borrowReturnButton_y = displayHeight / 2 + titleBarHeight;
    borrowReturnButton.setTranslationX(borrowReturnButton_x);
    borrowReturnButton.setTranslationY(borrowReturnButton_y);
    borrowReturnButton
            .setLayoutParams(new FrameLayout.LayoutParams(borrowReturnButton_width, borrowReturnButton_height));
    borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123));
    borrowReturnButton.setText("??\n");
    borrowReturnButton.setTextSize(textSize * 7 / 10);
    borrowReturnButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            arrayList.clear();
            registFlag = 0;

            borrowReturnButton.setText("??\n");
            borrowReturnButton.setEnabled(false);
            borrowReturnButton.setTextColor(Color.WHITE);
            borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123));

            registButton.setText("?\n??");
            registButton.setEnabled(true);
            registButton.setTextColor(Color.GRAY);
            registButton.setBackgroundColor(Color.argb(170, 21, 38, 45));

            modeText.setText("??");
            modeText.setTextColor(Color.rgb(56, 234, 123));
            returnBorrowHelpView.setVisibility(View.VISIBLE);
            registHelpView.setVisibility(View.GONE);
            strokeColor = Color.rgb(56, 234, 123);
        }
    });

    int registButton_width = displayWidth / 5 * 2;
    int registButton_height = displayHeight / 10;
    int registButton_x = (displayWidth / 2) + ((displayWidth / 2) - registButton_width) / 2;
    int registButton_y = displayHeight / 2 + titleBarHeight;
    registButton.setTranslationX(registButton_x);
    registButton.setTranslationY(registButton_y);
    registButton.setLayoutParams(new FrameLayout.LayoutParams(registButton_width, registButton_height));
    registButton.setBackgroundColor(Color.argb(170, 21, 38, 45));
    registButton.setTextColor(Color.GRAY);
    registButton.setTextSize(textSize * 7 / 10);
    registButton.setText("?\n??");
    registButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            arrayList.clear();
            registFlag = 1;

            borrowReturnButton.setText("??\n??");
            borrowReturnButton.setEnabled(true);
            borrowReturnButton.setTextColor(Color.GRAY);
            borrowReturnButton.setBackgroundColor(Color.argb(170, 9, 54, 16));

            registButton.setText("?\n");
            registButton.setEnabled(false);
            registButton.setTextColor(Color.WHITE);
            registButton.setBackgroundColor(Color.rgb(62, 162, 229));

            modeText.setText("?");
            modeText.setTextColor(Color.rgb(62, 162, 229));
            returnBorrowHelpView.setVisibility(View.GONE);
            registHelpView.setVisibility(View.VISIBLE);
            strokeColor = Color.rgb(62, 162, 229);
        }
    });

    returnHistoryButton.setText("????");
    returnHistoryButton.setTextSize(textSize * 7 / 10);
    returnHistoryButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            leftDrawerLayout.openDrawer(Gravity.RIGHT);
            //            animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight);
        }
    });
    getReturnHistory();
    getCurrentTime();

    setHelpView();
    setScanUnregisterBookView();
    setBookRegistView();

    arrayList = new ArrayList<String>();
    tempRegistIsbn = "";

    initBookRegistUrl = book_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initLendRegistUrl = lend_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initTemporaryLendRegistUrl = temporary_lend_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initCatalogRegistUrl = catalog_register_url + "?group_id=" + groupId + "&book_code=";
    initManuallyCatalogRegistUrl = manually_catalog_register_url + "?group_id=" + groupId + "&book_code=";
    getStatusUrl = get_status_url + "?group_id=" + groupId + "&user_id=" + userId;

    hasSurface = false;

    inactivityTimer = new InactivityTimer(this);
    bircleBeepManager = new BircleBeepManager(this);
    ambientLightManager = new AmbientLightManager(this);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    toastText = "";
}

From source file:com.android.deskclock.Utils.java

public static void setMidnightUpdater(Handler handler, Runnable runnable) {
    String timezone = TimeZone.getDefault().getID();
    if (handler == null || runnable == null || timezone == null) {
        return;//from  www .j a va 2 s .co m
    }
    long now = System.currentTimeMillis();
    Time time = new Time(timezone);
    time.set(now);
    long runInMillis = ((24 - time.hour) * 3600 - time.minute * 60 - time.second + 1) * 1000;
    handler.removeCallbacks(runnable);
    handler.postDelayed(runnable, runInMillis);
}

From source file:io.doist.datetimepicker.date.SimpleMonthView.java

/**
 * Sets all the parameters for displaying this week. Parameters have a default value and
 * will only update if a new value is included, except for focus month, which will always
 * default to no focus month if no value is passed in. The only required parameter is the
 * week start.// w  w w.  j a v a2  s .  c  o m
 *
 * @param selectedDay the selected day of the month, or -1 for no selection.
 * @param month the month.
 * @param year the year.
 * @param weekStart which day the week should start on. {@link Calendar#SUNDAY} through
 *        {@link Calendar#SATURDAY}.
 * @param enabledDayStart the first enabled day.
 * @param enabledDayEnd the last enabled day.
 */
void setMonthParams(int selectedDay, int month, int year, int weekStart, int enabledDayStart,
        int enabledDayEnd) {
    if (mRowHeight < MIN_HEIGHT) {
        mRowHeight = MIN_HEIGHT;
    }

    mSelectedDay = selectedDay;

    if (isValidMonth(month)) {
        mMonth = month;
    }
    mYear = year;

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (isValidDayOfWeek(weekStart)) {
        mWeekStart = weekStart;
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    if (enabledDayStart > 0 && enabledDayEnd < 32) {
        mEnabledDayStart = enabledDayStart;
    }
    if (enabledDayEnd > 0 && enabledDayEnd < 32 && enabledDayEnd >= enabledDayStart) {
        mEnabledDayEnd = enabledDayEnd;
    }

    mNumCells = getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

From source file:org.dmfs.webcal.fragments.CalendarItemFragment.java

@Override
public View onCreateItemView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View returnView = inflater.inflate(R.layout.fragment_calendar_item, container, false);

    // TODO: don't put the progress indicator into the header view
    View progressView = inflater.inflate(R.layout.progress_indicator, null, false);

    mProgressBar = (ProgressBar) progressView.findViewById(android.R.id.progress);

    mListView = (ListView) returnView.findViewById(android.R.id.list);

    mListView.addHeaderView(progressView);
    mListView.setOnItemClickListener(this);
    mListView.setHeaderDividersEnabled(false);
    mListAdapter = new EventListAdapter(inflater.getContext(), null);
    mListView.setAdapter(mSectionAdapter = new SectionTitlesAdapter(inflater.getContext(), mListAdapter,
            new SectionIndexer() {

                @Override//from  w  w  w . ja va2  s.c  o  m
                public String getSectionTitle(int index) {
                    Time start = new Time(TimeZone.getDefault().getID());
                    start.set(index & 0x00ff, (index >> 8) & 0x00ff, (index >> 16) & 0x0ffff);

                    return DateUtils.formatDateTime(getActivity(), start.toMillis(true),
                            DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
                                    | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY);
                }

                @Override
                public int getSectionIndex(Object object) {
                    Cursor cursor = (Cursor) object;

                    Time start = new Time(
                            cursor.getString(cursor.getColumnIndex(WebCalReaderContract.Events.TIMZONE)));
                    start.set(cursor.getLong(cursor.getColumnIndex(WebCalReaderContract.Events.DTSTART)));
                    boolean allday = cursor
                            .getInt(cursor.getColumnIndex(WebCalReaderContract.Events.IS_ALLDAY)) == 1;
                    start.allDay = allday;

                    // we return an encoded date as index
                    return (start.year << 16) + (start.month << 8) + start.monthDay;

                }
            }, R.layout.events_preview_list_section_header));

    FragmentManager fm = getChildFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();

    mTitleFragment = (CalendarTitleFragment) fm.findFragmentById(R.id.calendar_title_fragment_container);
    if (mTitleFragment == null) {
        mTitleFragment = CalendarTitleFragment.newInstance();
        ft.replace(R.id.calendar_title_fragment_container, mTitleFragment);
    }

    if (!ft.isEmpty()) {
        ft.commit();
    }

    LoaderManager lm = getLoaderManager();
    lm.initLoader(LOADER_CALENDAR_ITEM, null, this);
    lm.initLoader(LOADER_SUBSCRIBED_CALENDAR, null, this);
    lm.initLoader(LOADER_SUBSCRIPTION, null, this);

    // set this to true, so the menu is cleared automatically when leaving the fragment, otherwise the star icon will stay visible
    setHasOptionsMenu(true);

    return returnView;
}

From source file:org.holoeverywhere.widget.datetimepicker.date.SimpleMonthView.java

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *               {@link #VIEW_PARAMS_HEIGHT}
 *//*  ww w.  j a va 2s .co  m*/
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = DateTimePickerUtils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mNodeProvider.invalidateParent();
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }/*w  w  w.  j a v a2 s .co m*/
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Check and ask for most needed permissions
    checkAppPermissions();

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one_material);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);

    mFab = (FloatingActionButton) findViewById(R.id.floating_action_button);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    setupToolbar(viewType);
    setupNavDrawer();
    setupFloatingActionButton();

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}

From source file:app.android.datetimepicker.date.SimpleMonthView.java

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *            {@link #VIEW_PARAMS_HEIGHT}
 *//*w ww. j a  v  a2  s. c  o  m*/
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

From source file:com.intel.RtcPingDownloadTester.java

private void update_conole_writeln(String line) {
    Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();/* w ww  . j  a v a  2  s  . com*/
    if (full_lines >= 10) {
        full_lines = 0;
        string_console_text = "";
    }
    full_lines++;
    string_console_text += today.format("%k:%M:%S") + ": " + line + "\n";
    label_console_box.setText(string_console_text);
}