List of usage examples for android.widget RelativeLayout setOnTouchListener
public void setOnTouchListener(OnTouchListener l)
From source file:kiv.janecekz.ma.RecorderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.recorder, container, false); RelativeLayout space = (RelativeLayout) v.findViewById(R.id.sunspace); space.setOnTouchListener(TouchControl.getInstance()); circle = (ImageView) v.findViewById(R.id.circle); inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300); outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300); inAnimPr = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 1000); outAnimPr = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 1000); recStatusText = (TextView) v.findViewById(R.id.rec_status); // recTitleText = (TextView) v.findViewById(R.id.rec_title); progress = (ProgressBar) v.findViewById(R.id.progress); return v;//from w w w . java 2s. co m }
From source file:kiv.janecekz.ma.TunerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.tuner, container, false); RelativeLayout space = (RelativeLayout) v.findViewById(R.id.sunspace); space.setOnTouchListener(TouchControl.getInstance()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { refFreqOld = (net.simonvt.numberpicker.NumberPicker) v.findViewById(R.id.refFreq); refFreqOld.setMinValue(390);/*from w w w . j ava 2 s. c o m*/ refFreqOld.setMaxValue(460); refFreqOld.setOnValueChangedListener(new net.simonvt.numberpicker.NumberPicker.OnValueChangeListener() { @Override public void onValueChange(net.simonvt.numberpicker.NumberPicker picker, int oldVal, int newVal) { classify.changeRef(newVal); } }); refFreqOld.setValue(SharedPref.getConcertPitch(getActivity())); } else { refFreq = (NumberPicker) v.findViewById(R.id.refFreq); refFreq.setMinValue(390); refFreq.setMaxValue(460); refFreq.setOnValueChangedListener(new OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { classify.changeRef(newVal); } }); refFreq.setValue(SharedPref.getConcertPitch(getActivity())); } circle = (ImageView) v.findViewById(R.id.circle); tunerText = (TextView) v.findViewById(R.id.tuner_text); bar = (Tune) v.findViewById(R.id.tune); inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300); outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300); return v; }
From source file:kiv.janecekz.ma.ToneFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.tone, container, false); RelativeLayout space = (RelativeLayout) root.findViewById(R.id.sunspace); space.setOnTouchListener(TouchControl.getInstance()); circle = (ImageView) root.findViewById(R.id.circle); inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300); outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300); input = (EditText) root.findViewById(R.id.tone_value_edit); input.setOnEditorActionListener(this); TextView sharp = (TextView) root.findViewById(R.id.sharp); sharp.setOnClickListener(this); ViewGroup defList = (ViewGroup) root.findViewById(R.id.tone_list); for (int i = 0; i < defList.getChildCount(); i++) { TextView v = (TextView) defList.getChildAt(i); v.setOnClickListener(this); }//from www . j a va 2s. c om return root; }
From source file:nz.al4.airclock.AirClockFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.fragment_air_clock, container, false); // clockView = layout; layout.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { updateClock();//from w w w.j a va 2 s .c o m return true; } }); View tc = setupClock(); View td = setupDate(); View tz = setupTz(); layout.addView(td); layout.addView(tc); layout.addView(tz); updateClock(); return layout; }
From source file:kiv.janecekz.ma.MetronomeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.metronome, container, false); RelativeLayout space = (RelativeLayout) v.findViewById(R.id.sunspace); space.setOnTouchListener(TouchControl.getInstance()); peeper = new Peeper((byte) 0, (ImageView) v.findViewById(R.id.pend)); peeper.setBeats(SharedPref.getTime(getActivity())); tc = new TempoControl(); tc.addObserver(this); v.findViewById(R.id.split1).setOnClickListener(this); v.findViewById(R.id.split2).setOnClickListener(this); v.findViewById(R.id.split3).setOnClickListener(this); v.findViewById(R.id.split4).setOnClickListener(this); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { beatPickerOld = (net.simonvt.numberpicker.NumberPicker) v.findViewById(R.id.beatCount); beatPickerOld.setMinValue(1);//from ww w. ja va2 s.c o m beatPickerOld.setMinValue(4); beatPickerOld.setValue(SharedPref.getTime(getActivity())); beatPickerOld .setOnValueChangedListener(new net.simonvt.numberpicker.NumberPicker.OnValueChangeListener() { @Override public void onValueChange(net.simonvt.numberpicker.NumberPicker picker, int oldVal, int newVal) { peeper.setBeats(newVal); } }); bpmPickerOld = (net.simonvt.numberpicker.NumberPicker) v.findViewById(R.id.beatCount); bpmPickerOld.setMinValue(30); bpmPickerOld.setMinValue(220); bpmPickerOld.setValue(SharedPref.getBPM(getActivity())); bpmPickerOld .setOnValueChangedListener(new net.simonvt.numberpicker.NumberPicker.OnValueChangeListener() { @Override public void onValueChange(net.simonvt.numberpicker.NumberPicker picker, int oldVal, int newVal) { tc.setBPM(newVal); } }); } else { beatPicker = (NumberPicker) v.findViewById(R.id.beatCount); beatPicker.setMinValue(1); beatPicker.setMaxValue(4); beatPicker.setValue(SharedPref.getTime(getActivity())); beatPicker.setOnValueChangedListener(new OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { peeper.setBeats(newVal); } }); bpmPicker = (NumberPicker) v.findViewById(R.id.bpmCount); bpmPicker.setMinValue(30); bpmPicker.setMaxValue(200); bpmPicker.setValue(SharedPref.getBPM(getActivity())); bpmPicker.setOnValueChangedListener(new OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { tc.setBPM(newVal); } }); } circle = (ImageView) v.findViewById(R.id.circle); inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300); outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300); op = new Operator(peeper); tc.addObserver(op); tc.setBPM(SharedPref.getBPM(getActivity())); tc.refreshObservers(); op.start(); return v; }
From source file:com.ibm.mil.readyapps.physio.fragments.LandingFragment.java
private void setupMetricsTabs(View view) { LinearLayout metricsTabsArea = (LinearLayout) view.findViewById(R.id.metrics_tabs_area); heartRateTab = new HeartRateMetricsTab(getActivity(), null); heartRateTab.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2s. c o m*/ public void onClick(View v) { openDetailedMetricsScreen(HealthDataRetriever.DataType.HEART_RATE); } }); metricsTabsArea.addView(heartRateTab); if (DataManager.getCurrentPatient() == null) { return; } stepsTab = new StepsMetricsTab(getActivity(), null); stepsTab.setStepsGoal(DataManager.getCurrentPatient().getStepGoal()); stepsTab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openDetailedMetricsScreen(HealthDataRetriever.DataType.STEPS); } }); metricsTabsArea.addView(stepsTab); weightTab = new WeightMetricsTab(getActivity(), null); weightTab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openDetailedMetricsScreen(HealthDataRetriever.DataType.WEIGHT); } }); metricsTabsArea.addView(weightTab); Calendar cal = Calendar.getInstance(); Date now = new Date(); cal.setTime(now); cal.add(Calendar.WEEK_OF_YEAR, -1); Date startDate = cal.getTime(); HealthDataRetriever.Builder builder = new HealthDataRetriever.Builder().startDate(startDate).endDate(now) .timeUnit(TimeUnit.DAYS).timeInterval(1); HealthDataRetriever stepsRetriever = builder.dataType(HealthDataRetriever.DataType.STEPS) .handler(new HealthDataRetriever.Handler() { @Override public void handle(final List<Integer> data) { if (data != null) { stepsTab.setSteps(Utils.sum(data)); } } }).build(); stepsRetriever.retrieve(mClient); HealthDataRetriever weightRetriever = builder.dataType(HealthDataRetriever.DataType.WEIGHT) .handler(new HealthDataRetriever.Handler() { @Override public void handle(final List<Integer> data) { if (data != null) { int lastWeight = data.get(data.size() - 1); int firstWeight = data.get(0); int netWeight = lastWeight - firstWeight; weightTab.setWeight(lastWeight); weightTab.setNetWeight(netWeight); } } }).build(); weightRetriever.retrieve(mClient); HealthDataRetriever heartRateRetriever = builder.dataType(HealthDataRetriever.DataType.HEART_RATE) .handler(new HealthDataRetriever.Handler() { @Override public void handle(final List<Integer> data) { if (data != null) { heartRateTab.setBeatsPerMin(Utils.average(data)); heartRateTab.setMinMaxBpm(Utils.min(data), Utils.max(data)); } } }).build(); heartRateRetriever.retrieve(mClient); RelativeLayout metricsSwipeArea = (RelativeLayout) view.findViewById(R.id.metrics_swipe_area); metricsSwipeArea.setOnTouchListener(new OnSwipeTouchListener(getActivity()) { @Override public void onSwipeLeft() { if (!metricsIsOpen) { animateMetricsIn(false); metricsIsOpen = true; } } @Override public void onSwipeRight() { if (metricsIsOpen) { animateMetricsOut(false); metricsIsOpen = false; } } }); animateMetricsOut(true); }
From source file:uk.org.downiesoft.slideshow.SlideShowActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window win = getWindow();/* www .j a va2 s .co m*/ win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); win.requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); mUiHider = new UiHider(this); getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(mUiHider); mCacheManager = ThumbnailCacheManager.getInstance(this); SlideShowActivity.debug(1, TAG, "onCreate: %s", savedInstanceState == null ? "null" : savedInstanceState.toString()); setContentView(R.layout.activity_slide_show); PreferenceManager.setDefaultValues(this, R.xml.view_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.slideshow_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.cache_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.wallpaper_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.other_preferences, false); mSlideshowSettings = PreferenceManager.getDefaultSharedPreferences(this); int thumbSize = Integer.parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_THUMBSIZE), "1")); // Hack to convert old hard-coded thumbsize settings to platform dependent sizes if (thumbSize > 2) { thumbSize = thumbSize / 90; SharedPreferences.Editor editor = mSlideshowSettings.edit(); editor.putString(getString(R.string.PREFS_THUMBSIZE), Integer.toString(thumbSize)); editor.apply(); } FragmentManager fm = getFragmentManager(); int cacheLimit = Integer .parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_CACHE_LIMIT), "10")); mPreviewButton = (ImageView) findViewById(R.id.slideShowImageButton); mPreviewView = (FrameLayout) findViewById(R.id.previewContainer); RelativeLayout divider = (RelativeLayout) findViewById(R.id.frameDivider); if (divider != null) { divider.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { return mGestureDetector.onTouchEvent(event) || view.onTouchEvent(event); } }); } mPreviewFragment = (PreviewFragment) fm.findFragmentByTag(PreviewFragment.TAG); if (mPreviewView != null && mPreviewFragment == null) { mPreviewFragment = new PreviewFragment(); fm.beginTransaction().replace(R.id.previewContainer, mPreviewFragment, PreviewFragment.TAG).commit(); } mGridViewFragment = (GridViewFragment) fm.findFragmentByTag(GridViewFragment.TAG); if (mGridViewFragment == null) { mGridViewFragment = new GridViewFragment(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragmentContainer, mGridViewFragment, GridViewFragment.TAG); ft.commit(); } mGestureDetector = new GestureDetector(this, new DividerGestureListener()); // restart/stop service as required Intent intent = getIntent(); if (intent != null && intent.getAction() != null && intent.getAction().equals(ACTION_STOP_WALLPAPER) && isServiceRunning()) { stopWallpaperService(); finish(); } else { if (!mSlideshowSettings.getBoolean(getString(R.string.PREFS_WALLPAPER_ENABLE), false)) { if (isServiceRunning()) { stopWallpaperService(); } } else { if (!isServiceRunning()) { Intent startIntent = new Intent(SlideShowActivity.this, WallpaperService.class); startService(startIntent); invalidateOptionsMenu(); } } } mCacheManager.tidyCache(cacheLimit); BitmapManager.setDisplayMetrics(getResources().getDisplayMetrics()); }
From source file:info.tellmetime.TellmetimeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tellmetime); mDensity = getResources().getDisplayMetrics().density; mScreenWidth = getResources().getDisplayMetrics().widthPixels; mScreenHeight = getResources().getDisplayMetrics().heightPixels; mShorterEdge = Math.min(mScreenWidth, mScreenHeight); mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); mBacklightLight = getResources().getColor(R.color.backlight_light); mBacklightDark = getResources().getColor(R.color.backlight_dark); // Restore background and highlight colors from saved values or set defaults. mSettings = getSharedPreferences("PREFS", Context.MODE_PRIVATE); mHighlightColor = mSettings.getInt(HIGHLIGHT, Color.WHITE); mBacklightColor = mSettings.getInt(BACKLIGHT, mBacklightLight); mBackgroundColor = mSettings.getInt(BACKGROUND, getResources().getColor(R.color.background)); mBackgroundMode = mSettings.getInt(BACKGROUND_MODE, MODE_BACKGROUND_SOLID); mHighlightPosition = mSettings.getFloat(POSITION, 0.0f); mMinutesSize = mSettings.getInt(MINUTES_SIZE, 36); isNightMode = mSettings.getBoolean(NIGHTMODE, false); // Dim the navigation bar. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) getWindow().getDecorView().setSystemUiVisibility(isNightMode ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0); mSurface = (RelativeLayout) findViewById(R.id.surface); mSurface.setBackgroundColor(mBackgroundColor); resizeClock();//from ww w . ja v a2 s . co m Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); // Set typeface of all items in the clock to Roboto and dim each one and drop shadow on them. final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); tv.setTypeface(mTypefaceBold); tv.setTextColor(mBacklightColor); tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTypeface(mTypefaceBold); m.setTextColor(mBacklightColor); m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } // Set Roboto font on TextView where it isn't default. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { Typeface mTypefaceItalic = Typeface.createFromAsset(getAssets(), "Roboto-CondensedItalic.ttf"); ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.info_background)).setTypeface(mTypefaceItalic); ((TextView) findViewById(R.id.info_image)).setTypeface(mTypefaceItalic); ((TextView) findViewById(R.id.labelHighlight)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.labelBackground)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_light)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_dark)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.radio_backlight_highlight)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.labelMinutes)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m1)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m2)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m3)).setTypeface(mTypefaceBold); ((TextView) findViewById(R.id.m4)).setTypeface(mTypefaceBold); } FrameLayout mTouchZone = (FrameLayout) findViewById(R.id.touchZone); mTouchZone.setOnTouchListener(this); mTouchZone.setBackgroundColor( getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent)); mBackgroundImage = (ImageView) findViewById(R.id.background_image); switchBackgroundMode(mBackgroundMode); RelativeLayout mPanel = (RelativeLayout) findViewById(R.id.panel); mPanel.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mHider.delayedHide(4000); return true; } }); mHider = new PanelHider(mPanel, this); Spinner spinnerBackgroundMode = (Spinner) findViewById(R.id.spinnerBackgroundMode); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.backgrounds_modes, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerBackgroundMode.setAdapter(adapter); spinnerBackgroundMode.setOnItemSelectedListener(this); spinnerBackgroundMode.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { mHider.showNoAutoHide(); return false; } }); spinnerBackgroundMode.setSelection(mBackgroundMode); mSeekBarHighlight = (SeekBar) findViewById(R.id.highlightValue); mSeekBarHighlight.setOnSeekBarChangeListener(this); // Draw rainbow gradient on #mSeekBarHighlight and set position. drawRainbow(); if (mBacklightColor == mBacklightLight) ((RadioButton) findViewById(R.id.radio_backlight_light)).setChecked(true); else if (mBacklightColor == mBacklightDark) ((RadioButton) findViewById(R.id.radio_backlight_dark)).setChecked(true); else ((RadioButton) findViewById(R.id.radio_backlight_highlight)).setChecked(true); SeekBar mSeekBarMinutes = (SeekBar) findViewById(R.id.minutesSize); mSeekBarMinutes.setOnSeekBarChangeListener(this); mSeekBarMinutes.setProgress(mMinutesSize); mHider.hideNow(); Color.colorToHSV(mBackgroundColor, mHSV); mHSV[1] = 1.0f; //Trigger initial tick. mClockAlgorithm.tickTock(); // Schedule the clock algorithm to tick every round minute. Calendar time = Calendar.getInstance(); time.set(Calendar.MILLISECOND, 0); time.set(Calendar.SECOND, 0); time.add(Calendar.MINUTE, 1); Timer timer = new Timer(); timer.schedule(mClockTask, time.getTime(), 60 * 1000); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSurface.setAlpha(0.0f); mSurface.animate().alpha(1.0f).setDuration(1500); } // If it is first run, hint to user that panel is available. if (!mSettings.contains(HIGHLIGHT)) showToast(R.string.info_first_run); }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert//from w w w . j ava2 s. c o m * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }