List of usage examples for android.view.animation Animation setRepeatCount
public void setRepeatCount(int repeatCount)
From source file:de.grobox.liberario.ui.LocationInputGPSView.java
public void activateGPS() { if (isSearching()) return;/*from www .j a va 2 s. com*/ // check permissions if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // we don't have a permission, so store the information that we are requesting it request_permission = true; // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.ACCESS_FINE_LOCATION)) { Toast.makeText(context, R.string.permission_denied_gps, Toast.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission ActivityCompat.requestPermissions(context, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller); } return; } // we arrive here only once we have got the permission and are not longer requesting it request_permission = false; List<String> providers = locationManager.getProviders(true); for (String provider : providers) { // Register the listener with the Location Manager to receive location updates locationManager.requestSingleUpdate(provider, this, null); Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider); } // check if there is a non-passive provider available if (providers.size() == 0 || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) { locationManager.removeUpdates(this); Toast.makeText(context, context.getResources().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); return; } // clear input //noinspection deprecation setLocation(null, context.getResources().getDrawable(R.drawable.ic_gps)); ui.clear.setVisibility(View.VISIBLE); // clear current GPS location, because we are looking to find a new one gps_location = null; // show GPS button blinking final Animation animation = new AlphaAnimation(1, 0); animation.setDuration(500); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); ui.status.setAnimation(animation); ui.location.setHint(R.string.stations_searching_position); ui.location.clearFocus(); searching = true; }
From source file:ca.rmen.android.networkmonitor.app.log.LogActivity.java
private void startRefreshIconAnimation() { Log.v(TAG, "startRefreshIconAnimation"); if (mMenu == null) return; // This is null when we first enter the activity and the page loads. MenuItem menuItemRefresh = mMenu.findItem(R.id.action_refresh); if (menuItemRefresh == null) return;//from w w w. j ava2 s. co m View refreshIcon = View.inflate(this, R.layout.refresh_icon, null); Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotate); rotation.setRepeatCount(Animation.INFINITE); refreshIcon.startAnimation(rotation); MenuItemCompat.setActionView(menuItemRefresh, refreshIcon); }
From source file:com.pwned.steamfriends.views.TwitterStream.java
@Override public void onCreate(Bundle savedInstanceState) { setMyTheme();/*from w ww . j av a 2 s .com*/ super.onCreate(savedInstanceState); tracker = GoogleAnalyticsTracker.getInstance(); tracker.start(Constants.UACODE, 20, this); tracker.trackPageView("/TwitterStream"); mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mManager.cancel(APP_ID); setContentView(R.layout.twitter); m_streams = new ArrayList<Stream>(); this.m_adapter = new TwitterStreamAdapter(this, R.layout.row, m_streams); setListAdapter(this.m_adapter); viewStream = new Thread() { @Override public void run() { getStream(); } }; Animation a = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); a.setRepeatMode(Animation.RESTART); a.setRepeatCount(Animation.INFINITE); a.setDuration(750); a.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.linear_interpolator)); ivLoad = (ImageView) findViewById(R.id.loading_spinner); ivLoad.startAnimation(a); Thread thread = new Thread(null, viewStream, "SpecialsBackground"); thread.start(); //m_ProgressDialog = ProgressDialog.show(TwitterStream.this,"","Loading Twitter Stream...", true); steamHeader = (ImageView) findViewById(R.id.headerimage); steamHeader.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.HEADER_URL)); startActivity(myIntent); } }); }
From source file:de.grobox.liberario.ui.LocationGpsView.java
public void activateGPS() { if (searching) return;//from w w w . j a v a 2s .c om // check permissions if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION)) { Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller); } return; } searching = true; List<String> providers = locationManager.getProviders(true); for (String provider : providers) { // Register the listener with the Location Manager to receive location updates locationManager.requestSingleUpdate(provider, this, null); Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider); } // check if there is a non-passive provider available if (providers.size() == 0 || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) { locationManager.removeUpdates(this); Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); return; } // clear input setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps)); ui.clear.setVisibility(View.VISIBLE); // clear current GPS location, because we are looking to find a new one gps_location = null; // show GPS button blinking final Animation animation = new AlphaAnimation(1, 0); animation.setDuration(500); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); ui.status.startAnimation(animation); ui.location.setHint(R.string.stations_searching_position); ui.location.clearFocus(); if (gpsListener != null) gpsListener.activateGPS(); }
From source file:de.grobox.liberario.locations.LocationGpsView.java
public void activateGPS() { if (searching) return;//from www .j a v a 2s . c o m // check permissions if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? /* if(ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION)) { Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, caller); } */ return; } searching = true; List<String> providers = locationManager.getProviders(true); for (String provider : providers) { // Register the listener with the Location Manager to receive location updates locationManager.requestSingleUpdate(provider, this, null); Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider); } // check if there is a non-passive provider available if (providers.size() == 0 || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) { locationManager.removeUpdates(this); Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); // Set the flag that there is currently no active search. Otherwise the App won't // allow new searches even after GPS has been reenabled, because the app "hangs" in // a semistate where searching = true but now real search is active. searching = false; return; } // clear input setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps)); ui.clear.setVisibility(View.VISIBLE); // clear current GPS location, because we are looking to find a new one gps_location = null; // show GPS button blinking final Animation animation = new AlphaAnimation(1, 0); animation.setDuration(500); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); ui.status.startAnimation(animation); ui.location.setHint(R.string.stations_searching_position); ui.location.clearFocus(); if (gpsListener != null) gpsListener.activateGPS(); }
From source file:io.github.runassudo.ptoffline.ui.LocationGpsView.java
public void activateGPS() { if (searching) return;/* ww w . ja v a 2 s . co m*/ // check permissions if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION)) { Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller); } return; } searching = true; List<String> providers = locationManager.getProviders(true); for (String provider : providers) { // Register the listener with the Location Manager to receive location updates locationManager.requestSingleUpdate(provider, this, null); Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider); } // check if there is a non-passive provider available if (providers.size() == 0 || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) { locationManager.removeUpdates(this); Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); // Set the flag that there is currently no active search. Otherwise the App won't // allow new searches even after GPS has been reenabled, because the app "hangs" in // a semistate where searching = true but now real search is active. searching = false; return; } // clear input setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps)); ui.clear.setVisibility(View.VISIBLE); // clear current GPS location, because we are looking to find a new one gps_location = null; // show GPS button blinking final Animation animation = new AlphaAnimation(1, 0); animation.setDuration(500); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); ui.status.startAnimation(animation); ui.location.setHint(R.string.stations_searching_position); ui.location.clearFocus(); if (gpsListener != null) gpsListener.activateGPS(); }
From source file:com.carver.paul.truesight.Ui.MainActivity.java
/** * stopHeroRecognitionLoadingAnimations shows makes the the camera do one final pulse, and * then fades it away/*w ww . j a v a 2 s . c o m*/ */ protected void stopHeroRecognitionLoadingAnimations() { View processingText = findViewById(R.id.text_processing_image); processingText.animate().alpha(0).setDuration(150); View cameraImage = findViewById(R.id.image_pulsing_camera); Animation animation = cameraImage.getAnimation(); if (animation != null) { animation.setRepeatCount(0); } cameraImage.animate().alpha(0).setDuration(150); }
From source file:com.carver.paul.truesight.Ui.CounterPicker.CounterPickerFragment.java
/** * End the loading animation and then inform the presenter that it is complete by calling * loadingAnimationFinished//from w ww .j av a 2 s . co m */ //TODO-beauty: when I get lambda support remove animation boilerplate code protected void endLoadingAnimation() { Animation pulseAlphaAnimation = mLoadingText.getAnimation(); if (pulseAlphaAnimation == null) { mLoadingText.setVisibility(View.GONE); mPresenter.loadingAnimationFinished(); } else { pulseAlphaAnimation.setRepeatCount(0); mLoadingText.animate().alpha(0f).setDuration(300).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mLoadingText.setVisibility(View.GONE); mPresenter.loadingAnimationFinished(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } }
From source file:com.almalence.opencam.ui.AlmalenceStore.java
public void ShowUnlockControl() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext()); boolean bOnSale = prefs.getBoolean("bOnSale", false); final RotateImageView unlock = ((RotateImageView) guiView.findViewById(R.id.Unlock)); unlock.setImageDrawable(/*w ww .ja va2 s .c o m*/ MainScreen.getAppResources().getDrawable(bOnSale ? R.drawable.unlock_sale : R.drawable.unlock)); unlock.setAlpha(1.0f); unlock.setVisibility(View.VISIBLE); Animation invisible_alpha = new AlphaAnimation(1, 0.4f); invisible_alpha.setDuration(7000); invisible_alpha.setRepeatCount(0); invisible_alpha.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { unlock.clearAnimation(); unlock.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.unlock_gray)); unlock.setAlpha(0.4f); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); unlock.startAnimation(invisible_alpha); }
From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.passitem.MountainPassItemActivity.java
private void startRefreshAnimation() { MenuItem item = mToolbar.getMenu().findItem(MENU_ITEM_REFRESH); if (item == null) { Log.e(TAG, "null"); return;//from ww w. j a v a 2 s . com } // define the animation for rotation Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setActionView(null); mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setIcon(R.drawable.ic_menu_refresh); } @Override public void onAnimationRepeat(Animation animation) { } }); ImageView imageView = new ImageView(this, null, android.R.style.Widget_Material_ActionButton); imageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu_refresh)); imageView.setPadding(31, imageView.getPaddingTop(), 32, imageView.getPaddingBottom()); imageView.startAnimation(animation); item.setActionView(imageView); }