List of usage examples for android.view MotionEvent getAction
public final int getAction()
From source file:cn.emagsoftware.ui.BugFixedSlidingPaneLayout.java
@Override public boolean onTouchEvent(MotionEvent ev) { try {/*from w w w .j a v a2s . c om*/ if (!mCanSlide) { return super.onTouchEvent(ev); } mDragHelper.processTouchEvent(ev); final int action = ev.getAction(); boolean wantTouchEvents = true; switch (action & MotionEventCompat.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x; mInitialMotionY = y; break; } case MotionEvent.ACTION_UP: { if (isDimmed(mSlideableView)) { final float x = ev.getX(); final float y = ev.getY(); final float dx = x - mInitialMotionX; final float dy = y - mInitialMotionY; final int slop = mDragHelper.getTouchSlop(); if (dx * dx + dy * dy < slop * slop && mDragHelper.isViewUnder(mSlideableView, (int) x, (int) y)) { // Taps close a dimmed open pane. closePane(mSlideableView, 0); break; } } break; } } return wantTouchEvents; } catch (ArrayIndexOutOfBoundsException e) { LogManager.logE(BugFixedSlidingPaneLayout.class, "internal bug in SlidingPaneLayout,this bug can be ignored in most cases.", e); return false; } catch (IllegalArgumentException e) { LogManager.logE(BugFixedSlidingPaneLayout.class, "internal bug in SlidingPaneLayout,this bug can be ignored in most cases.", e); return false; } }
From source file:com.example.SmartBoard.DrawingView.java
public void onTouchCircleMode(MotionEvent event) { int eventaction = event.getAction(); int X = (int) event.getX(); int Y = (int) event.getY(); switch (eventaction) { case MotionEvent.ACTION_DOWN: // touch down so check if the finger is on // a ball finished = false;//from w w w . jav a2 s. co m if (points[0] == null) { //initialize rectangle. points[0] = new Point(); points[0].x = X; points[0].y = Y; points[1] = new Point(); points[1].x = X; points[1].y = Y + 30; points[2] = new Point(); points[2].x = X + 30; points[2].y = Y + 30; points[3] = new Point(); points[3].x = X + 30; points[3].y = Y; balID = 2; groupId = 1; // declare each ball with the ColorBall class for (Point pt : points) { colorballs.add(new ColorBall(getContext(), R.drawable.dot_drag_handle, pt)); } } invalidate(); break; case MotionEvent.ACTION_MOVE: // touch drag with the ball if (balID > -1) { // move the balls the same as the finger colorballs.get(balID).setX(X); colorballs.get(balID).setY(Y); if (groupId == 1) { colorballs.get(1).setX(colorballs.get(0).getX()); colorballs.get(1).setY(colorballs.get(2).getY()); colorballs.get(3).setX(colorballs.get(2).getX()); colorballs.get(3).setY(colorballs.get(0).getY()); } else { colorballs.get(0).setX(colorballs.get(1).getX()); colorballs.get(0).setY(colorballs.get(3).getY()); colorballs.get(2).setX(colorballs.get(3).getX()); colorballs.get(2).setY(colorballs.get(1).getY()); } invalidate(); } break; case MotionEvent.ACTION_UP: // touch drop - just do things here after dropping finished = true; break; } // redraw the canvas invalidate(); return; }
From source file:com.bofsoft.sdk.widget.menu.slidingmenu.CustomViewAbove.java
@Override public boolean onTouchEvent(MotionEvent ev) { if (!mEnabled) return false; if (!mIsBeingDragged && !thisTouchAllowed(ev)) return false; // if (!mIsBeingDragged && !mQuickReturn) // return false; final int action = ev.getAction(); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); }//www.j av a 2 s. c om mVelocityTracker.addMovement(ev); switch (action & MotionEventCompat.ACTION_MASK) { case MotionEvent.ACTION_DOWN: /* * If being flinged and user touches, stop the fling. isFinished will be false if being * flinged. */ completeScroll(); // Remember where the motion event started int index = MotionEventCompat.getActionIndex(ev); mActivePointerId = MotionEventCompat.getPointerId(ev, index); mLastMotionX = mInitialMotionX = ev.getX(); break; case MotionEvent.ACTION_MOVE: if (!mIsBeingDragged) { determineDrag(ev); if (mIsUnableToDrag) return false; } if (mIsBeingDragged) { // Scroll to follow the motion event final int activePointerIndex = getPointerIndex(ev, mActivePointerId); if (mActivePointerId == INVALID_POINTER) break; final float x = MotionEventCompat.getX(ev, activePointerIndex); final float deltaX = mLastMotionX - x; mLastMotionX = x; float oldScrollX = getScrollX(); float scrollX = oldScrollX + deltaX; final float leftBound = getLeftBound(); final float rightBound = getRightBound(); if (scrollX < leftBound) { scrollX = leftBound; } else if (scrollX > rightBound) { scrollX = rightBound; } // Don't lose the rounded component mLastMotionX += scrollX - (int) scrollX; scrollTo((int) scrollX, getScrollY()); pageScrolled((int) scrollX); } break; case MotionEvent.ACTION_UP: if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(velocityTracker, mActivePointerId); final int scrollX = getScrollX(); // final int widthWithMargin = getWidth(); // final float pageOffset = (float) (scrollX % widthWithMargin) / widthWithMargin; // TODO test this. should get better flinging behavior final float pageOffset = (float) (scrollX - getDestScrollX(mCurItem)) / getBehindWidth(); final int activePointerIndex = getPointerIndex(ev, mActivePointerId); if (mActivePointerId != INVALID_POINTER) { final float x = MotionEventCompat.getX(ev, activePointerIndex); final int totalDelta = (int) (x - mInitialMotionX); int nextPage = determineTargetPage(pageOffset, initialVelocity, totalDelta); setCurrentItemInternal(nextPage, true, true, initialVelocity); } else { setCurrentItemInternal(mCurItem, true, true, initialVelocity); } mActivePointerId = INVALID_POINTER; endDrag(); } else if (mQuickReturn && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) { // close the menu setCurrentItem(1); endDrag(); } break; case MotionEvent.ACTION_CANCEL: if (mIsBeingDragged) { setCurrentItemInternal(mCurItem, true, true); mActivePointerId = INVALID_POINTER; endDrag(); } break; case MotionEventCompat.ACTION_POINTER_DOWN: { final int indexx = MotionEventCompat.getActionIndex(ev); mLastMotionX = MotionEventCompat.getX(ev, indexx); mActivePointerId = MotionEventCompat.getPointerId(ev, indexx); break; } case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); int pointerIndex = getPointerIndex(ev, mActivePointerId); if (mActivePointerId == INVALID_POINTER) break; mLastMotionX = MotionEventCompat.getX(ev, pointerIndex); break; } return true; }
From source file:androidx.media.widget.VideoView2.java
@Override public boolean onTrackballEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_UP && mMediaControlView != null) { if (!mIsMusicMediaType || mSizeType != SIZE_TYPE_FULL) { toggleMediaControlViewVisibility(); }//from w w w. j a v a 2s . c o m } return super.onTrackballEvent(ev); }
From source file:sjizl.com.ChatActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (CommonUtilities.isInternetAvailable(getApplicationContext())) //returns true if internet available {// w w w .ja va 2 s .co m SharedPreferences sp = getApplicationContext().getSharedPreferences("loginSaved", Context.MODE_PRIVATE); pid = sp.getString("pid", null); naam = sp.getString("naam", null); username = sp.getString("username", null); password = sp.getString("password", null); foto = sp.getString("foto", null); foto_num = sp.getString("foto_num", null); Bundle bundle = getIntent().getExtras(); pid_user = bundle.getString("pid_user"); user = bundle.getString("user"); user_foto_num = bundle.getString("user_foto_num"); user_foto = bundle.getString("user_foto"); // Toast.makeText(getApplicationContext(), "pid_user"+pid_user, Toast.LENGTH_SHORT).show(); if (user.equalsIgnoreCase(naam.toString())) { Toast.makeText(getApplicationContext(), "You can't message yourself!", Toast.LENGTH_SHORT).show(); finish(); } AbsListViewBaseActivity.imageLoader.init(ImageLoaderConfiguration.createDefault(getBaseContext())); //registerReceiver(mHandleMessageReceiver2, new IntentFilter(DISPLAY_MESSAGE_ACTION)); setContentView(R.layout.activity_chat); imageLoader.loadImage("https://www.sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { d1 = new BitmapDrawable(getResources(), loadedImage); } }); imageLoader.loadImage("https://www.sjizl.com/fotos/" + foto_num + "/thumbs/" + foto + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { d2 = new BitmapDrawable(getResources(), loadedImage); } }); smilbtn = (ImageView) findViewById(R.id.smilbtn); listView = (ListView) findViewById(android.R.id.list); underlayout = (LinearLayout) findViewById(R.id.underlayout); smiles_layout = (LinearLayout) findViewById(R.id.smiles); textView1_bgtext = (TextView) findViewById(R.id.textView1_bgtext); textView1_bgtext.setText(user); imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard); imageView1_logo = (ImageView) findViewById(R.id.imageView1_logo); imageView_bericht = (ImageView) findViewById(R.id.imageView_bericht); textView2_under_title = (TextView) findViewById(R.id.textView2_under_title); right_lin = (LinearLayout) findViewById(R.id.right_lin); left_lin1 = (LinearLayout) findViewById(R.id.left_lin1); left_lin3 = (LinearLayout) findViewById(R.id.left_lin3); left_lin4 = (LinearLayout) findViewById(R.id.left_lin4); middle_lin = (LinearLayout) findViewById(R.id.middle_lin); smile_lin = (LinearLayout) findViewById(R.id.smile_lin); ber_lin = (LinearLayout) findViewById(R.id.ber_lin); progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole); progressBar_hole.setVisibility(View.INVISIBLE); imageLoader.displayImage("http://sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto, imageView2_dashboard, options); new UpdateChat().execute(); mNewMessage = (EditText) findViewById(R.id.newmsg); ber_lin = (LinearLayout) findViewById(R.id.ber_lin); photosend = (ImageView) findViewById(R.id.photosend); /* if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { imageLoader.loadImage("http://sjizl.com/fotos/"+user_foto_num+"/thumbs/"+user_foto, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); Bitmap LoadedImage2 = loadedImage; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { if(loadedImage!=null){ LoadedImage2 = CommonUtilities.fastblur16(loadedImage, 4,getApplicationContext()); } } if (Build.VERSION.SDK_INT >= 16) { listView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), LoadedImage2)); } else { listView.setBackgroundDrawable(new BitmapDrawable(LoadedImage2)); } } } ); } */ final ImageView left_button; left_button = (ImageView) findViewById(R.id.imageView1_back); CommonUtilities u = new CommonUtilities(); u.setHeaderConrols(getApplicationContext(), this, right_lin, left_lin3, left_lin4, left_lin1, left_button); listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { mScrollState = scrollState; } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); listView.setLongClickable(true); registerForContextMenu(listView); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); viewPager_smiles = new ViewPager(this); viewPager_smiles.setId(0x1000); LayoutParams layoutParams555 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams555.width = LayoutParams.MATCH_PARENT; layoutParams555.height = (metrics.heightPixels / 2); viewPager_smiles.setLayoutParams(layoutParams555); TabsPagerAdapter mAdapter = new TabsPagerAdapter(getSupportFragmentManager(), mNewMessage); viewPager_smiles.setAdapter(mAdapter); LayoutInflater inflater = null; viewPager_smiles.setVisibility(View.VISIBLE); smiles_layout.addView(viewPager_smiles); smiles_layout.setVisibility(View.GONE); left_lin4.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class); profile.putExtra("user", user); profile.putExtra("user_foto", user_foto); profile.putExtra("user_foto_num", user_foto_num); profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(profile); } return false; } }); middle_lin.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class); profile.putExtra("user", user); profile.putExtra("user_foto", user_foto); profile.putExtra("user_foto_num", user_foto_num); profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(profile); } return false; } }); smile_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { opensmiles(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent dashboard = new Intent(getApplicationContext(), ProfileActivityMain.class); dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dashboard.putExtra("user", ArrChatLines.get(position).getNaam()); dashboard.putExtra("user_foto", foto); dashboard.putExtra("user_foto_num", foto_num); startActivity(dashboard); } }); mNewMessage.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { v.setFocusable(true); v.setFocusableInTouchMode(true); smiles_layout.setVisibility(View.GONE); smilbtn.setImageResource(R.drawable.emoji_btn_normal); return false; } return false; } }); TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //after text changed } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (ArrChatLines.get(0).getblocked_profile().equals("1")) { } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) { } else { CommonUtilities.startandsendwebsock( "" + pid_user + " " + naam + " " + pid + " is typing to you ..."); } } @Override public void afterTextChanged(Editable s) { /* AsyncHttpClient.getDefaultInstance().websocket("ws://sjizl.com:9300", "my-protocol", new WebSocketConnectCallback() { @Override public void onCompleted(Exception ex, WebSocket webSocket) { if (ex != null) { ex.printStackTrace(); return; } webSocket.send(""+pid_user+" "+naam+" "+pid+" is typing to you ..."); webSocket.close(); } }); */ } }; photosend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ArrChatLines.get(0).getblocked_profile().equals("1")) { } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) { } else { openGallery(SELECT_FILE1); } } }); mNewMessage.addTextChangedListener(textWatcher); ber_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SpannableStringBuilder spanStr = (SpannableStringBuilder) mNewMessage.getText(); Spanned cs = (Spanned) mNewMessage.getText(); String a = Html.toHtml(spanStr); String text = mNewMessage.getText().toString(); mNewMessage.setText(""); mNewMessage.requestFocus(); mybmp2 = "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto; if (text.length() < 1) { } else { addItem(foto, foto_num, "0", naam, text.toString(), "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, "", a); } } }); hideSoftKeyboard(); } else { Intent dashboard = new Intent(getApplicationContext(), NoInternetActivity.class); dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dashboard); finish(); } mNewMessage.clearFocus(); listView.requestFocus(); final String wsuri = "ws://sjizl.com:9300"; WebSocketConnection mConnection8 = new WebSocketConnection(); if (mConnection8.isConnected()) { mConnection8.reconnect(); } else { try { mConnection8.connect(wsuri, new WebSocketConnectionHandler() { @Override public void onOpen() { Log.d("TAG", "Status: Connected to " + wsuri); } @Override public void onTextMessage(String payload) { if (payload.contains("message send")) { String[] parts = payload.split(" "); String zender = parts[0]; String send_from = parts[1]; String send_name = parts[2]; String send_foto = parts[3]; String send_foto_num = parts[4]; String send_xxx = parts[5]; // Toast.makeText(getApplication(), "" + "\n zender: "+zender+"" + "\n pid_user: "+pid_user+"" +"\n pid: "+pid+"" + // "\n send_from: "+send_from, // Toast.LENGTH_LONG).show(); if (zender.equalsIgnoreCase(pid) || zender.equalsIgnoreCase(pid_user)) { if (send_from.equalsIgnoreCase(pid_user) || send_from.equalsIgnoreCase(pid)) { //Toast.makeText(getApplication(), "uu", Toast.LENGTH_LONG).show(); new UpdateChat().execute(); } } } else if (payload.contains("is typing to you")) { String[] parts = payload.split(" "); String part1 = parts[0]; // 004 is_typing_name = parts[1]; // 034556 if (is_typing_name.equalsIgnoreCase(user)) { if (ArrChatLines.size() > 0) { oldvalue = ArrChatLines.get(0).getLaatstOnline(); } else { oldvalue = textView2_under_title.getText().toString(); } Timer t = new Timer(false); t.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { textView2_under_title.setText("typing ..."); } }); } }, 2); Timer t2 = new Timer(false); t2.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { textView2_under_title.setText(oldvalue); } }); } }, 2000); } } Log.d("TAG", "Got echo: " + payload); } @Override public void onClose(int code, String reason) { Log.d("TAG", "Connection lost."); } }); } catch (WebSocketException e) { Log.d("TAG", e.toString()); } } }
From source file:com.example.SmartBoard.DrawingView.java
public void onTouchRectangleMode(MotionEvent event) { int eventaction = event.getAction(); int X = (int) event.getX(); int Y = (int) event.getY(); switch (eventaction) { case MotionEvent.ACTION_DOWN: // touch down so check if the finger is on // a ball finished = false;/*from w w w . j ava 2s . c o m*/ if (points[0] == null) { //initialize rectangle. points[0] = new Point(); points[0].x = X; points[0].y = Y; points[1] = new Point(); points[1].x = X; points[1].y = Y + 30; points[2] = new Point(); points[2].x = X + 30; points[2].y = Y + 30; points[3] = new Point(); points[3].x = X + 30; points[3].y = Y; balID = 2; groupId = 1; // declare each ball with the ColorBall class for (Point pt : points) { colorballs.add(new ColorBall(getContext(), R.drawable.dot_drag_handle, pt)); } } else { //resize rectangle balID = -1; groupId = -1; for (int i = colorballs.size() - 1; i >= 0; i--) { ColorBall ball = colorballs.get(i); // check if inside the bounds of the ball (circle) // get the center for the ball int centerX = ball.getX() + ball.getWidthOfBall(); int centerY = ball.getY() + ball.getHeightOfBall(); // calculate the radius from the touch to the center of the // ball double radCircle = Math .sqrt((double) (((centerX - X) * (centerX - X)) + (centerY - Y) * (centerY - Y))); if (radCircle < ball.getWidthOfBall()) { balID = ball.getID(); if (balID == 1 || balID == 3) { groupId = 2; } else { groupId = 1; } invalidate(); break; } invalidate(); } } break; case MotionEvent.ACTION_MOVE: // touch drag with the ball if (balID > -1) { // move the balls the same as the finger colorballs.get(balID).setX(X); colorballs.get(balID).setY(Y); if (groupId == 1) { colorballs.get(1).setX(colorballs.get(0).getX()); colorballs.get(1).setY(colorballs.get(2).getY()); colorballs.get(3).setX(colorballs.get(2).getX()); colorballs.get(3).setY(colorballs.get(0).getY()); } else { colorballs.get(0).setX(colorballs.get(1).getX()); colorballs.get(0).setY(colorballs.get(3).getY()); colorballs.get(2).setX(colorballs.get(3).getX()); colorballs.get(2).setY(colorballs.get(1).getY()); } invalidate(); } break; case MotionEvent.ACTION_UP: // touch drop - just do things here after dropping finished = true; break; } // redraw the canvas invalidate(); return; }
From source file:com.example.SmartBoard.DrawingView.java
/***********************************************************************************/ //handles color dropper mode touch events public void onTouchColorDropperMode(MotionEvent event) { int X = (int) event.getX(); int Y = (int) event.getY(); dropperX = X;//from w w w. j ava 2 s .c o m dropperY = Y; if (event.getAction() == MotionEvent.ACTION_DOWN) { JSONObject touchedObject = getTouchedObject(X, Y); if (touchedObject != null) { try { touchedObject.put("color", dropperColor); //for text if (touchedObject.optString("type").compareTo("Text") == 0) { Bitmap bm = textToBitmap(touchedObject.optString("text"), dropperColor, touchedObject.optInt("x"), touchedObject.optInt("y"), touchedObject.optInt("size")); touchedObject.put("textBitmap", mqtt.bitmapToString(bm)); } mqtt.publishObject(touchedObject); } catch (JSONException e) { } invalidate(); } } }
From source file:com.VVTeam.ManHood.Fragment.HistogramFragment.java
private void initViews(View view) { parentLayout = (RelativeLayout) view.findViewById(R.id.fragment_histogram_parent_relative_layout); /*BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2;/*from ww w . j ava 2 s. co m*/ parentLayout.setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.histogram_bg, options)));*/ settingsRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_settings_relative_layout); markRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_mark_relative_layout); worldRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_world_relative); // worldRelative.setSelected(true); worldRelative.setBackgroundResource(R.drawable.cell_p); areaRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_area_relative); hoodRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_hood_relative); yourResultButton = (Button) view.findViewById(R.id.fragment_histogram_your_result_button); contentRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_content_relative); RelativeLayout shareRelative = (RelativeLayout) view .findViewById(R.id.fragment_histogram_share_button_relative); shareRelative.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub GoogleTracker.StarSendEvent(getActivity(), "ui_action", "user_action", "histogram_share"); Bitmap image = makeSnapshot(); File pictureFile = getOutputMediaFile(); try { FileOutputStream fos = new FileOutputStream(pictureFile); image.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close(); } catch (Exception e) { } // String pathofBmp = Images.Media.insertImage(getActivity().getContentResolver(), makeSnapshot(), "Man Hood App", null); // Uri bmpUri = Uri.parse(pathofBmp); Uri bmpUri = Uri.fromFile(pictureFile); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); emailIntent.setType("image/png"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Man Hood App"); getActivity().startActivity(emailIntent); } }); polarPlot = (PolarPlot) view.findViewById(R.id.polarPlot); thicknessHisto = (Histogram) view.findViewById(R.id.thicknessHisto); thicknessHisto.setOrientation(ORIENT.LEFT); thicknessHisto.setBackgroundColor(Color.TRANSPARENT); lengthHisto = (Histogram) view.findViewById(R.id.lengthHistogram); lengthHisto.setOrientation(ORIENT.RIGHT); lengthHisto.setBackgroundColor(Color.TRANSPARENT); girthHisto = (Histogram) view.findViewById(R.id.girthHistogram); girthHisto.setOrientation(ORIENT.BOTTOM); girthHisto.setBackgroundColor(Color.TRANSPARENT); lengthHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestLength(value)); setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID)); setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID)); // setSelection(false, lengthHisto, 0.0f); setSelection(true, lengthHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); girthHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestGirth(value)); setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID)); setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID)); // setSelection(false, girthHisto, 0.0f); setSelection(true, girthHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); thicknessHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestThickness(value)); setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID)); setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID)); // setSelection(false, thicknessHisto, 0.0f); setSelection(true, thicknessHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); textBoxTitleLabel = (TextView) view.findViewById(R.id.txtBoxTitle); textBoxTitleLabel.setText("AVERAGE"); layoutSubTitle = (LinearLayout) view.findViewById(R.id.layoutSubTitle); layoutSubTitle.setVisibility(View.INVISIBLE); textBoxSubtitleLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleLabel); textBoxSubtitleValueLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleValue); lengthSelectedLabel = (TextView) view.findViewById(R.id.txtlengthselected); lengthSelectedLabel.setText("50%"); lengthTOPLabel = (TextView) view.findViewById(R.id.lengthTOPLabel); girthSelectedLabel = (TextView) view.findViewById(R.id.txtgirthselected); girthSelectedLabel.setText("50%"); girthTOPLabel = (TextView) view.findViewById(R.id.girthTOPLabel); thicknessSelectedLabel = (TextView) view.findViewById(R.id.txtthicknessselected); thicknessSelectedLabel.setText("50%"); thinkestAtTOPLabel = (TextView) view.findViewById(R.id.thinkestAtTOPLabel); curvedSelectedLabel = (TextView) view.findViewById(R.id.txtcurvedselected); curvedSelectedLabel.setText("0"); girthTopLB = (TextView) view.findViewById(R.id.girthTop); girthMiddleLB = (TextView) view.findViewById(R.id.girthMiddle); girthBottomLB = (TextView) view.findViewById(R.id.girthBottom); thicknessTopLB = (TextView) view.findViewById(R.id.thicknessTop); thicknessMiddleLB = (TextView) view.findViewById(R.id.thicknessMiddle); thicknessBottomLB = (TextView) view.findViewById(R.id.thicknessBottom); lengthTopLB = (TextView) view.findViewById(R.id.lengthTop); lengthMiddleLB = (TextView) view.findViewById(R.id.lengthMiddle); lengthBottomLB = (TextView) view.findViewById(R.id.lengthBottom); settingsRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).openSettingsActivity(); } }); markRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).openCertificateActivity(); } }); worldRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRangeAll); updateRangeSwitch(); } }); areaRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRange200); updateRangeSwitch(); } }); hoodRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRange20); updateRangeSwitch(); } }); yourResultButton.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { youTouchDown(); } else if (event.getAction() == MotionEvent.ACTION_UP) { youTouchUp(); // final Handler handler = new Handler(); // handler.postDelayed(new Runnable() { // @Override // public void run() { // youTouchUp(); // } // }, 2000); } return true; } }); RequestManager.getInstance().checkUser(); /* in-app billing */ String base64EncodedPublicKey = LICENSE_KEY; // Create the helper, passing it our context and the public key to verify signatures with Log.d(TAG, "Creating IAB helper."); mHelper = new IabHelper(getActivity(), base64EncodedPublicKey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(true); // Start setup. This is asynchronous and the specified listener // will be called once setup completes. Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. Log.d(TAG, "Problem setting up in-app billing: " + result); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; // IAB is fully set up. Now, let's get an inventory of stuff we own. Log.d(TAG, "Setup successful. Querying inventory."); mHelper.queryInventoryAsync(mGotInventoryListener); } }); }
From source file:androidVNC.VncCanvasActivity.java
@Override public boolean onTrackballEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: trackballButtonDown = true;/*w ww . j av a2 s. c om*/ break; case MotionEvent.ACTION_UP: trackballButtonDown = false; break; } return inputHandler.onTrackballEvent(event); }
From source file:androidVNC.VncCanvasActivity.java
boolean touchPan(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: panTouchX = event.getX();//from ww w. j a va 2 s . co m panTouchY = event.getY(); break; case MotionEvent.ACTION_MOVE: pan(event); panTouchX = event.getX(); panTouchY = event.getY(); break; case MotionEvent.ACTION_UP: pan(event); break; } return true; }