Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); // 去掉标题栏
    setContentView(R.layout.activity_local);

    intentFromMain = getIntent();
    Bundle bundle = intentFromMain.getExtras();
    listPosition = bundle.getInt("listPosition");
    play_bt_press = bundle.getBoolean("bt_press");
    play_bt_check = bundle.getBoolean("bt_check");
    isFirstTime = bundle.getBoolean("isFirstTime");
    isPlaying = bundle.getBoolean("isPlaying");
    isPause = bundle.getBoolean("isPause");
    msg = bundle.getInt("msg");

    preferences = getSharedPreferences("songPosition", MODE_PRIVATE);
    editor = preferences.edit();

    appState = ((MApplication) getApplicationContext());
    helper = appState.getDBHelper();
    helperFavorite = appState.getDBHelperFavorite();
    fileInfos = appState.getFileInfos();

    findViewById(); // 从界面上根据id获取控件
    setViewOnclickListener(); // 给每一个控件设置监听器
    initLocalMusicList(); // 初始化歌曲列表

    playerReceiver = new PlayerReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(PlayerService.UPDATE_ACTION);
    filter.addAction(PlayerService.MUSIC_PLAY_PAUSE);
    registerReceiver(playerReceiver, filter);
  }
Пример #2
0
 @Override
 protected void onResume() {
   // TODO Auto-generated method stub
   super.onResume();
   appState = ((MApplication) getApplicationContext());
   helper = appState.getDBHelper();
   helperFavorite = appState.getDBHelperFavorite();
   fileInfos = appState.getFileInfos();
   music_play_bt.setPressed(play_bt_press);
   music_play_bt.setChecked(play_bt_check);
   setFavoriteDefault(); // 设置是否歌曲收藏状态
   if (anim != null && isPlaying == true) {
     if (!anim.isStarted()) {
       anim.start(); // 开始旋转
     } else {
       anim.resume(); // 继续旋转
     }
   } else {
     anim.pause(); // 停止旋转
   }
 }