Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_XLARGE

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

Introduction

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

Prototype

int SCREENLAYOUT_SIZE_XLARGE

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

Click Source Link

Document

Constant for #screenLayout : a #SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 720x960 dp units, corresponds to the xlarge resource qualifier.

Usage

From source file:org.solovyev.android.calculator.ActivityUi.java

private void addHelpInfo(@Nonnull Activity activity, @Nonnull View root) {
    if (CalculatorApplication.isMonkeyRunner(activity)) {
        if (root instanceof ViewGroup) {
            final TextView helperTextView = new TextView(activity);

            final DisplayMetrics dm = new DisplayMetrics();
            activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

            helperTextView.setTextSize(15);
            helperTextView.setTextColor(Color.WHITE);

            final Configuration c = activity.getResources().getConfiguration();

            final StringBuilder helpText = new StringBuilder();
            helpText.append("Size: ");
            if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE, c)) {
                helpText.append("xlarge");
            } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, c)) {
                helpText.append("large");
            } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL, c)) {
                helpText.append("normal");
            } else if (Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL, c)) {
                helpText.append("small");
            } else {
                helpText.append("unknown");
            }//  w  w  w .  ja  v  a 2s .  c o m

            helpText.append(" (").append(dm.widthPixels).append("x").append(dm.heightPixels).append(")");

            helpText.append(" Density: ");
            switch (dm.densityDpi) {
            case DisplayMetrics.DENSITY_LOW:
                helpText.append("ldpi");
                break;
            case DisplayMetrics.DENSITY_MEDIUM:
                helpText.append("mdpi");
                break;
            case DisplayMetrics.DENSITY_HIGH:
                helpText.append("hdpi");
                break;
            case DisplayMetrics.DENSITY_XHIGH:
                helpText.append("xhdpi");
                break;
            case DisplayMetrics.DENSITY_TV:
                helpText.append("tv");
                break;
            }

            helpText.append(" (").append(dm.densityDpi).append(")");

            helperTextView.setText(helpText);

            ((ViewGroup) root).addView(helperTextView, new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        }
    }
}

From source file:watch.oms.omswatch.application.OMSApplication.java

/**
 * Checks if the device is a tablet or a phone
 * /* ww  w .jav  a  2 s. c  o m*/
 * @param
 *
 * @return Returns true if the device is a Tablet
 */
public boolean isTabletDevice() {
    // Verifies if the Generalized Size of the device is XLARGE to be
    // considered a Tablet
    boolean xlarge = ((activity.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);

    // If XLarge, checks if the Generalized Density is at least MDPI
    // (160dpi)
    if (xlarge) {
        DisplayMetrics metrics = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        // MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160,
        // DENSITY_TV=213, DENSITY_XHIGH=320
        if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
                || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
                || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
                || metrics.densityDpi == DisplayMetrics.DENSITY_TV
                || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) {

            // Yes, this is a tablet!
            return true;
        }
    }
    return false;
}

From source file:com.money.manager.ex.core.Core.java

/**
 * Function that determines if the application is running on tablet
 * @return true if running on the tablet, otherwise false
 *///from  www . ja  va  2s .  c  o m
