Example usage for android.widget LinearLayout getChildCount

List of usage examples for android.widget LinearLayout getChildCount

Introduction

In this page you can find the example usage for android.widget LinearLayout getChildCount.

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:com.cairoconfessions.MainActivity.java

public void onNavigationDrawerItemSelected(int position) {
    LinearLayout confessions = (LinearLayout) findViewById(R.id.confession_list);
    switch (position) {
    case 0:/* w ww . j  a  va  2 s  .co m*/
        mTitle = "Cairo Confessions";
        for (int i = 0; i < confessions.getChildCount(); i++)
            if (((TextView) confessions.getChildAt(i).findViewById(R.id.follow_button)).getText()
                    .equals("Follow"))
                confessions.getChildAt(i).setVisibility(View.VISIBLE);
        updateFilters();
        break;
    case 1:
        mTitle = getString(R.string.title_section1);
        break;
    case 2:
        mTitle = getString(R.string.title_section2);
        for (int i = 0; i < confessions.getChildCount(); i++)
            if (((TextView) confessions.getChildAt(i).findViewById(R.id.follow_button)).getText()
                    .equals("Follow"))
                confessions.getChildAt(i).setVisibility(View.GONE);
        updateFilters();
        break;
    case 3:
        mTitle = getString(R.string.title_section3);
        getMessages();
        break;
    case 4:
        getSettings();
        break;

    }
}

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

/**
 * Iterate through all the measures and return a list of measure tag group objects.
 * The list is serialized out to the .retro project file.
 * @return ArrayList<MeasureTagGroup>
 *///from   w  ww  .j a  v  a2 s . c  o m

private ArrayList<MeasureTagGroup> getMeasureTags() {

    ArrayList<MeasureTagGroup> mtaglist = new ArrayList<>();

    LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout);

    //iterate through all the measures
    for (int t = 0; t < track_layout.getChildCount(); t++) {
        //get hscrollview
        HorizontalScrollView hchild = (HorizontalScrollView) track_layout.getChildAt(t);
        for (int h = 0; h < hchild.getChildCount(); h++) {
            //get gridlayout
            GridLayout gchild = (GridLayout) hchild.getChildAt(h);
            for (int g = 0; g < gchild.getChildCount(); g++) {
                //get measure
                if (gchild.getChildAt(g) instanceof ImageView) {
                    ImageView ivchild = (ImageView) gchild.getChildAt(g);
                    Drawable measureFill = ivchild.getDrawable();
                    if (measureFill.getConstantState()
                            .equals(ContextCompat
                                    .getDrawable(getApplicationContext(), R.drawable.measure_new_empty)
                                    .getConstantState())) {
                        mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW),
                                (int) ivchild.getTag(R.id.TAG_COLUMN), false,
                                (int) ivchild.getTag(R.id.TAG_GUISNAP),
                                (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES)));
                    } else if (measureFill.getConstantState()
                            .equals(ContextCompat
                                    .getDrawable(getApplicationContext(), R.drawable.measure_new_filled)
                                    .getConstantState())) {
                        mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW),
                                (int) ivchild.getTag(R.id.TAG_COLUMN), true,
                                (int) ivchild.getTag(R.id.TAG_GUISNAP),
                                (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES)));
                    }
                }

            }
        }
    }

    return mtaglist;
}

From source file:de.azapps.mirakel.new_ui.dialogs.PriorityDialog.java

@Nullable
@Override/*from w w w .j  a va2 s.c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout v = (LinearLayout) inflater.inflate(R.layout.priority_dialog, null);
    ButterKnife.inject(v);
    if (initialPriority.isPresent()) {
        final @IdRes int checkedID;
        switch (initialPriority.get()) {
        case -1:
        case -2:
            checkedID = R.id.wrapper_priority_low;
            break;
        case 1:
            checkedID = R.id.wrapper_priority_high;
            break;
        case 2:
            checkedID = R.id.wrapper_priority_veryhigh;
            break;
        case 0:
        default:
            checkedID = R.id.wrapper_priority_normal;
            break;
        }
        ((RadioButton) v.findViewById(checkedID).findViewById(R.id.radio_priority)).setChecked(true);
    }
    for (int i = 0; i < v.getChildCount(); i++) {
        v.getChildAt(i).setOnClickListener(this);
    }
    return v;
}

From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java

/**
 * Enable again the commands and menu buttons after sending all the movements to the robot
 *//*w w  w.  j  ava2s .c o  m*/
