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:de.androvdr.activities.AndroVDR.java

public void initWorkspaceView(Bundle savedInstanceState) {
    if (!Preferences.alternateLayout)
        setTheme(R.style.Theme_Original);

    logger.debug("Model: {}", Build.MODEL);
    logger.debug("SDK Version: {}", Build.VERSION.SDK_INT);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    logger.debug("Width: {}", metrics.widthPixels);
    logger.debug("Height: {}", metrics.heightPixels);
    logger.debug("Density: {}", metrics.densityDpi);

    Configuration conf = getResources().getConfiguration();
    boolean screenSmall = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_SMALL) == Configuration.SCREENLAYOUT_SIZE_SMALL);
    boolean screenNormal = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_NORMAL) == Configuration.SCREENLAYOUT_SIZE_NORMAL);
    boolean screenLong = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_LONG_YES) == Configuration.SCREENLAYOUT_LONG_YES);
    boolean screenLarge = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_LARGE) == Configuration.SCREENLAYOUT_SIZE_LARGE);
    boolean screenXLarge = ((conf.screenLayout
            & Configuration.SCREENLAYOUT_SIZE_XLARGE) == Configuration.SCREENLAYOUT_SIZE_XLARGE);

    logger.debug("Screen Small: {}", screenSmall);
    logger.debug("Screen Normal: {}", screenNormal);
    logger.debug("Screen Long: {}", screenLong);
    logger.debug("Screen Large: {}", screenLarge);
    logger.debug("Screen XLarge: {}", screenXLarge);

    if (screenSmall)
        Preferences.screenSize = Preferences.SCREENSIZE_SMALL;
    if (screenNormal)
        Preferences.screenSize = Preferences.SCREENSIZE_NORMAL;
    if (screenLong)
        Preferences.screenSize = Preferences.SCREENSIZE_LONG;
    if (screenLarge)
        Preferences.screenSize = Preferences.SCREENSIZE_LARGE;
    if (screenXLarge)
        Preferences.screenSize = Preferences.SCREENSIZE_XLARGE;
    logger.trace("Screen size: {}", Preferences.screenSize);

    // --- init default text size for buttons ---
    TextResizeButton.resetDefaultTextSize();
    TextResizeButton rb = (TextResizeButton) LayoutInflater.from(this).inflate(R.layout.reference_button, null);
    if ((Preferences.screenSize >= Preferences.SCREENSIZE_LARGE)
            && (metrics.widthPixels > metrics.heightPixels))
        rb.setTextSizeAsDefault(metrics.widthPixels / 2 / 5, 100);
    else/*from  w  w w  .jav a  2  s .  co m*/
        rb.setTextSizeAsDefault(Math.min(metrics.widthPixels, metrics.heightPixels) / 4, 100);
    logger.debug("Default TextSize (px): {}", rb.getTextSize());

    // --- landscape mode only on large displays ---
    if (Preferences.screenSize < Preferences.SCREENSIZE_LARGE) {
        logger.trace("setting SCREEN_ORIENTATION_PORTRAIT");
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    setContentView(R.layout.remote_pager);
    mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);

    LinePageIndicator indicator = (LinePageIndicator) findViewById(R.id.titles);
    if (mPagerAdapter.getCount() > 1) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        int last = sp.getInt("remote_last_page", 0);
        if (last < mPagerAdapter.getCount())
            indicator.setViewPager(mPager, last);
        else
            indicator.setViewPager(mPager);
    } else {
        indicator.setVisibility(View.GONE);
    }

    // --- show current channel in status bar ---
    if (Preferences.screenSize < Preferences.SCREENSIZE_XLARGE)
        mDevices.addOnSensorChangeListener("VDR.channel", 1, new OnSensorChangeListener() {
            @Override
            public void onChange(String result) {
                logger.trace("Channel: {}", result);
                Message msg = Message.obtain(mSensorHandler, SENSOR_CHANNEL);
                Bundle bundle = new Bundle();
                bundle.putString(MSG_RESULT, result);
                msg.setData(bundle);
                msg.sendToTarget();
            }
        });

    mDevices.startSensorUpdater(0);
}

