Example usage for android.content.res Configuration ORIENTATION_LANDSCAPE

List of usage examples for android.content.res Configuration ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.res Configuration ORIENTATION_LANDSCAPE.

Prototype

int ORIENTATION_LANDSCAPE

To view the source code for android.content.res Configuration ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant for #orientation , value corresponding to the land resource qualifier.

Usage

From source file:com.almalence.util.Util.java

public static boolean shouldRemapOrientation(final int orientationProc, final int rotation) {
    return (orientationProc == Configuration.ORIENTATION_LANDSCAPE && rotation == Surface.ROTATION_0)
            || (orientationProc == Configuration.ORIENTATION_LANDSCAPE && rotation == Surface.ROTATION_180)
            || (orientationProc == Configuration.ORIENTATION_PORTRAIT && rotation == Surface.ROTATION_90)
            || (orientationProc == Configuration.ORIENTATION_PORTRAIT && rotation == Surface.ROTATION_270);
}

From source file:dev.ronlemire.commoncontrols.MainActivity.java

    public void StartGalleryFragment() {
   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {/*  w  w  w  . j  a  va  2 s. com*/
      Fragment galleryFragment = (Fragment) fm
            .findFragmentById(R.id.sample_replacer);
      galleryFragment = GalleryFragment.newInstance("Gallery");

      fm.beginTransaction()
         .replace(R.id.sample_replacer, galleryFragment)
         .commit();
   } else {
      GalleryFragment galleryFragment = GalleryFragment
            .newInstance("Gallery");
      getSupportFragmentManager().beginTransaction()
            .replace(MainActivity.sampleListView.getId(), galleryFragment)
            .commit();
   }
}

From source file:com.caseystalnaker.android.popinvideodemo.fragments.Camera2VideoFragment.java

private void lockOrientation() {
    Log.d(LOGTAG, "lockOrientation()");
    final int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {/*from   w  w w.j  a v  a  2 s  .  c o m*/
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }
}

From source file:dev.ronlemire.commoncontrols.MainActivity.java

public void StartGridViewFragment() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {
        Fragment gridViewFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer);
        gridViewFragment = GridViewFragment.newInstance("GridView");

        fm.beginTransaction().replace(R.id.sample_replacer, gridViewFragment).commit();
    } else {// w w w . ja v  a  2s.com
        GridViewFragment gridViewFragment = GridViewFragment.newInstance("GridView");
        getSupportFragmentManager().beginTransaction()
                .replace(MainActivity.sampleListView.getId(), gridViewFragment).commit();
    }
}