public boolean isTablet() {
    int layout = getContext().getResources().getConfiguration().screenLayout;
    return ((layout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
            || ((layout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
}

From source file:com.miz.functions.MizLib.java

/**
 * Determines if the application is running on a xlarge tablet
 * @param c - Context of the application
 * @return True if running on a xlarge tablet, false if on a smaller device
 *//*from w  ww  . ja v  a 2  s .  c  o  m*/
public static boolean isXlargeTablet(Context c) {
    return (c.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

From source file:com.raja.knowme.FragmentWorkExp.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_work_exp, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    functions = new AppCommonFunctions(getActivity());
    pref = new AppPreferences(getActivity());
    knowmeData = new KnowMeDataObject(getActivity());
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading));

    mCompanyNameSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_name_text);
    mCompanySpanSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_span_text);
    mCompanySummarySwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_summary_text);
    mScrollContainer = (ScrollView) mHolderView.findViewById(R.id.work_scrollview);
    mInstructionBtn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    if (!pref.getWorkFirstRun()) {
        mInstructionBtn.setVisibility(RelativeLayout.GONE);
    }/*  ww  w  . j  a  v  a 2 s.  c om*/

    mInstructionBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setWorkRunned();
            mInstructionBtn.setVisibility(RelativeLayout.GONE);
        }
    });
    /*                 Multiple Screen Size Condition             */

    // Small Size

    if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show();
        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(24 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(12 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(6 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(14 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(10 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(9 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        //  Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();

        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(32 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(24 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(18 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    //X-large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        //  Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show();
        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(48 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(32 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(24 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    //Undefined Size

    else {
        // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();

        mCompanyNameSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(19 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySpanSwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11));
                textSwitcher_text.setTextSize(12 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mCompanySummarySwitcher.setFactory(new ViewFactory() {
            public View makeView() {
                /** Set up the custom auto scrolling text view class for lengthy album names */
                AppTextView textSwitcher_text = new AppTextView(getActivity());
                textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225));
                textSwitcher_text.setTextSize(12 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }

    mProgressDialog.show();
    new LoadData().execute();

    // Gesture detection
    gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() {

        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        public void onShowPress(MotionEvent e) {
        }

        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        public void onLongPress(MotionEvent e) {
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH)
                    return false;
                /** Left swipe */
                if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count < (MAX_COUNT - 1))
                        nextCompany();
                    else {
                        mCompanyNameSwitcher.startAnimation(shake);
                        mCompanySpanSwitcher.startAnimation(shake);
                        mCompanySummarySwitcher.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousComapny();
                    else {
                        mCompanyNameSwitcher.startAnimation(shake);
                        mCompanySpanSwitcher.startAnimation(shake);
                        mCompanySummarySwitcher.startAnimation(shake);
                    }
                }
            } catch (Exception e) {
            }

            return false;
        }

        public boolean onDown(MotionEvent e) {
            return false;
        }
    });

    gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    };

    mScrollContainer.setOnTouchListener(gestureListener);
    return mHolderView;
}

From source file:uni.oulu.mentor.TeacherVisionActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //DO NOT USE THIS SERVICE YET, DOES NOT WORK
    //Intent intent = new Intent(this, TeacherVisionService.class);
    //startService(intent);
    /*Idea from http://stackoverflow.com/questions/2902640/android-get-the-screen-resolution-pixels-as-integer-values */
    @SuppressWarnings("deprecation")
    int screenWidthPix = getWindowManager().getDefaultDisplay().getWidth();
    @SuppressWarnings("deprecation")
    int screenHeightPix = getWindowManager().getDefaultDisplay().getHeight();
    /*Idea from http://stackoverflow.com/questions/5015094/determine-device-screen-category-small-normal-large-xlarge-using-code*/
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
        screenType = 3;// w  ww  .j a v  a  2 s. co m
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE)
        screenType = 4;
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL)
        screenType = 1;
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL)
        screenType = 2;
    //screen density is investigated here
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int density = metrics.densityDpi;
    if (density == DisplayMetrics.DENSITY_HIGH) {
        //400 dpi is 600px
        if (screenType == 1)
            translationX = 240; //240 / 1.5 = 160
        else if (screenType == 2)
            translationX = 315; //315 / 1.5 = 210 in dpi, screen 800 pix wide screen, needs about 1024/400 = 800/x => 312,5, 2.56
        else if (screenType == 3)
            translationX = 540; //540 / 1.5 = 360 in dpi
        else if (screenType == 4)
            translationX = 600; //600 / 1.5 = 400 in dpi   
    } else if (density == DisplayMetrics.DENSITY_MEDIUM) {
        //400 dpi is 400px
        if (screenType == 1)
            translationX = 160; //160 / 1 = 160 in dpi
        else if (screenType == 2)
            translationX = 210; //210 / 1 = 210 in dpi
        else if (screenType == 3)
            translationX = 360; //360 / 1 = 360 in dpi
        else if (screenType == 4)
            translationX = 400; //400 / 1 = 400 in dpi
    } else if (density == DisplayMetrics.DENSITY_LOW) {
        //400 dpi is 300px
        if (screenType == 1)
            translationX = 120; //120 / 0.75 = 160 in dpi
        else if (screenType == 2)
            translationX = 158; //158 / 0.75 = 210 in dpi
        else if (screenType == 3)
            translationX = 270; //270 / 0.75 = 360 in dpi
        else if (screenType == 4)
            translationX = 300; //300 / 0.75 = 400 in dpi
    } else if (density == DisplayMetrics.DENSITY_XHIGH || density == DisplayMetrics.DENSITY_XXHIGH) {
        //400 dpi is 800px
        if (screenType == 1)
            translationX = 320; //320 / 2 = 160 in dpi
        else if (screenType == 2)
            translationX = 420; // 420 / 2 = 210 in dpi
        else if (screenType == 3)
            translationX = 720; // 720 / 2 = 360 in dpi
        else if (screenType == 4)
            translationX = 800; // 800 / 2 = 400 in dpi         
    } else {
        //not supported
    }
    int offsetX = ((int) screenWidthPix / 20);
    int offsetY = ((int) screenHeightPix / 10);
    maxPosOpenX = screenWidthPix;
    //boundary for minimum amount of width on x-axis, where the touch is seen as panel open touch
    minPosOpenX = screenWidthPix - offsetX;
    //boundary for maximum amount of width on x-axis, where the touch is seen as panel close touch
    maxPosCloseX = screenWidthPix - translationX + offsetX;
    //boundary for minimum amount of width on x-axis, where the touch is seen as panel close touch
    minPosCloseX = screenWidthPix - translationX - offsetX;
    //boundary for maximum amount of height on y-axis, where the touch is seen as panel open or close touch
    maxPosY = (screenHeightPix / 2) + offsetY;
    //boundary for minimum amount of height on y-axis, where the touch is seen as panel open or close touch
    minPosY = (screenHeightPix / 2) - offsetY;
    //instantiation of lists
    onlineStudentsList = new ArrayList<Student>();
    feedbacksList = new ArrayList<Feedback>();
    questionsList = new ArrayList<Question>();
    answersList = new ArrayList<Answer>();
    ownQuestionsList = new ArrayList<Question>();
    //data stored for this user is fetched here, from the previous activity, and stored into the teacher instance
    Intent intent2 = getIntent();
    teacher = (Teacher) intent2.getParcelableExtra("teacherObj");
    ipStr = getResources().getString(R.string.IP);
    usersUrl = "http://" + ipStr + "/mentor/users";
    coursesUrl = "http://" + ipStr + "/mentor/courses";
    //default preferences are fetched, and listener is set to listen for preference changes
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sp.registerOnSharedPreferenceChangeListener(this);
    //SharedPreferences.Editor editor = sp.edit();
    //editor.putString("flaretimePref", "5");
    //editor.clear();
    //editor.commit();
    // In case of notifications are added later
    /*String ns = Context.NOTIFICATION_SERVICE;
    mNotificationManager = (NotificationManager) getSystemService(ns);
    icon = R.drawable.mlogo2;*/
    //AndAR preview
    renderer = new CustomRenderer();//optional, may be set to null
    super.setNonARRenderer(renderer);//or might be omitted
    try {
        //register an object for each marker type
        artoolkit = super.getArtoolkit();
        oneObject = new CustomObject("onePatt", "onePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter, customColor
        twoObject = new CustomObject("twoPatt", "twoPatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter
        threeObject = new CustomObject("threePatt", "threePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter
        artoolkit.registerARObject(oneObject);
        artoolkit.registerARObject(twoObject);
        artoolkit.registerARObject(threeObject);
    } catch (AndARException ex) {
        Log.e("AndARException ", ex.getMessage());
    }
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View vv = inflater.inflate(R.layout.activity_teacher_vision, null);
    //screen width and height in pixels
    screenWidth = (float) this.getApplicationContext().getResources().getDisplayMetrics().widthPixels;
    screenHeight = (float) this.getApplicationContext().getResources().getDisplayMetrics().heightPixels;
    inflater.inflate(R.layout.fragment_teacher_vision, null);
    //UI elements are added on top of AndAR by calling this addContentView-method instead of setContentView
    super.addContentView(vv, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
    //create a layout for settings button. add it over video frames
    LinearLayout lil = new LinearLayout(this);
    Button settingsButton = new Button(this);
    settingsButton.setText("Settings");
    settingsButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    settingsButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment())
                    .addToBackStack("settings").commit();
        }
    });
    lil.addView(settingsButton);
    super.addContentView(lil, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
    //starts the AndAR
    startPreview();
    //mDetector is instantiated here for detecting gestures
    mDetector = new GestureDetectorCompat(this, new SwipeGestureListener());
    //view pager instantiation, also mAdapter instantiated and set as adapter for view pager
    mPager = (ViewPager) findViewById(R.id.pager);
    mAdapter = new TabAdapter(getFragmentManager(), mPager);
    mPager.setAdapter(mAdapter);
    //begin to poll online users
    pollUsersCancelled = false;
    pollUsersTask = new PollUsersTask(this);
    pollUsersTask.execute();
    //begin to poll feedbacks
    pollFeedbacksCancelled = false;
    pollFeedbacksTask = new PollFeedbacksTask(this);
    pollFeedbacksTask.execute();
    //begin to poll questions
    pollQuestionsCancelled = false;
    pollQuestionsTask = new PollQuestionsTask(this);
    pollQuestionsTask.execute();
    //begin to poll answers
    pollAnswersCancelled = false;
    pollAnswersTask = new PollAnswersTask(this);
    pollAnswersTask.execute();
    //initialize tab buttons
    button = (Button) findViewById(R.id.goto_first);
    //first one is not enabled at the beginning, because the user is in first tab at first 
    button.setEnabled(false);
    button2 = (Button) findViewById(R.id.goto_second);
    button3 = (Button) findViewById(R.id.goto_last);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(0);
            button.setEnabled(false);
            button2.setEnabled(true);
            button3.setEnabled(true);
        }
    });
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(1);
            button.setEnabled(true);
            button2.setEnabled(false);
            button3.setEnabled(true);
        }
    });
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(2);
            button.setEnabled(true);
            button2.setEnabled(true);
            button3.setEnabled(false);
        }
    });
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static float getTextSize(Context context) {
    float textSize = 12f;
    int screentLayoutSize = context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    if (screentLayoutSize == Configuration.SCREENLAYOUT_SIZE_LARGE
            || screentLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE)
        textSize = 15f;// ww w  .  ja v  a 2s .  c  om
    return textSize;
}

From source file:de.Maxr1998.xposed.maxlock.ui.LockFragment.java

private void setupPatternLayout() {
    // Pattern View
    lockPatternView = (LockPatternView) rootView.findViewById(R.id.pattern_view);
    // Pattern Listener
    patternListener = new LockPatternView.OnPatternListener() {
        @Override/*from   w  w w.  ja  va2  s .  co m*/
        public void onPatternStart() {
            lockPatternView.removeCallbacks(mLockPatternViewReloader);
        }

        @Override
        public void onPatternCleared() {
            lockPatternView.removeCallbacks(mLockPatternViewReloader);
            lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
        }

        @Override
        public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {

        }

        @Override
        public void onPatternDetected(List<LockPatternView.Cell> pattern) {
            key.setLength(0);
            key.append(pattern);
            if (!checkInput()) {
                lockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
                lockPatternView.postDelayed(mLockPatternViewReloader, DateUtils.SECOND_IN_MILLIS);
            }
        }
    };
    // Layout
    switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
    case Configuration.SCREENLAYOUT_SIZE_XLARGE: {
        final int size = getResources().getDimensionPixelSize(
                com.haibison.android.lockpattern.R.dimen.alp_42447968_lockpatternview_size);
        ViewGroup.LayoutParams lp = lockPatternView.getLayoutParams();
        lp.width = size;
        lp.height = size;
        lockPatternView.setLayoutParams(lp);
        break;
    }
    }
    lockPatternView.setOnPatternListener(patternListener);
    lockPatternView.setInStealthMode(!prefs.getBoolean(Common.PATTERN_SHOW_PATH, true));
    lockPatternView.setTactileFeedbackEnabled(prefs.getBoolean(Common.PATTERN_FEEDBACK, true));
}

From source file:com.m2dl.mini_projet.mini_projet_android.MainActivity.java

private boolean screenIsLarge() {
    int screenMask = getResources().getConfiguration().screenLayout;
    if ((screenMask & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        return true;
    }/*ww w . j  a  va  2s  .  co  m*/

    if ((screenMask & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        return true;
    }

    return false;
}

From source file:de.baumann.thema.RequestActivity.java

private static boolean isXLargeTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}