private void enableControllerButtons() {
    GridLayout controlsLayout = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container);
    for (int i = 0; i < controlsLayout.getChildCount(); i++) {
        controlsLayout.getChildAt(i).setEnabled(true);
    }

    ((ProgressBar) getActivity().findViewById(R.id.progress_bar)).setVisibility(View.GONE);

    LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container);
    for (int i = 0; i < optionsLayout.getChildCount(); i++) {
        optionsLayout.getChildAt(i).setEnabled(true);
    }

    gridView.setEnabled(true);
}

From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java

/**
 * Disable the commands and menu buttons when the app is sending the movements to the robot
 *//* www .jav  a  2  s. c  om*/
private void disableControllerButtons() {
    GridLayout controlsViews = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container);
    for (int i = 0; i < controlsViews.getChildCount(); i++) {
        controlsViews.getChildAt(i).setEnabled(false);
    }

    LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container);
    for (int i = 0; i < optionsLayout.getChildCount(); i++) {
        optionsLayout.getChildAt(i).setEnabled(false);
    }

    ((ProgressBar) getActivity().findViewById(R.id.progress_bar)).setVisibility(View.VISIBLE);

    gridView.setEnabled(false);
}

From source file:com.luseen.spacenavigation.SpaceNavigationView.java

/**
 * Adding given space items to content// w w  w  . jav  a  2s. c  o  m
 *
 * @param leftContent  to left content
 * @param rightContent and right content
 */
private void addSpaceItems(LinearLayout leftContent, LinearLayout rightContent) {

    /**
     * Removing all views for not being duplicated
     */
    if (leftContent.getChildCount() > 0 || rightContent.getChildCount() > 0) {
        leftContent.removeAllViews();
        rightContent.removeAllViews();
    }

    /**
     * Clear spaceItemList and badgeList for not being duplicated
     */
    spaceItemList.clear();
    badgeList.clear();

    /**
     * Getting LayoutInflater to inflate space item view from XML
     */
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    for (int i = 0; i < spaceItems.size(); i++) {
        final int index = i;
        int targetWidth;
        if (spaceItems.size() > 2)
            targetWidth = contentWidth / 2;
        else
            targetWidth = contentWidth;

        RelativeLayout.LayoutParams textAndIconContainerParams = new RelativeLayout.LayoutParams(targetWidth,
                mainContentHeight);
        RelativeLayout textAndIconContainer = (RelativeLayout) inflater.inflate(R.layout.space_item_view, this,
                false);
        textAndIconContainer.setLayoutParams(textAndIconContainerParams);

        ImageView spaceItemIcon = (ImageView) textAndIconContainer.findViewById(R.id.space_icon);
        TextView spaceItemText = (TextView) textAndIconContainer.findViewById(R.id.space_text);
        RelativeLayout badgeContainer = (RelativeLayout) textAndIconContainer
                .findViewById(R.id.badge_container);
        spaceItemIcon.setImageResource(spaceItems.get(i).getItemIcon());
        spaceItemText.setText(spaceItems.get(i).getItemName());
        spaceItemText.setTextSize(TypedValue.COMPLEX_UNIT_PX, spaceItemTextSize);

        /**
         * Set custom font to space item textView
         */
        if (isCustomFont)
            spaceItemText.setTypeface(customFont);

        /**
         * Hide item icon and show only text
         */
        if (textOnly)
            Utils.changeViewVisibilityGone(spaceItemIcon);

        /**
         * Hide item text and change icon size
         */
        ViewGroup.LayoutParams iconParams = spaceItemIcon.getLayoutParams();
        if (iconOnly) {
            iconParams.height = spaceItemIconOnlySize;
            iconParams.width = spaceItemIconOnlySize;
            spaceItemIcon.setLayoutParams(iconParams);
            Utils.changeViewVisibilityGone(spaceItemText);
        } else {
            iconParams.height = spaceItemIconSize;
            iconParams.width = spaceItemIconSize;
            spaceItemIcon.setLayoutParams(iconParams);
        }

        /**
         * Adding space items to item list for future
         */
        spaceItemList.add(textAndIconContainer);

        /**
         * Adding badge items to badge list for future
         */
        badgeList.add(badgeContainer);

        /**
         * Adding sub views to left and right sides
         */
        if (spaceItems.size() == 2 && leftContent.getChildCount() == 1) {
            rightContent.addView(textAndIconContainer, textAndIconContainerParams);
        } else if (spaceItems.size() > 2 && leftContent.getChildCount() == 2) {
            rightContent.addView(textAndIconContainer, textAndIconContainerParams);
        } else {
            leftContent.addView(textAndIconContainer, textAndIconContainerParams);
        }

        /**
         * Changing current selected item tint
         */
        if (i == currentSelectedItem) {
            spaceItemText.setTextColor(activeSpaceItemColor);
            Utils.changeImageViewTint(spaceItemIcon, activeSpaceItemColor);
        } else {
            spaceItemText.setTextColor(inActiveSpaceItemColor);
            Utils.changeImageViewTint(spaceItemIcon, inActiveSpaceItemColor);
        }

        textAndIconContainer.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                updateSpaceItems(index);
            }
        });
    }

    /**
     * Restore available badges from saveInstance
     */
    restoreBadges();
}

