List of usage examples for android.view.animation AnimationUtils AnimationUtils
AnimationUtils
From source file:com.example.android.interpolator.InterpolatorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the fragment_animation layout View v = inflater.inflate(R.layout.interpolator_fragment, container, false); // Set up the 'animate' button, when it is clicked the view is animated with the options // selected: the Interpolator, duration and animation path Button button = (Button) v.findViewById(R.id.animateButton); button.setOnClickListener(new View.OnClickListener() { @Override//from w w w. ja va2 s .com public void onClick(View view) { // Interpolator selected in the spinner Interpolator interpolator = mInterpolators[mInterpolatorSpinner.getSelectedItemPosition()]; // Duration selected in SeekBar long duration = mDurationSeekbar.getProgress(); // Animation path is based on whether animating in or out Path path = mIsOut ? mPathIn : mPathOut; // Log animation details Log.i(TAG, String.format("Starting animation: [%d ms, %s, %s]", duration, (String) mInterpolatorSpinner.getSelectedItem(), ((mIsOut) ? "Out (growing)" : "In (shrinking)"))); // Start the animation with the selected options startAnimation(interpolator, duration, path); // Toggle direction of animation (path) mIsOut = !mIsOut; } }); // Get the label to display the selected duration mDurationLabel = (TextView) v.findViewById(R.id.durationLabel); // Initialize Interpolators programmatically by loading them from their XML definitions // provided by the framework. mInterpolators = new Interpolator[] { new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.linear), new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.fast_out_linear_in), new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.fast_out_slow_in), new AnimationUtils().loadInterpolator(getActivity(), android.R.interpolator.linear_out_slow_in) }; // Load names of interpolators from a resource String[] interpolatorNames = getResources().getStringArray(R.array.interpolator_names); // Set up the Spinner with the names of interpolators mInterpolatorSpinner = (Spinner) v.findViewById(R.id.interpolatorSpinner); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, interpolatorNames); mInterpolatorSpinner.setAdapter(spinnerAdapter); // Set up SeekBar that defines the duration of the animation mDurationSeekbar = (SeekBar) v.findViewById(R.id.durationSeek); // Register listener to update the text label when the SeekBar value is updated mDurationSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { mDurationLabel.setText(getResources().getString(R.string.animation_duration, i)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // Set initial progress to trigger SeekBarChangeListener and update UI mDurationSeekbar.setProgress(INITIAL_DURATION_MS); // Get the view that will be animated mView = v.findViewById(R.id.square); // The following Path definitions are used by the ObjectAnimator to scale the view. // Path for 'in' animation: growing from 20% to 100% mPathIn = new Path(); mPathIn.moveTo(0.2f, 0.2f); mPathIn.lineTo(1f, 1f); // Path for 'out' animation: shrinking from 100% to 20% mPathOut = new Path(); mPathOut.moveTo(1f, 1f); mPathOut.lineTo(0.2f, 0.2f); return v; }
From source file:com.huofu.RestaurantOS.ui.splash.activate.java
/** * ?//ww w.j a v a 2 s . c om */ public void widgetConfigure() { buttonActivate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (authDialog == null) { authDialog = new Dialog(activate.this, R.style.PauseDialog); } if (ttv.getParent() != null) { ttv = new TitanicTextView(ctxt); } String key = etActivteCode.getText().toString(); if (key.length() >= 16) { CommonUtils.LogWuwei(tag, "key is " + key); CommonUtils.sendMsg("?", activate.SHOW_LOADING_TEXT, mUiHandler); activate(ctxt, key); } else { CommonUtils.sendMsg("????", activate.SHOW_ERROR_MESSAGE, mUiHandler); } } }); InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // TODO Auto-generated method stub for (int i = start; i < end; i++) { //???'-' if (!Character.isLetter(source.charAt(i)) && source.charAt(i) != '-') { return ""; } } return null; } }; InputFilter filterLength = new InputFilter.LengthFilter(19); etActivteCode.setCursorVisible(false); etActivteCode.setFilters(new InputFilter[] { filter, filterLength }); etActivteCode.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub etActivteCode.setCursorVisible(true); etActivteCode.removeTextChangedListener(this);// ? etActivteCode.setText(s.toString().toUpperCase());// ? etActivteCode.setSelection(s.toString().length());// ?? etActivteCode.addTextChangedListener(this);// ? String licensePlateNumber = etActivteCode.getText().toString().trim(); if (s.length() == 19) { InputMethodUtils.HideKeyboard(etActivteCode); } } }); etActivteCode.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_DEL) { CommonUtils.LogWuwei(tag, "delete"); etActivteCode.setCursorVisible(false); } return false; } }); rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); OnClickListener oclGetQrCode = new OnClickListener() { @Override public void onClick(View v) { flagInQrcodeDialog = true; CommonUtils.sendMsg("??", SHOW_LOADING_TEXT, mUiHandler); if (LocalDataDeal.readFromLocalPublicKey(ctxt) == null || LocalDataDeal.readFromLocalPublicKey(ctxt).equals("")) { ApisManager.GetPublicKey(new ApiCallback() { @Override public void success(Object object) { sendUIMessage(HIDE_LOADING, ""); try { org.json.JSONObject obj = new org.json.JSONObject((String) object); String public_key = obj.getString("public_key"); LocalDataDeal.writeToLocalPublicKey(public_key, ctxt);//key?base64? } catch (Exception e) { } CommonUtils.sendMsg("", GET_QRCODE, mUiHandler); } @Override public void error(BaseApi.ApiResponse response) { sendUIMessage(HIDE_LOADING, ""); sendUIMessage(SHOW_ERROR_MESSAGE, response.error_message); } }); } else { CommonUtils.sendMsg("", GET_QRCODE, mUiHandler); } rl_activate_input.setVisibility(View.INVISIBLE); rl_activate_qrscan_ready.setVisibility(View.VISIBLE); imageViewQrcode.setVisibility(View.INVISIBLE); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); textviewScanStauts.setTextColor(Color.parseColor("#898989")); textviewScanStauts.setText(R.string.activateByQrCodeTips); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_in)); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_out)); } }; buttonSwitchQrScan.setOnClickListener(oclGetQrCode); findViewById(R.id.rl_switch_activate_qrcode_way).setOnClickListener(oclGetQrCode); buttonSwitchInputCode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); stopQrScanTimer(); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_in)); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_out)); } }); findViewById(R.id.rl_switch_activate_keyboard_way).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); stopQrScanTimer(); } }); PackageManager manager; PackageInfo info = null; manager = this.getPackageManager(); String versionName = null; try { info = manager.getPackageInfo(this.getPackageName(), 0); versionName = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ((TextView) findViewById(R.id.tv_app_version)) .setText(getResources().getString(R.string.app_name) + " V" + versionName); LocalDataDeal.writeToLocalVersion(versionName, ctxt); LocalDataDeal.writeToLocalVersionCode(info.versionCode, ctxt); ftpServiceStart(); }
From source file:com.huofu.RestaurantOS.ui.splash.activate.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { if (flagInQrcodeDialog)//??????? {/*from ww w. j a v a 2 s . co m*/ stopQrScanTimer(); flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); return true; } } return super.onKeyDown(keyCode, event); }