Example usage for android.widget TimePicker getWindowToken

List of usage examples for android.widget TimePicker getWindowToken

Introduction

In this page you can find the example usage for android.widget TimePicker getWindowToken.

Prototype

public IBinder getWindowToken() 

Source Link

Document

Retrieve a unique token identifying the window this view is attached to.

Usage

From source file:net.czlee.debatekeeper.DebatingActivity.java

/**
 * Finishes editing the current time and restores the GUI to its prior state.
 * @param save true if the edited time should become the new current time, false if it should
 * be discarded./*from  w w w .  j a va 2 s  . c om*/
 */
private void editCurrentTimeFinish(boolean save) {

    TimePicker currentTimePicker = (TimePicker) mDebateTimerDisplay
            .findViewById(R.id.debateTimer_currentTimePicker);

    if (currentTimePicker == null) {
        Log.e(TAG, "editCurrentTimeFinish: currentTimePicker was null");
        return;
    }

    currentTimePicker.clearFocus();

    // Hide the keyboard
    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(currentTimePicker.getWindowToken(), 0);

    if (save && mDebateManager != null && mIsEditingTime) {
        // We're using this in hours and minutes, not minutes and seconds
        int minutes = currentTimePicker.getCurrentHour();
        int seconds = currentTimePicker.getCurrentMinute();
        long newTime = minutes * 60 + seconds;
        // Invert the time if in count-down mode
        newTime = subtractFromSpeechLengthIfCountingDown(newTime);
        mDebateManager.setActivePhaseCurrentTime(newTime);
    }

    mIsEditingTime = false;

    updateGui();

}