From source file:com.zns.comicdroid.dialog.AuthorIllustratorDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    final int comicId = getArguments().getInt("ComicId");
    final String[] names = getArguments().getStringArray("Names");

    LayoutInflater inflater = getActivity().getLayoutInflater();

    final LinearLayout parent = new LinearLayout(getActivity());
    parent.setOrientation(1);//  www .  j  av  a2 s  .c  om
    final View viewHead = inflater.inflate(R.layout.dialog_author_illustrator_head, null);
    parent.addView(viewHead);
    for (String name : names) {
        final View view = inflater.inflate(R.layout.dialog_author_illustrator, null);
        ((TextView) view.findViewById(R.id.tvName)).setText(name);
        parent.addView(view);
    }
    builder.setView(parent);

    builder.setPositiveButton(getResources().getString(R.string.common_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String authors = "";
                    String illustrators = "";
                    for (int i = 1; i < parent.getChildCount(); i++) //Start at 1 to skip header
                    {
                        View child = parent.getChildAt(i);
                        TextView tvName = (TextView) child.findViewById(R.id.tvName);
                        RadioButton rbAuthor = (RadioButton) child.findViewById(R.id.rbIsAuthor);
                        RadioButton rbIllustrator = (RadioButton) child.findViewById(R.id.rbIsIllustrator);
                        if (rbAuthor.isChecked())
                            authors += tvName.getText() + ",";
                        if (rbIllustrator.isChecked())
                            illustrators += tvName.getText() + ",";
                    }
                    authors = authors.replaceAll("[,]+$", "");
                    illustrators = illustrators.replaceAll("[,]+$", "");
                    if (mAuthorIllustratorCallback != null)
                        mAuthorIllustratorCallback.onAuthorIllustratorDialogPositiveClick(comicId, authors,
                                illustrators);
                }
            })

            .setNegativeButton(getResources().getString(R.string.common_cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            AuthorIllustratorDialogFragment.this.getDialog().cancel();
                        }
                    });

    AlertDialog dialog = builder.create();
    return dialog;
}

From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java

/**
 * Set the listeners to the views that need them. It must be done here in the fragment in order
 * to get the callback here and not in the FragmentActivity, that would be a mess with all the 
 * callbacks of all the possible fragments
 *//* www.  ja v a2 s  . co  m*/
