示例#1
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;
    }
  }
示例#2
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);
 }
示例#3
0
 /** 语音相关 */
 public void stopAnimation(BmobMsg item, ImageView iv_voice, ImageView iv_anim_voice) {
   iv_voice.setVisibility(View.VISIBLE);
   iv_anim_voice.setVisibility(View.INVISIBLE);
   if (anim != null) {
     anim.stop();
   }
 }
示例#4
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();
            }
          }
        }
        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;
          }
        }
示例#6
0
 public void error() {
   animLoading.stop();
   setEnabled(true);
   setCompoundDrawablesWithIntrinsicBounds(playIcon, null, null, null);
   Dialogs.toast(
       AudioButton.this.getContext(), getContext().getString(R.string.err_communicationfailed));
 }
示例#7
0
 @Override
 protected void onStop() {
   super.onStop();
   if (mAnimationArrow != null && mAnimationArrow.isRunning()) { // 防止按home键可以退出的情况可能产生的问题
     mAnimationArrow.stop();
   }
 }
 @Override
 public void dismiss() {
   if (anim != null && anim.isRunning()) {
     anim.stop();
   }
   iv_loading.setVisibility(View.INVISIBLE);
   super.dismiss();
 }
  // Turning Off flash
  private void turnOffFlash() {

    frameAnimation.stop();
    params = camera.getParameters();
    params.setFlashMode(Parameters.FLASH_MODE_OFF);
    camera.setParameters(params);
    camera.stopPreview();
  }
示例#10
0
        @Override
        public void onReceive(Context context, Intent intent) {
          AnimationDrawable drawable = (AnimationDrawable) mIvScan.getBackground();
          drawable.stop();
          ToastUtils.show(context, "找到" + SongManager.with(getActivity()).getSongSize() + "首歌");

          updateList();
        }
示例#11
0
 @Override
 public void dismiss() {
   super.dismiss();
   if (animationDrawable != null) {
     animationDrawable.stop();
     animationDrawable = null;
   }
 }
示例#12
0
 public void kliknieto(View v) {
   if (w_ruchu) {
     a.stop();
     w_ruchu = false;
   } else {
     a.start();
     w_ruchu = true;
   }
 }
  @Override
  protected void onStop() {
    System.out.println("[WaitingForSherpa]STOPPED!!!");

    loadingAnimation.stop();
    cancelUpdates();

    super.onStop();
  }
示例#14
0
  /**
   * @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");
      }
    }
  }
示例#15
0
  /** @see android.media.MediaPlayer.OnPreparedListener#onPrepared(MediaPlayer) */
  @Override
  public void onPrepared(MediaPlayer arg0) {
    // Switch to pause icon
    animLoading.stop();
    setEnabled(true);
    setCompoundDrawablesWithIntrinsicBounds(pauseIcon, null, null, null);

    // Play audio
    player.start();
  }
 /** 停止播放语音动画 */
 private void stopRecordAnimation() {
   setCompoundDrawablesWithIntrinsicBounds(
       leftSide ? R.drawable.lcim_chat_voice_right3 : 0,
       0,
       !leftSide ? R.drawable.lcim_chat_voice_left3 : 0,
       0);
   if (anim != null) {
     anim.stop();
   }
 }
示例#17
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());
   }
 }
示例#18
0
  private void stopAnimation() {
    if (progressBar.getVisibility() == View.VISIBLE) {

    } else if (null != iv_animation && iv_animation.getVisibility() == View.VISIBLE) {
      if (null != animationDrawable) {
        if (animationDrawable.isRunning()) {
          animationDrawable.stop();
        }
      }
    }
  }
 private void setListShown(boolean shown, boolean animate) {
   ensureList();
   if (mProgressContainer == null) {
     throw new IllegalStateException("Can't be used with a custom content view");
   }
   if (mListShown == shown) {
     return;
   }
   mListShown = shown;
   if (shown) {
     if (animate) {
       animationDrawable.start();
       // mProgressContainer.startAnimation(AnimationUtils.loadAnimation(this,
       // android.R.anim.fade_out));
       mListContainer.startAnimation(
           AnimationUtils.loadAnimation(mContext, android.R.anim.fade_in));
     } else {
       animationDrawable.stop();
       // mProgressContainer.clearAnimation();
       mListContainer.clearAnimation();
     }
     mProgressContainer.setVisibility(View.GONE);
     mListContainer.setVisibility(View.VISIBLE);
   } else {
     if (animate) {
       animationDrawable.start();
       // mProgressContainer.startAnimation(AnimationUtils.loadAnimation(this,
       // android.R.anim.fade_in));
       mListContainer.startAnimation(
           AnimationUtils.loadAnimation(mContext, android.R.anim.fade_out));
     } else {
       animationDrawable.stop();
       // mProgressContainer.clearAnimation();
       mListContainer.clearAnimation();
     }
     mProgressContainer.setVisibility(View.VISIBLE);
     mListContainer.setVisibility(View.GONE);
   }
 }
