Example usage for android.widget RelativeLayout RIGHT_OF

List of usage examples for android.widget RelativeLayout RIGHT_OF

Introduction

In this page you can find the example usage for android.widget RelativeLayout RIGHT_OF.

Prototype

int RIGHT_OF

To view the source code for android.widget RelativeLayout RIGHT_OF.

Click Source Link

Document

Rule that aligns a child's left edge with another child's right edge.

Usage

From source file:nu.yona.timepicker.time.TimePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.mdtp_dual_time_picker_dialog, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }//from  w  w w .j a  v a2s  .  c  o m

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(getActivity(), mThemeDark);
    }

    Resources res = getResources();
    Context context = getActivity();
    mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description);
    mSelectHours = res.getString(R.string.mdtp_select_hours);
    mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description);
    mSelectMinutes = res.getString(R.string.mdtp_select_minutes);
    mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description);
    mSelectSeconds = res.getString(R.string.mdtp_select_seconds);
    mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_accent_color_focused);
    if (mIsDualScreenMode) {
        view.findViewById(R.id.next_backgroud).setVisibility(View.VISIBLE);

        tabHost = (TabHost) view.findViewById(R.id.tabHost);
        tabHost.findViewById(R.id.tabHost);
        tabHost.setOnTabChangedListener(this);
        tabHost.setup();
        setNewTab(tabHost, getString(R.string.from), R.string.from, R.id.time_picker, 0);
        setNewTab(tabHost, getString(R.string.to), R.string.to, R.id.time_picker_end, 1);
        tabHost.setCurrentTab(0);
    } else {
        ((TextView) view.findViewById(R.id.previous)).setText(getString(R.string.mdtp_cancel));
        view.findViewById(R.id.done_background).setVisibility(View.VISIBLE);
    }

    doneBackgroudnView = view.findViewById(R.id.done_background);
    nextBackgroundView = view.findViewById(R.id.next_backgroud);
    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourView.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mHourSpaceViewEnd = (TextView) view.findViewById(R.id.hour_space_end);
    mHourViewEnd = (TextView) view.findViewById(R.id.hours_end);
    mHourViewEnd.setOnKeyListener(keyboardListener);
    mHourViewEnd.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteSpaceViewEnd = (TextView) view.findViewById(R.id.minutes_space_end);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mMinuteView.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mMinuteViewEnd = (TextView) view.findViewById(R.id.minutes_end);
    mMinuteViewEnd.setOnKeyListener(keyboardListener);
    mMinuteViewEnd.setTypeface(TypefaceHelper.get(context, Utils.OSWALD_LIGHT));
    mSecondSpaceView = (TextView) view.findViewById(R.id.seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
    mAmPmTextView.setOnKeyListener(keyboardListener);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());
    mInitialTime = roundToNearest(mInitialTime);

    mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
    mTimePicker.setOnValueSelectedListener(this);
    mTimePicker.setOnKeyListener(keyboardListener);
    mTimePicker.initialize(getActivity(), this, mInitialTime, mIs24HourMode);

    mTimePickerEnd = (RadialPickerLayout) view.findViewById(R.id.time_picker_end);
    mTimePickerEnd.setOnValueSelectedListener(this);
    mTimePickerEnd.setOnKeyListener(keyboardListener);
    //mTimePickerEnd.setVisibility(View.GONE);
    if (mSecondTime != null) {
        mTimePickerEnd.initialize(getActivity(), this, mSecondTime, mIs24HourMode);
    }

    int currentItemShowing = HOUR_INDEX;
    int currentItemShowingEnd = HOUR_INDEX;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
        currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
    }
    /*if (savedInstanceState != null &&
        savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING_END)) {
    currentItemShowingEnd = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING_END);
    }*/
    setCurrentItemShowing(currentItemShowing, false, true, true);
    setCurrentItemShowing(currentItemShowingEnd, false, true, true);
    mTimePicker.invalidate();
    mTimePickerEnd.invalidate();

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 1) {
                tabHost.setCurrentTab(0);
            } else {
                setCurrentItemShowing(HOUR_INDEX, true, false, true);
            }
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 1) {
                tabHost.setCurrentTab(0);
            } else {
                setCurrentItemShowing(MINUTE_INDEX, true, false, true);
                tryVibrate();
            }
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mHourViewEnd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 0) {
                tabHost.setCurrentTab(1);
            } else {
                setCurrentItemShowing(HOUR_INDEX, true, false, true);
                tryVibrate();
            }
        }
    });
    mMinuteViewEnd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabHost.getCurrentTab() == 0) {
                tabHost.setCurrentTab(1);
            } else {
                setCurrentItemShowing(MINUTE_INDEX, true, false, true);
                tryVibrate();
            }
        }
    });
    mSecondView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setCurrentItemShowing(SECOND_INDEX, true, false, true);
            tryVibrate();
        }
    });

    mOkButton = (Button) view.findViewById(R.id.ok);
    mOkButton.setOnClickListener(clickListener);
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, Utils.ROBOTO_MEDIUM));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(mOkResid);

    mErrorMsg = (TextView) view.findViewById(R.id.time_picker_error_msg);

    mPreviousButton = (Button) view.findViewById(R.id.previous);
    mPreviousButton.setOnClickListener(clickListener);

    mNextButton = (Button) view.findViewById(R.id.next);
    mNextButton.setOnClickListener(clickListener);

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(clickListener);
    mCancelButton.setTypeface(TypefaceHelper.get(context, Utils.ROBOTO_MEDIUM));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(mCancelResid);
    mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // Enable or disable the AM/PM view.
    mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
    if (mIs24HourMode) {
        mAmPmTextView.setVisibility(View.GONE);
    } else {
        mAmPmTextView.setVisibility(View.VISIBLE);
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);
        mAmPmHitspace.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Don't do anything if either AM or PM are disabled
                if (isAmDisabled() || isPmDisabled())
                    return;

                tryVibrate();
                int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
                if (amOrPm == AM) {
                    amOrPm = PM;
                } else if (amOrPm == PM) {
                    amOrPm = AM;
                }
                mTimePicker.setAmOrPm(amOrPm);
            }
        });
    }

    // Disable seconds picker
    if (!mEnableSeconds) {
        mSecondSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.separator_seconds).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    if (mIs24HourMode && !mEnableSeconds) {
        // center first separator
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
        TextView separatorView = (TextView) view.findViewById(R.id.separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.minutes_space);
        paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        separator.setLayoutParams(paramsSeparator);

        if (!mIs24HourMode) {
            // center minutes
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        } else {
            // move minutes to right of center
            RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mFirstTime.getHour(), true);
    setMinute(mFirstTime.getMinute());
    setSecond(mFirstTime.getSecond());

    setHourEnd(mSecondTime.getHour(), true);
    setMinuteEnd(mSecondTime.getMinute());
    setSecondEnd(mSecondTime.getSecond());

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.mdtp_deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();
    if (mInKbMode) {
        mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
        tryStartingKbMode(-1);
        mHourView.invalidate();
    } else if (mTypedTimes == null) {
        mTypedTimes = new ArrayList<>();
    }

    /* // Set the title (if any)
     if (!mTitle.isEmpty()) {
    timePickerHeader.setVisibility(TextView.VISIBLE);
    timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault()));
     }*/

    // Set the theme at the end so that the initialize()s above don't counteract the theme.
    mOkButton.setTextColor(mAccentColor);
    mCancelButton.setTextColor(mAccentColor);
    //timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.time_display_background)
            .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.mdtp_white));
    view.findViewById(R.id.time_display).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.time_display_end).setBackgroundColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background);
    int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color);
    int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray);
    int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray);

    mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    mTimePickerEnd.setBackgroundColor(mThemeDark ? lightGray : circleBackground);
    view.findViewById(R.id.time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:github.daneren2005.dsub.fragments.SelectDirectoryFragment.java

private void setupTextDisplay(final View header) {
    final TextView titleView = (TextView) header.findViewById(R.id.select_album_title);
    if (playlistName != null) {
        titleView.setText(playlistName);
    } else if (podcastName != null) {
        titleView.setText(podcastName);//  w  w w  . ja  va 2s .c om
        titleView.setPadding(0, 6, 4, 8);
    } else if (name != null) {
        titleView.setText(name);

        if (artistInfo != null) {
            titleView.setPadding(0, 6, 4, 8);
        }
    } else if (share != null) {
        titleView.setVisibility(View.GONE);
    }

    int songCount = 0;

    Set<String> artists = new HashSet<String>();
    Set<Integer> years = new HashSet<Integer>();
    Integer totalDuration = 0;
    for (Entry entry : entries) {
        if (!entry.isDirectory()) {
            songCount++;
            if (entry.getArtist() != null) {
                artists.add(entry.getArtist());
            }
            if (entry.getYear() != null) {
                years.add(entry.getYear());
            }
            Integer duration = entry.getDuration();
            if (duration != null) {
                totalDuration += duration;
            }
        }
    }

    final TextView artistView = (TextView) header.findViewById(R.id.select_album_artist);
    if (podcastDescription != null || artistInfo != null) {
        artistView.setVisibility(View.VISIBLE);
        String text = podcastDescription != null ? podcastDescription : artistInfo.getBiography();
        Spanned spanned = null;
        if (text != null) {
            spanned = Html.fromHtml(text);
        }
        artistView.setText(spanned);
        artistView.setSingleLine(false);
        final int minLines = context.getResources().getInteger(R.integer.TextDescriptionLength);
        artistView.setLines(minLines);
        artistView.setTextAppearance(context, android.R.style.TextAppearance_Small);

        final Spanned spannedText = spanned;
        artistView.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onClick(View v) {
                if (artistView.getMaxLines() == minLines) {
                    // Use LeadingMarginSpan2 to try to make text flow around image
                    Display display = context.getWindowManager().getDefaultDisplay();
                    ImageView coverArtView = (ImageView) header.findViewById(R.id.select_album_art);
                    coverArtView.measure(display.getWidth(), display.getHeight());

                    int height, width;
                    ViewGroup.MarginLayoutParams vlp = (ViewGroup.MarginLayoutParams) coverArtView
                            .getLayoutParams();
                    if (coverArtView.getDrawable() != null) {
                        height = coverArtView.getMeasuredHeight() + coverArtView.getPaddingBottom();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    } else {
                        height = coverArtView.getHeight();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    }
                    float textLineHeight = artistView.getPaint().getTextSize();
                    int lines = (int) Math.ceil(height / textLineHeight);

                    SpannableString ss = new SpannableString(spannedText);
                    ss.setSpan(new MyLeadingMarginSpan2(lines, width), 0, ss.length(),
                            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

                    View linearLayout = header.findViewById(R.id.select_album_text_layout);
                    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) linearLayout
                            .getLayoutParams();
                    int[] rules = params.getRules();
                    rules[RelativeLayout.RIGHT_OF] = 0;
                    params.leftMargin = vlp.rightMargin;

                    artistView.setText(ss);
                    artistView.setMaxLines(100);

                    vlp = (ViewGroup.MarginLayoutParams) titleView.getLayoutParams();
                    vlp.leftMargin = width;
                } else {
                    artistView.setMaxLines(minLines);
                }
            }
        });
        artistView.setMovementMethod(LinkMovementMethod.getInstance());
    } else if (topTracks) {
        artistView.setText(R.string.menu_top_tracks);
        artistView.setVisibility(View.VISIBLE);
    } else if (showAll) {
        artistView.setText(R.string.menu_show_all);
        artistView.setVisibility(View.VISIBLE);
    } else if (artists.size() == 1) {
        String artistText = artists.iterator().next();
        if (years.size() == 1) {
            artistText += " - " + years.iterator().next();
        }
        artistView.setText(artistText);
        artistView.setVisibility(View.VISIBLE);
    } else {
        artistView.setVisibility(View.GONE);
    }

    TextView songCountView = (TextView) header.findViewById(R.id.select_album_song_count);
    TextView songLengthView = (TextView) header.findViewById(R.id.select_album_song_length);
    if (podcastDescription != null || artistInfo != null) {
        songCountView.setVisibility(View.GONE);
        songLengthView.setVisibility(View.GONE);
    } else {
        String s = context.getResources().getQuantityString(R.plurals.select_album_n_songs, songCount,
                songCount);
        songCountView.setText(s.toUpperCase());
        songLengthView.setText(Util.formatDuration(totalDuration));
    }
}

