Example usage for android.widget TextView getVisibility

List of usage examples for android.widget TextView getVisibility

Introduction

In this page you can find the example usage for android.widget TextView getVisibility.

Prototype

@ViewDebug.ExportedProperty(mapping = { @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
        @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
        @ViewDebug.IntToString(from = GONE, to = "GONE") })
@Visibility
public int getVisibility() 

Source Link

Document

Returns the visibility status for this view.

Usage

From source file:com.freeme.filemanager.view.FileViewFragment.java

private boolean isMemoryNotAvailableShow() {
    TextView view = (TextView) mRootView.findViewById(R.id.memory_not_available_page);
    return view.getVisibility() == View.VISIBLE;
}

From source file:com.android.tv.menu.MenuLayoutManager.java

/**
 * Move the current selection to the given {@code position} with animation.
 * The animation specification is included in http://b/21069476
 *///w ww . j  av  a  2s  . c om
public void setSelectedPositionSmooth(final int position) {
    if (DEBUG) {
        Log.d(TAG, "setSelectedPositionSmooth(position=" + position + ") {previousPosition=" + mSelectedPosition
                + "}");
    }
    if (mMenuView.getVisibility() != View.VISIBLE) {
        setSelectedPosition(position);
        return;
    }
    if (mSelectedPosition == position) {
        return;
    }
    boolean oldIndexValid = Utils.isIndexValid(mMenuRowViews, mSelectedPosition);
    SoftPreconditions.checkState(oldIndexValid, TAG, "No previous selection: " + mSelectedPosition);
    if (!oldIndexValid) {
        return;
    }
    boolean newIndexValid = Utils.isIndexValid(mMenuRowViews, position);
    SoftPreconditions.checkArgument(newIndexValid, TAG, "position " + position);
    if (!newIndexValid) {
        return;
    }
    MenuRow row = mMenuRows.get(position);
    if (!row.isVisible()) {
        Log.e(TAG, "Moving to the invisible row: " + position);
        return;
    }
    if (mAnimatorSet != null) {
        // Do not cancel the animation here. The property values should be set to the end values
        // when the animation finishes.
        mAnimatorSet.end();
    }
    if (mTitleFadeOutAnimator != null) {
        // Cancel the animation instead of ending it in order that the title animation starts
        // again from the intermediate state.
        mTitleFadeOutAnimator.cancel();
    }
    final int oldPosition = mSelectedPosition;
    mSelectedPosition = position;
    if (DEBUG)
        dumpChildren("startRowAnimation()");

    MenuRowView currentView = mMenuRowViews.get(position);
    // Show the children of the next row.
    currentView.getTitleView().setVisibility(View.VISIBLE);
    currentView.getContentsView().setVisibility(View.VISIBLE);
    // Request focus after the new contents view shows up.
    mMenuView.requestFocus();
    if (mTempTitleViewForOld == null) {
        // Initialize here because we don't know when the views are inflated.
        mTempTitleViewForOld = (TextView) mMenuView.findViewById(R.id.temp_title_for_old);
        mTempTitleViewForCurrent = (TextView) mMenuView.findViewById(R.id.temp_title_for_current);
    }

    // Animations.
    mPropertyValuesAfterAnimation.clear();
    List<Animator> animators = new ArrayList<>();
    boolean scrollDown = position > oldPosition;
    List<Rect> layouts = getViewLayouts(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(),
            mMenuView.getBottom());

    // Old row.
    MenuRow oldRow = mMenuRows.get(oldPosition);
    MenuRowView oldView = mMenuRowViews.get(oldPosition);
    View oldContentsView = oldView.getContentsView();
    // Old contents view.
    animators.add(createAlphaAnimator(oldContentsView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn)
            .setDuration(mOldContentsFadeOutDuration));
    final TextView oldTitleView = oldView.getTitleView();
    setTempTitleView(mTempTitleViewForOld, oldTitleView);
    Rect oldLayoutRect = layouts.get(oldPosition);
    if (scrollDown) {
        // Old title view.
        if (oldRow.hideTitleWhenSelected() && oldTitleView.getVisibility() != View.VISIBLE) {
            // This case is not included in the animation specification.
            mTempTitleViewForOld.setScaleX(1.0f);
            mTempTitleViewForOld.setScaleY(1.0f);
            animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(),
                    mFastOutLinearIn));
            int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop();
            animators.add(createTranslationYAnimator(mTempTitleViewForOld, offset + mRowScrollUpAnimationOffset,
                    offset));
        } else {
            animators
                    .add(createScaleXAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f));
            animators
                    .add(createScaleYAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f));
            animators.add(createAlphaAnimator(mTempTitleViewForOld, oldTitleView.getAlpha(),
                    oldView.getTitleViewAlphaDeselected(), mLinearOutSlowIn));
            animators.add(createTranslationYAnimator(mTempTitleViewForOld, 0,
                    oldLayoutRect.top - mTempTitleViewForOld.getTop()));
        }
        oldTitleView.setAlpha(oldView.getTitleViewAlphaDeselected());
        oldTitleView.setVisibility(View.INVISIBLE);
    } else {
        Rect currentLayoutRect = new Rect(layouts.get(position));
        // Old title view.
        // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset).
        // But if the height of the upper row is small, the upper row will move down a lot. In
        // this case, this row needs to move more than the specification to avoid the overlap of
        // the two titles.
        // The maximum is to the top of the start position of mTempTitleViewForOld.
        int distanceCurrentTitle = currentLayoutRect.top - currentView.getTop();
        int distance = Math.max(mRowScrollUpAnimationOffset, distanceCurrentTitle);
        int distanceToTopOfSecondTitle = oldLayoutRect.top - mRowScrollUpAnimationOffset - oldView.getTop();
        animators.add(
                createTranslationYAnimator(oldTitleView, 0.0f, Math.min(distance, distanceToTopOfSecondTitle)));
        animators.add(createAlphaAnimator(oldTitleView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn)
                .setDuration(mOldContentsFadeOutDuration));
        animators.add(createScaleXAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f));
        animators.add(createScaleYAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f));
        mTempTitleViewForOld.setScaleX(1.0f);
        mTempTitleViewForOld.setScaleY(1.0f);
        animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(),
                mFastOutLinearIn));
        int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop();
        animators.add(
                createTranslationYAnimator(mTempTitleViewForOld, offset - mRowScrollUpAnimationOffset, offset));
    }
    // Current row.
    Rect currentLayoutRect = new Rect(layouts.get(position));
    TextView currentTitleView = currentView.getTitleView();
    View currentContentsView = currentView.getContentsView();
    currentContentsView.setAlpha(0.0f);
    if (scrollDown) {
        // Current title view.
        setTempTitleView(mTempTitleViewForCurrent, currentTitleView);
        // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset).
        // But if the height of the upper row is small, the upper row will move up a lot. In
        // this case, this row needs to start the move from more than the specification to avoid
        // the overlap of the two titles.
        // The maximum is to the top of the end position of mTempTitleViewForCurrent.
        int distanceOldTitle = oldView.getTop() - oldLayoutRect.top;
        int distance = Math.max(mRowScrollUpAnimationOffset, distanceOldTitle);
        int distanceTopOfSecondTitle = currentView.getTop() - mRowScrollUpAnimationOffset
                - currentLayoutRect.top;
        animators.add(createTranslationYAnimator(currentTitleView, Math.min(distance, distanceTopOfSecondTitle),
                0.0f));
        currentView.setTop(currentLayoutRect.top);
        ObjectAnimator animator = createAlphaAnimator(currentTitleView, 0.0f, 1.0f, mFastOutLinearIn)
                .setDuration(mCurrentContentsFadeInDuration);
        animator.setStartDelay(mOldContentsFadeOutDuration);
        currentTitleView.setAlpha(0.0f);
        animators.add(animator);
        animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected()));
        animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected()));
        animators.add(createTranslationYAnimator(mTempTitleViewForCurrent, 0.0f, -mRowScrollUpAnimationOffset));
        animators.add(createAlphaAnimator(mTempTitleViewForCurrent, currentView.getTitleViewAlphaDeselected(),
                0, mLinearOutSlowIn));
        // Current contents view.
        animators.add(createTranslationYAnimator(currentContentsView, mRowScrollUpAnimationOffset, 0.0f));
        animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn)
                .setDuration(mCurrentContentsFadeInDuration);
        animator.setStartDelay(mOldContentsFadeOutDuration);
        animators.add(animator);
    } else {
        currentView.setBottom(currentLayoutRect.bottom);
        // Current title view.
        int currentViewOffset = currentLayoutRect.top - currentView.getTop();
        animators.add(createTranslationYAnimator(currentTitleView, 0, currentViewOffset));
        animators.add(createAlphaAnimator(currentTitleView, currentView.getTitleViewAlphaDeselected(), 1.0f,
                mFastOutSlowIn));
        animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected()));
        animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected()));
        // Current contents view.
        animators.add(createTranslationYAnimator(currentContentsView,
                currentViewOffset - mRowScrollUpAnimationOffset, currentViewOffset));
        ObjectAnimator animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn)
                .setDuration(mCurrentContentsFadeInDuration);
        animator.setStartDelay(mOldContentsFadeOutDuration);
        animators.add(animator);
    }
    // Next row.
    int nextPosition;
    if (scrollDown) {
        nextPosition = findNextVisiblePosition(position);
        if (nextPosition != -1) {
            MenuRowView nextView = mMenuRowViews.get(nextPosition);
            Rect nextLayoutRect = layouts.get(nextPosition);
            animators.add(createTranslationYAnimator(nextView,
                    nextLayoutRect.top + mRowScrollUpAnimationOffset - nextView.getTop(),
                    nextLayoutRect.top - nextView.getTop()));
            animators.add(createAlphaAnimator(nextView, 0.0f, 1.0f, mFastOutLinearIn));
        }
    } else {
        nextPosition = findNextVisiblePosition(oldPosition);
        if (nextPosition != -1) {
            MenuRowView nextView = mMenuRowViews.get(nextPosition);
            animators.add(createTranslationYAnimator(nextView, 0, mRowScrollUpAnimationOffset));
            animators.add(createAlphaAnimator(nextView, nextView.getTitleViewAlphaDeselected(), 0.0f, 1.0f,
                    mLinearOutSlowIn));
        }
    }
    // Other rows.
    int count = mMenuRowViews.size();
    for (int i = 0; i < count; ++i) {
        MenuRowView view = mMenuRowViews.get(i);
        if (view.getVisibility() == View.VISIBLE && i != oldPosition && i != position && i != nextPosition) {
            Rect rect = layouts.get(i);
            animators.add(createTranslationYAnimator(view, 0, rect.top - view.getTop()));
        }
    }
    // Run animation.
    final List<ViewPropertyValueHolder> propertyValuesAfterAnimation = new ArrayList<>();
    propertyValuesAfterAnimation.addAll(mPropertyValuesAfterAnimation);
    mAnimatorSet = new AnimatorSet();
    mAnimatorSet.playTogether(animators);
    mAnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            if (DEBUG)
                dumpChildren("onRowAnimationEndBefore");
            mAnimatorSet = null;
            // The property values which are different from the end values and need to be
            // changed after the animation are set here.
            // e.g. setting translationY to 0, alpha of the contents view to 1.
            for (ViewPropertyValueHolder holder : propertyValuesAfterAnimation) {
                holder.property.set(holder.view, holder.value);
            }
            oldTitleView.setVisibility(View.VISIBLE);
            mMenuRowViews.get(oldPosition).onDeselected();
            mMenuRowViews.get(position).onSelected(true);
            mTempTitleViewForOld.setVisibility(View.GONE);
            mTempTitleViewForCurrent.setVisibility(View.GONE);
            layout(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom());
            if (DEBUG)
                dumpChildren("onRowAnimationEndAfter");

            MenuRow currentRow = mMenuRows.get(position);
            if (currentRow.hideTitleWhenSelected()) {
                View titleView = mMenuRowViews.get(position).getTitleView();
                mTitleFadeOutAnimator = createAlphaAnimator(titleView, titleView.getAlpha(), 0.0f,
                        mLinearOutSlowIn);
                mTitleFadeOutAnimator.setStartDelay(TITLE_SHOW_DURATION_BEFORE_HIDDEN_MS);
                mTitleFadeOutAnimator.addListener(new AnimatorListenerAdapter() {
                    private boolean mCanceled;

                    @Override
                    public void onAnimationCancel(Animator animator) {
                        mCanceled = true;
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        mTitleFadeOutAnimator = null;
                        if (!mCanceled) {
                            mMenuRowViews.get(position).onSelected(false);
                        }
                    }
                });
                mTitleFadeOutAnimator.start();
            }
        }
    });
    mAnimatorSet.start();
    if (DEBUG)
        dumpChildren("startedRowAnimation()");
}

