List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:com.app.uafeed.activity.EditFeedActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish();/*w ww .j a va 2 s . c o m*/ return true; case R.id.menu_add_filter: { final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null); new AlertDialog.Builder(this) // .setTitle(R.string.filter_add_title) // .setView(dialogView) // .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText() .toString(); if (filterText.length() != 0) { String feedId = getIntent().getData().getLastPathSegment(); ContentValues values = new ContentValues(); values.put(FilterColumns.FILTER_TEXT, filterText); values.put(FilterColumns.IS_REGEX, ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked()); values.put(FilterColumns.IS_APPLIED_TO_TITLE, ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked()); ContentResolver cr = getContentResolver(); cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }).show(); return true; } case R.id.menu_search_feed: { final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null); final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText); if (!mUrlEditText.getText().toString().startsWith(Constants.HTTP_SCHEME) && !mUrlEditText.getText().toString().startsWith(Constants.HTTPS_SCHEME)) { searchText.setText(mUrlEditText.getText()); } final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup); new AlertDialog.Builder(EditFeedActivity.this) // .setIcon(R.drawable.action_search) // .setTitle(R.string.feed_search) // .setView(dialogView) // .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (searchText.getText().length() > 0) { String tmp = searchText.getText().toString(); try { tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8); } catch (UnsupportedEncodingException ignored) { } final String text = tmp; switch (radioGroup.getCheckedRadioButtonId()) { case R.id.byWebSearch: final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this); pd.setMessage(getString(R.string.loading)); pd.setCancelable(true); pd.setIndeterminate(true); pd.show(); getLoaderManager().restartLoader(1, null, new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() { @Override public Loader<ArrayList<HashMap<String, String>>> onCreateLoader( int id, Bundle args) { return new GetFeedSearchResultsLoader(EditFeedActivity.this, text); } @Override public void onLoadFinished( Loader<ArrayList<HashMap<String, String>>> loader, final ArrayList<HashMap<String, String>> data) { pd.cancel(); if (data == null) { Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); } else if (data.isEmpty()) { Toast.makeText(EditFeedActivity.this, R.string.no_result, Toast.LENGTH_SHORT).show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder( EditFeedActivity.this); builder.setTitle(R.string.feed_search); // create the grid item mapping String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC }; int[] to = new int[] { android.R.id.text1, android.R.id.text2 }; // fill in the grid_item layout SimpleAdapter adapter = new SimpleAdapter( EditFeedActivity.this, data, R.layout.item_search_result, from, to); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mNameEditText.setText(data.get(which) .get(FEED_SEARCH_TITLE)); mUrlEditText.setText(data.get(which) .get(FEED_SEARCH_URL)); } }); builder.show(); } } @Override public void onLoaderReset( Loader<ArrayList<HashMap<String, String>>> loader) { } }); break; case R.id.byTopic: mUrlEditText.setText("http://www.faroo.com/api?q=" + text + "&start=1&length=10&l=en&src=news&f=rss"); break; case R.id.byYoutube: mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "") + "/videos.rss"); break; } } } }).setNegativeButton(android.R.string.cancel, null).show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:butter.droid.activities.MainActivity.java
private void openPlayerTestDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); final String[] file_types = getResources().getStringArray(R.array.file_types); final String[] files = getResources().getStringArray(R.array.files); builder.setTitle("Player Tests").setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override/*from ww w . j av a 2 s .c o m*/ public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).setSingleChoiceItems(file_types, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int index) { dialogInterface.dismiss(); final String location = files[index]; if (location.equals("dialog")) { final EditText dialogInput = new EditText(MainActivity.this); dialogInput.setText( "http://download.wavetlan.com/SVV/Media/HTTP/MP4/ConvertedFiles/QuickTime/QuickTime_test13_5m19s_AVC_VBR_324kbps_640x480_25fps_AAC-LCv4_CBR_93.4kbps_Stereo_44100Hz.mp4"); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this).setView(dialogInput) .setPositiveButton("Start", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Movie media = new Movie(new MoviesProvider(), new YSubsProvider()); media.videoId = "dialogtestvideo"; media.title = "User input test video"; String location = dialogInput.getText().toString(); BeamManager bm = BeamManager.getInstance(MainActivity.this); if (bm.isConnected()) { BeamPlayerActivity.startActivity(MainActivity.this, new StreamInfo(media, null, null, null, null, location), 0); } else { VideoPlayerActivity.startActivity(MainActivity.this, new StreamInfo(media, null, null, null, null, location), 0); } } }); builder.show(); } else if (YouTubeData.isYouTubeUrl(location)) { Intent i = new Intent(MainActivity.this, TrailerPlayerActivity.class); Movie media = new Movie(new MoviesProvider(), new YSubsProvider()); media.title = file_types[index]; i.putExtra(TrailerPlayerActivity.DATA, media); i.putExtra(TrailerPlayerActivity.LOCATION, location); startActivity(i); } else { final Movie media = new Movie(new MoviesProvider(), new YSubsProvider()); media.videoId = "bigbucksbunny"; media.title = file_types[index]; media.subtitles = new HashMap<>(); media.subtitles.put("en", "http://sv244.cf/bbb-subs.srt"); SubsProvider.download(MainActivity.this, media, "en", new Callback() { @Override public void onFailure(Request request, IOException e) { BeamManager bm = BeamManager.getInstance(MainActivity.this); if (bm.isConnected()) { BeamPlayerActivity.startActivity(MainActivity.this, new StreamInfo(media, null, null, null, null, location), 0); } else { VideoPlayerActivity.startActivity(MainActivity.this, new StreamInfo(media, null, null, null, null, location), 0); } } @Override public void onResponse(Response response) throws IOException { BeamManager bm = BeamManager.getInstance(MainActivity.this); if (bm.isConnected()) { BeamPlayerActivity.startActivity(MainActivity.this, new StreamInfo(media, null, null, "en", null, location), 0); } else { VideoPlayerActivity.startActivity(MainActivity.this, new StreamInfo(media, null, null, "en", null, location), 0); } } }); } } }); builder.show(); }
From source file:fi.mikuz.boarder.gui.internet.Uploads.java
private void boardUploader(final InternetFullBoard board, final int phpOperation) { LayoutInflater inflater = (LayoutInflater) Uploads.this.getSystemService(LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.internet_uploads_alert_upload_board, (ViewGroup) findViewById(R.id.alert_settings_root)); TextView wikiLink = (TextView) layout.findViewById(R.id.wikiLink); wikiLink.setText("\n Guide here!\n\n"); wikiLink.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Mikuz/Boarder/wiki/Uploading-guide")); startActivity(browserIntent); }/*from w w w.j a v a2 s. c o m*/ }); AlertDialog.Builder builder = new AlertDialog.Builder(Uploads.this); builder.setView(layout); builder.setTitle("Upload board"); refreshUploadAlertBoard(layout, board); final Button sendButton = (Button) layout.findViewById(R.id.sendButton); sendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mWaitDialog = new TimeoutProgressDialog(Uploads.this, "Waiting for response", TAG, false); HashMap<String, String> sendList = getSendList(layout, board, phpOperation); new ConnectionManager(Uploads.this, InternetMenu.mUploadBoardURL, sendList); } }); final Button previewButton = (Button) layout.findViewById(R.id.previewButton); previewButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { HashMap<String, String> sendList = getSendList(layout, board, phpOperation); // Simulate a board from web sendList.put(InternetMenu.BOARD_ID_KEY, "-1"); sendList.put(InternetMenu.RATING_KEY, "0"); sendList.put(InternetMenu.USERNAME_KEY, "Preview"); JSONObject databaseValues = new JSONObject(); if (sendList != null) { for (String key : sendList.keySet()) { try { databaseValues.put(key, sendList.get(key)); } catch (JSONException e) { Log.e(TAG, "Error putting '" + key + "' to JSONObject as database value"); } } } JSONArray jArray = new JSONArray(); jArray.put(databaseValues); JSONObject fakeMessage = null; try { fakeMessage = new JSONObject(); fakeMessage.put(ConnectionUtils.returnData, jArray); } catch (JSONException e) { Log.e(TAG, "Error constructing fake json message", e); } Intent i = new Intent(Uploads.this, DownloadBoard.class); XStream xstream = new XStream(); i.putExtra(DownloadBoard.SHOW_KEY, DownloadBoard.SHOW_PREVIEW_BOARD); i.putExtra(DownloadBoard.JSON_KEY, xstream.toXML(fakeMessage)); startActivity(i); } }); builder.show(); }
From source file:com.paramonod.kikos.MainActivity.java
public void makingFullStackIcon(int id, GeoPoint geoPoint) { OverlayItem oi = new OverlayItem(geoPoint, main.getResources().getDrawable(id)); final BalloonItem bi = new BalloonItem(main, oi.getGeoPoint()); if (id != R.drawable.orpgshop) { bi.setOnBalloonListener(new OnBalloonListener() { @Override/*from w w w.jav a2 s . c o m*/ public void onBalloonViewClick(BalloonItem balloonItem, View view) { } @Override public void onBalloonShow(BalloonItem balloonItem) { Intent intent = new Intent(main, DetailActivity.class); int m = 0; for (int i = 0; i < shopInterfaces.size(); i++) { GeoPoint g = new GeoPoint(shopInterfaces.get(i).getCoordX(), shopInterfaces.get(i).getCoordY()); if (g.equals(balloonItem.getGeoPoint())) { m = i; // Log.e("Search", "got here" + Integer.toString(m)); } } intent.putExtra(DetailActivity.EXTRA_POSITION, m); startActivity(intent); } @Override public void onBalloonHide(BalloonItem balloonItem) { } @Override public void onBalloonAnimationStart(BalloonItem balloonItem) { } @Override public void onBalloonAnimationEnd(BalloonItem balloonItem) { } }); } else { bi.setOnBalloonListener(new OnBalloonListener() { @Override public void onBalloonViewClick(BalloonItem balloonItem, View view) { } @Override public void onBalloonShow(BalloonItem balloonItem) { final AlertDialog.Builder b = new AlertDialog.Builder(main); b.setTitle(" ?"); b.setMessage( "? ? ? ? ? ? ?, "); b.setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AlertDialog.Builder builder = new AlertDialog.Builder(main); final EditText et = new EditText(main); builder.setMessage( " ?, ? ? ? ? ??: " + searchView.getQuery()); builder.setTitle(" "); builder.setView(et); builder.setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = et.getText().toString(); if (s.equals("")) s = searchView.getQuery().toString(); GeoPoint biGeo = bi.getGeoPoint(); Pair p = new Pair(); p.first = s; p.second = biGeo; places.add(p); SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); String connectionsJSONString1 = new Gson().toJson(p); editor.putString("places" + placesIDX, connectionsJSONString1); editor.commit(); placesIDX++; } }); builder.show(); } }); b.setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); b.show(); /* mc.getDownloader().getGeoCode(new GeoCodeListener() { @Override public boolean onFinishGeoCode(final GeoCode geoCode) { if (geoCode != null) { Log.e("Not so fucking", "title" + geoCode.getTitle() + "\nsubtitle" + geoCode.getSubtitle() + "\ndisplayname" + geoCode.getDisplayName() + "\nkind" + geoCode.getKind()); main.name = geoCode.getTitle(); } else { } AsyncTask asyncTask = new AsyncTask() { @Override protected Object doInBackground(Object[] params) { String namme = ""; try { URL url = new URL("https://search-maps.yandex.ru/v1/?text=" + params[0] + "&type=biz&lang=ru_RU&apikey=245e2b86-5cfb-40c3-a064-516c37dba6b2"); System.out.println(url); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.connect(); // optional default is GET con.setRequestMethod("GET"); //int responseCode = con.getResponseCode(); if smth crashes BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; String response = ""; while ((inputLine = in.readLine()) != null) { response += inputLine; } in.close(); con.disconnect(); MapActivity.jsonObject = new JSONObject(response); JSONArray ja1 = MapActivity.jsonObject.getJSONArray("features"); for (int i = 0; i < ja1.length(); i++) { JSONObject j0 = ja1.getJSONObject(i); JSONObject j11 = j0.getJSONObject("properties"); main.namme += " " + j11.getString("name"); } } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Object o) { super.onPostExecute(o); main.selectName(); } }.execute(main.name); return true; } }, balloonItem.getGeoPoint()); intent = new Intent(main, DetailYandexActivity.class); */ } @Override public void onBalloonHide(BalloonItem balloonItem) { } @Override public void onBalloonAnimationStart(BalloonItem balloonItem) { } @Override public void onBalloonAnimationEnd(BalloonItem balloonItem) { } }); } bi.setDrawable(getResources().getDrawable(R.drawable.itkerk)); oi.setBalloonItem(bi); o.addOverlayItem(oi); }
From source file:com.mocap.MocapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /*// w ww. j a va 2s. c o m connection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { try { mService = IInAppBillingService.Stub.asInterface(service); } catch (Exception e) { Log.i(TAG2, "InappBillingservice erreur: "+e); } } @Override public void onServiceDisconnected(ComponentName name) { mService = null; } }; this.getActivity().bindService(new Intent("android.vending.billing.InAppBillingService.BIND"), connection, getActivity().getBaseContext().BIND_AUTO_CREATE); Log.i(TAG2, "InappBillingservice OK: "); */ // processArguments(); fa = super.getActivity(); View layout = inflater.inflate(R.layout.layout_opengl, container, false);//com.mocap.MyGLSurfaceView final MyGLSurfaceView GLView = (MyGLSurfaceView) layout.findViewById(R.id.glsurfaceview); final ImageButton mInitButton = (ImageButton) layout.findViewById(R.id.init); final ImageButton mRefreshButton = (ImageButton) layout.findViewById(R.id.refresh); final ImageButton mStopButton = (ImageButton) layout.findViewById(R.id.stop); final ImageButton mStartButton = (ImageButton) layout.findViewById(R.id.start); final ImageButton mSaveButton = (ImageButton) layout.findViewById(R.id.save_file); final ImageButton mZommPlusButton = (ImageButton) layout.findViewById(R.id.zoomplus); final ImageButton mZommMoinsButton = (ImageButton) layout.findViewById(R.id.zoommoins); mRefreshButton.setEnabled(false); mRefreshButton.getDrawable().setAlpha(150); mStopButton.setEnabled(false); mStopButton.getDrawable().setAlpha(150); mStartButton.setEnabled(false); mStartButton.getDrawable().setAlpha(150); mSaveButton.setEnabled(false); mSaveButton.getDrawable().setAlpha(150); mZommPlusButton.setEnabled(false); mZommPlusButton.getDrawable().setAlpha(150); mZommMoinsButton.setEnabled(false); mZommMoinsButton.getDrawable().setAlpha(150); // Create the helper, passing it our context and the public key to verify signatures with Log.i(TAG2, "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.i(TAG2, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.i(TAG2, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. complain("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.i(TAG2, "Setup successful. Querying inventory."); mHelper.queryInventoryAsync(mGotInventoryListener); } }); mInitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); final View alertDialogView = inflater.inflate(R.layout.init_dialog, null); builder.setView(alertDialogView); builder.setMessage(R.string.Init_phrase); builder.setTitle(R.string.Init_titre); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { try { GLView.onInitGravity(); Toast.makeText(getActivity(), "Init Gravity: ", Toast.LENGTH_SHORT).show(); mStartButton.setEnabled(true); mStartButton.getDrawable().setAlpha(255); mZommMoinsButton.setEnabled(true); mZommMoinsButton.getDrawable().setAlpha(255); mZommPlusButton.setEnabled(true); mZommPlusButton.getDrawable().setAlpha(255); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getActivity(), "Erreur save login: " + e, Toast.LENGTH_SHORT).show(); } } }); builder.setNegativeButton(R.string.Annuler, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { try { } catch (Exception e) { e.printStackTrace(); Toast.makeText(getActivity(), "Erreur save login: " + e, Toast.LENGTH_SHORT).show(); } } }); builder.show(); //activation des sensors } }); mRefreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //activation des sensors GLView.onRefresh(); Toast.makeText(getActivity(), "Refresh: ", Toast.LENGTH_SHORT).show(); mStartButton.setEnabled(true); mStartButton.getDrawable().setAlpha(255); mStopButton.setEnabled(false); mStopButton.getDrawable().setAlpha(150); mSaveButton.setEnabled(false); mSaveButton.getDrawable().setAlpha(150); mZommMoinsButton.setEnabled(true); mZommMoinsButton.getDrawable().setAlpha(255); mZommPlusButton.setEnabled(true); mZommPlusButton.getDrawable().setAlpha(255); } }); mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //activation des sensors GLView.onSensorsStart(); mStartButton.setEnabled(false); mStartButton.getDrawable().setAlpha(150); mStopButton.setEnabled(true); mStopButton.getDrawable().setAlpha(255); mInitButton.setEnabled(false); mInitButton.getDrawable().setAlpha(150); Toast.makeText(getActivity(), "Start: ", Toast.LENGTH_SHORT).show(); } }); mStopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pause des sensor GLView.onSensorsPause(); mStartButton.setEnabled(true); mStartButton.getDrawable().setAlpha(255); mStopButton.setEnabled(false); mStopButton.getDrawable().setAlpha(150); mSaveButton.setEnabled(true); mSaveButton.getDrawable().setAlpha(255); mInitButton.setEnabled(true); mInitButton.getDrawable().setAlpha(255); mRefreshButton.setEnabled(true); mRefreshButton.getDrawable().setAlpha(250); Toast.makeText(getActivity(), "Stop: ", Toast.LENGTH_SHORT).show(); //enregistrer le fichier .obj //SaveOBJ(getActivity(),GLView); } }); mSaveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onUpgradeAppButtonClicked(v); //pause des sensor /* ArrayList skuList = new ArrayList(); skuList.add(inappid); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); Bundle skuDetails; try { Log.i(TAG, "Pas Erreur div: " + mService.toString()); skuDetails = mService.getSkuDetails(3, getActivity().getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if(response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(inappid)){ Log.i(TAG, "Price: "+price); Bundle buyIntentBundle = mService .getBuyIntent(3, getActivity().getPackageName() , sku, "inapp" , "test"); PendingIntent pendingIntent = buyIntentBundle .getParcelable("BUY_INTENT"); getActivity().startIntentSenderForResult( pendingIntent.getIntentSender(),1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } //} catch (RemoteException e) { // Log.i(TAG, "Erreur remote: "+e); // } //catch (JSONException e) { // Log.i(TAG, "Erreur json: " + e); } catch (Exception e) { Log.i(TAG, "Erreur div: "+ e); } */ } }); mZommPlusButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GLView.onChangeCam(1); } }); mZommMoinsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GLView.onChangeCam(-1); } }); if (mText != null) { mTextView.setText(mText); Log.i("SimpleTextFragment", mText); } return layout; }
From source file:com.Beat.RingdroidEditActivity.java
/** * Called from both onCreate and onConfigurationChanged * (if the user switched layouts)// w ww . ja v a 2s . co m */ private void loadGui() { // Inflate our UI from its XML layout description. setContentView(R.layout.editor); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mDensity = metrics.density; mMarkerLeftInset = (int) (46 * mDensity); mMarkerRightInset = (int) (48 * mDensity); mMarkerTopOffset = (int) (10 * mDensity); mMarkerBottomOffset = (int) (10 * mDensity); mStartText = (TextView) findViewById(R.id.starttext); mStartText.addTextChangedListener(mTextWatcher); mEndText = (TextView) findViewById(R.id.endtext); mEndText.addTextChangedListener(mTextWatcher); mPlayButton = (ImageButton) findViewById(R.id.play); mPlayButton.setOnClickListener(mPlayListener); mRewindButton = (ImageButton) findViewById(R.id.rew); mRewindButton.setOnClickListener(mRewindListener); mFfwdButton = (ImageButton) findViewById(R.id.ffwd); mFfwdButton.setOnClickListener(mFfwdListener); mZoomInButton = (ImageButton) findViewById(R.id.zoom_in); mZoomInButton.setOnClickListener(mZoomInListener); mZoomOutButton = (ImageButton) findViewById(R.id.zoom_out); mZoomOutButton.setOnClickListener(mZoomOutListener); mSaveButton = (ImageButton) findViewById(R.id.save); mSaveButton.setOnClickListener(mSaveListener); TextView markStartButton = (TextView) findViewById(R.id.mark_start); markStartButton.setOnClickListener(mMarkStartListener); TextView markEndButton = (TextView) findViewById(R.id.mark_end); markEndButton.setOnClickListener(mMarkStartListener); enableDisableButtons(); mWaveformView = (WaveformView) findViewById(R.id.waveform); mWaveformView.setListener(this); mInfo = (TextView) findViewById(R.id.info); mInfo.setText(mCaption); mMaxPos = 0; mLastDisplayedStartPos = -1; mLastDisplayedEndPos = -1; if (mSoundFile != null) { mWaveformView.setSoundFile(mSoundFile); mWaveformView.recomputeHeights(mDensity); mMaxPos = mWaveformView.maxPos(); } mStartMarker = (MarkerView) findViewById(R.id.startmarker); mStartMarker.setListener(this); mStartMarker.setAlpha(255); mStartMarker.setFocusable(true); mStartMarker.setFocusableInTouchMode(true); mStartVisible = true; mEndMarker = (MarkerView) findViewById(R.id.endmarker); mEndMarker.setListener(this); mEndMarker.setAlpha(255); mEndMarker.setFocusable(true); mEndMarker.setFocusableInTouchMode(true); mEndVisible = true; final AlertDialog.Builder nomp3 = new AlertDialog.Builder(this); nomp3.setCancelable(true); nomp3.setMessage("Filters Only work on wav files at this time"); nomp3.setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); Button echo = (Button) findViewById(R.id.echobutton); echo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.echo(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_echo" + mExtension, 200, .6, false); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_echo" + mExtension); } else nomp3.show(); } }); Button high = (Button) findViewById(R.id.highbutton); high.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.filter(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_high" + mExtension, true, 2000); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_high" + mExtension); } else nomp3.show(); } }); Button low = (Button) findViewById(R.id.Lowbutton); low.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.filter(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_low" + mExtension, false, 2000); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_low" + mExtension); } else nomp3.show(); } }); Button speedup = (Button) findViewById(R.id.up); speedup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.decreaseTimescaleIncreasePitch(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sup" + mExtension, 2); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sup" + mExtension); } else nomp3.show(); } }); Button speeddown = (Button) findViewById(R.id.down); speeddown.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.increaseTimescaleDecreasePitch(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sdown" + mExtension, 2); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sdown" + mExtension); } else nomp3.show(); } }); Button record = (Button) findViewById(R.id.record); record.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { Intent i = new Intent(); i.setClassName("com.Beat", "com.Beat.recordScreen"); startActivity(i); exit(); } }); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); updateDisplay(); }
From source file:com.speedtong.example.ui.chatting.ChattingActivity.java
public void upload(View view) { JSONArray all = messageDao.getAll(); if (all.length() == 0) { Toast.makeText(this, "?", Toast.LENGTH_SHORT).show(); return;/* w w w. ja v a 2s . c om*/ } // ?? final android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this); builder.setTitle("Upload"); builder.setMessage(""); builder.setCancelable(false); builder.setNegativeButton("", null); // final Button btn = (Button) view; btn.setText("uploading ..."); btn.setClickable(false); RequestParams params = new RequestParams(); params.put("act", "upload_hxs"); params.put("data", all.toString()); Log.e("jsondata", all.toString()); new AsyncHttpClient().post("http://cms.orenda.com.cn:29055/upload_data", params, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); String hasErrors = MockUtil.getString(response, "hasErrors"); if ("false".equals(hasErrors)) { builder.setMessage("?"); messageDao.deleteAll(); } else { String msg = MockUtil.getString(response, "message"); Log.e("upload.hasError=true", msg); builder.setMessage(msg); } btn.setText("UPLOAD"); btn.setClickable(true); builder.show(); } @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { super.onFailure(statusCode, headers, responseString, throwable); Log.e("onFailure1", String.valueOf(responseString) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e("onFailure2", String.valueOf(errorResponse) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); Log.e("onFailure3", String.valueOf(errorResponse) + "|" + throwable); builder.show(); btn.setText("UPLOAD"); btn.setClickable(true); } }); }
From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java
/** * Get image from photo library.// w w w. j a v a 2s.c o m * * @param quality * Compression quality hint (0-100: 0=low quality & high * compression, 100=compress of max quality) * @param srcType * The album to get image from. * @param returnType * Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from // CAMERA ALBUM do! public void getImage(int srcType, int returnType) { final int srcTypeFinal = srcType; final int returnTypeFinal = returnType; String[] choices = { "Upload a Photo", "Upload a Video" }; AlertDialog.Builder builder = new AlertDialog.Builder(this.cordova.getActivity()); builder.setItems(choices, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.d(LOG_TAG, "Index #" + which + " chosen."); Intent intent = new Intent(); if (which == 0) { // set up photo intent WsiCameraLauncher.this.mediaType = PICTURE; intent.setType("image/*"); } else if (which == 1) { // set up video intent WsiCameraLauncher.this.mediaType = VIDEO; intent.setType("video/*"); } else { WsiCameraLauncher.this.failPicture("Selection cancelled."); return; } intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (WsiCameraLauncher.this.cordova != null) { WsiCameraLauncher.this.cordova.startActivityForResult((CordovaPlugin) WsiCameraLauncher.this, Intent.createChooser(intent, new String("Pick")), (srcTypeFinal + 1) * 16 + returnTypeFinal + 1); } } }); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { dialog.cancel(); WsiCameraLauncher.this.failPicture("Selection cancelled."); return true; } return false; } }); builder.show(); }
From source file:uf.edu.encDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.encdetail_activity); context = this.getApplicationContext(); TextView tv = null;// w w w . jav a 2s. co m SeekBar sb = null; Button b = null; Bundle bundle = this.getIntent().getExtras(); Log.i("TAG", "encDetailActivity:onCreate, Max Trust =" + getString(R.string.TrustSliderMax)); MaxTrust = Integer.parseInt(getString(R.string.TrustSliderMax)) / 2; final AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: //Okay clicked. break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; //builder.setMessage("Are you sure?").setPositiveButton("Okay", dialogClickListener); final EncUser encUser = (EncUser) bundle.getSerializable("userdata"); final ArrayList<String> Address = (ArrayList<String>) bundle.getSerializable("useraddress"); if (encUser == null) { Log.i(TAG, "encDetailsActivity: parameter received was null"); } //Name tv = (TextView) findViewById(R.id.encdetail_name); tv.setText(encUser.Name); //Mac tv = (TextView) findViewById(R.id.encdetail_mac); tv.setText(encUser.Mac); tv.setOnClickListener(new View.OnClickListener() { //event listener to fetch more info abt a user. @Override public void onClick(View v) { iTrust.cd.write("Registration Lookup requested for " + encUser.Mac); Toast.makeText(encDetailActivity.this, "Please wait while we lookup the information", Toast.LENGTH_LONG).show(); String data = getData(encUser.Mac).replace('\n', ' ').trim(); String message = null; if (data.substring(0, 5).compareToIgnoreCase("Error") == 0) { message = "No more info available for this device"; } else { data = data.replace('\'', ' '); //remove single quotes data = data.replace(')', ' ').trim(); //remove closing brackets. StringTokenizer tok = new StringTokenizer(data.substring(1), ","); message = "Name: " + tok.nextToken() + " " + tok.nextToken() + "\n" + "Email: " + tok.nextToken() + "\n" + "Profile: " + tok.nextToken(); } //Toast.makeText(encDetailActivity.this, getData(encUser.Mac), Toast.LENGTH_LONG).show(); builder.setMessage(message); builder.show(); } }); //lasttime tv = (TextView) findViewById(R.id.encdetail_lasttime); tv.setText((new java.util.Date((long) encUser.lastEncounterTime * 1000)).toString()); tv.setOnClickListener(new View.OnClickListener() { //To generate graph @Override public void onClick(View v) { Intent intent = barchartIntent(encUser.timeSeries, encUser.Mac, encUser.Name); startActivity(intent); } }); //tv.setText(Integer.toString(encUser.lastEncounterTime)); //FE tv = (TextView) findViewById(R.id.encdetail_FE); tv.setText(Float.toString(encUser.score[0])); tv = (TextView) findViewById(R.id.encdetail_decayFE); tv.setText(Float.toString(encUser.decayScore[0] * ((float) Math.pow(.5, (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime) / (float) 15552000.0F)))); //DE tv = (TextView) findViewById(R.id.encdetail_DE); tv.setText(Float.toString(encUser.score[1])); tv = (TextView) findViewById(R.id.encdetail_decayDE); tv.setText(Float.toString(encUser.decayScore[1] * ((float) Math.pow(.5, (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime) / (float) 15552000.0F)))); //LV-C tv = (TextView) findViewById(R.id.encdetail_LVC); tv.setText(Float.toString(encUser.score[2])); //LV-D tv = (TextView) findViewById(R.id.encdetail_LVD); tv.setText(Float.toString(encUser.score[3])); //combined //FE tv = (TextView) findViewById(R.id.encdetail_comb); tv.setText(Float.toString(encUser.score[4])); //check the toggle button state sb = (SeekBar) findViewById(R.id.encdetail_trust); //since Seekbar cannot go into -ve values we scale -Max Value to Max Value sb.setProgress(encUser.trusted + MaxTrust); tv = (TextView) findViewById(R.id.CurrentTrustValue); tv.setText(TrustArray[encUser.trusted + MaxTrust]); sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { TextView tvcurrent = (TextView) findViewById(R.id.CurrentTrustValue); @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser == true) { Log.i(TAG, "encDetailsActivity: User changed value for Trust to " + progress); encUser.trusted = progress - MaxTrust; tvcurrent.setText(TrustArray[progress]); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }); b = (Button) findViewById(R.id.encdetail_done); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { iTrust.cd.write("Trust Value changed for this user :" + encUser.Mac + " to:" + encUser.trusted); Bundle bundle = new Bundle(); Intent returnIntent = new Intent(); bundle.putSerializable("Object", encUser); returnIntent.putExtras(bundle); //returnIntent.putExtra("TrustSet",trustResult); encDetailActivity.this.setResult(Activity.RESULT_OK, returnIntent); finish(); } }); //show map tv = (TextView) findViewById(R.id.encdetail_map); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { iTrust.cd.write("Map lookup for encounter user " + encUser.Mac); Bundle bundle = new Bundle(); Intent newIntent = new Intent(context, map.class); bundle.putSerializable("useraddress", Address); newIntent.putExtras(bundle); startActivity(newIntent); } }); }
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
private void showAddress(final String addressTouch) { Log.d(NAM4JAndroidActivity.TAG, "Tapped address: " + addressTouch); AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage("Do you want to see information about building located in " + addressTouch + " ?"); dialog.setCancelable(true);/*from w w w . j a v a2s . co m*/ dialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); Intent intent = new Intent(NAM4JAndroidActivity.this, BuildingLookupActivity.class); intent.putExtra("AddressBuilding", addressTouch); NAM4JAndroidActivity.this.startActivity(intent); } }); dialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); dialog.show(); }