From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java

private void setupTextDisplay(final View header) {

    final TextView titleView = (TextView) header.findViewById(R.id.select_album_title);
    if (playlistName != null) {
        titleView.setText(playlistName);
    } else if (podcastName != null) {
        Collections.reverse(entries);
        titleView.setText(podcastName);/*www  .j  a v a 2s  . c om*/
        titleView.setPadding(0, 6, 4, 8);
    } else if (name != null) {
        titleView.setText(name);
        if (artistInfo != null) {
            titleView.setPadding(0, 6, 4, 8);
        }
    } else if (share != null) {
        titleView.setVisibility(View.GONE);
    }

    int songCount = 0;

    Set<String> artists = new HashSet<String>();
    Set<Integer> years = new HashSet<Integer>();
    totalDuration = 0;
    for (Entry entry : entries) {
        if (!entry.isDirectory()) {
            songCount++;
            if (entry.getArtist() != null) {
                artists.add(entry.getArtist());
            }
            if (entry.getYear() != null) {
                years.add(entry.getYear());
            }
            Integer duration = entry.getDuration();
            if (duration != null) {
                totalDuration += duration;
            }
        }
    }
    String artistName = "";
    bookDescription = "Could not collect any info about the book at this time";
    try {

        artistName = artists.iterator().next();
        String endpoint = "getBookDirectory";
        if (Util.isTagBrowsing(context)) {
            endpoint = "getBook";
        }
        SharedPreferences prefs = Util.getPreferences(context);
        String url = Util.getRestUrl(context, endpoint) + "&id=" + directory.getId() + "&f=json";

        Log.w("GetInfo", url);
        String artist, title;
        int year = 0;
        artist = title = "";

        try {
            artist = artists.iterator().next();
        } catch (Exception e) {
            Log.w("GetInfoArtist", e.toString());
        }
        try {
            title = titleView.getText().toString();
        } catch (Exception e) {
            Log.w("GetInfoTitle", e.toString());
        }
        try {
            year = years.iterator().next();
        } catch (Exception e) {
            Log.w("GetInfoYear", e.toString());
        }

        BookInfoAPIParams params = new BookInfoAPIParams(url, artist, title, year);
        bookInfo = new BookInfoAPI(context).execute(params).get();
        bookDescription = bookInfo[0];
        bookReader = bookInfo[1];

    } catch (Exception e) {
        Log.w("GetInfoError", e.toString());
    }
    if (bookDescription.equals("noInfo")) {
        bookDescription = "The server has no description for this book";
    }

    final TextView artistView = (TextView) header.findViewById(R.id.select_album_artist);
    if (podcastDescription != null || artistInfo != null || bookDescription != null) {
        artistView.setVisibility(View.VISIBLE);

        String text = "";
        if (bookDescription != null) {
            text = bookDescription;
        }
        if (podcastDescription != null) {
            text = podcastDescription;
        }
        if (artistInfo != null) {
            text = artistInfo.getBiography();
        }
        Spanned spanned = null;
        if (text != null) {
            String newText = "";
            try {
                if (!artistName.equals("")) {
                    newText += "<b>" + context.getResources().getString(R.string.main_artist) + "</b>: "
                            + artistName + "<br/>";
                }
            } catch (Exception e) {
            }
            try {
                if (totalDuration > 0) {
                    newText += "<b>" + context.getResources().getString(R.string.album_book_reader) + "</b>: "
                            + bookReader + "<br/>";
                }
            } catch (Exception e) {
            }
            try {
                if (totalDuration > 0) {
                    newText += "<b>" + context.getResources().getString(R.string.album_book_length) + "</b>: "
                            + Util.formatDuration(totalDuration) + "<br/>";
                }
            } catch (Exception e) {
            }
            try {
                newText += text + "<br/>";
            } catch (Exception e) {
            }
            spanned = Html.fromHtml(newText);
        }

        artistView.setText(spanned);
        artistView.setSingleLine(false);
        final int minLines = context.getResources().getInteger(R.integer.TextDescriptionLength);
        artistView.setLines(minLines);
        artistView.setTextAppearance(context, android.R.style.TextAppearance_Small);

        final Spanned spannedText = spanned;
        artistView.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onClick(View v) {
                if (artistView.getMaxLines() == minLines) {
                    // Use LeadingMarginSpan2 to try to make text flow around image
                    Display display = context.getWindowManager().getDefaultDisplay();
                    ImageView coverArtView = (ImageView) header.findViewById(R.id.select_album_art);
                    coverArtView.measure(display.getWidth(), display.getHeight());

                    int height, width;
                    ViewGroup.MarginLayoutParams vlp = (ViewGroup.MarginLayoutParams) coverArtView
                            .getLayoutParams();
                    if (coverArtView.getDrawable() != null) {
                        height = coverArtView.getMeasuredHeight() + coverArtView.getPaddingBottom();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    } else {
                        height = coverArtView.getHeight();
                        width = coverArtView.getWidth() + coverArtView.getPaddingRight();
                    }
                    float textLineHeight = artistView.getPaint().getTextSize();

                    int lines = (int) Math.ceil(height / textLineHeight) + 1;

                    SpannableString ss = new SpannableString(spannedText);
                    ss.setSpan(new MyLeadingMarginSpan2(lines, width), 0, ss.length(),
                            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

                    View linearLayout = header.findViewById(R.id.select_album_text_layout);
                    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) linearLayout
                            .getLayoutParams();
                    int[] rules = params.getRules();
                    rules[RelativeLayout.RIGHT_OF] = 0;
                    params.leftMargin = vlp.rightMargin;

                    artistView.setText(ss);
                    artistView.setMaxLines(100);

                    vlp = (ViewGroup.MarginLayoutParams) titleView.getLayoutParams();
                    vlp.leftMargin = width;
                } else {
                    artistView.setMaxLines(minLines);
                }
            }
        });
        artistView.setMovementMethod(LinkMovementMethod.getInstance());
    } else if (topTracks) {
        artistView.setText(R.string.menu_top_tracks);
        artistView.setVisibility(View.VISIBLE);
    } else if (showAll) {
        artistView.setText(R.string.menu_show_all);
        artistView.setVisibility(View.VISIBLE);
    } else if (artists.size() == 1) {
        String artistText = artists.iterator().next();
        if (years.size() == 1) {
            artistText += " - " + years.iterator().next();
        }
        artistView.setText(artistText);
        artistView.setVisibility(View.VISIBLE);
    } else {
        artistView.setVisibility(View.GONE);
    }

    TextView songCountView = (TextView) header.findViewById(R.id.select_album_song_count);
    TextView songLengthView = (TextView) header.findViewById(R.id.select_album_song_length);
    if (podcastDescription != null || artistInfo != null) {
        songCountView.setVisibility(View.GONE);
        songLengthView.setVisibility(View.GONE);
    } else {
        String s = context.getResources().getQuantityString(R.plurals.select_album_n_songs, songCount,
                songCount);

        songCountView.setVisibility(View.GONE);
        songLengthView.setVisibility(View.GONE);
    }
}

