我的代码无法正常工作。有人能帮我吗?我需要的只是GestureListener
才能工作。提前谢谢。
package com.redevents.copd;
import android.support.v4.view.GestureDetectorCompat;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
public class LastPage extends Activity implements Animation.AnimationListener {
private GestureDetectorCompat _detectorCompat;
private SqlDbHelper _sqlDbHelper;
Animation animation_page_two;
Animation animation_breathing_difficulties;
Animation animation_productive_cough;
Animation animation_poor_appetite;
Animation animation_dofilin;
Animation animation_exflem;
Animation animation_appebon;
Animation animation_green_bg;
Animation animation_group_fade_in;
Animation animation_we_med_thank_you;
final float volumeChange = 0.8f;
float volume = 1.0f;
int count, length;
boolean start, cheeringIsPlaying, coughingIsPlaying, applauseIsPlaying, coughingHasBeenPlayed, applauseHasBeenPlayed, applauseIncreasing;
boolean wtf = false;
boolean wth = false;
boolean jinde = false;
Context l_context;
@Override
public boolean onTouchEvent(MotionEvent event) {
this._detectorCompat.onTouchEvent(event);
return super.onTouchEvent(event);
}
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
/*if((animation_page_two.hasEnded() && count == 1) ||
(animation_dofilin.hasEnded() && count == 2) ||
(animation_exflem.hasEnded() && count == 3) ||
(animation_appebon.hasEnded() && count == 4) ||
(animation_group_fade_in.hasEnded() && count == 5)) {
start = true;
count++;
}
if (wth) {
wth = false;
count = 2;
} else if (wtf) {
wtf = false;
count = 6;
modal.setVisibility(View.VISIBLE);
modal.setAnimation(animation_group_fade_in);
rating_header.startAnimation(animation_group_fade_in);
rating_bar_label.startAnimation(animation_group_fade_in);
rating_bar.startAnimation(animation_group_fade_in);
done.startAnimation(animation_group_fade_in);
} else if(animation_we_med_thank_you.hasEnded() && count == 11 && jinde) {
submit.setVisibility(View.VISIBLE);
footnote.setVisibility(View.VISIBLE);
count++;
}*/
}
@Override
public void onAnimationRepeat(Animation animation) {
}
/*@Override
public void onAnimationEnd(Animation animation) {
if((animation_page_two.hasEnded() && count == 1) ||
(animation_dofilin.hasEnded() && count == 2) ||
(animation_exflem.hasEnded() && count == 3) ||
(animation_appebon.hasEnded() && count == 4) ||
(animation_group_fade_in.hasEnded() && count == 5)) {
start = true;
count++;
}
if (wth) {
wth = false;
count = 5;
} else if (wtf) {
wtf = false;
count = 10;
modal.setVisibility(View.VISIBLE);
modal.setAnimation(animation_group_fade_in);
rating_header.startAnimation(animation_group_fade_in);
rating_bar_label.startAnimation(animation_group_fade_in);
rating_bar.startAnimation(animation_group_fade_in);
done.startAnimation(animation_group_fade_in);
} else if(animation_we_med_thank_you.hasEnded() && count == 11 && jinde) {
submit.setVisibility(View.VISIBLE);
footnote.setVisibility(View.VISIBLE);
count++;
}
}*/
private class GestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onSingleTapConfirmed(MotionEvent event) {
if (start) {
if (count >= 100) {
count = 1;
wth = true;
//green_bg.startAnimation(animation_green_bg);
x_mark.setEnabled(false);
}
//Toast.makeText(getApplicationContext(), ""+count, Toast.LENGTH_SHORT).show();
switch (count) {
case 0:
x_mark.setVisibility(View.VISIBLE);
start = false;
//_playSounds(4);
cross_one.setVisibility(View.VISIBLE);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
cross_two.setVisibility(View.VISIBLE);
count++;
start = true;
}
}, 500);
break;
case 1:
x_mark.setVisibility(View.VISIBLE);
page_two.startAnimation(animation_page_two);
applauseIncreasing = true;
//_playSounds(5);
volume = 0.1f;
new Thread(new Runnable() {
@Override
public void run() {
while (!Thread.interrupted() && (volume <= 1.0f) && applauseIncreasing) {
try {
Thread.sleep(1000);
runOnUiThread(new Runnable() {
@Override
public void run() {
volume = volume / volumeChange;
sound_applause.setVolume(volume, volume);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
break;
case 2:
x_mark.setVisibility(View.VISIBLE);
dofilin.startAnimation(animation_dofilin);
break;
case 3:
x_mark.setVisibility(View.VISIBLE);
exflem.startAnimation(animation_exflem);
break;
case 4:
x_mark.setVisibility(View.VISIBLE);
appebon.startAnimation(animation_appebon);
break;
case 5:
wtf = true;
green_bg.startAnimation(animation_green_bg);
// oNLastPage();
x_mark.setEnabled(false);
break;
default:
break;
}
}
return false;
}
}
}