From source file:com.winneredge.stockly.wcommons.floatingactionwidget.FloatingActionButton.java

public int getLabelVisibility() {
    TextView labelView = getLabelView();
    if (labelView != null) {
        return labelView.getVisibility();
    }/*from   w  ww  .  j a  v  a  2  s  .co  m*/

    return -1;
}

From source file:com.mobicage.rogerthat.plugins.messaging.widgets.AdvancedOrderWidget.java

private void setDetailScrollViewHeight() {
    final Point displaySize = UIUtils.getDisplaySize(mActivity);
    final TextView nameLbl = (TextView) mDetailDialog.findViewById(R.id.name);
    final TextView priceLbl = (TextView) mDetailDialog.findViewById(R.id.price);
    final ScrollView scrollView = (ScrollView) mDetailDialog.findViewById(R.id.scroll_view);
    final LinearLayout valueContainer = (LinearLayout) mDetailDialog.findViewById(R.id.value_container);
    final Button dismissBtn = (Button) mDetailDialog.findViewById(R.id.dismiss);
    int maxPopupHeight = (int) Math.floor(displaySize.y * 0.75);

    int desiredWidth = MeasureSpec.makeMeasureSpec(nameLbl.getWidth(), MeasureSpec.AT_MOST);

    nameLbl.measure(desiredWidth, 0);/*ww  w.  j a  va2 s.  c o  m*/
    int nameLblHeight = nameLbl.getMeasuredHeight();
    int priceLblHeight = 0;
    if (priceLbl.getVisibility() == View.VISIBLE) {
        priceLbl.measure(desiredWidth, 0);
        priceLblHeight = priceLbl.getMeasuredHeight();
    }
    valueContainer.measure(desiredWidth, 0);
    int valueContainerHeight = valueContainer.getMeasuredHeight();
    dismissBtn.measure(desiredWidth, 0);
    int dismissBtnHeight = dismissBtn.getMeasuredHeight();

    int maxScrollViewHeight = maxPopupHeight - nameLblHeight - priceLblHeight - valueContainerHeight
            - dismissBtnHeight;

    ViewGroup.LayoutParams params = scrollView.getLayoutParams();
    scrollView.measure(desiredWidth, 0);
    params.height = scrollView.getMeasuredHeight();
    if (maxScrollViewHeight > 0 && params.height > maxScrollViewHeight) {
        params.height = maxScrollViewHeight;
    }
    scrollView.setLayoutParams(params);
    scrollView.requestLayout();
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

private void setDaysInCalendar() {
    Calendar auxCalendar = Calendar.getInstance(locale);
    auxCalendar.setTime(currentCalendar.getTime());
    auxCalendar.set(Calendar.DAY_OF_MONTH, 1);
    int firstDayOfMonth = auxCalendar.get(Calendar.DAY_OF_WEEK);
    TextView dayOfMonthText;
    ViewGroup dayOfMonthContainer;//w  w w .ja v  a 2s .  com

    // Calculate dayOfMonthIndex
    int dayOfMonthIndex = getWeekIndex(firstDayOfMonth, auxCalendar);

    for (int i = 1; i <= auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++, dayOfMonthIndex++) {
        dayOfMonthContainer = (ViewGroup) view.findViewWithTag(DAY_OF_MONTH_CONTAINER + dayOfMonthIndex);
        dayOfMonthText = (TextView) view.findViewWithTag(DAY_OF_MONTH_TEXT + dayOfMonthIndex);
        if (dayOfMonthText == null) {
            break;
        }
        dayOfMonthContainer.setOnClickListener(onDayOfMonthClickListener);
        dayOfMonthText.setVisibility(View.VISIBLE);
        dayOfMonthText.setText(String.valueOf(i));
        dayOfMonthText.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_day_of_month));
        dayOfMonthContainer.setBackgroundResource(0);
    }

    // If the last week row has no visible days, hide it or show it in case
    ViewGroup weekRow = (ViewGroup) view.findViewWithTag("weekRow6");
    dayOfMonthText = (TextView) view.findViewWithTag("dayOfMonthText36");
    if (dayOfMonthText.getVisibility() == INVISIBLE) {
        weekRow.setVisibility(GONE);
    } else {
        weekRow.setVisibility(VISIBLE);
    }
    updateBackgroundSelectDays();
}