From source file:androidx.media.widget.MediaControlView2.java

@SuppressWarnings("deprecation")
private void updateLayoutForSizeChange(int sizeType) {
    mSizeType = sizeType;//from  w ww. j  a  v a  2  s  .  co m
    RelativeLayout.LayoutParams timeViewParams = (RelativeLayout.LayoutParams) mTimeView.getLayoutParams();
    SeekBar seeker = (SeekBar) mProgress;
    switch (mSizeType) {
    case SIZE_TYPE_EMBEDDED:
        // Relating to Title Bar
        mTitleBar.setVisibility(View.VISIBLE);
        mBackButton.setVisibility(View.GONE);

        // Relating to Full Screen Button
        mMinimalExtraView.setVisibility(View.GONE);
        mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen);
        mFullScreenButton.setOnClickListener(mFullScreenListener);

        // Relating to Center View
        mCenterView.removeAllViews();
        mBottomBarLeftView.removeView(mTransportControls);
        mBottomBarLeftView.setVisibility(View.GONE);
        mTransportControls = inflateTransportControls(R.layout.embedded_transport_controls);
        mCenterView.addView(mTransportControls);

        // Relating to Progress Bar
        seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb));
        mProgressBuffer.setVisibility(View.VISIBLE);

        // Relating to Bottom Bar
        mBottomBar.setVisibility(View.VISIBLE);
        if (timeViewParams.getRules()[RelativeLayout.LEFT_OF] != 0) {
            timeViewParams.removeRule(RelativeLayout.LEFT_OF);
            timeViewParams.addRule(RelativeLayout.RIGHT_OF, R.id.bottom_bar_left);
        }
        break;
    case SIZE_TYPE_FULL:
        // Relating to Title Bar
        mTitleBar.setVisibility(View.VISIBLE);
        mBackButton.setVisibility(View.VISIBLE);

        // Relating to Full Screen Button
        mMinimalExtraView.setVisibility(View.GONE);
        mFullScreenButton = mBottomBarRightView.findViewById(R.id.fullscreen);
        mFullScreenButton.setOnClickListener(mFullScreenListener);

        // Relating to Center View
        mCenterView.removeAllViews();
        mBottomBarLeftView.removeView(mTransportControls);
        mTransportControls = inflateTransportControls(R.layout.full_transport_controls);
        mBottomBarLeftView.addView(mTransportControls, 0);
        mBottomBarLeftView.setVisibility(View.VISIBLE);

        // Relating to Progress Bar
        seeker.setThumb(mResources.getDrawable(R.drawable.custom_progress_thumb));
        mProgressBuffer.setVisibility(View.VISIBLE);

        // Relating to Bottom Bar
        mBottomBar.setVisibility(View.VISIBLE);
        if (timeViewParams.getRules()[RelativeLayout.RIGHT_OF] != 0) {
            timeViewParams.removeRule(RelativeLayout.RIGHT_OF);
            timeViewParams.addRule(RelativeLayout.LEFT_OF, R.id.bottom_bar_right);
        }
        break;
    case SIZE_TYPE_MINIMAL:
        // Relating to Title Bar
        mTitleBar.setVisibility(View.GONE);
        mBackButton.setVisibility(View.GONE);

        // Relating to Full Screen Button
        mMinimalExtraView.setVisibility(View.VISIBLE);
        mFullScreenButton = mMinimalExtraView.findViewById(R.id.minimal_fullscreen);
        mFullScreenButton.setOnClickListener(mFullScreenListener);

        // Relating to Center View
        mCenterView.removeAllViews();
        mBottomBarLeftView.removeView(mTransportControls);
        mTransportControls = inflateTransportControls(R.layout.minimal_transport_controls);
        mCenterView.addView(mTransportControls);

        // Relating to Progress Bar
        seeker.setThumb(null);
        mProgressBuffer.setVisibility(View.GONE);

        // Relating to Bottom Bar
        mBottomBar.setVisibility(View.GONE);
        break;
    }
    mTimeView.setLayoutParams(timeViewParams);

    if (isPlaying()) {
        mPlayPauseButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_pause_circle_filled, null));
        mPlayPauseButton.setContentDescription(mResources.getString(R.string.mcv2_pause_button_desc));
    } else {
        mPlayPauseButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_play_circle_filled, null));
        mPlayPauseButton.setContentDescription(mResources.getString(R.string.mcv2_play_button_desc));
    }

    if (mIsFullScreen) {
        mFullScreenButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_fullscreen_exit, null));
    } else {
        mFullScreenButton.setImageDrawable(mResources.getDrawable(R.drawable.ic_fullscreen, null));
    }
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*******************************************
 * /*from w  w w . jav a 2 s.co  m*/
 * initializeUiVariables
 * 
 *******************************************/
