Example usage for android.content.res Configuration SCREENLAYOUT_SIZE_NORMAL

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

Introduction

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

Prototype

int SCREENLAYOUT_SIZE_NORMAL

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

Click Source Link

Document

Constant for #screenLayout : a #SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 320x470 dp units, corresponds to the normal resource qualifier.

Usage

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

private AppTextView addItem(final SkillsDetailsObject data) {
    final AppTextView mTextView = new AppTextView(getActivity());

    /*                 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();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(12);//from  w ww  .j  a  va  2  s.  c o m
        mTextView.setPadding(3, 15, 0, 0);
    }

    //Normal Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(16);
        mTextView.setPadding(3, 15, 0, 0);

    }

    // Large Size

    else if ((getContext().getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        //  Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    //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();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(24);
        mTextView.setPadding(3, 15, 0, 0);

    }

    //Undefined Size

    else {
        // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show();
        LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        mViewParams.setMargins(0, 5, -5, 0);
        mTextView.setLayoutParams(mViewParams);
        mTextView.setText(data.getSkillsName());
        mTextView.setGravity(Gravity.LEFT);
        mTextView.setTextColor(Color.WHITE);
        mTextView.setTextSize(20);
        mTextView.setPadding(3, 15, 0, 0);

    }

    /*try {
      mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mImage, 0);
    } catch (Exception e) {
      Log.w(this.getClass().getName(), "Drawable not found for : " + name);
    }*/
    if (data.getSkillsLink().length() > 0) {
        mTextView.setBackgroundResource(R.drawable.button_config);
        mTextView.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (data.getSkillsLink().trim().length() > 0)
                    openWebPage(data.getSkillsLink(), mTextView);
                else {
                    mTextView.startAnimation(shake);
                    Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
    return mTextView;
}

From source file:com.adjust.sdk.Util.java

private static String getScreenSize(final int screenLayout) {
    final int screenSize = screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

    switch (screenSize) {
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        return SMALL;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        return NORMAL;
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        return LARGE;
    case 4:/*from w  ww.j  a  v a  2s  . co m*/
        return XLARGE;
    default:
        return UNKNOWN;
    }
}

From source file:com.honeycomb.cocos2dx.Soccer.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(com.honeycomb.cocos2dx.R.layout.main);
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId("ca-app-pub-2442035138707094/8795197567");
    activity = Soccer.this;
    AndroidNDKHelper.SetNDKReciever(this);

    Cocos2dxGLSurfaceView mGLView = (Cocos2dxGLSurfaceView) findViewById(
            com.honeycomb.cocos2dx.R.id.game_gl_surfaceview);

    mGLView.setEGLContextClientVersion(2);
    mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());

    new Handler().postDelayed(new Runnable() {
        @Override/*from  www .j av a 2  s .co  m*/
        public void run() {
            Soccer.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    findViewById(com.honeycomb.cocos2dx.R.id.logolayout).setVisibility(View.GONE);
                }
            });
        }
    }, 3000);

    iapSetup = new IAPSetup();
    mIABHelper = iapSetup.mIABHelper;

    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
        isLargeDevice = true;
    } else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        isLargeDevice = true;
    } else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
        isLargeDevice = false;
    } else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
        isLargeDevice = false;
    }
    gamePrefrence = getSharedPreferences("null", MODE_PRIVATE);
}

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);
    }//from   www  .j  ava2  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);
    }/* ww w .  ja  va2s . c  om*/

    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.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);
    }//ww  w .j av  a  2  s. com

    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.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);
    }/*  www  . j  a  v  a  2  s.  c o 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.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  w w  w .  j a  va  2  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:gr.scify.newsum.ui.SearchViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL
            & (getResources().getConfiguration().screenLayout
                    & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }// w w w.j  a  v  a2s.  c o m
    SharedPreferences usertheme = getSharedPreferences("theme", 0);
    int newTheme = usertheme.getInt("theme", 2);
    Utils.onActivityCreateSetTheme(this, newTheme);

    SharedPreferences userlang = getSharedPreferences("lang", 0);
    String newlang = userlang.getString("lang", Locale.getDefault().getLanguage());
    Setlanguage.updateLanguage(getApplicationContext(), newlang);

    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.view, null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    gestureOverlayView.setGestureColor(Color.TRANSPARENT);
    gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT);
    gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gestureLib.load()) {
        finish();
    }
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(gestureOverlayView);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    ImageView title_image = (ImageView) findViewById(R.id.title_image);
    title_image.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.scify)));
            startActivity(browse);
        }

    });

    // setContentView(R.layout.view);
    // TODO: Add Loading dialog

    SharedPreferences setvmassage = getSharedPreferences("dialog", 0);
    boolean dialogShown = setvmassage.getBoolean("dialogShown", false);

    if (!dialogShown) {
        // prepare the alert box
        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage(R.string.view_massage);
        alertbox.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {

            }
        });
        alertbox.setCancelable(false);
        alertbox.show();

        SharedPreferences.Editor editor = setvmassage.edit();
        editor.putBoolean("dialogShown", true);
        editor.commit();
    }

    // Init waiting dialog
    showWaitingDialog();

    initLayoutAndControls();

}

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  www.j a v a2  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);
}