From source file:dev.ronlemire.commoncontrols.MainActivity.java

    public void StartGridViewFragment() {
   if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
         && isTablet()) {//from  ww w .  ja  va  2 s .c o m
      Fragment gridViewFragment = (Fragment) fm
            .findFragmentById(R.id.sample_replacer);
      gridViewFragment = GridViewFragment.newInstance("GridView");

      fm.beginTransaction()
         .replace(R.id.sample_replacer, gridViewFragment)
         .commit();
   } else {
      GridViewFragment gridViewFragment = GridViewFragment
            .newInstance("GridView");
      getSupportFragmentManager().beginTransaction()
            .replace(MainActivity.sampleListView.getId(), gridViewFragment)
            .commit();
   }
}

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   ww w . j av  a 2 s .c  om*/

    // 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.b44t.ui.Components.PasscodeView.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = AndroidUtilities.displaySize.y
            - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight);

    LayoutParams layoutParams;/*from w  w w.  j  a  va  2 s.co  m*/

    if (!AndroidUtilities.isTablet() && getContext().getResources()
            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
        layoutParams.width = UserConfig.passcodeType == 0 ? width / 2 : width;
        layoutParams.height = AndroidUtilities.dp(140);
        layoutParams.topMargin = (height - AndroidUtilities.dp(140)) / 2;
        passwordFrameLayout.setLayoutParams(layoutParams);

        layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
        layoutParams.height = height;
        layoutParams.leftMargin = width / 2;
        layoutParams.topMargin = height - layoutParams.height;
        layoutParams.width = width / 2;
        numbersFrameLayout.setLayoutParams(layoutParams);
    } else {
        int top = 0;
        int left = 0;
        if (AndroidUtilities.isTablet()) {
            if (width > AndroidUtilities.dp(498)) {
                left = (width - AndroidUtilities.dp(498)) / 2;
                width = AndroidUtilities.dp(498);
            }
            if (height > AndroidUtilities.dp(528)) {
                top = (height - AndroidUtilities.dp(528)) / 2;
                height = AndroidUtilities.dp(528);
            }
        }
        layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
        layoutParams.height = height / 3;
        layoutParams.width = width;
        layoutParams.topMargin = top;
        layoutParams.leftMargin = left;
        passwordFrameLayout.setTag(top);
        passwordFrameLayout.setLayoutParams(layoutParams);

        layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams();
        layoutParams.height = height / 3 * 2;
        layoutParams.leftMargin = left;
        layoutParams.topMargin = height - layoutParams.height + top;
        layoutParams.width = width;
        numbersFrameLayout.setLayoutParams(layoutParams);
    }

    int sizeBetweenNumbersX = (layoutParams.width - AndroidUtilities.dp(50) * 3) / 4;
    int sizeBetweenNumbersY = (layoutParams.height - AndroidUtilities.dp(50) * 4) / 5;

    for (int a = 0; a < 11; a++) {
        LayoutParams layoutParams1;
        int num;
        if (a == 0) {
            num = 10;
        } else if (a == 10) {
            num = 11;
        } else {
            num = a - 1;
        }
        int row = num / 3;
        int col = num % 3;
        int top;
        if (a < 10) {
            TextView textView = numberTextViews.get(a);
            TextView textView1 = lettersTextViews.get(a);
            layoutParams = (LayoutParams) textView.getLayoutParams();
            layoutParams1 = (LayoutParams) textView1.getLayoutParams();
            top = layoutParams1.topMargin = layoutParams.topMargin = sizeBetweenNumbersY
                    + (sizeBetweenNumbersY + AndroidUtilities.dp(50)) * row;
            layoutParams1.leftMargin = layoutParams.leftMargin = sizeBetweenNumbersX
                    + (sizeBetweenNumbersX + AndroidUtilities.dp(50)) * col;
            layoutParams1.topMargin += AndroidUtilities.dp(40);
            textView.setLayoutParams(layoutParams);
            textView1.setLayoutParams(layoutParams1);
        } else {
            layoutParams = (LayoutParams) eraseView.getLayoutParams();
            top = layoutParams.topMargin = sizeBetweenNumbersY
                    + (sizeBetweenNumbersY + AndroidUtilities.dp(50)) * row + AndroidUtilities.dp(8);
            layoutParams.leftMargin = sizeBetweenNumbersX
                    + (sizeBetweenNumbersX + AndroidUtilities.dp(50)) * col;
            top -= AndroidUtilities.dp(8);
            eraseView.setLayoutParams(layoutParams);
        }

        FrameLayout frameLayout = numberFrameLayouts.get(a);
        layoutParams1 = (LayoutParams) frameLayout.getLayoutParams();
        layoutParams1.topMargin = top - AndroidUtilities.dp(17);
        layoutParams1.leftMargin = layoutParams.leftMargin - AndroidUtilities.dp(25);
        frameLayout.setLayoutParams(layoutParams1);
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:com.b44t.ui.PasscodeActivity.java

private void fixLayoutInternal() {
    if (dropDownContainer != null) {
        if (!AndroidUtilities.isTablet()) {
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer
                    .getLayoutParams();//from  ww w. j av a2s  .com
            layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
            dropDownContainer.setLayoutParams(layoutParams);
        }
        if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources()
                .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            dropDown.setTextSize(18);
        } else {
            dropDown.setTextSize(20);
        }
    }
}

From source file:dev.ronlemire.commoncontrols.MainActivity.java