private void initializeUiVariables() {

    /*
     *  Retrieve components from layout
     */
    this.currentAlbumPlayingImageView = (ImageView) findViewById(R.id.current_album_image);
    this.currentAlbumPlayingOverlayImageView = (ImageView) findViewById(R.id.current_album_image_overlay);
    this.mainUIContainer = (ViewGroup) findViewById(R.id.songfest_main_ui_container);
    this.containerLayout = (ViewGroup) findViewById(R.id.songfest_container);
    this.currentPlayingLayout = (ViewGroup) findViewById(R.id.songfest_current_playing_container);
    this.currentAlbumPlayingLayout = (ViewGroup) findViewById(R.id.songfest_current_album_playing_container);
    this.currentAlbumPlayingLayoutOuter = (ViewGroup) findViewById(
            R.id.songfest_current_album_playing_container_global);
    this.albumNavigatorLayout = (ViewGroup) findViewById(R.id.songfest_navigator_container);
    this.albumNavigatorLayoutOuter = (ViewGroup) findViewById(R.id.songfest_navigator_container_outer);
    this.albumNavigatorList = (ListView) findViewById(R.id.navigator_listview);
    //       this.albumNavigatorTextContainer   = (ViewGroup)
    //                                     findViewById(R.id.navigator_album_text_container);
    //       this.navigatorInitialTextView      = (TextView)
    //                                     findViewById(R.id.navigator_initial);
    this.currentPlayingSongContainer = (ViewGroup) findViewById(R.id.current_playing_song_container);
    this.artistNameText = (TextView) findViewById(R.id.songfest_current_playing_artist);
    this.albumNameText = (TextView) findViewById(R.id.songfest_current_playing_album_name);
    this.songNameText = (TextView) findViewById(R.id.songfest_current_playing_song_name);
    this.songDurationText = (TextView) findViewById(R.id.songfest_current_playing_song_progress);
    this.songDurationOngoingText = (TextView) findViewById(R.id.songfest_current_playing_song_progress_ongoing);
    //       this.songListContainer            = (ViewGroup)
    //                                     findViewById(R.id.song_listview_container);
    //       this.songListHint               = (TextView)
    //                                     findViewById(R.id.song_listhint);
    //       this.songListView               = (ListView)
    //                                     findViewById(R.id.song_listview);
    this.eventListViewContainer = (ViewGroup) findViewById(R.id.event_listview_container);
    this.eventListDecreaseRadius = (ImageButton) findViewById(R.id.event_decrease_radius);
    this.eventListIncreaseRadius = (ImageButton) findViewById(R.id.event_increase_radius);
    this.eventListRadius = (EditText) findViewById(R.id.event_radius);
    this.eventListRadiusMetric = (TextView) findViewById(R.id.event_radius_metric);
    this.eventListView = (ListView) findViewById(R.id.event_listview);
    this.songProgressBar = (ProgressBar) findViewById(R.id.songfest_current_playing_song_progressbar);
    //       this.webView                  = (WebView)
    //                                     findViewById(R.id.web_view);
    this.songSearchContainer = (ViewGroup) findViewById(R.id.songsearch_container);
    this.songSearchTextView = (AutoCompleteTextView) findViewById(R.id.songsearch_textview);
    this.helpImageView = (ImageView) findViewById(R.id.help_image);
    this.helpView = (ViewGroup) findViewById(R.id.help_view);

    /*
     * Control buttons and button overlays
     */
    this.playPauseImage = (ImageView) findViewById(R.id.current_album_image_play_pause);
    //playPauseImage.setImageResource(android.R.drawable.ic_media_play);
    //       this.playPauseImageOverlay         = (ImageView)
    //                                    findViewById(R.id.current_album_image_play_pause_overlay);
    //       playPauseImageOverlay.setVisibility(View.GONE);
    //       playPauseImageOverlay.setImageResource(R.drawable.button_big_highlight_gradient);
    //       
    //       this.rewindImage               = (ImageView)
    //                                     findViewById(R.id.rewind_image);
    //       rewindImage.setImageResource(android.R.drawable.ic_media_rew);
    //      this.rewindImageOverlay            = (ImageView)
    //                                     findViewById(R.id.rewind_image_overlay);
    //       rewindImageOverlay.setVisibility(View.GONE);
    //      rewindImageOverlay.setImageResource(R.drawable.button_small_highlight_gradient);
    //       
    //      this.forwardImage               = (ImageView)
    //                                     findViewById(R.id.forward_image);
    //       forwardImage.setImageResource(android.R.drawable.ic_media_ff);
    //       this.forwardImageOverlay         = (ImageView)
    //                                     findViewById(R.id.forward_image_overlay);
    //       forwardImageOverlay.setVisibility(View.GONE);
    //       forwardImageOverlay.setImageResource(R.drawable.button_small_highlight_gradient);
    //       
    //       this.nextImage                  = (ImageView)
    //                                     findViewById(R.id.next_image);
    //       nextImage.setImageResource(android.R.drawable.ic_media_next);
    //this.nextImageOverlay            = (ImageView)
    //                              findViewById(R.id.skipsong_image_overlay);
    //nextImageOverlay.setImageResource(android.R.drawable.ic_media_next);
    //       this.songSearchButton            = (Button)
    //                                     findViewById(R.id.songsearch_button);
    //       this.songProgressTotalView         = (ImageView)
    //                                    findViewById(R.id.songfest_current_playing_song_progress_total);
    //      this.songProgressView            = (ImageView)
    //                                    findViewById(R.id.songfest_current_playing_song_progress_current);
    //       this.preferenceScreen            = (PreferenceScreen)
    //                                     findViewById(R.id.preference_screen);

    /*
     *  Put views in perspective
     */
    //this.currentAlbumPlayingLayout.startAnimation(perspectiveLeft);
    this.currentPlayingLayout.startAnimation(perspectiveLeft);
    this.albumNavigatorList.startAnimation(perspectiveRight);

    /*
     *  Setup interaction listeners
     */
    this.albumNavigatorList.setOnItemClickListener(this.albumNavigatorListItemClickListener);
    this.albumNavigatorList.setOnItemLongClickListener(this.albumNavigatorListItemLongClickListener);
    this.albumNavigatorList.setOnScrollListener(this.albumNavigatorScrollListener);
    this.albumNavigatorList.setOnTouchListener(this.mainUIContainerTouchListener);

    this.currentAlbumPlayingImageView.setOnTouchListener(this.mainUIContainerTouchListener);

    this.currentAlbumPlayingImageView.setOnClickListener(currentAlbumClickListener);

    this.currentPlayingSongContainer.setOnClickListener(this.songNameClickListener);
    this.currentPlayingSongContainer.setOnTouchListener(this.songTouchListener);

    //       this.songNameText.setOnClickListener(this.songNameClickListener);
    //       this.songNameText.setOnTouchListener(this.songTouchListener);
    //       this.songDurationText.setOnClickListener(this.songNameClickListener);
    //       this.songDurationText.setOnTouchL   istener(this.songTouchListener);
    //       this.songProgressBar.setOnClickListener(this.songNameClickListener);
    //       this.songProgressBar.setOnTouchListener(this.songTouchListener);
    //this.songListView.setOnKeyListener(this.songListKeyListener);
    //this.songListContainer.setOnKeyListener(this.songListKeyListener);
    //this.containerLayout.setOnKeyListener(this.songListKeyListener);
    //       this.songListView.setOnItemClickListener(this.songListItemClickListener);
    //       this.songListView.setOnItemLongClickListener(this.songListItemLongClickListener);
    // Temporary change - for now
    //this.currentAlbumPlayingImageView.setOnLongClickListener(this.songNameLongClickListener);
    //this.songNameText.setOnLongClickListener(this.songNameLongClickListener);
    //this.songDurationText.setOnLongClickListener(this.songNameLongClickListener);
    this.artistNameText.setOnClickListener(this.artistNameClickListener);
    this.albumNameText.setOnClickListener(this.artistNameClickListener);
    //this.webView.setOnKeyListener(this.webViewKeyListener);
    this.songSearchTextView.setOnItemClickListener(this.songSearchTextItemClickListener);
    this.eventListIncreaseRadius.setOnClickListener(this.eventListIncreaseRadiusClickListener);
    this.eventListDecreaseRadius.setOnClickListener(this.eventListDecreaseRadiusClickListener);
    this.helpImageView.setOnClickListener(this.helpImageClickListener);

    /*
     *  Fix layout stuff
     */
    // TODO:
    //  set the height of the top panel to be ~66% of the screen height (LANDSCAPE)

    //   set the width of the left panel to be ~66% of the screen width   (PORTRAIT)
    RelativeLayout.LayoutParams params = null;
    /* Don't know the code of Portrait */
    if (this.display.getOrientation() == 0) {
        params = new RelativeLayout.LayoutParams(
                (int) Math.round(this.display.getWidth() * CURRENT_PLAY_SCREEN_FRACTION),
                LayoutParams.FILL_PARENT);
        this.currentPlayingLayout.setLayoutParams(params);

    } else {
        params = new RelativeLayout.LayoutParams(
                (int) Math.round(this.display.getWidth() * CURRENT_PLAY_SCREEN_FRACTION_LANDSCAPE),
                LayoutParams.FILL_PARENT);
        this.currentPlayingLayout.setLayoutParams(params);

        /* 
         * Special Positioning in Landscape Mode
         * ------- can go into a different function 
         * ------- or maybe into the XML...
         */
        //getWindow().setBackgroundDrawableResource(R.drawable.bg_landscape);
        RelativeLayout.LayoutParams p = null;
        /* album image */
        p = new RelativeLayout.LayoutParams(
                (int) Math.round(this.display.getWidth() * CURRENT_PLAY_SCREEN_FRACTION_LANDSCAPE / 2),
                (int) Math.round(this.display.getWidth() * CURRENT_PLAY_SCREEN_FRACTION_LANDSCAPE / 2));
        p.topMargin = 12;
        p.leftMargin = 12;
        this.currentAlbumPlayingLayoutOuter.setLayoutParams(p);

        /*
         * Current Artist&Album container to the right of the album
         */
        p = (LayoutParams) findViewById(R.id.current_playing_artist_album_container).getLayoutParams();
        p.addRule(RelativeLayout.RIGHT_OF, R.id.songfest_current_album_playing_container_global);
        p.addRule(RelativeLayout.ABOVE, R.id.current_playing_song_container);
        findViewById(R.id.current_playing_artist_album_container).setLayoutParams(p);
        /* artist name */
        //          p = (LayoutParams) this.artistNameText.getLayoutParams();
        //          p.addRule(RelativeLayout.RIGHT_OF, R.id.songfest_current_album_playing_container_global);
        //          this.artistNameText.setLayoutParams(p);
        /* album name */
        //          p = (LayoutParams) this.albumNameText.getLayoutParams();
        //          p.addRule(RelativeLayout.RIGHT_OF, R.id.songfest_current_album_playing_container_global);
        //          this.albumNameText.setLayoutParams(p);
        /* song name */
        //          p = (LayoutParams) this.songNameText.getLayoutParams();
        //          p.addRule(RelativeLayout.BELOW, R.id.songfest_current_album_playing_container_global);
        //          this.songNameText.setLayoutParams(p);
        this.songNameText.setSingleLine();
        /* song progress */
        //p = (LayoutParams) this.songProgressBar.getLayoutParams();
        //p.addRule(RelativeLayout.RIGHT_OF, R.id.songfest_current_album_playing_container_global);
        //this.songProgressBar.setLayoutParams(p);
    }

    /*       RelativeLayout.LayoutParams rParams = new RelativeLayout.LayoutParams(
                            (int) Math.round(
                                     this.display.getWidth()*CURRENT_PLAY_SCREEN_FRACTION),
                            LayoutParams.FILL_PARENT);
           this.currentAlbumPlayingLayout.setLayoutParams(rParams);*/

    /*
     * Create Album Labels (TextViews)
     */
    /*
    int listHeight = this.display.getHeight()-20;
    int numberOfVisibleAlbums = (int) Math.floor(listHeight/(this.display.getWidth()*NAVIGATOR_SCREEN_FRACTION))+1;
    for(int i = 0; i < numberOfVisibleAlbums; i++){
       TextView albumLabel = new TextView(this);
       LinearLayout.LayoutParams tParams = new LinearLayout.LayoutParams(
                               (int) (this.display.getWidth()*NAVIGATOR_SCREEN_FRACTION*1.75),
                               (int) (this.display.getWidth()*NAVIGATOR_SCREEN_FRACTION*0.5));
       tParams.bottomMargin = (int) (this.display.getWidth()*NAVIGATOR_SCREEN_FRACTION*0.25);
       tParams.topMargin = (int) (this.display.getWidth()*NAVIGATOR_SCREEN_FRACTION*0.25);
       albumLabel.setLayoutParams(tParams);
       albumLabel.setTextColor(Color.argb(200, 255, 255, 255));
       albumLabel.setTextSize(20);
       albumLabel.setMaxLines(4);
       albumLabel.setBackgroundResource(R.drawable.album_text_bg);
       this.albumNavigatorTextContainer.addView(albumLabel);
    }
    this.albumNavigatorTextContainer.setVisibility(View.GONE);
    */
}

