// Start the game private void enterGame() { if (gameStatus == GAME_MENU) { gameStatus = GAME_GOGAME; showView(R.id.start, 0, 2); showLayout(R.id.main, R.id.start); // Show Tips animation AnimationDrawable animationDo; ImageView doImage = (ImageView) findViewById(R.id.ani_do); doImage.setBackgroundResource(R.drawable.animation_do); animationDo = (AnimationDrawable) doImage.getBackground(); animationDo.start(); AnimationDrawable animationNotDo; ImageView ndoImage = (ImageView) findViewById(R.id.ani_notdo); ndoImage.setBackgroundResource(R.drawable.animation_notdo); animationNotDo = (AnimationDrawable) ndoImage.getBackground(); animationNotDo.start(); showView(R.id.ani_do, 600, 4); showView(R.id.ani_notdo, 600, 4); showView(R.id.text_do, 1000, 4); showView(R.id.text_notdo, 1000, 4); label01.setText("0"); label02.setText("00:00"); label03.setText(getString(R.string.highscore) + " " + Integer.toString(mHighScore)); VideoView videoView = (VideoView) findViewById(R.id.videoView); videoView.pause(); } }
/** * @param flag An flag to start or stop the animation of an ImageView. true for start, and false * for stop. */ @android.view.RemotableViewMethod public void setAnimationRunning(boolean flag) { Drawable drawable = this.getDrawable(); if (flag) { if (drawable != null && (drawable instanceof AnimationDrawable)) { AnimationDrawable tempAD = (AnimationDrawable) drawable; if (!tempAD.isRunning()) tempAD.start(); } else { ImageView iv = null; ViewParent parent = this.getParent(); if (parent instanceof ViewGroup) { ViewGroup vg = (ViewGroup) parent; iv = (ImageView) vg.findViewWithTag(STORE_PIC_TAG); } else { Log.e("test", "ViewParent is not a ViewGroup!"); return; } if (iv != null && (iv instanceof ImageView)) { Drawable d = iv.getBackground(); if (d != null && d instanceof AnimationDrawable) { AnimationDrawable ad = (AnimationDrawable) d; this.setImageDrawable(ad); ad.start(); } } else { Log.e("com.mediatek.sns", "Iv is null"); } } } // stop animation else { if (drawable != null && (drawable instanceof AnimationDrawable)) { AnimationDrawable tempAD = (AnimationDrawable) drawable; if (tempAD.isRunning()) tempAD.stop(); } ImageView iv = null; ViewParent parent = this.getParent(); if (parent instanceof ViewGroup) { ViewGroup vg = (ViewGroup) parent; iv = (ImageView) vg.findViewWithTag(STORE_PIC_TAG); } else { Log.e("test", "ViewParent is not a ViewGroup!"); return; } if (iv != null && (iv instanceof ImageView)) { Drawable d = iv.getDrawable(); if (d != null /*&& d instanceof BitmapDrawable*/) { this.setImageDrawable(d); } } else { Log.e("com.mediatek.sns", "Iv is null"); } } }
@Override public void onWindowFocusChanged(boolean hasFocus) { if (hasFocus == true) { frameAnimation.start(); frameAnimation_title.start(); } else { frameAnimation.stop(); frameAnimation_title.stop(); frameAnimation = null; frameAnimation_title = null; } super.onWindowFocusChanged(hasFocus); }
public void doLogoAnimation() { logo_login.setBackgroundResource(R.drawable.logo_intro_anim); AnimationDrawable frameAnimation = (AnimationDrawable) logo_login.getBackground(); frameAnimation.setEnterFadeDuration(450); frameAnimation.setExitFadeDuration(450); frameAnimation.start(); new Handler() .postDelayed( new Runnable() { @Override public void run() { logo_login.animate().yBy(-150).setDuration(INTRO_DURATION); textView_login.animate().yBy(-150).setDuration(INTRO_DURATION); } }, LOGO_ANIM_DURATION); new Handler() .postDelayed( new Runnable() { @Override public void run() { linearLayout.setVisibility(LinearLayout.VISIBLE); } }, (LOGO_ANIM_DURATION + INTRO_DURATION)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.day03_02layout); day03_02_edi_01 = (EditText) findViewById(R.id.day03_02_edi_01); day03_02_edi_02 = (EditText) findViewById(R.id.day03_02_edi_02); day03_02_rad_01 = (RadioGroup) findViewById(R.id.day03_02_rad_01); dao = new StudentDao(this); // 获取控件 添加学生 day03_02_but_01 = (Button) findViewById(R.id.day03_02_but_01); day03_02_but_01.setOnClickListener(this); // day03_02_but_02 = (Button) findViewById(R.id.day03_02_but_02); // day03_02_but_03 = (Button) findViewById(R.id.day03_02_but_03); day03_02_lis_01 = (ListView) findViewById(R.id.day03_02_lis_01); day03_02_ima_01 = (ImageView) findViewById(R.id.day03_02_ima_01); day03_02_ima_01.setBackgroundResource(R.drawable.bg); // 获取它的背景资源,强制类型转化成 动画对象 AnimationDrawable drawable = (AnimationDrawable) day03_02_ima_01.getBackground(); // 让动画播放 drawable.start(); refreshData(); }
public static ProgressDialog buildProgressDialog(Context context, boolean cancelble) { final ProgressDialog dialog = new ProgressDialog(context, ResourceUtils.getStyleId(context, "LoadingDialog")); // 设置window type if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); } else { dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE); } try { if (context instanceof Activity) { if (!((Activity) context).isFinishing()) { dialog.show(); } } else { dialog.show(); } } catch (Exception e) { e.printStackTrace(); } dialog.setContentView(ResourceUtils.getLayoutId(context, "pj_layout_progressbar")); ImageView loading = (ImageView) dialog.findViewById(ResourceUtils.getId(context, "iv_loading")); AnimationDrawable anim = (AnimationDrawable) loading.getBackground(); anim.start(); dialog.setCancelable(cancelble); return dialog; }
private void startRefresh(boolean isUserInitiated, boolean isSwipeInitiated) { if (mIsRefreshing) { return; } mIsRefreshing = true; mIsRefreshUserInitiated = isUserInitiated; // Clear the list adapter to trigger the empty list display. mAdapter.clear(); Collection<String> urls = UrlManager.getInstance(this).getUrls(true); if (urls.isEmpty()) { finishRefresh(); } else { // Show the swipe-to-refresh busy indicator for refreshes initiated by a swipe. if (isSwipeInitiated) { mSwipeRefreshWidget.setRefreshing(true); } // Update the empty list view to show a scanning animation. mEmptyListText.setText(R.string.physical_web_empty_list_scanning); mScanningImageView.setImageResource(R.drawable.physical_web_scanning_animation); mScanningImageView.setColorFilter(null); AnimationDrawable animationDrawable = (AnimationDrawable) mScanningImageView.getDrawable(); animationDrawable.start(); resolve(urls); } // Clear stored URLs and resubscribe to Nearby. PhysicalWeb.startPhysicalWeb((ChromeApplication) getApplicationContext()); }
@Override public void onClick(View arg0) { // If audio is playing then this is a pause button if (player.isPlaying()) { player.stop(); setCompoundDrawablesWithIntrinsicBounds(playIcon, null, null, null); } else { // Set animated throbber setCompoundDrawablesWithIntrinsicBounds(animLoading, null, null, null); setEnabled(false); // Start animation animLoading.setOneShot(false); animLoading.start(); try { if (cached) { onFetchCompleted(null, true); } else { int timeout = getContext().getResources().getInteger(R.integer.connection_timeout); FetchToFileTask audioFetchTask = new FetchToFileTask(cacheFile, timeout); audioFetchTask.setListener(this); audioFetchTask.execute(audioURL); } } catch (Exception e) { Dialogs.toast(getContext(), getContext().getString(R.string.err_communicationfailed)); } } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mAnimation != null) { mAnimation.start(); } }
private void PrepararPantalla() { Log.d(TAG, "ejecutando PrepararPantalla()"); contadorPalabras = 0; // -> contador de palabras contadorPantallas = 0; // -> contador pantallas para salir de la rotacion // Setup sonidos, imagen, palabras y animaciones jugar = (Button) findViewById(R.id.irJuegoCosas); repetir = (Button) findViewById(R.id.irAtras); palabrasCosas = getResources().getStringArray(R.array.cosasArray); llenarIdSonidos(); llenarIdSonidosCosas(); llenarImagenes(); text = (TextView) findViewById(R.id.palabraCosas); text.setText(palabrasCosas[contadorPalabras]); imagenCosa = (ImageView) findViewById(R.id.imagenCosa); imagenCosa.setImageDrawable(imagenesCosas[contadorPalabras]); animacion = (ImageView) findViewById(R.id.tapAnimationCosas); animacion.setBackgroundResource(R.drawable.tap_animation); tapAnimation = (AnimationDrawable) animacion.getBackground(); tapAnimation.start(); // Fin setup recursos // Setup del flipper de palabras flip = (ViewFlipper) findViewById(R.id.flipperCosas); }
@Override protected void onUpdateView(CommonViewHolder viewHolder, XMessage m) { VoiceViewHolder voiceHolder = (VoiceViewHolder) viewHolder; if (m.isVoiceUploading() || m.isVoiceDownloading()) { voiceHolder.mProgressBar.setVisibility(View.VISIBLE); voiceHolder.mImageViewVoice.setVisibility(View.GONE); } else { ImageView imageViewVoice = voiceHolder.mImageViewVoice; voiceHolder.mProgressBar.setVisibility(View.GONE); imageViewVoice.setVisibility(View.VISIBLE); if (m.isUploadSuccess()) { if (VoicePlayProcessor.getInstance().isPlaying(m)) { imageViewVoice.setImageResource(R.drawable.animlist_play_voice); AnimationDrawable ad = (AnimationDrawable) imageViewVoice.getDrawable(); ad.start(); } else { imageViewVoice.setImageResource(R.drawable.voice_played); } } else { imageViewVoice.setImageResource(R.drawable.voice_played); setShowWarningView(voiceHolder.mViewWarning, true); } } showSeconds(voiceHolder.mTextViewVoice, m); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.iv_upload_up: changeUpUnit(true); break; case R.id.iv_upload_down: changeUpUnit(false); break; case R.id.iv_download_up: changeDownUnit(); break; case R.id.iv_download_down: changeDownUnit(); break; case R.id.layout_traffic_limit_upload: uploadState = !uploadState; refreshView(); break; case R.id.layout_traffic_limit_download: downloadState = !downloadState; refreshView(); break; case R.id.save_setting: iv_loading.setVisibility(View.VISIBLE); anim = (AnimationDrawable) mContext.getResources().getDrawable(R.drawable.frame); iv_loading.setImageDrawable(anim); anim.start(); saveSetting(); break; } }
public void handleMessage(Message msg) { switch (msg.what) { case REFLASH_LISTVIEW: if (mixtureAdapter != null) mixtureAdapter.notifyDataSetChanged(); // 刷新UI break; case REFLASH_LISTVIEW_FAIL: Toast.makeText( getApplication(), MixGridActivity.this.getResources().getString(R.string.package_net_error), Toast.LENGTH_SHORT) .show(); Log.e("合成列表", "合成道具图片下载失败,错误码为:" + msg.arg1); break; case CardZoneProtocolListener.HANDLER_PACK_QUERY_SUCCESS: // 获取背包列表数据成功 flag = true; break; case CardZoneProtocolListener.HANDLER_PACK_QUERY_SUCCESS_NODATA: flag = true; break; case START_ANIM: if (btnFreeBean != null) { AnimationDrawable ad = (AnimationDrawable) btnFreeBean.getBackground(); ad.stop(); ad.start(); } break; default: break; } }
@Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); if (event.getPropertyName().equals("playing")) { Log.i("gobelieve", "playing changed"); boolean playing = this.message.getPlaying(); AudioHolder audioHolder = new AudioHolder(this); if (playing) { AnimationDrawable voiceAnimation; if (incomming) { audioHolder.control.setImageResource(R.anim.voice_from_icon); } else { audioHolder.control.setImageResource(R.anim.voice_to_icon); } voiceAnimation = (AnimationDrawable) audioHolder.control.getDrawable(); voiceAnimation.start(); Log.i("gobelieve", "start animation"); } else { if (incomming) { audioHolder.control.setImageResource(R.drawable.ease_chatfrom_voice_playing); } else { audioHolder.control.setImageResource(R.drawable.ease_chatto_voice_playing); } } } }
/** 当窗口焦点改变时调用 */ public void onWindowFocusChanged(boolean hasFocus) { ImageView imageView = (ImageView) findViewById(R.id.spinnerImageView); // 获取ImageView上的动画背景 AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground(); // 开始动画 spinner.start(); }
private void newWait() { if (DeviceUtil.checkConnection(mContext)) { // 加载动画 progressLinear.setVisibility(View.VISIBLE); AnimationDrawable animationDrawable = (AnimationDrawable) progreView.getDrawable(); animationDrawable.start(); mRecyclerView.setVisibility(View.VISIBLE); networkInfo.setVisibility(View.GONE); initData(sessionData); } else { errorInfo.setImageDrawable(getResources().getDrawable(R.mipmap.error_nowifi)); mRecyclerView.setVisibility(View.GONE); networkInfo.setVisibility(View.VISIBLE); newLoading.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { newWait(); } }); } }
@Override public void onWindowFocusChanged(boolean hasFocus) { if (hasFocus && mAnimation != null) { mAnimation.start(); mKillActivityHandler.sleep(mAnimation.getDuration(0) * mAnimation.getNumberOfFrames()); } }
/** * 设置加载界面 * * @param rootView 你所要放置的加载动画的根布局 */ public static void setAutoLoadingView(ViewGroup rootView) { if (rootView != null) { AutoLoadingUtil.rootView = rootView; view = LayoutInflater.from(rootView.getContext()).inflate(R.layout.autoloading, rootView, false); saveView = new ArrayList<View>(); ImageView image = (ImageView) view.findViewById(R.id.imageView_autoLoading); image.setBackgroundResource(R.anim.autoloading); AnimationDrawable anim = (AnimationDrawable) image.getBackground(); anim.start(); rootView.setOnHierarchyChangeListener( new OnHierarchyChangeListener() { @Override public void onChildViewRemoved(View parent, View child) { // TODO Auto-generated method stub saveView.add(child); } @Override public void onChildViewAdded(View parent, View child) { // TODO Auto-generated method stub } }); rootView.removeAllViews(); rootView.addView(view); view.bringToFront(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_acoustic); price = (TextView) this.findViewById(R.id.price); price.setText(getIntent().getStringExtra("price")); AssetManager mgr = getAssets(); Typeface tf = Typeface.createFromAsset(mgr, "fonts/arial.ttf"); price.setTypeface(tf); mSinVoicePlayer = new SinVoicePlayer(CODEBOOK); mSinVoicePlayer.setListener(this); mRecognition = new SinVoiceRecognition(CODEBOOK); mRecognition.setListener(this); mSinVoicePlayer.play(Utils.sendStr(price.getText().toString().substring(2)), true, 1000); image = (ImageView) this.findViewById(R.id.image); animationDrawable = (AnimationDrawable) image.getBackground(); animationDrawable.start(); Intent mIntent = new Intent(Utils.ACTION_NAME_SONIC_OPEN); sendBroadcast(mIntent); handler.sendEmptyMessageDelayed(MSG_END, Utils.DELAY); }
public void onReceive(Context context, Intent intent) { String action = intent.getAction(); bluetoothImage.setBackgroundResource(R.drawable.discovering_animation); anim = (AnimationDrawable) bluetoothImage.getBackground(); if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) { discoverBT.setText(R.string.cancel_discovery); enableBT.setEnabled(false); checkBT.setEnabled(false); anim.start(); Toast.makeText(MainActivity.this, R.string.discovering, Toast.LENGTH_SHORT).show(); } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { discoverBT.setText(R.string.discover_devices); enableBT.setEnabled(true); checkBT.setEnabled(true); anim.stop(); bluetoothImage.setBackground(getResources().getDrawable((R.drawable.btooth_on))); Toast.makeText(MainActivity.this, R.string.discovery_finished, Toast.LENGTH_SHORT) .show(); } else if (BluetoothDevice.ACTION_FOUND.equals(action)) { BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (!tmpBtChecker.contains(device)) { tmpBtChecker.add(device); discoveredDevicesArList.add(device.getName() + "\n" + device.getAddress()); adapterForDiscoveredDevices.notifyDataSetChanged(); } } }
private void changeHeaderByState(int state) { switch (state) { case DONE: headerView.setPadding(0, -headerViewHeight, 0, 0); firstSetpView.setVisibility(View.VISIBLE); secondAnimation.stop(); secondStepView.setVisibility(View.GONE); break; case RELEASE_TO_REFRESH: tv_pull_to_refresh.setText("松开刷新"); break; case PULL_TO_REFRESH: tv_pull_to_refresh.setText("下拉刷新"); state = DONE; firstSetpView.setVisibility(View.VISIBLE); secondAnimation.stop(); secondStepView.setVisibility(View.GONE); break; case REFRESHING: tv_pull_to_refresh.setText("正在刷新"); firstSetpView.setVisibility(View.GONE); secondStepView.setVisibility(View.VISIBLE); secondAnimation.stop(); secondAnimation.start(); break; default: break; } }
private void animateBulbs(String biString) { List<Integer> bits = new ArrayList<>(8); for (int count = biString.length() - 1; count >= 0; count--) { int bit = Integer.parseInt(String.valueOf(biString.charAt(count))); bits.add(bit); } // Toast.makeText(getActivity(), bits.size() + " "+ images.size(), Toast.LENGTH_LONG).show(); // use bits.siz() for (int i = bits.size() - 1; i >= 0; i--) { if (bits.get(i) != null && bits.get(i) == 1) { ImageView currentView = images.get(i); @SuppressWarnings("ResourceType") AnimationDrawable drawable = (AnimationDrawable) getActivity().getResources().getDrawable(R.anim.splash); currentView.setImageDrawable(drawable); drawable.start(); currentView.setTag("on"); } else { ImageView currentView = images.get(i); currentView.setImageDrawable( getActivity().getResources().getDrawable(R.drawable.green_light_bulb)); currentView.setTag("off"); } } displayBinaryValue(); }
void refreshRoute() { if (mAttachedToWindow) { final MediaRouter.RouteInfo route = mRouter.getSelectedRoute(); final boolean isRemote = !route.isDefaultOrBluetooth() && route.matchesSelector(mSelector); final boolean isConnecting = isRemote && route.isConnecting(); boolean needsRefresh = false; if (mRemoteActive != isRemote) { mRemoteActive = isRemote; needsRefresh = true; } if (mIsConnecting != isConnecting) { mIsConnecting = isConnecting; needsRefresh = true; } if (needsRefresh) { updateContentDescription(); refreshDrawableState(); if (mRemoteIndicator.getCurrent() instanceof AnimationDrawable) { AnimationDrawable curDrawable = (AnimationDrawable) mRemoteIndicator.getCurrent(); if (!curDrawable.isRunning()) { curDrawable.start(); } } } } }
public void onWindowFocusChanged(boolean hasFocus) { if (customProgressDialog == null) { return; } ImageView imageView = (ImageView) customProgressDialog.findViewById(R.id.loadingImageView); AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground(); animationDrawable.start(); }
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus) { if (drawable != null) { drawable.start(); } } }
/** 初始化 */ public void setupViews() { intent = getIntent(); mAppId = intent.getIntExtra("app_id", 0); // 获取对应app 的ID mAmount = intent.getIntExtra("amount", 0); // 评论人数 mUserID = intent.getStringExtra("user_id"); // 用户id mHaveBeenEvaluated = intent.getBooleanExtra("isScore", false); // 获取是否评分 mScoreValue = intent.getFloatExtra("ScoreValue", 0); // 获取已评分数 if ("-1".equals(mUserID)) { // 祥情里没获取userid,则默认此时已评价(不提交评分信息) mHaveBeenEvaluated = true; } mRatingBar = (RatingBar) findViewById(R.id.ratingBar); bar = (LinearLayout) findViewById(R.id.bar); mRatingBarText = (TextView) findViewById(R.id.text); animationDrawable = (AnimationDrawable) bar.getBackground(); mCloseButton = (ImageButton) findViewById(R.id.close); mTextView1 = (TextView) findViewById(R.id.text_1); // 已有多少人评价 mTextView2 = (TextView) findViewById(R.id.text_2); // 使用说明 mRatingBar.setRating(mScoreValue); mRatingBar.setOnRatingBarChangeListener(new RatingBarListener()); // if(mHaveBeenEvaluated){ //已评价 // evaluated(); // //mRatingBar.setFocusable(false);//让星星失去焦点 // AppLog.d(TAG,"-------------------------id--"+mAppId +"--已评价----------------"); // }else{ // mRatingBar.setRating(mScoreValue); // mRatingBar.setOnRatingBarChangeListener(new RatingBarListener()); // AppLog.d(TAG,"-------------------------id--"+mAppId +"--未评价----------------"); // } // 每次都让评价 // mRatingBar.setOnRatingBarChangeListener(new RatingBarListener()); mCloseButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { if (v.getId() == R.id.close) { finish(); } } }); setCloseFocuseChange(mCloseButton); mRatingBar.requestFocus(); animationDrawable.start(); mRatingBar.setOnClickListener( new OnClickListener() { public void onClick(View v) { mIsSuer = true; mTextView1.setText( AppAppraisalActivity.this.getString(R.string.app_appraisal_text1, mAmount + 1)); handler.sendEmptyMessageDelayed(CLOSE, 700); } }); setBarFocuseChange(mRatingBar); }
@Override protected void onRestart() { super.onRestart(); // System.out.println("is in service ? "+inService); loadingAnimation.start(); // --restart requesting scheduleAttentionQuery(0); }
public void changeToReleaseRefresh() { mReleaseRefreshingView.setImageResource(mChangeToReleaseRefreshAnimResId); mChangeToReleaseRefreshAd = (AnimationDrawable) mReleaseRefreshingView.getDrawable(); mReleaseRefreshingView.setVisibility(VISIBLE); mPullDownView.setVisibility(INVISIBLE); mChangeToReleaseRefreshAd.start(); }
public void kliknieto(View v) { if (w_ruchu) { a.stop(); w_ruchu = false; } else { a.start(); w_ruchu = true; } }
/** 开始播放语音动画 */ private void startRecordAnimation() { setCompoundDrawablesWithIntrinsicBounds( leftSide ? R.drawable.lcim_chat_anim_voice_left : 0, 0, !leftSide ? R.drawable.lcim_chat_anim_voice_right : 0, 0); anim = (AnimationDrawable) getCompoundDrawables()[leftSide ? 0 : 2]; anim.start(); }