| | |
| | | import androidx.annotation.Nullable; |
| | | |
| | | import com.auto.lyric.R; |
| | | import com.auto.lyric.data.LyricObject; |
| | | import com.auto.lyric.data.LyricServer; |
| | | import com.auto.lyric.databinding.FloatViewBinding; |
| | | import com.auto.lyric.util.DeviceUtil; |
| | |
| | | Log.e(TAG,"onStartCommand flags:"+flags+" startId:"+startId+ " intent:"+intent); |
| | | manager.addView(binding.getRoot(),params); |
| | | binding.lyric.setTextSize(); |
| | | binding.lyric.setOnTouchListener(new View.OnTouchListener() { |
| | | float touchY; //当触摸歌词View时,保存为当前触点的Y轴坐标 |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent event) { |
| | | float tt=event.getY(); |
| | | switch(event.getAction()){ |
| | | case MotionEvent.ACTION_DOWN: |
| | | break; |
| | | case MotionEvent.ACTION_MOVE: |
| | | touchY=tt-touchY; |
| | | binding.lyric.setOffsetY(binding.lyric.getOffsetY()+touchY); |
| | | Log.e("LyricView","offsety:"+binding.lyric.getOffsetY()); |
| | | binding.lyric.invalidate(); |
| | | break; |
| | | case MotionEvent.ACTION_UP: |
| | | if(binding.btnStart.getText().equals("开启") || pause) { |
| | | int index = binding.lyric.getIndexFromOffsetY(binding.lyric.getOffsetY()); |
| | | binding.lyric.setIndex(index); |
| | | binding.lyric.setOffsetY(220 - index * (binding.lyric.getSIZEWORD() + 44)); |
| | | LyricObject object = LyricServer.getLrc_map().get(index); |
| | | Log.e("LyricView", "object:" + object); |
| | | progress = object.begintime; |
| | | binding.lyric.invalidate(); |
| | | } |
| | | break; |
| | | } |
| | | touchY=tt; |
| | | return true; |
| | | } |
| | | }); |
| | | return super.onStartCommand(intent, flags, startId); |
| | | } |
| | | |