示例#20
0
 static void setBitmap(
     ImageView imageView,
     Context context,
     Bitmap bitmap,
     LoadedFrom loadedFrom,
     boolean z,
     boolean z2) {
   Drawable drawable = imageView.getDrawable();
   if (drawable instanceof AnimationDrawable) {
     ((AnimationDrawable) drawable).stop();
   }
   imageView.setImageDrawable(new PicassoDrawable(context, bitmap, drawable, loadedFrom, z, z2));
 }
 public void stopPlayVoice() {
   voiceAnimation.stop();
   if (message.direct == EMMessage.Direct.RECEIVE) {
     voiceIconView.setImageResource(R.drawable.chatfrom_voice_playing);
   } else {
     voiceIconView.setImageResource(R.drawable.chatto_voice_playing);
   }
   // stop play voice
   if (mediaPlayer != null) {
     mediaPlayer.stop();
     mediaPlayer.release();
   }
   isPlaying = false;
 }
 public void setProgressVisibility(boolean visible) {
   if (visible) {
     mFavicon.setImageDrawable(mProgressSpinner);
     mProgressSpinner.start();
     setStopVisibility(true);
     Log.i(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - Throbber start");
   } else {
     mProgressSpinner.stop();
     setStopVisibility(false);
     Tab selectedTab = Tabs.getInstance().getSelectedTab();
     if (selectedTab != null) setFavicon(selectedTab.getFavicon());
     Log.i(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - Throbber stop");
   }
 }
  @Override
  public void onBindView(View view) {
    super.onBindView(view);
    ImageView syncActiveView = (ImageView) view.findViewById(R.id.sync_active);
    View syncPendingView = view.findViewById(R.id.sync_pending);
    View syncFailedView = view.findViewById(R.id.sync_failed);

    syncActiveView.setVisibility(mIsActive ? View.VISIBLE : View.GONE);
    final AnimationDrawable anim = (AnimationDrawable) syncActiveView.getDrawable();
    boolean showError;
    boolean showPending;
    if (mIsActive) {
      syncActiveView.post(
          new Runnable() {
            public void run() {
              anim.start();
            }
          });
      showPending = false;
      showError = false;
    } else {
      anim.stop();
      if (mIsPending) {
        showPending = true;
        showError = false;
      } else {
        showPending = false;
        showError = mFailed;
      }
    }

    syncFailedView.setVisibility(showError ? View.VISIBLE : View.GONE);
    syncPendingView.setVisibility((showPending && !mIsActive) ? View.VISIBLE : View.GONE);

    View checkBox = view.findViewById(android.R.id.checkbox);
    if (mOneTimeSyncMode) {
      checkBox.setVisibility(View.GONE);

      /*
       * Override the summary. Fill in the %1$s with the existing summary
       * (what ends up happening is the old summary is shown on the next
       * line).
       */
      TextView summary = (TextView) view.findViewById(android.R.id.summary);
      summary.setText(getContext().getString(R.string.sync_one_time_sync, getSummary()));
    } else {
      checkBox.setVisibility(View.VISIBLE);
    }
  }
 public void stopPlayVoice() {
   voiceAnimation.stop();
   if (message.direct == EMMessage.Direct.RECEIVE) {
     voiceIconView.setImageResource(R.drawable.chatfrom_voice_playing);
   } else {
     voiceIconView.setImageResource(R.drawable.chatto_voice_playing);
   }
   // stop play voice
   if (mediaPlayer != null) {
     mediaPlayer.stop();
     mediaPlayer.release();
   }
   isPlaying = false;
   ((ChatActivity) activity).playMsgId = null;
   adapter.notifyDataSetChanged();
 }
  private void markAsDone(InstallResult result) {
    fadeInStartButton();
    mFairyAnimation.stop();
    switch (result.getResult()) {
      case OK:
        final View.OnClickListener onClickListener =
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {

                setResult(RESULT_OK);
                finish();
              }
            };
        mButtonStartApp.setOnClickListener(onClickListener);
        mFairyContainer.setOnClickListener(onClickListener);
        mFairySpeechBubble.setVisibility(View.VISIBLE);
        mFairyText.setText(R.string.start_app);
        break;
      case NOT_ENOUGH_DISK_SPACE:
        String errorMsg = getString(R.string.install_error_disk_space);
        final long diff = result.getNeededSpace() - result.getFreeSpace();
        errorMsg = String.format(errorMsg, (diff / (1024 * 1024)));
        mFairyText.setText(errorMsg);
        mButtonStartApp.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                setResult(RESULT_CANCELED);
                finish();
              }
            });
        break;
      case UNSPECIFIED_ERROR:
        errorMsg = getString(R.string.install_error);
        mFairyText.setText(errorMsg);
        mButtonStartApp.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                setResult(RESULT_CANCELED);
                finish();
              }
            });
        break;
    }
  }
