Created
December 22, 2013 14:21
-
-
Save sukso96100/8083307 to your computer and use it in GitHub Desktop.
TouchTrigger Class(xtends StandOut)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by youngbin on 13. 12. 22. | |
*/ | |
package com.example.app; | |
import android.content.Intent; | |
import android.os.IBinder; | |
import android.util.Log; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.widget.FrameLayout; | |
import android.widget.ImageView; | |
import wei.mark.standout.StandOutWindow; | |
import wei.mark.standout.ui.Window; | |
import android.view.View.OnTouchListener; | |
public class TouchTrigger extends StandOutWindow { | |
private ImageView mTouchDetector; | |
@Override | |
public String getAppName() { | |
return null; | |
} | |
@Override | |
public int getAppIcon() { | |
return 0; | |
} | |
@Override | |
public IBinder onBind(Intent arg0) { | |
return null; | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
Log.d("TouchTrigger","onCreate"); | |
} | |
@Override | |
public void createAndAttachView(int id, FrameLayout frame) { | |
Log.d("TouchTrigger","createAttachView"); | |
mTouchDetector = new ImageView(this); | |
mTouchDetector.setImageResource(R.drawable.ic_launcher); | |
// mTouchDetector.setImageResource(R.drawable.trigger_left); | |
// mTouchDetector.setImageResource(R.drawable.trigger_bottom); | |
frame.addView(mTouchDetector); | |
mTouchDetector.setOnTouchListener(new OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { | |
switch (event.getAction()) { | |
case MotionEvent.ACTION_DOWN: | |
//Do Something | |
/* | |
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); | |
vibe.vibrate(10); | |
Intent intent = new Intent(TouchTrigger.this, DrawerActivity.class); | |
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
getApplication().startActivity(intent); | |
*/ | |
} | |
return true; | |
} | |
}); | |
} | |
@Override | |
public StandOutLayoutParams getParams(int id, Window window) { | |
//RIGHT | |
return new StandOutLayoutParams(id, StandOutLayoutParams.WRAP_CONTENT, | |
StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.RIGHT, | |
StandOutLayoutParams.CENTER); | |
/* | |
//LEFT | |
return new StandOutLayoutParams(id, StandOutLayoutParams.WRAP_CONTENT, | |
StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.LEFT, | |
StandOutLayoutParams.CENTER); | |
//BOTTOM | |
return new StandOutLayoutParams(id, StandOutLayoutParams.WRAP_CONTENT, | |
StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.BOTTOM, | |
StandOutLayoutParams.CENTER); | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment