• 自定义ImageButton,实现快进快退功能


          具体做法是仿照系统的RockAudioPlayer,我也是通过查看源码,然后把它简化出来,更容易于应用。通过自定义一个RepeatingImageButton,当然这个名字可以自己更改,RepeatingImageButton里的代码可以查看RockAudioPlayer的源码,我这里只给出经过简化过的java代码。

    1 public class MainActivity extends Activity {
    2 /** Called when the activity is first created. edit by etgyd*/
    3 private RepeatingImageButton last;
    4 @Override
    5 public void onCreate(Bundle savedInstanceState) {
    6 super.onCreate(savedInstanceState);
    7 setContentView(R.layout.main);
    8 last = (RepeatingImageButton) findViewById(R.id.last);
    9 last.setRepeatListener(rep, 260);
    10 last.setOnClickListener(new OnClickListener() {
    11
    12 @Override
    13 public void onClick(View v) {
    14 // TODO Auto-generated method stub
    15   System.out.println("last");
    16 }
    17 });
    18 }
    19
    20 private RepeatingImageButton.RepeatListener rep = new RepeatingImageButton.RepeatListener() {
    21
    22 @Override
    23 public void onRepeat(View v, long duration, int repeatcount) {
    24 // TODO Auto-generated method stub
    25 scanBackward(repeatcount, duration);
    26 }
    27 };
    28
    29 private void scanBackward(int repcnt, long delta) {
    30 try {
    31 if (delta < 5000) {
    32 // seek at 10x speed for the first 5 seconds
    33 delta = delta * 10;
    34 System.out.println("long pause" + delta);
    35 } else {
    36 // seek at 40x after that
    37 delta = 50000 + (delta - 5000) * 40;
    38 System.out.println("long pause fast");
    39 }
    40 } catch (Exception ex) {
    41 }
    42 }
    43 }
  • 相关阅读:
    epii.js简约而不简单的JS模板引擎
    Acwing 165. 小猫爬山
    《将博客搬家到csdn》
    Tourism【codeforces 1200E】
    Middle-Out【codeforces 1231E】(字符串匹配问题)
    super_log (广义欧拉降幂)(2019南京网络赛)
    Different Circle Permutation (HDU
    Knapsack Cryptosystem(状压dp)
    Quadratic equation(二次剩余定理)
    分级(线性dp)
  • 原文地址:https://www.cnblogs.com/etgyd/p/2013762.html
Copyright © 2020-2023  润新知