Example usage for android.widget RelativeLayout TRUE

List of usage examples for android.widget RelativeLayout TRUE

Introduction

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

Prototype

int TRUE

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

Click Source Link

Usage

From source file:com.jarklee.materialdatetimepicker.time.TimePickerDialog.java

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

    View view = inflater.inflate(R.layout.mdtp_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());
    }/*w w w. j av  a2  s  .co  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);

    mHourView = (TextView) view.findViewById(R.id.hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    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(getLocale()).getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

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

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

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            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(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(Utils.getStringFromLocale(getContext(), mOkResid, getLocale()));

    mCancelButton = (Button) view.findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mCancelString != null)
        mCancelButton.setText(mCancelString);
    else
        mCancelButton.setText(Utils.getStringFromLocale(getContext(), mCancelResid, getLocale()));
    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) {
        mSecondView.setVisibility(View.GONE);
        view.findViewById(R.id.separator_seconds).setVisibility(View.GONE);
    }

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // 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 (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.hour_space);
            mAmPmTextView.setLayoutParams(paramsAmPm);
        }
    } 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(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.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)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.time_picker_header);
    if (!mTitle.isEmpty()) {
        timePickerHeader.setVisibility(TextView.VISIBLE);
        timePickerHeader.setText(mTitle.toUpperCase(getLocale()));
    }

    // 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(mAccentColor);
    view.findViewById(R.id.time_display).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);
    view.findViewById(R.id.time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

From source file:com.wit.and.dialog.internal.BaseDialog.java

/**
 * <p>/*from   ww  w .  j  av a  2  s . c  o  m*/
 * Corrects the dialog view (if is instance of <code>RelativeLayout</code>).
 * This actually place the dialog main views (title, body, buttons) into
 * correct place. If you decide override this for better dialog view
 * performance it is necessary to call <code>super</code> here.
 * </p>
 *
 * @param requestedCorrection Requested operation for correction in the dialog view as
 *                            relative layout.
 * @param dialogView          Inflated dialog view.
 */