private void setUiListeners() {

    gridView.setOnRearrangeListener(new OnRearrangeListener() {
        public void onRearrange(int oldIndex, int newIndex) {
            if (scheduledControls.isEmpty()) {
                return;
            }

            String scheduledControl = scheduledControls.remove(oldIndex);
            if (oldIndex < newIndex)
                scheduledControls.add(newIndex, scheduledControl);
            else
                scheduledControls.add(newIndex, scheduledControl);
        }

        public void onRearrange(boolean isDraggedDeleted, int draggedDeletedIndex) {
            if (scheduledControls.isEmpty()) {
                return;
            }

            if (isDraggedDeleted) {
                scheduledControls.remove(draggedDeletedIndex);
            }
        }
    });

    GridLayout movementsViews = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container);
    for (int i = 0; i < movementsViews.getChildCount(); i++) {
        movementsViews.getChildAt(i).setOnClickListener(onMovementsButtonClick);
    }

    LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container);
    for (int i = 0; i < optionsLayout.getChildCount(); i++) {
        optionsLayout.getChildAt(i).setOnClickListener(onOptionsButtonClick);
    }

    // Resize the GridLayout depending on the number of icons (depending on the current robot
    // selected). In order not to get too much number of columns in little screen, it is limited
    // to two and scroll the  screen if there are more icons. If scroll is not needed the icons
    // are centered in the layout
    final GridLayout typeOfMovementsContainer = (GridLayout) getActivity()
            .findViewById(R.id.type_of_movements_container);
    final ViewTreeObserver vto = typeOfMovementsContainer.getViewTreeObserver();
    final ViewTreeObserver.OnPreDrawListener preDrawListener = new ViewTreeObserver.OnPreDrawListener() {
        public boolean onPreDraw() {
            Rect scrollBounds = new Rect();
            ScrollView scroll = (ScrollView) getActivity().findViewById(R.id.scroll_container);
            scroll.getDrawingRect(scrollBounds);
            //                int finalHeight = scrollBounds.bottom - getActivity().getResources().getDimensionPixelSize(R.dimen.scheduler_grid_margin);
            int finalHeight = scrollBounds.bottom;
            int childCount = typeOfMovementsContainer.getChildCount();

            if (childCount > 1) {
                for (int i = 0; i < childCount; i++) {

                    if (typeOfMovementsContainer.getChildAt(i).getBottom() > finalHeight) {
                        typeOfMovementsContainer.setColumnCount(2);
                        break;
                    }
                }
            }

            scroll.invalidate();

            final ViewTreeObserver vto = typeOfMovementsContainer.getViewTreeObserver();
            vto.removeOnPreDrawListener(this);

            return true;
        }
    };

    vto.addOnPreDrawListener(preDrawListener);

}

From source file:org.uoyabause.android.YabauseHandler.java

private void showBottomMenu() {
    if (menu_showing == true) {
        menu_showing = false;//from  ww  w.  j  a v a  2s.co  m
        View mainview = (View) findViewById(R.id.yabause_view);
        mainview.requestFocus();
        YabauseRunnable.resume();
        audio.unmute(audio.SYSTEM);
        this.mDrawerLayout.closeDrawer(GravityCompat.START);
    } else {
        menu_showing = true;
        YabauseRunnable.pause();
        audio.mute(audio.SYSTEM);
        String name = YabauseRunnable.getGameTitle();
        TextView tx = (TextView) findViewById(R.id.menu_title);
        if (tx != null) {
            tx.setText(name);
        }
        if (adView != null) {
            LinearLayout lp = (LinearLayout) findViewById(R.id.navilayer);
            if (lp != null) {
                final int mCount = lp.getChildCount();
                boolean find = false;
                for (int i = 0; i < mCount; ++i) {
                    final View mChild = lp.getChildAt(i);
                    if (mChild == adView) {
                        find = true;
                    }
                }
                if (find == false) {
                    lp.addView(adView);
                }
                AdRequest adRequest = new AdRequest.Builder().addTestDevice("303A789B146C169D4BDB5652D928FF8E")
                        .build();
                adView.loadAd(adRequest);
            }
        }
        this.mDrawerLayout.openDrawer(GravityCompat.START);
    }
}