From source file:com.qubittech.feelknit.app.MainActivity.java

@Override
protected void onNavItemSelected(int id) {
    switch (id) {
    case 101://w  w w  . j ava  2  s  . com
        ShowProfileFragment(ApplicationHelper.getAvatar(getApplicationContext()));
        break;
    case 102:
        ShowCurrentFeelingsFragment();
        break;
    case 103:
        StartUserFeelingsFragment();
        break;
    case 104:
        showCommentsFeelingsFragment();
        break;
    case 105:
        ShowRelatedFeelingFragment();
        break;
    case 106:
        final Dialog d = new Dialog(this, R.style.CustomDialogTheme);
        d.setContentView(R.layout.custom_dialog);
        d.show();

        TextView version = (TextView) d.findViewById(R.id.versionTextView);
        TextView saripaar = (TextView) d.findViewById(R.id.saripaar);
        TextView licenseLink = (TextView) d.findViewById(R.id.licenseLink);
        final TextView license = (TextView) d.findViewById(R.id.license);
        saripaar.setText(Html.fromHtml("<u>android-saripaar</u>"));
        licenseLink.setText(Html.fromHtml("(<u>license</u>)"));

        saripaar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Uri uriUrl = Uri.parse("https://github.com/ragunathjawahar/android-saripaar");
                Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
                startActivity(launchBrowser);
            }
        });

        license.setText("Copyright 2012 - 2015 Mobs and Geeks\n\n"
                + "Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                + "you may not use this file except in compliance with the License.\n"
                + "You may obtain a copy of the License at\n" + "\n"
                + "    http://www.apache.org/licenses/LICENSE-2.0\n" + "\n"
                + "Unless required by applicable law or agreed to in writing, software\n"
                + "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                + "See the License for the specific language governing permissions and\n"
                + "limitations under the License.");
        licenseLink.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                license.setVisibility(license.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
            }
        });
        try {
            version.setText(getApplicationContext().getPackageManager()
                    .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        TextView close_btn = (TextView) d.findViewById(R.id.okButton);
        close_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                d.dismiss();
            }
        });
    }
}