protected void onCorrectLayout(DialogLayoutCorrection requestedCorrection, View dialogView) {
    // Save call state.
    this.bCalled = true;

    // Perform only if we have valid body view.
    if (mBodyView == null || mLayoutCorrection == requestedCorrection
            || !(dialogView instanceof RelativeLayout))
        return;

    // Create layout parameters for body and buttons view.
    RelativeLayout.LayoutParams bodyParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams buttonsParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    if (mBodyView.getLayoutParams() != null) {
        bodyParams = new RelativeLayout.LayoutParams(mBodyView.getLayoutParams());
    }
    if (mButtonsView != null && mButtonsView.getLayoutParams() != null) {
        buttonsParams = new RelativeLayout.LayoutParams(mButtonsView.getLayoutParams());
    }

    // Default merge.
    DialogLayoutCorrection helper = this.mLayoutCorrection;
    this.mLayoutCorrection = requestedCorrection;

    // Merge actual state of the relative layout correction.
    switch (requestedCorrection) {
    case WITH_TITLE_AND_BUTTONS:
    case WITHOUT_BOTH:
        break;
    case WITH_TITLE:
        if (helper == DialogLayoutCorrection.WITH_BUTTONS) {
            this.mLayoutCorrection = DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS;
        }
        break;
    case WITHOUT_TITLE:
        if (helper == DialogLayoutCorrection.WITH_BUTTONS) {
            this.mLayoutCorrection = DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS;
        } else if (helper == DialogLayoutCorrection.WITHOUT_BUTTONS) {
            this.mLayoutCorrection = DialogLayoutCorrection.WITHOUT_BOTH;
        }
        break;
    case WITH_BUTTONS:
        if (helper == DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS) {
            return;
        } else if (helper == DialogLayoutCorrection.WITH_TITLE) {
            this.mLayoutCorrection = DialogLayoutCorrection.WITH_TITLE_AND_BUTTONS;
        }
        break;
    case WITHOUT_BUTTONS:
        if (helper == DialogLayoutCorrection.WITHOUT_TITLE) {
            this.mLayoutCorrection = DialogLayoutCorrection.WITHOUT_BOTH;
        }
        break;
    }

    // We just will set new parameters to the body view, which can depends
    // on the title or buttons view existence in the layout but in some
    // situations we don't have for example title view in the dialog view
    // (if the title text is empty).
    switch (mLayoutCorrection) {
    case WITH_TITLE_AND_BUTTONS:
        if (mTitleView != null) {
            bodyParams.addRule(RelativeLayout.BELOW, mTitleView.getId());
        }
        buttonsParams.addRule(RelativeLayout.BELOW, mBodyView.getId());
        break;
    case WITHOUT_TITLE:
    case WITH_BUTTONS:
        bodyParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
        buttonsParams.addRule(RelativeLayout.BELOW, mBodyView.getId());
        break;
    case WITHOUT_BUTTONS:
    case WITH_TITLE:
        if (mTitleView != null) {
            bodyParams.addRule(RelativeLayout.BELOW, mTitleView.getId());
        }
        break;
    case WITHOUT_BOTH:
        bodyParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
        break;
    }

    if (DEBUG)
        Log.d(TAG, "Dialog layout corrected to state " + mLayoutCorrection);

    // Set new parameters to the body view.
    mBodyView.setLayoutParams(bodyParams);
    // Set new parameters to the buttons view if we have it.
    if (mButtonsView != null) {
        mButtonsView.setLayoutParams(buttonsParams);
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

public void makeLayout() {
    // make fonts
    this.makeFonts();
    // clear the existing themes. 
    themes.clear();//from   w  w  w  .  ja  v  a2  s . c o m
    // add themes 
    // String name,int foregroundColor,int backgroundColor,int controlColor,int controlHighlightColor,int seekBarColor,int seekThumbColor,int selectorColor,int selectionColor,String portraitName,String landscapeName,String doublePagedName,int bookmarkId
    themes.add(new Theme("white", Color.BLACK, 0xffffffff, Color.argb(240, 94, 61, 35), Color.LTGRAY,
            Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95), Color.DKGRAY, 0x22222222,
            "Phone-Portrait-White.png", "Phone-Landscape-White.png", "Phone-Landscape-Double-White.png",
            R.drawable.bookmark2x));
    themes.add(new Theme("brown", Color.BLACK, 0xffece3c7, Color.argb(240, 94, 61, 35),
            Color.argb(255, 255, 255, 255), Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95),
            Color.DKGRAY, 0x22222222, "Phone-Portrait-Brown.png", "Phone-Landscape-Brown.png",
            "Phone-Landscape-Double-Brown.png", R.drawable.bookmark2x));
    themes.add(new Theme("black", Color.LTGRAY, 0xff323230, Color.LTGRAY, Color.LTGRAY, Color.LTGRAY,
            Color.LTGRAY, Color.LTGRAY, 0x77777777, null, null, "Phone-Landscape-Double-Black.png",
            R.drawable.bookmarkgray2x));
    themes.add(new Theme("Leaf", 0xFF1F7F0E, 0xffF8F7EA, 0xFF186D08, Color.LTGRAY, 0xFF186D08, 0xFF186D08,
            Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x));
    themes.add(new Theme("", 0xFFA13A0A, 0xFFF6DFD9, 0xFFA13A0A, 0xFFDC4F0E, 0xFFA13A0A, 0xFFA13A0A,
            Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x));
    this.setBrightness((float) setting.brightness);
    // create highlights object to contains highlights of this book. 
    highlights = new Highlights();
    Bundle bundle = getIntent().getExtras();
    fileName = bundle.getString("BOOKNAME");
    author = bundle.getString("AUTHOR");
    title = bundle.getString("TITLE");
    bookCode = bundle.getInt("BOOKCODE");
    if (pagePositionInBook == -1)
        pagePositionInBook = bundle.getDouble("POSITION");
    themeIndex = setting.theme;
    this.isGlobalPagination = bundle.getBoolean("GLOBALPAGINATION");
    this.isRTL = bundle.getBoolean("RTL");
    this.isVerticalWriting = bundle.getBoolean("VERTICALWRITING");
    this.isDoublePagedForLandscape = bundle.getBoolean("DOUBLEPAGED");
    //      if (this.isRTL) this.isDoublePagedForLandscape = false; // In RTL mode, SDK does not support double paged. 

    ePubView = new RelativeLayout(this);

    RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT);
    ePubView.setLayoutParams(rlp);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    if (this.getOSVersion() >= 11) {
        rv = new ReflowableControl(this); // in case that device supports transparent webkit, the background image under the content can be shown. in some devices, content may be overlapped.
    } else {
        rv = new ReflowableControl(this, getCurrentTheme().backgroundColor); // in case that device can not support transparent webkit, the background color will be set in one color.
    }

    // if false highlight will be drawed on the back of text - this is default. 
    // for the very old devices of which GPU does not support transparent webView background, set the value to true.  
    rv.setDrawingHighlightOnFront(false);

    // set the bookCode to identify the book file. 
    rv.bookCode = this.bookCode;

    // set bitmaps for engine. 
    rv.setPagesStackImage(this.getBitmap("PagesStack.png"));
    rv.setPagesCenterImage(this.getBitmap("PagesCenter.png"));
    // for epub3 which has page-progression-direction="rtl", rv.isRTL() will return true.
    // for old RTL epub which does not have <spine toc="ncx" page-progression-direction="rtl"> in opf file. 
    // you can enforce RTL mode.  

    /*      
          // delay times for proper operations. 
          // !! DO NOT SET these values if there's no issue on your epub reader. !!
          // !! if delayTime is decresed, performance will be increase
          // !! if delayTime is set to too low value, a lot of problem can be occurred. 
          // bringDelayTime(default 500 ms) is for curlView and mainView transition - if the value is too short, blink may happen.
          rv.setBringDelayTime(500);
          // reloadDelayTime(default 100) is used for delay before reload (eg. changeFont, loadChapter or etc) 
          rv.setReloadDelayTime(100);
          // reloadDelayTimeForRotation(default 1000) is used for delay before rotation
          rv.setReloadDelayTimeForRotation(1000);
          // retotaionDelayTime(default 1500) is used for delay after rotation.
          rv.setRotationDelayTime(1500);
          // finalDelayTime(default 500) is used for the delay after loading chapter. 
          rv.setFinalDelayTime(500);
          // rotationFactor affects the delayTime before Rotation. default value 1.0f
          rv.setRotationFactor(1.0f);      
          // If recalcDelayTime is too short, setContentBackground function failed to work properly.  
          rv.setRecalcDelayTime(2500);
    */

    // set the max width or height for background. 
    rv.setMaxSizeForBackground(1024);
    //      rv.setBaseDirectory(SkySetting.getStorageDirectory() + "/books");
    //      rv.setBookName(fileName);
    // set the file path of epub to open
    // Be sure that the file exists before setting.
    rv.setBookPath(SkySetting.getStorageDirectory() + "/books/" + fileName);
    // if true, double pages will be displayed on landscape mode. 
    rv.setDoublePagedForLandscape(this.isDoublePagedForLandscape);
    // set the initial font style for book. 
    rv.setFont(setting.fontName, this.getRealFontSize(setting.fontSize));
    // set the initial line space for book. 
    rv.setLineSpacing(this.getRealLineSpace(setting.lineSpacing)); // the value is supposed to be percent(%).
    // set the horizontal gap(margin) on both left and right side of each page.  
    rv.setHorizontalGapRatio(0.30);
    // set the vertical gap(margin) on both top and bottom side of each page. 
    rv.setVerticalGapRatio(0.22);
    // set the HighlightListener to handle text highlighting. 
    rv.setHighlightListener(new HighlightDelegate());
    // set the PageMovedListener which is called whenever page is moved. 
    rv.setPageMovedListener(new PageMovedDelegate());
    // set the SelectionListener to handle text selection. 
    rv.setSelectionListener(new SelectionDelegate());
    // set the pagingListener which is called when GlobalPagination is true. this enables the calculation for the total number of pages in book, not in chapter.   
    rv.setPagingListener(new PagingDelegate());
    // set the searchListener to search keyword.
    rv.setSearchListener(new SearchDelegate());
    // set the stateListener to monitor the state of sdk engine. 
    rv.setStateListener(new StateDelegate());
    // set the clickListener which is called when user clicks
    rv.setClickListener(new ClickDelegate());
    // set the bookmarkListener to toggle bookmark
    rv.setBookmarkListener(new BookmarkDelegate());
    // set the scriptListener to set custom javascript. 
    rv.setScriptListener(new ScriptDelegate());

    // enable/disable scroll mode
    rv.setScrollMode(false);

    // for some anroid device, when rendering issues are occurred, use "useSoftwareLayer"
    //      rv.useSoftwareLayer();
    // In search keyword, if true, sdk will return search result with the full information such as position, pageIndex. 
    rv.setFullSearch(true);
    // if true, sdk will return raw text for search result, highlight text or body text without character escaping.  
    rv.setRawTextRequired(false);

    // if true, sdk will read the content of book directry from file system, not via Internal server. 
    //      rv.setDirectRead(true);

    // If you want to make your own provider, please look into EpubProvider.java in Advanced demo.
    //      EpubProvider epubProvider = new EpubProvider();
    //      rv.setContentProvider(epubProvider);      

    // SkyProvider is the default ContentProvider which is presented with SDK. 
    // SkyProvider can read the content of epub file without unzipping. 
    // SkyProvider is also fully integrated with SkyDRM solution.  
    SkyProvider skyProvider = new SkyProvider();
    skyProvider.setKeyListener(new KeyDelegate());
    rv.setContentProvider(skyProvider);

    // set the start positon to open the book. 
    rv.setStartPositionInBook(pagePositionInBook);
    // DO NOT USE BELOW, if true , sdk will use DOM to highlight text.  
    //      rv.useDOMForHighlight(false);
    // if true, globalPagination will be activated. 
    // this enables the calculation of page number based on entire book ,not on each chapter.
    // this globalPagination consumes huge computing power. 
    // AVOID GLOBAL PAGINATION FOR LOW SPEC DEVICES.
    rv.setGlobalPagination(this.isGlobalPagination);
    // set the navigation area on both left and right side to go to the previous or next page when the area is clicked. 
    rv.setNavigationAreaWidthRatio(0.1f); // both left and right side.
    // set the device locked to prevent Rotation. 
    rv.setRotationLocked(setting.lockRotation);
    isRotationLocked = setting.lockRotation;
    // set the mediaOverlayListener for MediaOverlay.
    rv.setMediaOverlayListener(new MediaOverlayDelegate());
    // set the audio playing based on Sequence. 
    rv.setSequenceBasedForMediaOverlay(false);

    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.MATCH_PARENT;

    rv.setLayoutParams(params);
    this.applyThemeToRV(themeIndex);

    if (this.isFullScreenForNexus && SkyUtility.isNexus() && Build.VERSION.SDK_INT >= 19) {
        rv.setImmersiveMode(true);
    }
    // If you want to get the license key for commercial use, please email us (skytree21@gmail.com). 
    // Without the license key, watermark message will be shown in background. 
    rv.setLicenseKey("a99b-3914-a63b-8ecb");

    // set PageTransition Effect 
    int transitionType = bundle.getInt("transitionType");
    if (transitionType == 0) {
        rv.setPageTransition(PageTransition.None);
    } else if (transitionType == 1) {
        rv.setPageTransition(PageTransition.Slide);
    } else if (transitionType == 2) {
        rv.setPageTransition(PageTransition.Curl);
    }

    // setCurlQuality effects the image quality when tuning page in Curl Transition Mode. 
    // If "Out of Memory" occurs in high resolution devices with big screen, 
    // this value should be decreased like 0.25f or below.
    if (this.getMaxSize() > 1280) {
        rv.setCurlQuality(0.5f);
    }

    // set the color of text selector. 
    rv.setSelectorColor(getCurrentTheme().selectorColor);
    // set the color of text selection area. 
    rv.setSelectionColor(getCurrentTheme().selectionColor);

    // setCustomDrawHighlight & setCustomDrawCaret work only if SDK >= 11
    // if true, sdk will ask you how to draw the highlighted text
    rv.setCustomDrawHighlight(true);
    // if true, sdk will require you to draw the custom selector.
    rv.setCustomDrawCaret(true);

    rv.setFontUnit("px");

    rv.setFingerTractionForSlide(true);
    rv.setVideoListener(new VideoDelegate());

    // make engine not to send any event to iframe
    // if iframe clicked, onIFrameClicked will be fired with source of iframe
    // By Using that source of iframe, you can load the content of iframe in your own webView or another browser. 
    rv.setSendingEventsToIFrameEnabled(false);

    // make engine send any event to video(tag) or not
    // if video tag is clicked, onVideoClicked will be fired with source of iframe
    // By Using that source of video, you can load the content of video in your own media controller or another browser. 
    rv.setSendingEventsToVideoEnabled(true);

    // make engine send any event to video(tag) or not
    // if video tag is clicked, onVideoClicked will be fired with source of iframe
    // By Using that source of video, you can load the content of video in your own media controller or another browser.
    rv.setSendingEventsToAudioEnabled(true);

    // if true, sdk will return the character offset from the chapter beginning , not from element index.
    // then startIndex, endIndex of highlight will be 0 (zero) 
    rv.setGlobalOffset(true);
    // if true, sdk will return the text of each page in the PageInformation object which is passed in onPageMoved event. 
    rv.setExtractText(true);

    ePubView.addView(rv);

    this.makeControls();
    this.makeBoxes();
    this.makeIndicator();
    this.recalcFrames();
    if (this.isRTL) {
        this.seekBar.setReversed(true);
    }
    setContentView(ePubView);
    this.isInitialized = true;
}

From source file:im.vector.fragments.VectorRecentsListFragment.java

/**
 * Start the drag and drop mode//from w  w  w . jav a2  s.  c  o  m
 */
private void startDragAndDrop() {
    mIsWaitingTagOrderEcho = false;

    if (isDragAndDropSupported() && groupIsMovable(mRecentsListView.getTouchedGroupPosition())) {
        // enable the drag and drop mode
        mAdapter.setIsDragAndDropMode(true);
        mSession.getDataHandler().removeListener(mEventsListener);

        int groupPos = mRecentsListView.getTouchedGroupPosition();
        int childPos = mRecentsListView.getTouchedChildPosition();

        mDraggedView = mAdapter.getChildView(groupPos, childPos, false, null, null);
        mDraggedView.setBackgroundColor(getResources().getColor(R.color.vector_silver_color));
        mDraggedView.setAlpha(0.3f);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
        mSelectedCellLayout.addView(mDraggedView, params);

        mDestGroupPosition = mOriginGroupPosition = groupPos;
        mDestChildPosition = mOriginChildPosition = childPos;

        onTouchMove(mRecentsListView.getTouchedY(), groupPos, childPos);
    }
}

From source file:org.dkf.jmule.activities.MainActivity.java

private void updateHeader(Fragment fragment) {
    try {/* w  ww  .  j  av a  2  s .c  om*/
        RelativeLayout placeholder = (RelativeLayout) getActionBar().getCustomView();
        if (placeholder != null && placeholder.getChildCount() > 0) {
            placeholder.removeAllViews();
        }

        if (fragment instanceof MainFragment) {
            View header = ((MainFragment) fragment).getHeader(this);
            if (placeholder != null && header != null) {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT);
                params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
                placeholder.addView(header, params);
            }
        }
    } catch (Exception e) {
        log.error("Error updating main header", e);
    }
}