From source file:info.tellmetime.TellmetimeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_tellmetime);

    mDensity = getResources().getDisplayMetrics().density;
    mScreenWidth = getResources().getDisplayMetrics().widthPixels;
    mScreenHeight = getResources().getDisplayMetrics().heightPixels;
    mShorterEdge = Math.min(mScreenWidth, mScreenHeight);
    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
    mBacklightLight = getResources().getColor(R.color.backlight_light);
    mBacklightDark = getResources().getColor(R.color.backlight_dark);

    // Restore background and highlight colors from saved values or set defaults.
    mSettings = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
    mHighlightColor = mSettings.getInt(HIGHLIGHT, Color.WHITE);
    mBacklightColor = mSettings.getInt(BACKLIGHT, mBacklightLight);
    mBackgroundColor = mSettings.getInt(BACKGROUND, getResources().getColor(R.color.background));
    mBackgroundMode = mSettings.getInt(BACKGROUND_MODE, MODE_BACKGROUND_SOLID);
    mHighlightPosition = mSettings.getFloat(POSITION, 0.0f);
    mMinutesSize = mSettings.getInt(MINUTES_SIZE, 36);
    isNightMode = mSettings.getBoolean(NIGHTMODE, false);

    // Dim the navigation bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
        getWindow().getDecorView().setSystemUiVisibility(isNightMode ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0);

    mSurface = (RelativeLayout) findViewById(R.id.surface);
    mSurface.setBackgroundColor(mBackgroundColor);

    resizeClock();/*  w w w.  j a  v a2  s.com*/

    Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf");

    // Set typeface of all items in the clock to Roboto and dim each one and drop shadow on them.
    final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock);
    for (int i = 0; i < mClock.getChildCount(); i++) {
        LinearLayout row = (LinearLayout) mClock.getChildAt(i);

        for (int j = 0; j < row.getChildCount(); j++) {
            TextView tv = (TextView) row.getChildAt(j);

            tv.setTypeface(mTypefaceBold);
            tv.setTextColor(mBacklightColor);
            tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor);
        }
    }

    ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots);
    for (int i = 0; i < minutesDots.getChildCount(); i++) {
        TextView m = (TextView) minutesDots.getChildAt(i);

        m.setTypeface(mTypefaceBold);
        m.setTextColor(mBacklightColor);
        m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor);
    }

    // Set Roboto font on TextView where it isn't default.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        Typeface mTypefaceItalic = Typeface.createFromAsset(getAssets(), "Roboto-CondensedItalic.ttf");

        ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.info_background)).setTypeface(mTypefaceItalic);
        ((TextView) findViewById(R.id.info_image)).setTypeface(mTypefaceItalic);
        ((TextView) findViewById(R.id.labelHighlight)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.radio_backlight_light)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.radio_backlight_dark)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.radio_backlight_highlight)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.labelMinutes)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m1)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m2)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m3)).setTypeface(mTypefaceBold);
        ((TextView) findViewById(R.id.m4)).setTypeface(mTypefaceBold);
    }

    FrameLayout mTouchZone = (FrameLayout) findViewById(R.id.touchZone);
    mTouchZone.setOnTouchListener(this);
    mTouchZone.setBackgroundColor(
            getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent));

    mBackgroundImage = (ImageView) findViewById(R.id.background_image);
    switchBackgroundMode(mBackgroundMode);

    RelativeLayout mPanel = (RelativeLayout) findViewById(R.id.panel);
    mPanel.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            mHider.delayedHide(4000);
            return true;
        }
    });

    mHider = new PanelHider(mPanel, this);

    Spinner spinnerBackgroundMode = (Spinner) findViewById(R.id.spinnerBackgroundMode);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.backgrounds_modes,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerBackgroundMode.setAdapter(adapter);
    spinnerBackgroundMode.setOnItemSelectedListener(this);
    spinnerBackgroundMode.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            mHider.showNoAutoHide();
            return false;
        }
    });
    spinnerBackgroundMode.setSelection(mBackgroundMode);

    mSeekBarHighlight = (SeekBar) findViewById(R.id.highlightValue);
    mSeekBarHighlight.setOnSeekBarChangeListener(this);

    // Draw rainbow gradient on #mSeekBarHighlight and set position.
    drawRainbow();

    if (mBacklightColor == mBacklightLight)
        ((RadioButton) findViewById(R.id.radio_backlight_light)).setChecked(true);
    else if (mBacklightColor == mBacklightDark)
        ((RadioButton) findViewById(R.id.radio_backlight_dark)).setChecked(true);
    else
        ((RadioButton) findViewById(R.id.radio_backlight_highlight)).setChecked(true);

    SeekBar mSeekBarMinutes = (SeekBar) findViewById(R.id.minutesSize);
    mSeekBarMinutes.setOnSeekBarChangeListener(this);
    mSeekBarMinutes.setProgress(mMinutesSize);

    mHider.hideNow();

    Color.colorToHSV(mBackgroundColor, mHSV);
    mHSV[1] = 1.0f;

    //Trigger initial tick.
    mClockAlgorithm.tickTock();

    // Schedule the clock algorithm to tick every round minute.
    Calendar time = Calendar.getInstance();
    time.set(Calendar.MILLISECOND, 0);
    time.set(Calendar.SECOND, 0);
    time.add(Calendar.MINUTE, 1);

    Timer timer = new Timer();
    timer.schedule(mClockTask, time.getTime(), 60 * 1000);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mSurface.setAlpha(0.0f);
        mSurface.animate().alpha(1.0f).setDuration(1500);
    }

    // If it is first run, hint to user that panel is available.
    if (!mSettings.contains(HIGHLIGHT))
        showToast(R.string.info_first_run);
}