List of usage examples for android.view.animation AlphaAnimation AlphaAnimation
public AlphaAnimation(float fromAlpha, float toAlpha)
From source file:nu.yona.app.ui.pincode.BasePasscodeActivity.java
/** * Initialize animation.//from ww w . j a v a 2 s. com */ protected void initializeAnimation() { final Animation in = new AlphaAnimation(0.0f, 1.0f); in.setDuration(AppConstant.ANIMATION_DURATION); animationView = new AnimationSet(true); in.setStartOffset(AppConstant.TIMER_DELAY); animationView.addAnimation(in); }
From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java
private Animation createAlphaInAnimation() { AlphaAnimation an = new AlphaAnimation(0, 1); an.setDuration(ALPHA_DURATION); return an; }
From source file:io.github.runassudo.ptoffline.ui.LocationGpsView.java
public void activateGPS() { if (searching) return;/*w ww . j a v a2s .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:de.grobox.liberario.locations.LocationGpsView.java
public void activateGPS() { if (searching) return;/* w w w. ja v a 2 s . 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:widgets.Graphical_Range.java
public Graphical_Range(tracerengine Trac, Activity context, String address, String name, int id, int dev_id, String state_key, String url, String usage, String parameters, String model_id, int update, int widgetSize, int session_type, int place_id, String place_type, SharedPreferences params) throws JSONException { super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container); this.Tracer = Trac; this.address = address; this.url = url; this.dev_id = dev_id; this.id = id; this.state_key = state_key; this.usage = usage; this.update = update; this.wname = name; this.myself = this; this.session_type = session_type; this.place_id = place_id; this.place_type = place_type; this.context = context; stateThread = 1;/*from w w w . jav a 2 s . com*/ this.stateS = getResources().getText(R.string.State).toString(); mytag = "Graphical_Range(" + dev_id + ")"; this.params = params; login = params.getString("http_auth_username", null); password = params.getString("http_auth_password", null); //get parameters JSONObject jparam = new JSONObject(parameters.replaceAll(""", "\"")); command = jparam.getString("command"); valueMin = jparam.getInt("valueMin"); valueMax = jparam.getInt("valueMax"); range = valueMax - valueMin; scale = 100 / range; try { test_unite = jparam.getString("unit"); } catch (JSONException e) { test_unite = "%"; } if (test_unite == null || test_unite.length() == 0) { test_unite = "%"; } String[] model = model_id.split("\\."); type = model[0]; //linearlayout horizontal body bodyPanHorizontal = new LinearLayout(context); bodyPanHorizontal.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.CENTER_VERTICAL)); bodyPanHorizontal.setOrientation(LinearLayout.HORIZONTAL); //right panel with different info and seekbars rightPan = new FrameLayout(context); rightPan.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); rightPan.setPadding(0, 0, 10, 0); // panel leftPan = new LinearLayout(context); leftPan.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.BOTTOM)); leftPan.setOrientation(LinearLayout.VERTICAL); leftPan.setGravity(Gravity.CENTER_VERTICAL); leftPan.setPadding(4, 5, 0, 0); state = new TextView(context); state.setTextColor(Color.BLACK); state.setPadding(20, 0, 0, 0); animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(1000); //first seekbar variator seekBarVaria = new SeekBar(context); seekBarVaria.setProgress(0); seekBarVaria.setMax(valueMax - valueMin); seekBarVaria.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL)); seekBarVaria.setProgressDrawable(getResources().getDrawable(R.drawable.bgseekbarvaria)); seekBarVaria.setThumb(getResources().getDrawable(R.drawable.buttonseekbar)); seekBarVaria.setThumbOffset(-3); seekBarVaria.setOnSeekBarChangeListener(this); seekBarVaria.setPadding(0, 0, 15, 7); leftPan.addView(state); leftPan.addView(seekBarVaria); rightPan.addView(leftPan); bodyPanHorizontal.addView(rightPan); super.LL_topPan.removeView(super.LL_featurePan); super.LL_infoPan.addView(bodyPanHorizontal); handler = new Handler() { @Override public void handleMessage(Message msg) { /// Deprecated method to die ///////////////////////////////////////// if (activate) { Tracer.d(mytag, "Handler receives a request to die "); //That seems to be a zombie removeView(LL_background); myself.setVisibility(GONE); if (container != null) { container.removeView(myself); container.recomputeViewAttributes(myself); } try { finalize(); } catch (Throwable t) { } //kill the handler thread itself /////////////////////////////////////////////////////////////////// } else { int new_val = 0; if (msg.what == 9999) { //state_engine send us a signal to notify value changed if (session == null) return; try { Tracer.d(mytag, "Handler receives a new value from cache_engine <" + session.getValue() + ">"); new_val = Integer.parseInt(session.getValue()); } catch (Exception e) { new_val = 0; } //#1649 //Value min and max should be the limit of the widget if (new_val <= valueMin) { state.setText(stateS + valueMin + " " + test_unite); } else if (new_val > valueMin && new_val < valueMax) { state.setText(stateS + new_val + " " + test_unite); } else if (new_val >= valueMax) { state.setText(stateS + valueMax + " " + test_unite); } state.setAnimation(animation); new SBAnim(seekBarVaria.getProgress(), new_val - valueMin).execute(); } else if (msg.what == 9998) { // state_engine send us a signal to notify it'll die ! Tracer.d(mytag, "state engine disappeared ===> Harakiri !"); session = null; realtime = false; removeView(LL_background); myself.setVisibility(GONE); if (container != null) { container.removeView(myself); container.recomputeViewAttributes(myself); } try { finalize(); } catch (Throwable t) { } //kill the handler thread itself } } } }; //================================================================================ /* * New mechanism to be notified by widgetupdate engine when our value is changed * */ WidgetUpdate cache_engine = WidgetUpdate.getInstance(); if (cache_engine != null) { session = new Entity_client(dev_id, state_key, mytag, handler, session_type); if (Tracer.get_engine().subscribe(session)) { realtime = true; //we're connected to engine //each time our value change, the engine will call handler handler.sendEmptyMessage(9999); //Force to consider current value in session } } //================================================================================ }
From source file:org.cm.podd.report.activity.ReportTypeActivity.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, final int position, long id) { Animation animation = new AlphaAnimation(0.3f, 1f); animation.setDuration(600);/*w w w. j a v a 2 s. c o m*/ view.startAnimation(animation); ReportType item = adapter.getItem(position); if (item.getId() == -99) { if (RequestDataUtil.hasNetworkConnection(this)) { listView.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.VISIBLE); startSyncReportType(); // send event hit Tracker tracker = ((PoddApplication) getApplication()) .getTracker(PoddApplication.TrackerName.APP_TRACKER); tracker.send( new HitBuilders.EventBuilder().setCategory("ReportType").setAction("syncReport").build()); } } else { if (item.getId() == 0) { long reportId = reportDataSource.createPositiveReport(); // after save positive report, submit to queue right away reportQueueDataSource.addDataQueue(reportId); broadcastReportSubmission(); finish(); } else { Log.d(TAG, String.format("select report type = %d", item.getId(), testCheckbox.isChecked())); Intent intent = new Intent(this, ReportActivity.class); intent.putExtra("reportType", item.getId()); intent.putExtra("test", testCheckbox.isChecked()); startActivity(intent); } // send event hit Tracker tracker = ((PoddApplication) getApplication()) .getTracker(PoddApplication.TrackerName.APP_TRACKER); tracker.send( new HitBuilders.EventBuilder().setCategory("ReportType").setAction(item.getName()).build()); } }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * On click image view to start stop recording * //from w w w .j a va 2 s . c o m * Records time SYNCHRONOUSLY * * @param v */ public void onClickSwitchAction(View v) { Drawable drwStart = getResources().getDrawable(R.drawable.play); Drawable drwStop = getResources().getDrawable(R.drawable.stop); LinearLayout lllFrag = (LinearLayout) v.getParent(); LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker); LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus); TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording); ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording); Animation anim = new AlphaAnimation(0.0f, 1.0f); Log.d(CLASSNAME, "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); ImageView iv = (ImageView) v; int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus(); if (currentStatus == ActivitySession.STATUS_STOPPED) { Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED"); iv.setImageDrawable(drwStop); llTimePicker.setVisibility(View.INVISIBLE); anim.setDuration(500); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn(); } else { Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED"); iv.setImageDrawable(drwStart); llTimePicker.setVisibility(View.VISIBLE); anim.setRepeatCount(0); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckOut = new Date().getTime(); long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut(); // Save data into both databases DateUtils du = new DateUtils(); Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional // Save in backend recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS); // Save in local database recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT).show(); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); // ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart); // ivParent.setImageResource(R.drawable.rec_50x); //TextView tvTimeStamp = (TextView) liContent.getChildAt(1); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); } tvRecording.startAnimation(anim); ivRecording.startAnimation(anim); Log.d(CLASSNAME, "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); }
From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java
private Animation createAlphaOutAnimation() { AlphaAnimation an = new AlphaAnimation(1, 0); an.setDuration(ALPHA_DURATION); an.setFillAfter(true); return an; }
From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java
private void initAnim() { long duration = 300; long durationS = 160; float alpha = 0.3f; AccelerateInterpolator accInterpolator = new AccelerateInterpolator(); tab_left = new TranslateAnimation(tabW, 0, 0, 0); tab_right = new TranslateAnimation(0, tabW, 0, 0); tab_alpha_1 = new AlphaAnimation(1.0f, alpha); tab_alpha_2 = new AlphaAnimation(alpha, 1.0f); pop_in = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_out = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_in.setDuration(durationS);//from w w w .j a v a 2 s. c o m pop_in.setInterpolator(accInterpolator); pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN)); pop_out.setDuration(durationS); pop_out.setInterpolator(accInterpolator); pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT)); tab_left.setFillAfter(true); tab_left.setFillEnabled(true); tab_left.setDuration(duration); tab_left.setInterpolator(accInterpolator); tab_right.setFillAfter(true); tab_right.setFillEnabled(true); tab_right.setDuration(duration); tab_right.setInterpolator(accInterpolator); tab_alpha_1.setFillAfter(true); tab_alpha_1.setFillEnabled(true); tab_alpha_1.setDuration(duration); tab_alpha_1.setInterpolator(accInterpolator); tab_alpha_2.setFillAfter(true); tab_alpha_2.setFillEnabled(true); tab_alpha_2.setDuration(duration); tab_alpha_2.setInterpolator(accInterpolator); AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha); alphaInit.setFillAfter(true); alphaInit.setFillEnabled(true); tv_tab_box.startAnimation(alphaInit); }
From source file:quickbeer.android.next.views.ProgressIndicatorBar.java
private void animateToHidden() { Log.v(TAG, "animateToHidden()"); AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f); animation.setStartOffset(ANIMATION_END_PAUSE_DURATION); animation.setDuration(ANIMATION_END_FADE_DURATION); animation.setFillAfter(true);/*from w ww. ja v a 2s .c om*/ progressBar.clearAnimation(); progressBar.startAnimation(animation); }