From source file:com.customdatepicker.time.TimePickerDialog.java

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

    int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_time_picker_dialog
            : R.layout.mdtp_time_picker_dialog_v2;
    View view = inflater.inflate(viewRes, container, false);
    KeyboardListener keyboardListener = new KeyboardListener();
    view.findViewById(R.id.mdtp_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 ww.ja va 2 s .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);

    mHourView = (TextView) view.findViewById(R.id.mdtp_hours);
    mHourView.setOnKeyListener(keyboardListener);
    mHourSpaceView = (TextView) view.findViewById(R.id.mdtp_hour_space);
    mMinuteSpaceView = (TextView) view.findViewById(R.id.mdtp_minutes_space);
    mMinuteView = (TextView) view.findViewById(R.id.mdtp_minutes);
    mMinuteView.setOnKeyListener(keyboardListener);
    mSecondSpaceView = (TextView) view.findViewById(R.id.mdtp_seconds_space);
    mSecondView = (TextView) view.findViewById(R.id.mdtp_seconds);
    mSecondView.setOnKeyListener(keyboardListener);
    mAmTextView = (TextView) view.findViewById(R.id.mdtp_am_label);
    mAmTextView.setOnKeyListener(keyboardListener);
    mPmTextView = (TextView) view.findViewById(R.id.mdtp_pm_label);
    mPmTextView.setOnKeyListener(keyboardListener);
    mAmPmLayout = view.findViewById(R.id.mdtp_ampm_layout);
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mHapticFeedbackController = new HapticFeedbackController(getActivity());

    if (mTimePicker != null) {
        mInitialTime = new Timepoint(mTimePicker.getHours(), mTimePicker.getMinutes(),
                mTimePicker.getSeconds());
    }

    mInitialTime = roundToNearest(mInitialTime);

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

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

    mHourView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setCurrentItemShowing(HOUR_INDEX, true, false, true);
            tryVibrate();
        }
    });
    mMinuteView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            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.mdtp_ok);
    mOkButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInKbMode && isTypedTimeFullyLegal()) {
                finishKbMode(false);
            } else {
                tryVibrate();
            }
            notifyOnDateListener();
            dismiss();
        }
    });
    mOkButton.setOnKeyListener(keyboardListener);
    mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium"));
    if (mOkString != null)
        mOkButton.setText(mOkString);
    else
        mOkButton.setText(mOkResid);

    mCancelButton = (Button) view.findViewById(R.id.mdtp_cancel);
    mCancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    mCancelButton.setTypeface(TypefaceHelper.get(context, "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.
    if (mIs24HourMode) {
        mAmPmLayout.setVisibility(View.GONE);
    } else {
        OnClickListener listener = 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);
            }
        };
        mAmTextView.setVisibility(View.GONE);
        mPmTextView.setVisibility(View.VISIBLE);
        mAmPmLayout.setOnClickListener(listener);
        if (mVersion == Version.VERSION_2) {
            mAmTextView.setText(mAmText);
            mPmTextView.setText(mPmText);
            mAmTextView.setVisibility(View.VISIBLE);
        }
        updateAmPmDisplay(mInitialTime.isAM() ? AM : PM);

    }

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

    // Disable minutes picker
    if (!mEnableMinutes) {
        mMinuteSpaceView.setVisibility(View.GONE);
        view.findViewById(R.id.mdtp_separator).setVisibility(View.GONE);
    }

    // Center stuff depending on what's visible
    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    // Landscape layout is radically different
    if (isLandscape) {
        if (!mEnableMinutes && !mEnableSeconds) {
            // Just the hour
            // Put the hour above the center
            RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsHour.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            paramsHour.addRule(RelativeLayout.CENTER_HORIZONTAL);
            mHourSpaceView.setLayoutParams(paramsHour);
            if (mIs24HourMode) {
                // Hour + Am/Pm indicator
                // Put the am / pm indicator next to the hour
                RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space);
                mAmPmLayout.setLayoutParams(paramsAmPm);
            }
        } else if (!mEnableSeconds && mIs24HourMode) {
            // Hour + Minutes
            // Put the separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
        } else if (!mEnableSeconds) {
            // Hour + Minutes + Am/Pm indicator
            // Put separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_center_view);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Put the am/pm indicator below the separator
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.CENTER_IN_PARENT);
            paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_center_view);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        } else if (mIs24HourMode) {
            // Hour + Minutes + Seconds
            // Put the separator above the center
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Center the seconds
            RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT);
            mSecondSpaceView.setLayoutParams(paramsSeconds);
        } else {
            // Hour + Minutes + Seconds + Am/Pm Indicator
            // Put the seconds on the center
            RelativeLayout.LayoutParams paramsSeconds = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeconds.addRule(RelativeLayout.CENTER_IN_PARENT);
            mSecondSpaceView.setLayoutParams(paramsSeconds);
            // Put the separator above the seconds
            RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsSeparator.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsSeparator.addRule(RelativeLayout.ABOVE, R.id.mdtp_seconds_space);
            TextView separatorView = (TextView) view.findViewById(R.id.mdtp_separator);
            separatorView.setLayoutParams(paramsSeparator);
            // Put the Am/Pm indicator below the seconds
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.CENTER_HORIZONTAL);
            paramsAmPm.addRule(RelativeLayout.BELOW, R.id.mdtp_seconds_space);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        }
    } else if (mIs24HourMode && !mEnableSeconds && mEnableMinutes) {
        // 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.mdtp_separator);
        separatorView.setLayoutParams(paramsSeparator);
    } else if (!mEnableMinutes && !mEnableSeconds) {
        // center the hour
        RelativeLayout.LayoutParams paramsHour = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsHour.addRule(RelativeLayout.CENTER_IN_PARENT);
        mHourSpaceView.setLayoutParams(paramsHour);

        if (!mIs24HourMode) {
            RelativeLayout.LayoutParams paramsAmPm = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            paramsAmPm.addRule(RelativeLayout.RIGHT_OF, R.id.mdtp_hour_space);
            paramsAmPm.addRule(RelativeLayout.ALIGN_BASELINE, R.id.mdtp_hour_space);
            mAmPmLayout.setLayoutParams(paramsAmPm);
        }
    } else if (mEnableSeconds) {
        // link separator to minutes
        final View separator = view.findViewById(R.id.mdtp_separator);
        RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.mdtp_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.mdtp_center_view);
            mMinuteSpaceView.setLayoutParams(paramsMinutes);
        }
    }

    mAllowAutoAdvance = true;
    setHour(mInitialTime.getHour(), true);
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.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)
    TextView timePickerHeader = (TextView) view.findViewById(R.id.mdtp_time_picker_header);
    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.
    timePickerHeader.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.mdtp_time_display_background).setBackgroundColor(mAccentColor);
    view.findViewById(R.id.mdtp_time_display).setBackgroundColor(mAccentColor);

    // Button text can have a different color
    if (mOkColor != -1)
        mOkButton.setTextColor(mOkColor);
    else
        mOkButton.setTextColor(mAccentColor);
    if (mCancelColor != -1)
        mCancelButton.setTextColor(mCancelColor);
    else
        mCancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.mdtp_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);
    view.findViewById(R.id.mdtp_time_picker_dialog)
            .setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor);
    return view;
}

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

