List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_SMALL
int SCREENLAYOUT_SIZE_SMALL
To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_SMALL.
Click Source Link
From source file:com.raja.knowme.FragmentSpecialization.java
private AppTextView addItem(final SpecializationDetailsObject 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(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(14);/*from w w w .j a v a2 s . co 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(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); 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(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); 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(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); 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(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); 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.getSpecializationLink().length() > 0) { mTextView.setBackgroundResource(R.drawable.button_config); mTextView.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (data.getSpecializationLink().trim().length() > 0) openWebPage(data.getSpecializationLink(), mTextView); else { mTextView.startAnimation(shake); Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show(); } } }); } return mTextView; }
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 ww w. j a v a 2 s . com 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:gr.scify.newsum.ui.Facebook.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); }/*from ww w . j av a 2 s .co m*/ SharedPreferences userlang = getSharedPreferences("lang", 0); String newlang = userlang.getString("lang", Locale.getDefault().getLanguage()); // Changed getApplicationContext() to "this" Setlanguage.updateLanguage(this, newlang); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); } setContentView(R.layout.facebook); Bundle extras = getIntent().getExtras(); summaryF = extras.getString("summaryF"); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { Facebook.this.user = user; updateUI(); // It's possible that we were waiting for this.user to be populated in order to post a // status update. handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostStatusUpdate(); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); }
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 www . j ava 2 s . c o m return XLARGE; default: return UNKNOWN; } }
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 w ww . j a v a2 s . c o 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.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 w w . j a v a2s .co m*/ mInstructionBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { pref.setProfileRunned(); mInstructionBtn.setVisibility(RelativeLayout.GONE); } }); /* Multiple Screen Size Condition */ // Small Size if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(6 * functions.getScreenDPI()); return textSwitcher_text; } }); } //Normal Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { //Toast.makeText(getActivity(),"normal" , Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(14 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(9 * functions.getScreenDPI()); return textSwitcher_text; } }); } // Large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { //Toast.makeText(getActivity(),"large" , Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(32 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(18 * functions.getScreenDPI()); return textSwitcher_text; } }); } //X-large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // Toast.makeText(getActivity(),"xlarge" , Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(48 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); return textSwitcher_text; } }); } //Undefined Size else { // Toast.makeText(getActivity(),"undefined" , Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(32 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(20 * functions.getScreenDPI()); return textSwitcher_text; } }); } mProgressDialog.show(); new LoadData().execute(); gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() { public boolean onSingleTapUp(MotionEvent e) { return false; } public void onShowPress(MotionEvent e) { } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } public void onLongPress(MotionEvent e) { } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH) return false; /** Left swipe */ if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count < (MAX_COUNT - 1)) nextDetail(); else { mHeaderSwitcher.startAnimation(shake); mBodySwitcher.startAnimation(shake); } /** Right Swipe */ } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count != 0) previousDetail(); else { mHeaderSwitcher.startAnimation(shake); mBodySwitcher.startAnimation(shake); } } } catch (Exception e) { } return false; } public boolean onDown(MotionEvent e) { return false; } }); gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }; mScrollview.setOnTouchListener(gestureListener); return mHolderView; }
From source file:com.raja.knowme.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); }// w ww . ja 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 av a 2s. c o m*/ mInstructionBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { pref.setTestimonialsRunned(); mInstructionBtn.setVisibility(RelativeLayout.GONE); } }); /* Multiple Screen Size Condition */ // Small Size if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(6 * functions.getScreenDPI()); return textSwitcher_text; } }); } //Normal Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(14 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(9 * functions.getScreenDPI()); return textSwitcher_text; } }); } // Large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(32 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(18 * functions.getScreenDPI()); return textSwitcher_text; } }); } //X-large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(48 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); return textSwitcher_text; } }); } //Undefined Size else { // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show(); mHeaderSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(20 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mBodySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(12 * functions.getScreenDPI()); return textSwitcher_text; } }); } mProgressDialog.show(); new LoadData().execute(); gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() { public boolean onSingleTapUp(MotionEvent e) { return false; } public void onShowPress(MotionEvent e) { } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } public void onLongPress(MotionEvent e) { } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH) return false; /** Left swipe */ if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count < (MAX_COUNT - 1)) nextDetail(); else { mHeaderSwitcher.startAnimation(shake); mBodySwitcher.startAnimation(shake); } /** Right Swipe */ } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count != 0) previousDetail(); else { mHeaderSwitcher.startAnimation(shake); mBodySwitcher.startAnimation(shake); } } } catch (Exception e) { } return false; } public boolean onDown(MotionEvent e) { return false; } }); gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }; mScrollview.setOnTouchListener(gestureListener); return mHolderView; }
From source file:com.raja.knowme.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 . j ava 2 s. co m*/ instruction_btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { pref.setQualificationRunned(); instruction_btn.setVisibility(RelativeLayout.GONE); } }); /* Multiple Screen Size Condition */ // Small Size if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show(); institution_switcher.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(16 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); } //Normal Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show(); institution_switcher.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(14 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); } // Large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show(); institution_switcher.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(32 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); } //X-large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show(); institution_switcher.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(48 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); } //Undefined Size else { // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show(); institution_switcher.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(20 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TextUtils.TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); } mProgressDialog.show(); new LoadData().execute(); // Gesture detection gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() { public boolean onSingleTapUp(MotionEvent e) { return false; } public void onShowPress(MotionEvent e) { } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } public void onLongPress(MotionEvent e) { } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH) return false; /** Left swipe */ if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count < (MAX_COUNT - 1)) nextInstitution(); else { institution_switcher.startAnimation(shake); qualification_list.startAnimation(shake); } /** Right Swipe */ } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count != 0) previousInstitution(); else { institution_switcher.startAnimation(shake); qualification_list.startAnimation(shake); } } } catch (Exception e) { } return false; } public boolean onDown(MotionEvent e) { return false; } }); gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }; qualification_list.setOnTouchListener(gestureListener); return mHolderView; }
From source file:com.raja.knowme.FragmentWorkExp.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mHolderView = inflater.inflate(R.layout.fragment_work_exp, null); shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake); functions = new AppCommonFunctions(getActivity()); pref = new AppPreferences(getActivity()); knowmeData = new KnowMeDataObject(getActivity()); mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setCancelable(false); mProgressDialog.setMessage(getString(R.string.loading)); mCompanyNameSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_name_text); mCompanySpanSwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_span_text); mCompanySummarySwitcher = (TextSwitcher) mHolderView.findViewById(R.id.work_company_summary_text); mScrollContainer = (ScrollView) mHolderView.findViewById(R.id.work_scrollview); mInstructionBtn = (RelativeLayout) mHolderView.findViewById(R.id.instrunstions_layout); if (!pref.getWorkFirstRun()) { mInstructionBtn.setVisibility(RelativeLayout.GONE); }/*from ww w . j a v a 2s . com*/ mInstructionBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { pref.setWorkRunned(); mInstructionBtn.setVisibility(RelativeLayout.GONE); } }); /* Multiple Screen Size Condition */ // Small Size if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show(); mCompanyNameSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySpanSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(12 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySummarySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(6 * functions.getScreenDPI()); return textSwitcher_text; } }); } //Normal Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show(); mCompanyNameSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(14 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySpanSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(10 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySummarySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(9 * functions.getScreenDPI()); return textSwitcher_text; } }); } // Large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show(); mCompanyNameSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(32 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySpanSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySummarySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(18 * functions.getScreenDPI()); return textSwitcher_text; } }); } //X-large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show(); mCompanyNameSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(48 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySpanSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(32 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySummarySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(24 * functions.getScreenDPI()); return textSwitcher_text; } }); } //Undefined Size else { // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show(); mCompanyNameSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(19 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySpanSwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 245, 242, 11)); textSwitcher_text.setTextSize(12 * functions.getScreenDPI()); textSwitcher_text.setSingleLine(true); textSwitcher_text.setEllipsize(TruncateAt.MARQUEE); textSwitcher_text.setMarqueeRepeatLimit(-1); textSwitcher_text.setHorizontallyScrolling(true); return textSwitcher_text; } }); mCompanySummarySwitcher.setFactory(new ViewFactory() { public View makeView() { /** Set up the custom auto scrolling text view class for lengthy album names */ AppTextView textSwitcher_text = new AppTextView(getActivity()); textSwitcher_text.setTextColor(Color.argb(225, 225, 225, 225)); textSwitcher_text.setTextSize(12 * functions.getScreenDPI()); return textSwitcher_text; } }); } mProgressDialog.show(); new LoadData().execute(); // Gesture detection gestureDetector = new GestureDetector(getActivity(), new OnGestureListener() { public boolean onSingleTapUp(MotionEvent e) { return false; } public void onShowPress(MotionEvent e) { } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } public void onLongPress(MotionEvent e) { } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > AppGlobalVariables.SWIPE_MAX_OFF_PATH) return false; /** Left swipe */ if (e1.getX() - e2.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count < (MAX_COUNT - 1)) nextCompany(); else { mCompanyNameSwitcher.startAnimation(shake); mCompanySpanSwitcher.startAnimation(shake); mCompanySummarySwitcher.startAnimation(shake); } /** Right Swipe */ } else if (e2.getX() - e1.getX() > AppGlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > AppGlobalVariables.SWIPE_THRESHOLD_VELOCITY) { if (count != 0) previousComapny(); else { mCompanyNameSwitcher.startAnimation(shake); mCompanySpanSwitcher.startAnimation(shake); mCompanySummarySwitcher.startAnimation(shake); } } } catch (Exception e) { } return false; } public boolean onDown(MotionEvent e) { return false; } }); gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }; mScrollContainer.setOnTouchListener(gestureListener); return mHolderView; }