From source file:com.aimfire.demo.CamcorderActivity.java

private void adjustUIControls(int rotation) {
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mShutterLayout.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mShutterLayout.setLayoutParams(layoutParams);
    mShutterLayout.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mPvButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ABOVE, 0);
    layoutParams.addRule(RelativeLayout.BELOW, R.id.shutter_layout);
    mPvButton.setLayoutParams(layoutParams);
    mPvButton.setRotation(rotation);/*from   w  w  w . j a  v a2  s  .c o  m*/

    /*
    layoutParams = (RelativeLayout.LayoutParams)mFbButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ABOVE, R.id.shutter_layout);
    layoutParams.addRule(RelativeLayout.BELOW, 0);
    mFbButton.setLayoutParams(layoutParams);
    mFbButton.setRotation(rotation);
    */

    layoutParams = (RelativeLayout.LayoutParams) mExitButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    mExitButton.setLayoutParams(layoutParams);
    mExitButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mView3DButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mView3DButton.setLayoutParams(layoutParams);
    mView3DButton.setRotation(rotation);

    View view3DPb = findViewById(R.id.view3D_progress_bar);
    layoutParams = (RelativeLayout.LayoutParams) view3DPb.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    view3DPb.setLayoutParams(layoutParams);
    view3DPb.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mScanProgView.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.LEFT_OF, 0);
    layoutParams.addRule(RelativeLayout.RIGHT_OF, 0);
    mScanProgView.setLayoutParams(layoutParams);
    mScanProgView.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mScanModeButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.LEFT_OF, 0);
    layoutParams.addRule(RelativeLayout.RIGHT_OF, 0);
    mScanModeButton.setLayoutParams(layoutParams);
    mScanModeButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mLevelButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    mLevelButton.setLayoutParams(layoutParams);
    mLevelButton.setRotation(rotation);

    layoutParams = (RelativeLayout.LayoutParams) mTimeCounter.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.LEFT_OF, R.id.mode_button);
    layoutParams.addRule(RelativeLayout.RIGHT_OF, 0);
    layoutParams.addRule(RelativeLayout.ABOVE, 0);
    layoutParams.addRule(RelativeLayout.BELOW, 0);
    mTimeCounter.setLayoutParams(layoutParams);

    if ((rotation == 0) || (rotation == 180)) {
        mTimeCounter.setTranslationY(0);
    } else {
        mTimeCounter.setTranslationY(mTimeCounter.getWidth() / 2);
    }
    mTimeCounter.setRotation(rotation);

    CustomToast.setRotation(rotation);
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/********************************
 * //from w w  w . ja v  a2s  .c o  m
 * switch between different UI modes
 * 
 ********************************/