private void adjustUIControls(int rotation) {
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mCaptureButton.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mCaptureButton.setLayoutParams(layoutParams);
    mCaptureButton.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.capture_button);
    mPvButton.setLayoutParams(layoutParams);
    mPvButton.setRotation(rotation);//from www .j  a va 2  s  . com

    /*
    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.capture_button);
    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);

    layoutParams = (RelativeLayout.LayoutParams) mModeButton.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);
    mModeButton.setLayoutParams(layoutParams);
    mModeButton.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);

    CustomToast.setRotation(rotation);
}

From source file:im.neon.fragments.VectorRecentsListFragment.java

/**
 * Start the drag and drop mode/*from w  ww  . j a v  a 2 s  .com*/
 */
private void startDragAndDrop() {
    mIsWaitingTagOrderEcho = false;
    mIsWaitingDirectChatEcho = false;

    if (isDragAndDropSupported() && groupIsMovable(mRecentsListView.getTouchedGroupPosition())) {
        int groupPos = mRecentsListView.getTouchedGroupPosition();
        int childPos = mRecentsListView.getTouchedChildPosition();

        try {
            mDraggedView = mAdapter.getChildView(groupPos, childPos, false, null, null);
        } catch (Exception e) {
            Log.e(LOG_TAG, "## startDragAndDrop() : getChildView failed " + e.getMessage());
            return;
        }

        // enable the drag and drop mode
        mAdapter.setIsDragAndDropMode(true);
        mSession.getDataHandler().removeListener(mEventsListener);

        mDraggedView.setBackgroundColor(getResources().getColor(R.color.vector_silver_color));
        mDraggedView.setAlpha(0.3f);

        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
        mSelectedCellLayout.addView(mDraggedView, params);

        mDestGroupPosition = mOriginGroupPosition = groupPos;
        mDestChildPosition = mOriginChildPosition = childPos;

        onTouchMove(mRecentsListView.getTouchedY(), groupPos, childPos);
    }
}

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  ww.j a  va  2  s .  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:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

private RelativeLayout createParticipantView(MemberStatusTO ms) {
    RelativeLayout rl = new RelativeLayout(this);
    int rlW = UIUtils.convertDipToPixels(this, 55);
    rl.setLayoutParams(new RelativeLayout.LayoutParams(rlW, rlW));

    getLayoutInflater().inflate(R.layout.avatar, rl);
    ImageView avatar = (ImageView) rl.getChildAt(rl.getChildCount() - 1);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(avatar.getLayoutParams());
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    avatar.setLayoutParams(params);//from  w  w w  .  jav a2 s .c  om
    setAvatar(avatar, ms.member);

    ImageView statusView = new ImageView(this);
    int w = UIUtils.convertDipToPixels(this, 12);
    RelativeLayout.LayoutParams iconParams = new RelativeLayout.LayoutParams(w, w);
    iconParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    iconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    statusView.setLayoutParams(iconParams);
    statusView.setAdjustViewBounds(true);
    statusView.setScaleType(ScaleType.CENTER_CROP);
    setStatusIcon(statusView, ms);
    rl.addView(statusView);
    return rl;
}