示例#26
0
  private void setBluetoothState(int btState) {
    if (bluetoothMenutItem != null) {
      final ImageView imageView =
          (ImageView)
              bluetoothMenutItem.getActionView().findViewById(R.id.animated_menu_item_action);

      // stop the animation if there is one running
      AnimationDrawable frameAnimation;
      if (imageView.getBackground() instanceof AnimationDrawable) {
        frameAnimation = (AnimationDrawable) imageView.getBackground();
        if (frameAnimation.isRunning()) frameAnimation.stop();
      }

      switch (btState) {
        case BLUETOOTH_DISCONNECTED:
          imageView.setBackgroundResource(R.mipmap.bluetooth_none);
          break;
        case BLUETOOTH_CONNECTED:
          imageView.setBackgroundResource(R.mipmap.bluetooth_3);
          break;
        case BLUETOOTH_SEARCH:
          runOnUiThread(
              new Runnable() {
                @SuppressLint("NewApi")
                @Override
                public void run() {
                  AnimationDrawable drawable =
                      (AnimationDrawable)
                          ContextCompat.getDrawable(
                              getApplicationContext(), R.anim.animation_bluetooth);
                  // Use setBackgroundDrawable() for API 14 and 15 and setBackground() for API 16+:
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    imageView.setBackground(drawable);
                  } else {
                    imageView.setBackgroundDrawable(drawable);
                  }
                  AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
                  frameAnimation.start();
                }
              });
          break;
        default:
          break;
      }
    }
  }
  public void setState(int state) {
    if (state == mState) return;

    if (state == STATE_REFRESHING) { // 显示进度
      mArrowImageView.clearAnimation();
      mArrowImageView.setVisibility(View.INVISIBLE);
      mProgressBar.setVisibility(View.VISIBLE);
      if (animationDrawable != null) {
        animationDrawable.start();
      }
    } else { // 显示箭头图片
      mArrowImageView.setVisibility(View.VISIBLE);
      mProgressBar.setVisibility(View.INVISIBLE);
      if (animationDrawable != null) {
        animationDrawable.stop();
      }
    }

    switch (state) {
      case STATE_NORMAL:
        if (mState == STATE_READY) {
          mArrowImageView.startAnimation(mRotateDownAnim);
        }
        if (mState == STATE_REFRESHING) {
          mArrowImageView.clearAnimation();
        }
        mHintTextView.setText(R.string.xlistview_header_hint_normal);
        break;
      case STATE_READY:
        if (mState != STATE_READY) {
          mArrowImageView.clearAnimation();
          mArrowImageView.startAnimation(mRotateUpAnim);
          mHintTextView.setText(R.string.xlistview_header_hint_ready);
        }
        break;
      case STATE_REFRESHING:
        mHintTextView.setText(R.string.xlistview_header_hint_loading);
        break;
      default:
    }

    mState = state;
  }
 private void setIconRunning(ImageView imageView, boolean running) {
   if (imageView != null) {
     Drawable drawable = imageView.getDrawable();
     if (drawable instanceof AnimationDrawable) {
       AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
       if (running) {
         animationDrawable.start();
       } else {
         animationDrawable.stop();
       }
     } else if (drawable instanceof AnimatedVectorDrawable) {
       AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable;
       if (running) {
         animationDrawable.start();
       } else {
         animationDrawable.stop();
       }
     }
   }
 }
示例#29
0
  @Override
  public boolean onMenuItemClick(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.action_a12:
        new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "12");
        return true;
      case R.id.action_a18:
        new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "18");
        return true;
      case R.id.action_a6:
        new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "6");
        return true;
      case R.id.action_stop:
        animDrawable.stop();
        return true;
      case R.id.action_share:
        if (anim_ran)
          UtilityShare.ShareAnimGif(
              this, "NWS mosaic: " + nws_radar_mosaic_sector_label_current, animDrawable);
        else
          UtilityShare.ShareBitmap(
              this,
              "NWS mosaic: " + nws_radar_mosaic_sector_label_current,
              UtilityImg.LayerDrawableToBitmap(ld));
        return true;
      case R.id.action_spotters:
        if (spotters) {
          spotters = false;
          new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
          spotters = true;
          new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
示例#30
0
  /** React to a selection in the option menu */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getGroupId() == BAND_SELECTION_MENU) {
      switch (item.getItemId()) {
        case BAND_US:
          mSelectedBand = FmBand.BAND_US;
          item.setChecked(true);
          break;
        case BAND_EU:
          mSelectedBand = FmBand.BAND_EU;
          item.setChecked(true);
          break;
        case BAND_JAPAN:
          mSelectedBand = FmBand.BAND_JAPAN;
          item.setChecked(true);
          break;
        case BAND_CHINA:
          mSelectedBand = FmBand.BAND_CHINA;
          item.setChecked(true);
          break;
        default:
          break;
      }
      mFmBand = new FmBand(mSelectedBand);
      try {
        mFmTransmitter.reset();
        ((Button) findViewById(R.id.Transmit)).setBackgroundResource(R.drawable.transmitgobutton);
        ((TextView) findViewById(R.id.FrequencyTextView)).setText("----");
        mFrequencyIncrement = mFmBand.getChannelOffset() / 1000;
        mTransmitAnimation.stop();
      } catch (Exception e) {
        showToast("Unable to restart the FM Radio", Toast.LENGTH_LONG);
      }
    }
    return super.onOptionsItemSelected(item);
  }