public void StartGridViewCustomFragment() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && isTablet()) {
        Fragment gridViewCustomFragment = (Fragment) fm.findFragmentById(R.id.sample_replacer);
        gridViewCustomFragment = GridViewCustomFragment.newInstance("GridViewCustom");

        fm.beginTransaction().replace(R.id.sample_replacer, gridViewCustomFragment).commit();
    } else {//from w w w  .j  ava  2 s.  c o  m
        GridViewCustomFragment gridViewCustomFragment = GridViewCustomFragment.newInstance("GridViewCustom");
        getSupportFragmentManager().beginTransaction()
                .replace(MainActivity.sampleListView.getId(), gridViewCustomFragment).commit();
    }
}

From source file:com.cssn.samplesdk.MainActivity.java

/**
 * Updates the card's frame layout, shows/hides the back side card frame,
 * highlights the selected option, and load the card images in the view.
 *//*w w w  .j  av  a  2s.c  o  m*/
public void updateUI() {
    if (Utils.LOG_ENABLED) {
        Utils.appendLog(TAG, "private void updateUI()");
    }

    if (mainActivityModel.getErrorMessage() != null) {
        Util.dismissDialog(alertDialog);

        alertDialog = Util.showDialog(this, mainActivityModel.getErrorMessage(),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        mainActivityModel.setErrorMessage(null);
                        isShowErrorAlertDialog = false;
                    }
                });
        isShowErrorAlertDialog = true;
    }

    // change orientation issues
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        layoutCards.setOrientation(LinearLayout.HORIZONTAL);
    } else {
        layoutCards.setOrientation(LinearLayout.VERTICAL);
    }

    // enable/disable the activate button
    updateActivateLicenseButtonFromModel();

    if (mainActivityModel.getCurrentOptionType() == -1) {
        // do not do any extra processing
        return;
    }

    // calculate the width and height of the front side card image and resize them
    resizeImageFrames(mainActivityModel.getCurrentOptionType());

    // show/hide the front and back views in the layout
    switch (mainActivityModel.getCurrentOptionType()) {
    case CardType.PASSPORT:
        txtTapToCaptureFront.setText(getResources().getString(R.string.tap_to_capture));
        showFrontSideCardImage();
        hideBackSideCardImage();
        break;

    case CardType.DRIVERS_LICENSE:
        showFrontSideCardImage();
        if (mainActivityModel.getBackSideCardImage() != null) {
            showBackSideCardImage();
        } else {
            hideBackSideCardImage();
        }
        break;

    case CardType.MEDICAL_INSURANCE:
        txtTapToCaptureFront.setText(R.string.tap_to_capture_front_side);
        showFrontSideCardImage();
        showBackSideCardImage();
        break;
    case CardType.FACIAL_RECOGNITION:
        showFrontSideCardImage();
        if (mainActivityModel.getBackSideCardImage() != null) {
            showBackSideCardImage();
        } else {
            hideBackSideCardImage();
        }
        break;

    default:
        throw new IllegalArgumentException(
                "This method is wrong implemented, there is not processing for the card type '"
                        + mainActivityModel.getCurrentOptionType() + "'");

    }

    // update card in front image view
    frontImageView.setImageBitmap(Util.getRoundedCornerBitmap(mainActivityModel.getFrontSideCardImage(),
            this.getApplicationContext()));

    if (mainActivityModel.getFrontSideCardImage() != null) {
        hideFrontImageText();
    } else {
        showFrontImageText();
    }

    // update card in back image view
    backImageView.setImageBitmap(Util.getRoundedCornerBitmap(mainActivityModel.getBackSideCardImage(),
            this.getApplicationContext()));

    if (mainActivityModel.getBackSideCardImage() != null) {
        hideBackImageText();
    } else {
        showBackImageText();
    }

    // update the process button
    if (mainActivityModel.getFrontSideCardImage() != null) {
        processCardButton.setVisibility(View.VISIBLE);
    } else {
        processCardButton.setVisibility(View.GONE);
    }

    highlightCurrentCardOption();

}