public void setNormalView() {
    if (VIEW_STATE == NORMAL_VIEW) {

    } else if (VIEW_STATE == LIST_EXPANDED_VIEW) {
        /*
         * Animate fading of the current playing layout
         */

        /*
         * Put album navigator full screen (this will happen in the end of the animation)
         */
        RelativeLayout.LayoutParams params = (LayoutParams) albumNavigatorLayoutOuter.getLayoutParams();
        params.addRule(RelativeLayout.RIGHT_OF, R.id.songfest_current_playing_container);
        albumNavigatorLayoutOuter.setLayoutParams(params);

        /*
         * Animate growth of the album navigator
         */
        int slideAmount = currentPlayingLayout.getWidth();
        albumNavigatorLayoutOuter.bringToFront();
        TranslateAnimation slideRight = new TranslateAnimation(-slideAmount, 0, 0, 0);
        slideRight.setFillAfter(true);
        slideRight.setDuration(250);
        slideRight.setAnimationListener(slideRightAnimationListener);
        albumNavigatorLayoutOuter.startAnimation(slideRight);

    } else if (VIEW_STATE == FULLSCREEN_VIEW) {

        setBackground();

        AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        fadeOut.setFillAfter(true);
        fadeOut.setDuration(300);
        this.mainUIContainer.startAnimation(fadeOut);

        showFullScreenHandler.sendEmptyMessageDelayed(VIEW_STATE, 300);

        VIEW_STATE = FULLSCREEN_VIEW;

    }

    VIEW_STATE = NORMAL_VIEW;
    return;
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

public void setListExpandedView() {

    try {/*from w  w w .ja v a  2 s .  c o  m*/
        /*
         * Animate fading of the current playing layout
         */
        Rotate3dAnimation perspectiveFullLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                90, 90, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
        perspectiveFullLeft.setFillAfter(true);
        perspectiveFullLeft.setDuration(1);
        currentPlayingLayout.startAnimation(perspectiveFullLeft);

        // hide parts of mainUI

        /*
         * Animate growth of the album navigator
         */
        int slideAmount = display.getWidth() - albumNavigatorList.getWidth();
        TranslateAnimation slideLeft = new TranslateAnimation(slideAmount, 0, 0, 0);
        slideLeft.setFillAfter(true);
        slideLeft.setDuration(400);
        albumNavigatorLayoutOuter.startAnimation(slideLeft);

        /*
         * Put album navigator full screen
         */
        RelativeLayout.LayoutParams params = (LayoutParams) albumNavigatorLayoutOuter.getLayoutParams();
        params.addRule(RelativeLayout.RIGHT_OF, 0);
        albumNavigatorLayoutOuter.setLayoutParams(params);
        //albumNavigatorLayout.setBackgroundColor(Color.WHITE);
        //            
        //            LayoutParams paramsList = (LayoutParams) albumNavigatorList.getLayoutParams();
        //            paramsList.width = display.getWidth();
        //            albumNavigatorList.setLayoutParams(paramsList);

        //         currentPlayingLayout.setVisibility(View.GONE);

        VIEW_STATE = LIST_EXPANDED_VIEW;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return;

}