From source file:net.peterkuterna.android.apps.devoxxsched.util.UIUtils.java

public static boolean isHoneycombTablet(Context context) {
    // Can use static final constants like HONEYCOMB, declared in later
    // versions/*  w  ww  .  j  av  a  2s  . co  m*/
    // of the OS since they are inlined at compile time. This is guaranteed
    // behavior.
    return isHoneycomb() && (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_projects, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    adapter = new ProjectsListAdapter(getActivity());
    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));

    projects_list = (ListView) mHolderView.findViewById(R.id.projects_listview);
    comapny_switcher = (TextSwitcher) mHolderView.findViewById(R.id.projects_company_name_text);
    instruction_btn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    projects_list.setSelector(this.getResources().getDrawable(R.drawable.transparent_shape));

    if (!pref.getProjectsFirstRun()) {
        instruction_btn.setVisibility(RelativeLayout.GONE);
    }//  w w w .ja v  a  2  s  . co  m

    instruction_btn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setProjectsRunned();
            instruction_btn.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();
        comapny_switcher.setFactory(new ViewSwitcher.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(16 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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();
        comapny_switcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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();
        comapny_switcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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();
        comapny_switcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    //Undefined Size

    else {
        //  Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        comapny_switcher.setFactory(new ViewSwitcher.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(20 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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 {
                        comapny_switcher.startAnimation(shake);
                        projects_list.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 {
                        comapny_switcher.startAnimation(shake);
                        projects_list.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);
        }
    };

    projects_list.setOnTouchListener(gestureListener);
    return mHolderView;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_qualification, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    adapter = new QualificationListAdapter(getActivity());
    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));

    qualification_list = (ListView) mHolderView.findViewById(R.id.qualification_listview);
    institution_switcher = (TextSwitcher) mHolderView.findViewById(R.id.qualification_institution_name_text);
    instruction_btn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    qualification_list.setSelector(this.getResources().getDrawable(R.drawable.transparent_shape));

    if (!pref.getQualificationFirstRun()) {
        instruction_btn.setVisibility(RelativeLayout.GONE);
    }//w w  w.jav a 2  s .  c  o m

    instruction_btn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setQualificationRunned();
            instruction_btn.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();
        institution_switcher.setFactory(new ViewSwitcher.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(16 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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();
        institution_switcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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();
        institution_switcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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();
        institution_switcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

    }

    //Undefined Size

    else {
        //  Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        institution_switcher.setFactory(new ViewSwitcher.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(20 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                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))
                        nextInstitution();
                    else {
                        institution_switcher.startAnimation(shake);
                        qualification_list.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousInstitution();
                    else {
                        institution_switcher.startAnimation(shake);
                        qualification_list.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);
        }
    };

    qualification_list.setOnTouchListener(gestureListener);
    return mHolderView;
}

