List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_LARGE
int SCREENLAYOUT_SIZE_LARGE
To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_LARGE.
Click Source Link
From source file:timer.com.maydaysdk.MayDayMessageChatFragment.java
private int getScreenResolution() { int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; int height;//from w ww.j a v a 2 s.co m switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_LARGE: height = MayDayConstant.SIZE_LARGE; break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: height = MayDayConstant.SIZE_NORMAL; break; case Configuration.SCREENLAYOUT_SIZE_SMALL: height = MayDayConstant.SIZE_SMALL; break; case Configuration.SCREENLAYOUT_SIZE_XLARGE: height = MayDayConstant.SIZE_XLARGE; break; default: height = MayDayConstant.SIZE_SMALL; } return height; }
From source file:gov.cdc.epiinfo.RecordList.java
@Override public void openOptionsMenu() { Configuration config = getResources().getConfiguration(); if ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) > Configuration.SCREENLAYOUT_SIZE_LARGE) { int originalScreenLayout = config.screenLayout; config.screenLayout = Configuration.SCREENLAYOUT_SIZE_LARGE; super.openOptionsMenu(); config.screenLayout = originalScreenLayout; } else {/*from w w w.j a va 2s . c o m*/ super.openOptionsMenu(); } }
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 . ja v a2s .c o 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:org.jitsi.android.gui.util.AndroidUtils.java
/** * Returns <tt>true</tt> if we are currently running on tablet device. * @return <tt>true</tt> if we are currently running on tablet device. *//*from w w w . j av a 2 s . c o m*/ public static boolean isTablet() { Context context = JitsiApplication.getGlobalContext(); return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
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 w ww. ja v a 2s .c o 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); }// ww w . j a va 2 s. c om 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 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.near.chimerarevo.activities.PostContainerActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if ((newConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) { if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) isLandscapeLarge = true;/*from w w w . ja v a2s . c o m*/ else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) isLandscapeLarge = false; } }
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();/*from w ww. ja v a 2s . c o m*/ if (a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } }
From source file:com.cypress.cysmart.HomePageActivity.java
/** * Method to detect whether the device is phone or tablet *//*from ww w.j av a 2 s . c o m*/ private static boolean isTablet(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }