Releases/January2014/src/src/org/nypl/SelectionWebView.java
/**
	 * Shows the context menu using the given region as an anchor point.
	 * @param region
	 */
Shows the context menu using the given region as an anchor point.
@param region
Shows the context menu using the given region as an anchor point . @param region
private void showContextMenu(Rect displayRect){
		if(this.contextMenuVisible){
			return;
		}
		if(displayRect.right <= displayRect.left){
			return;
		}
		ActionItem buttonThree = new ActionItem();
		buttonThree.setTitle("Add Note");
		buttonThree.setActionId(3);
		mContextMenu  = new QuickAction(this.getContext());
		mContextMenu.setOnDismissListener(this);
		mContextMenu.addActionItem(buttonThree);
		mContextMenu.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
			@Override
			public void onItemClick(QuickAction source, int pos,
					int actionId) {
				if (actionId == 1) { 
					Log.i(TAG, "Hit Button 1");
					((Activity)ctx).runOnUiThread(new Runnable() {
						@Override
						public void run() {
							SelectionWebView.this.getSettings().setJavaScriptEnabled(true);
							 ViewPagerAdapter.getAudio();
						}
					});
				} 
				/*else if (actionId == 2) { 
					// Do Button 2 stuff
					Log.i(TAG, "Hit Button 2");
				} */
				else if (actionId == 3) { 
					Log.i(TAG, "Hit Button 3");
					((Activity)ctx).runOnUiThread(new Runnable() {
						@Override
						public void run() {
							SelectionWebView.this.getSettings().setJavaScriptEnabled(true);
							saveNoteDetail();
						}
					});
				}
				contextMenuVisible = false;
			}
		});
		this.contextMenuVisible = true;
		mContextMenu.show(this, displayRect);
	}
private void showContextMenu ( Rect displayRect ) { if ( this . contextMenuVisible ) { return ; } if ( displayRect . right <= displayRect . left ) { return ; } ActionItem buttonThree = new ActionItem ( ) ; buttonThree . setTitle ( "Add Note" ) ; buttonThree . setActionId ( 3 ) ; mContextMenu = new QuickAction ( this . getContext ( ) ) ; mContextMenu . setOnDismissListener ( this ) ; mContextMenu . addActionItem ( buttonThree ) ; mContextMenu . setOnActionItemClickListener ( new QuickAction . OnActionItemClickListener ( ) { @ Override public void onItemClick ( QuickAction source , int pos , int actionId ) { if ( actionId == 1 ) { Log . i ( TAG , "Hit Button 1" ) ; ( ( Activity ) ctx ) . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { SelectionWebView . this . getSettings ( ) . setJavaScriptEnabled ( true ) ; ViewPagerAdapter . getAudio ( ) ; } } ) ; } /*else if (actionId == 2) { 
					// Do Button 2 stuff
					Log.i(TAG, "Hit Button 2");
				} */ else if ( actionId == 3 ) { Log . i ( TAG , "Hit Button 3" ) ; ( ( Activity ) ctx ) . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { SelectionWebView . this . getSettings ( ) . setJavaScriptEnabled ( true ) ; saveNoteDetail ( ) ; } } ) ; } contextMenuVisible = false ; } } ) ; this . contextMenuVisible = true ; mContextMenu . show ( this , displayRect ) ; }
Shows the context menu using the given region as an anchor point.
Shows the context menu using the given region as an anchor point .
// Don't show this twice // Don't use empty rect //if(displayRect.isEmpty()){ //	buttonThree.setIcon(getResources().getDrawable(R.drawable.menu_eraser)); // The action menu // Add buttons ///	mContextMenu.addActionItem(buttonOne); //mContextMenu.addActionItem(buttonTwo); //setup the action item click listener // TODO Auto-generated method stub // Do Button 1 stuff // TODO Auto-generated method stub //SelectionWebView.this.setWebViewClient(new MyWebview()); //	SelectionWebView.this.getSettings().setJavaScriptEnabled(true); //	SelectionWebView.this.loadUrl("javascript:highlightsTextAudio();"); ///SelectionWebView.this.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT"); //	SelectionWebView.this.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');"); // Do Button 3 stuff // TODO Auto-generated method stub //SelectionWebView.this.setWebViewClient(new MyWebview());