From source file:no.barentswatch.fiskinfo.BaseActivity.java

/**
 * This function creates a pop up dialog which takes in the context of the
 * current activity//from w w w . j a  v  a  2  s .  c o  m
 * 
 * @param activityContext
 *            the context of the current activity
 * @param rPathToTitleOfPopup
 *            The R.path to the title
 * @param customView
 *            the custom view for the dialog
 */
public void ShowLoginDialog(Context activityContext, int rPathToTitleOfPopup, View customView) {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.dialog_login, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(activityContext);
    builder.setTitle(rPathToTitleOfPopup);

    final EditText usernameEditText = (EditText) view.findViewById(R.id.LoginDialogEmailField);
    final EditText passwordEditText = (EditText) view.findViewById(R.id.loginDialogPasswordField);
    final TextView incorrectCredentialsTextView = (TextView) view
            .findViewById(R.id.loginIncorrectCredentialsTextView);

    Button loginButton = (Button) view.findViewById(R.id.loginDialogButton);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_login_button);
    builder.setView(view);
    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    loginButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (incorrectCredentialsTextView.getVisibility() == 0) {
                incorrectCredentialsTextView.setVisibility(android.view.View.INVISIBLE);
            }

            if (!isNetworkAvailable()) {
                incorrectCredentialsTextView.setText(getString(R.string.no_internet_access));
                incorrectCredentialsTextView.setVisibility(android.view.View.VISIBLE);
                return;
            }

            String usernameText = usernameEditText.getText().toString();
            String passwordText = passwordEditText.getText().toString();

            if (!validateEmail(usernameText)) {
                usernameEditText.requestFocus();
                usernameEditText.setError(getString(R.string.login_invalid_email));
                return;
            }
            usernameEditText.setError(null);

            if (passwordText.length() == 0) {
                passwordEditText.requestFocus();
                passwordEditText.setError(getString(R.string.login_password_field_empty_string));
                return;
            }
            passwordEditText.setError(null);

            try {
                authenticateUserCredentials(usernameText, passwordText);
            } catch (Exception e) {
                e.printStackTrace();
            }

            if (userIsAuthenticated) {
                loadView(MyPageActivity.class);
            } else {
                incorrectCredentialsTextView.setText(getString(R.string.login_incorrect_credentials));
                incorrectCredentialsTextView.setVisibility(android.view.View.VISIBLE);
                return;
            }
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }
    });

    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            actionBar.setSelectedNavigationItem(adapter.getCount());
        }
    });

    dialog.show();
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public void updateTitle(CharSequence cs) {
    TextView title = (TextView) findViewById(R.id.title_path);
    if ((title == null || !title.isShown()) && !BEFORE_HONEYCOMB && getActionBar() != null
            && getActionBar().getCustomView() != null)
        title = (TextView) getActionBar().getCustomView().findViewById(R.id.title_path);
    //if(BEFORE_HONEYCOMB || !USE_ACTION_BAR || getActionBar() == null)
    if (title != null && title.getVisibility() != View.GONE)
        title.setText(cs, BufferType.SPANNABLE);
    if (!BEFORE_HONEYCOMB && USE_ACTION_BAR && getActionBar() != null && (title == null || !title.isShown()))
        getActionBar().setSubtitle(cs);//from   ww  w  . j  a va  2s .co  m
    //else
    {
        SpannableStringBuilder sb = new SpannableStringBuilder(getResources().getString(R.string.app_title));
        sb.append(cs.equals("") ? "" : " - ");
        sb.append(cs);
        setTitle(cs);
    }
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

public void updateBackgroundSelectDays() {
    if (startDay != null && endDay != null) {
        Calendar auxCalendar = Calendar.getInstance(locale);
        auxCalendar.setTime(currentCalendar.getTime());
        auxCalendar.set(Calendar.DAY_OF_MONTH, 1);
        auxCalendar.set(Calendar.HOUR_OF_DAY, 0);
        auxCalendar.set(Calendar.MINUTE, 0); // set minute in hour
        auxCalendar.set(Calendar.SECOND, 0); // set second in minute
        auxCalendar.set(Calendar.MILLISECOND, 0);
        Calendar startCalendar = getCurrentCalendar();
        startCalendar.setTime(startDay);
        Calendar endCalendar = getCurrentCalendar();
        endCalendar.setTime(endDay);//from   ww  w . j a v  a 2  s.c  o m
        if (auxCalendar.compareTo(endCalendar) > 0)
            return;
        if (auxCalendar.compareTo(startCalendar) > 0) {
            startCalendar = auxCalendar;
            if (startCalendar.compareTo(endCalendar) != 0) {
                ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
                startDayOfMonthBackground.setBackgroundColor(
                        ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                TextView dayOfMonth = getDayOfMonthText(startCalendar);
                dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
            }
            int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            Calendar endDayOnMonthCalendar = Calendar.getInstance(locale);
            endDayOnMonthCalendar.setTime(auxCalendar.getTime());
            endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth);
            if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) {
                endCalendar = endDayOnMonthCalendar;
                ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                endDayOfMonthBackground.setBackgroundColor(
                        ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                TextView dayOfMonth = getDayOfMonthText(endCalendar);
                dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
            } else {
                ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right);
                TextView dayOfMonth = getDayOfMonthText(endCalendar);
                dayOfMonth
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                ViewGroup dayOfMonthBackground = getDayOfMonthBackground(endCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
            }
        } else {
            int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            Calendar endDayOnMonthCalendar = Calendar.getInstance(locale);
            endDayOnMonthCalendar.setTime(auxCalendar.getTime());
            endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth);
            if (endDayOnMonthCalendar.compareTo(startCalendar) < 0)
                return;
            if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) {
                endCalendar = endDayOnMonthCalendar;
                if (startCalendar.compareTo(endCalendar) != 0) {
                    ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                    endDayOfMonthBackground.setBackgroundColor(
                            ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                    TextView dayOfMonth = getDayOfMonthText(endCalendar);
                    dayOfMonth
                            .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
                }
                ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
                startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left);
                ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);

            } else {
                int compare = startCalendar.compareTo(endCalendar);//compare startdate and enddate, if they are equal, just draw circle not draw background startdate and enddate
                ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
                if (compare != 0)
                    startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left);
                ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
                ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar);
                if (compare != 0)
                    endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right);
                dayOfMonthBackground = getDayOfMonthBackground(endCalendar);
                dayOfMonthBackground.setBackgroundResource(R.drawable.circle);
                TextView dayOfMonth = getDayOfMonthText(endCalendar);
                dayOfMonth
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
                dayOfMonth = getDayOfMonthText(startCalendar);
                dayOfMonth
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
            }

        }
        String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startCalendar.getTime());
        int days = getDays(startCalendar, endCalendar);

        for (int i = 1; i < days; i++) {
            startCalendar.add(Calendar.DAY_OF_YEAR, 1);
            ViewGroup dayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar);
            TextView dayOfMonth = getDayOfMonthText(startCalendar);
            if (dayOfMonth.getVisibility() != View.VISIBLE)
                continue;
            dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white));
            dayOfMonthBackground.setBackgroundColor(
                    ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day));
        }
    } else {
        if (startDay != null) {
            Calendar startDayOnMonthCalendar = Calendar.getInstance(locale);
            startDayOnMonthCalendar.setTime(currentCalendar.getTime());
            startDayOnMonthCalendar.set(Calendar.DAY_OF_MONTH, 1);
            startDayOnMonthCalendar.set(Calendar.HOUR_OF_DAY, 0);
            startDayOnMonthCalendar.set(Calendar.MINUTE, 0); // set minute in hour
            startDayOnMonthCalendar.set(Calendar.SECOND, 0); // set second in minute
            startDayOnMonthCalendar.set(Calendar.MILLISECOND, 0);

            Calendar endDayOnMonthCalendar = Calendar.getInstance(locale);
            endDayOnMonthCalendar.setTime(startDayOnMonthCalendar.getTime());
            int totalDaysInMonth = startDayOnMonthCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth);
            Calendar startCalendar = getCurrentCalendar();
            startCalendar.setTime(startDay);
            if (startCalendar.compareTo(startDayOnMonthCalendar) >= 0
                    && startCalendar.compareTo(endDayOnMonthCalendar) <= 0) {
                selectStartDay(startDay);
            }
        }
    }

}