List of usage examples for android.widget TextView setOnLongClickListener
public void setOnLongClickListener(@Nullable OnLongClickListener l)
From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java
public void attachOnLongTouchCurrent(final TextView view) { view.setOnLongClickListener(new OnLongClickListener() { @Override/*from w w w .j a v a 2s . c o m*/ public boolean onLongClick(View v) { view.setText("0.0"); currentMin = 0.0; currentMax = 0.0; current_show_type = 1; currentType.setText("live"); return false; } }); }
From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java
public void attachOnLongTouchHeight(final TextView view) { view.setOnLongClickListener(new OnLongClickListener() { @Override//from www. j ava2 s . co m public boolean onLongClick(View v) { heightMin = 0.0; heightMax = 0.0; air1.setText("0.0"); air2.setText("0.0"); height_show_type = 1; heightType.setText("live"); if (worker != null) { worker.resetClimbRateData(); } return false; } }); }
From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java
public void attachOnLongTouchVoltage(final TextView view) { view.setOnLongClickListener(new OnLongClickListener() { @Override/* www. j a v a2 s . c o m*/ public boolean onLongClick(View v) { view.setText("0.0"); voltageMin = 0.0; voltageMax = 0.0; voltage_show_type = 1; voltageType.setText("live"); if (tts != null) { tts.stop(); } if (mp != null) { if (mp.isPlaying() == true) { mp.pause(); } } mSound_on = !mSound_on; if (vibrate_on == true) vibrate_on = false; if (mSound_on != false) { worker.resetHysteresis(); } if (mSound_on) { Toast.makeText(getBaseContext(), "sound on", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getBaseContext(), "sound off", Toast.LENGTH_SHORT).show(); } return false; } }); }
From source file:com.goftagram.telegram.ui.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages);//from ww w. j av a 2 s. c o m super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { setContentView(R.layout.intro_layout_tablet); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.intro_layout); } if (LocaleController.isRTL) { icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4, R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 }; titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title, R.string.Page3Title, R.string.Page2Title, R.string.Page1Title }; messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message, R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message }; } else { icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 }; titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title, R.string.Page5Title, R.string.Page6Title, R.string.Page7Title }; messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message, R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message }; } viewPager = (ViewPager) findViewById(R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button); startMessagingButton .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(R.id.icon_image1); topImage2 = (ImageView) findViewById(R.id.icon_image2); bottomPages = (ViewGroup) findViewById(R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); startActivity(intent2); finish(); } }); if (BuildConfig.DEBUG) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }
From source file:com.panahit.ui.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages);//from w ww . j av a2s.com super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { setContentView(R.layout.intro_layout_tablet); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.intro_layout); } if (LocaleController.isRTL) { icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4, R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 }; titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title, R.string.Page3Title, R.string.Page2Title, R.string.Page1Title }; messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message, R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message }; } else { icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 }; titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title, R.string.Page5Title, R.string.Page6Title, R.string.Page7Title }; messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message, R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message }; } viewPager = (ViewPager) findViewById(R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button); startMessagingButton .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(R.id.icon_image1); topImage2 = (ImageView) findViewById(R.id.icon_image2); bottomPages = (ViewGroup) findViewById(R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); startActivity(intent2); finish(); } }); if (BuildVars.DEBUG_VERSION) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }
From source file:ir.besteveryeverapp.ui.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages);/*w w w .j a v a2s . co m*/ super.onCreate(savedInstanceState); Theme.loadRecources(this); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { setContentView(R.layout.intro_layout_tablet); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.intro_layout); } if (LocaleController.isRTL) { icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4, R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 }; titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title, R.string.Page3Title, R.string.Page2Title, R.string.Page1Title }; messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message, R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message }; } else { icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 }; titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title, R.string.Page5Title, R.string.Page6Title, R.string.Page7Title }; messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message, R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message }; } viewPager = (ViewPager) findViewById(R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button); startMessagingButton .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(R.id.icon_image1); topImage2 = (ImageView) findViewById(R.id.icon_image2); bottomPages = (ViewGroup) findViewById(R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); startActivity(intent2); finish(); } }); if (BuildVars.DEBUG_VERSION) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }
From source file:org.giffftalk.ui.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages);/*from w w w . jav a2 s . c om*/ super.onCreate(savedInstanceState); Theme.loadRecources(this); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { setContentView(R.layout.intro_layout_tablet); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.intro_layout); } if (LocaleController.isRTL) { icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4, R.drawable.intro3, R.drawable.intro2, R.drawable.intro8 }; titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title, R.string.Page3Title, R.string.Page2Title, R.string.Page1Title }; messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message, R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message }; } else { icons = new int[] { R.drawable.intro8, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 }; titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title, R.string.Page5Title, R.string.Page6Title, R.string.Page7Title }; messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message, R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message }; } viewPager = (ViewPager) findViewById(R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button); startMessagingButton .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(R.id.icon_image1); topImage2 = (ImageView) findViewById(R.id.icon_image2); bottomPages = (ViewGroup) findViewById(R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); startActivity(intent2); finish(); } }); if (BuildVars.DEBUG_VERSION) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }
From source file:net.bluehack.ui.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages);//www . j a va 2 s . c om super.onCreate(savedInstanceState); Theme.loadRecources(this); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { setContentView(R.layout.intro_layout_tablet); View imageView = findViewById(R.id.background_image_intro); BitmapDrawable drawable = (BitmapDrawable) getResources().getDrawable(R.drawable.catstile); drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); imageView.setBackgroundDrawable(drawable); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.intro_layout); } if (LocaleController.isRTL) { icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4, R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 }; titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title, R.string.Page3Title, R.string.Page2Title, R.string.Page1Title }; messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message, R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message }; } else { icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 }; titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title, R.string.Page5Title, R.string.Page6Title, R.string.Page7Title }; messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message, R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message }; } viewPager = (ViewPager) findViewById(R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button); startMessagingButton .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(R.id.icon_image1); topImage2 = (ImageView) findViewById(R.id.icon_image2); bottomPages = (ViewGroup) findViewById(R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); startActivity(intent2); finish(); } }); if (BuildVars.DEBUG_VERSION) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }
From source file:ir.irani.telecam.ui.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_TMessages);//from www .j av a 2s . com super.onCreate(savedInstanceState); Theme.loadRecources(this); requestWindowFeature(Window.FEATURE_NO_TITLE); if (AndroidUtilities.isTablet()) { setContentView(R.layout.intro_layout_tablet); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.intro_layout); } if (LocaleController.isRTL) { icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4, R.drawable.intro3, R.drawable.intro2, R.drawable.intro1, }; titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title, R.string.Page3Title, R.string.Page2Title, R.string.Page1Title }; messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message, R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message }; } else { icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 }; titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title, R.string.Page5Title, R.string.Page6Title, R.string.Page7Title }; messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message, R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message }; } viewPager = (ViewPager) findViewById(R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button); startMessagingButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); startMessagingButton .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(R.id.icon_image1); topImage2 = (ImageView) findViewById(R.id.icon_image2); bottomPages = (ViewGroup) findViewById(R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); startActivity(intent2); finish(); } }); if (BuildVars.DEBUG_VERSION) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }
From source file:kr.wdream.ui.IntroActivity.java
private void initView() { viewPager = (ViewPager) findViewById(kr.wdream.storyshop.R.id.intro_view_pager); TextView startMessagingButton = (TextView) findViewById(kr.wdream.storyshop.R.id.start_messaging_button); startMessagingButton.setText(LocaleController .getString("StartMessaging", kr.wdream.storyshop.R.string.StartMessaging).toUpperCase()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200));/* ww w . ja va 2 s. c o m*/ animator.addState(new int[] {}, ObjectAnimator .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); startMessagingButton.setStateListAnimator(animator); } topImage1 = (ImageView) findViewById(kr.wdream.storyshop.R.id.icon_image1); topImage2 = (ImageView) findViewById(kr.wdream.storyshop.R.id.icon_image2); bottomPages = (ViewGroup) findViewById(kr.wdream.storyshop.R.id.bottom_pages); topImage2.setVisibility(View.GONE); viewPager.setAdapter(new IntroAdapter()); viewPager.setPageMargin(0); viewPager.setOffscreenPageLimit(1); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { } @Override public void onPageScrollStateChanged(int i) { if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) { if (lastPage != viewPager.getCurrentItem()) { lastPage = viewPager.getCurrentItem(); final ImageView fadeoutImage; final ImageView fadeinImage; if (topImage1.getVisibility() == View.VISIBLE) { fadeoutImage = topImage1; fadeinImage = topImage2; } else { fadeoutImage = topImage2; fadeinImage = topImage1; } fadeinImage.bringToFront(); fadeinImage.setImageResource(icons[lastPage]); fadeinImage.clearAnimation(); fadeoutImage.clearAnimation(); Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, kr.wdream.storyshop.R.anim.icon_anim_fade_out); outAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { fadeoutImage.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, kr.wdream.storyshop.R.anim.icon_anim_fade_in); inAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { fadeinImage.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); fadeoutImage.startAnimation(outAnimation); fadeinImage.startAnimation(inAnimation); } } } }); startMessagingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (startPressed) { return; } startPressed = true; Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class); intent2.putExtra("fromIntro", true); Log.d(LOG_TAG, "startActivity(LaunchActivity), fromIntro : " + true); startActivity(intent2); finish(); } }); if (BuildVars.DEBUG_VERSION) { startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConnectionsManager.getInstance().switchBackend(); return true; } }); } justCreated = true; }