From source file:com.health.openscale.gui.OverviewFragment.java

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);

    if (isVisibleToUser) {
        if ((getActivity().getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE
                && (getActivity().getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE) {
            Activity a = getActivity();/* w ww  .  j a  va 2  s  .  co m*/
            if (a != null)
                a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }
}

From source file:be.deadba.ampd.SettingsActivity.java

/**
 * Helper method to determine if the device has an extra-large screen. For
 * example, 10" tablets are extra-large.
 *///from   w  ww.  j  av  a 2 s . c o  m
private static boolean isXLargeTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_profile, 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));

    mHeaderSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.profile_subheader_text);
    mBodySwitcher = (TextSwitcher) mHolderView.findViewById(R.id.profile_body_text);
    mScrollview = (ScrollView) mHolderView.findViewById(R.id.profile_scrollview);
    mInstructionBtn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    if (!pref.getProfileFirstRun()) {
        mInstructionBtn.setVisibility(RelativeLayout.GONE);
    }//from  www . j  a va2s  .  co m

    mInstructionBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setProfileRunned();
            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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();

        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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(20 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });
    }
    mProgressDialog.show();
    new LoadData().execute();

    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))
                        nextDetail();
                    else {
                        mHeaderSwitcher.startAnimation(shake);
                        mBodySwitcher.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousDetail();
                    else {
                        mHeaderSwitcher.startAnimation(shake);
                        mBodySwitcher.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);
        }
    };

    mScrollview.setOnTouchListener(gestureListener);
    return mHolderView;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_testimonials, 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));

    mHeaderSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.testimonials_subheader_text);
    mBodySwitcher = (TextSwitcher) mHolderView.findViewById(R.id.testimonials_body_text);
    mScrollview = (ScrollView) mHolderView.findViewById(R.id.testimonials_scrollview);
    mInstructionBtn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    if (!pref.getTestimonialsFirstRun()) {
        mInstructionBtn.setVisibility(RelativeLayout.GONE);
    }//from  www. j  a  va2 s. co m

    mInstructionBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setTestimonialsRunned();
            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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();

        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();
        mHeaderSwitcher.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;
            }
        });

        mBodySwitcher.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();
        mHeaderSwitcher.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(20 * functions.getScreenDPI());
                textSwitcher_text.setSingleLine(true);
                textSwitcher_text.setEllipsize(TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mBodySwitcher.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();

    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))
                        nextDetail();
                    else {
                        mHeaderSwitcher.startAnimation(shake);
                        mBodySwitcher.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousDetail();
                    else {
                        mHeaderSwitcher.startAnimation(shake);
                        mBodySwitcher.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);
        }
    };

    mScrollview.setOnTouchListener(gestureListener);
    return mHolderView;
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_references, 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));

    mHeaderSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.references_subheader_text);
    mBodySwitcher = (TextSwitcher) mHolderView.findViewById(R.id.references_body_text);
    mScrollview = (ScrollView) mHolderView.findViewById(R.id.references_scrollview);
    mInstructionBtn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout);

    if (!pref.getReferencesFirstRun()) {
        mInstructionBtn.setVisibility(RelativeLayout.GONE);
    }/*from  w  ww . j a va  2 s . co  m*/

    mInstructionBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            pref.setReferencesRunned();
            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();
        mHeaderSwitcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mBodySwitcher.setFactory(new ViewSwitcher.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();
        mHeaderSwitcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mBodySwitcher.setFactory(new ViewSwitcher.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();
        mHeaderSwitcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mBodySwitcher.setFactory(new ViewSwitcher.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();
        mHeaderSwitcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mBodySwitcher.setFactory(new ViewSwitcher.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();
        mHeaderSwitcher.setFactory(new ViewSwitcher.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(TextUtils.TruncateAt.MARQUEE);
                textSwitcher_text.setMarqueeRepeatLimit(-1);
                textSwitcher_text.setHorizontallyScrolling(true);
                return textSwitcher_text;
            }
        });

        mBodySwitcher.setFactory(new ViewSwitcher.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(20 * functions.getScreenDPI());
                return textSwitcher_text;
            }
        });

    }

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

    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))
                        nextDetail();
                    else {
                        mHeaderSwitcher.startAnimation(shake);
                        mBodySwitcher.startAnimation(shake);
                    }
                    /** Right Swipe */
                } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE
                        && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) {
                    if (count != 0)
                        previousDetail();
                    else {
                        mHeaderSwitcher.startAnimation(shake);
                        mBodySwitcher.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);
        }
    };

    mScrollview.setOnTouchListener(gestureListener);
    return mHolderView;
}

From source file:com.juick.android.JuickMessagesAdapter.java

private String getDefaultScale(Context context) {
    int screenSize = context.getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK;
    if (screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        return "2.0";
    }//w w  w.  j  a  v  a 2s .  co m
    if (screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        return "3.0";
    }
    return "1.0";
}