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;
          }
        }
Example #2
0
 @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);
       }
     }
   }
 }
  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());
  }
  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();
          }
        }
      }
    }
  }
Example #6
0
        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();
            }
          }
        }
Example #7
0
  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;
    }
  }
 @Override
 protected void onStop() {
   super.onStop();
   if (mAnimationArrow != null && mAnimationArrow.isRunning()) { // 防止按home键可以退出的情况可能产生的问题
     mAnimationArrow.stop();
   }
 }
 @Override
 public void onWindowFocusChanged(boolean hasFocus) {
   if (hasFocus && mAnimation != null) {
     mAnimation.start();
     mKillActivityHandler.sleep(mAnimation.getDuration(0) * mAnimation.getNumberOfFrames());
   }
 }
Example #10
0
  @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();
  }
Example #11
0
  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));
  }
Example #12
0
  // 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();
    }
  }
Example #13
0
  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;
  }
Example #14
0
 /** 当窗口焦点改变时调用 */
 public void onWindowFocusChanged(boolean hasFocus) {
   ImageView imageView = (ImageView) findViewById(R.id.spinnerImageView);
   // 获取ImageView上的动画背景
   AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
   // 开始动画
   spinner.start();
 }
  /**
   * 设置加载界面
   *
   * @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();
    }
  }
Example #16
0
  @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));
      }
    }
  }
  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
  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 onReceive(Context context, Intent intent) {
          AnimationDrawable drawable = (AnimationDrawable) mIvScan.getBackground();
          drawable.stop();
          ToastUtils.show(context, "找到" + SongManager.with(getActivity()).getSongSize() + "首歌");

          updateList();
        }
 @Override
 public void dismiss() {
   if (anim != null && anim.isRunning()) {
     anim.stop();
   }
   iv_loading.setVisibility(View.INVISIBLE);
   super.dismiss();
 }
 public void onWindowFocusChanged(boolean hasFocus) {
   if (customProgressDialog == null) {
     return;
   }
   ImageView imageView = (ImageView) customProgressDialog.findViewById(R.id.loadingImageView);
   AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
   animationDrawable.start();
 }
 public void kliknieto(View v) {
   if (w_ruchu) {
     a.stop();
     w_ruchu = false;
   } else {
     a.start();
     w_ruchu = true;
   }
 }
Example #23
0
 @Override
 protected void onResume() {
   // TODO Auto-generated method stub
   super.onResume();
   if (mAnimationArrow != null && !mAnimationArrow.isRunning()) { // 防止按home键可以退出的情况可能产生的问题
     mAnimationArrow.start();
   }
   //		view.reDraw();
 }
  // Progress Bar Animation
  private void initAnimation() {
    //  R.drawable.tile1 is PNG
    Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.progress_bar_tile);
    AnimationDrawable shiftedAnimation = getAnimation(b);

    //  R.id.img_3 is ImageView in my application
    View v = findViewById(R.id.rlProgressBackroundImage);
    v.setBackgroundDrawable(shiftedAnimation);
    shiftedAnimation.start();
  }
Example #25
0
 public void setProgressVisibility(boolean visible) {
   if (visible) {
     mFavicon.setImageDrawable(mProgressSpinner);
     mProgressSpinner.start();
     setStopVisibility(true);
   } else {
     mProgressSpinner.stop();
     setStopVisibility(false);
     setFavicon(Tabs.getInstance().getSelectedTab().getFavicon());
   }
 }
Example #26
0
  private void startAnimation() {
    if (progressBar.getVisibility() == View.VISIBLE) {}

    if (null != iv_animation && iv_animation.getVisibility() == View.VISIBLE) {
      if (null != animationDrawable) {
        if (!animationDrawable.isRunning()) {
          animationDrawable.start();
        }
      }
    }
  }
Example #27
0
 private void showInProgress(int item) {
   ImageView imageView = (ImageView) findViewById(item);
   if (imageView != null) {
     final AnimationDrawable yourAnimation;
     imageView.setBackgroundResource(R.drawable.preparation_progress);
     yourAnimation = (AnimationDrawable) imageView.getBackground();
     imageView.setImageDrawable(yourAnimation);
     imageView.setVisibility(ImageView.VISIBLE);
     yourAnimation.start();
   }
   return;
 }
Example #28
0
 @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);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTitle("Frame Animation");

    setContentView(R.layout.frame_animation_example);

    ImageView animatedImage = (ImageView) findViewById(R.id.animated_image);
    animatedImage.setBackgroundResource(R.drawable.example_frame_animation);

    AnimationDrawable exampleAnimation = (AnimationDrawable) animatedImage.getBackground();
    exampleAnimation.start();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_saomiao_layout);

    imageView = (ImageView) findViewById(R.id.imageView);
    imageView.setImageResource(R.drawable.image_values);
    animationDrawable = (AnimationDrawable) imageView.getDrawable();
    // 是否循环一次
    animationDrawable.setOneShot(false);
    animationDrawable.start();
    MyThread();
  }