List of usage examples for android.app ProgressDialog show
public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)
From source file:org.ubicompforall.cityexplorer.CityExplorer.java
public static void showProgressDialog(Context context, String... msg) { String status = "Loading"; if (!(msg == null || msg.length == 0 || msg[0].equals(""))) { status = msg[0];//from www .j a v a 2 s.c o m } pd = ProgressDialog.show(context, "", status + "...", true, false); timerDelayRemoveDialog(1000, pd); // new Thread() { // public void run() { // handler.sendEmptyMessage( CityExplorer.MSG_DOWNLOADED ); // } // }.start(); }
From source file:com.fvd.nimbus.BrowseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); //overridePendingTransition(R.anim.carbon_slide_in,R.anim.carbon_slide_out); //overridePendingTransition(R.anim.activity_open_scale,R.anim.activity_close_translate); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); try {/*from w w w . j a v a 2s . co m*/ requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception e) { e.printStackTrace(); } clipData = new DataExchange(); isInitNow = true; setContentView(R.layout.screen_browser); serverHelper.getInstance().setCallback(this, this); prefs = PreferenceManager.getDefaultSharedPreferences(this); lastUrl = prefs.getString("LAST_URL", ""); saveCSS = prefs.getString("clipStyle", "1").equals("1"); ctx = this; //adapter = new TextAdapter(this); /*Uri data = getIntent().getData(); if(data!=null){ lastUrl=data.toString(); }*/ Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_VIEW.equals(action) /*&& type != null*/) { Uri data = intent.getData(); if (data != null) { lastUrl = data.toString(); appSettings.appendLog("browse:onCreate " + lastUrl); } } else if (Intent.ACTION_SEND.equals(action) /*&& type != null*/) { if ("text/plain".equals(type)) { String surl = intent.getStringExtra(Intent.EXTRA_TEXT); if (surl.contains(" ")) { String[] arr = surl.replace("\t", " ").split(" "); for (String s : arr) { if (s.contains("://")) { lastUrl = s.trim(); break; } } } else if (surl.contains("://")) lastUrl = surl.trim(); appSettings.appendLog("browse:onCreate " + lastUrl); } } drawer = (DrawerLayout) findViewById(R.id.root); View v = findViewById(R.id.wv); wv = (fvdWebView) findViewById(R.id.wv); wv.setEventsHandler(this); //registerForContextMenu(wv); urlField = (AutoCompleteTextView) findViewById(R.id.etAddess); urlField.setSelectAllOnFocus(true); urlField.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { /*InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0);*/ onNavButtonClicked(); return true; } else if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { onNavButtonClicked(); return true; } return false; } }); onViewCreated(); handler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case 0: findViewById(R.id.bZoomStack).setVisibility(View.VISIBLE); findViewById(R.id.bToggleMenu).setVisibility(View.GONE); break; default: break; } } }; navButton = (ImageButton) findViewById(R.id.ibReloadWebPage); navButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Toast.makeText(getApplicationContext(), "You made a mess", Toast.LENGTH_LONG).show(); onNavButtonClicked(); } }); findViewById(R.id.bSavePageFragment).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //toggleTools(); floatMenu.collapse(); if (!wv.getInjected()) Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show(); clipMode = 2; if (wv.getInjected()/* && !v.isSelected()*/) { wv.setCanClip(true); v.setSelected(true); Toast.makeText(ctx, ctx.getString(R.string.use_longtap), Toast.LENGTH_LONG).show(); } } }); (findViewById(R.id.bSaveFullPage)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { floatMenu.collapse(); if (wv.getInjected()) { wv.setCanClip(false); wv.saveArticle(); clipMode = 1; progressDialog = ProgressDialog.show(v.getContext(), "Nimbus Clipper", getString(R.string.please_wait), true, false); } else { Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show(); } } }); findViewById(R.id.bTakeScreenshot).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //toggleTools(); floatMenu.collapse(); findViewById(R.id.bSaveFullPage).setVisibility(View.GONE); findViewById(R.id.bSavePageFragment).setVisibility(View.GONE); findViewById(R.id.bTakeScreenshot).setVisibility(View.GONE); if (wv.getInjected()) { wv.setCanClip(false); } findViewById(R.id.bToggleMenu).setVisibility(View.GONE); /*screenCapture(); findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE);*/ findViewById(R.id.bTakeScreenshot).postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub screenCapture(); findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE); finish(); } }, 10); //showDialog(DIALOG_CAPTURE); } }); (findViewById(R.id.bDone)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { { try { wv.setCanClip(false); wv.endSelectionMode(); //findViewById(R.id.bSavePageFragment).setSelected(false); clipMode = 2; wv.endSelectionMode(); String selHtml = clipData.getContent(); if (selHtml.length() > 0) { String ss = selHtml.substring(0, selHtml.indexOf(">") + 1).toLowerCase(); int j = ss.indexOf("<div"); if (j == 0) { j = ss.indexOf("style"); if (j > 0) { int k = ss.indexOf("\"", j + 11); if (k > 0) selHtml = selHtml.replace(selHtml.substring(j, k + 1), ""); } //selHtml="<DIV>"+selHtml.substring(ss.length()); } clipData.setContent(selHtml); clipData.setTitle(wv.getTitle()); /*if (true){ if(sessionId.length() == 0 || userPass.length()==0) showSettings(); else { if(prefs.getBoolean("check_fast", false)){ sendNote(wv.getTitle(), clipData.getContent(), parent, tag); clipData.setContent(""); } else { //serverHelper.getInstance().setCallback(this,this); if(appSettings.sessionId.length()>0) { serverHelper.getInstance().sendRequest("notes:getFolders", "",""); } } } wv.endSelectionMode(); } */ Intent i = new Intent(getApplicationContext(), previewActivity.class); i.putExtra("content", clipData); startActivityForResult(i, 5); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } //clipData.setContent(""); } catch (Exception e) { BugReporter.Send("onEndSelection", e.getMessage()); } } //showDialog(DIALOG_CAPTURE); } }); findViewById(R.id.bZoomIn).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { wv.ZoomInSelection(); } }); findViewById(R.id.bZoomOut).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { wv.ZoomOutSelection(); } }); setNavButtonState(NavButtonState.NBS_GO); progressBar = (ProgressBar) findViewById(R.id.progressbar); //CookieSyncManager.createInstance(this); //webSettings.setLoadsImagesAutomatically(imgOn); userMail = prefs.getString("userMail", ""); userPass = prefs.getString("userPass", ""); sessionId = prefs.getString("sessionId", ""); appSettings.sessionId = sessionId; appSettings.userMail = userMail; appSettings.userPass = userPass; if ("1".equals(prefs.getString("userAgent", "1"))) { wv.setUserAgent(null); } else wv.setUserAgent(deskAgent); final Activity activity = this; //lastUrl="file:///android_asset/android.html"; if (lastUrl.length() > 0) { //wv.navigate(lastUrl); //if(!urlField.getText().toString().equals(wv.getUrl())) urlField.setText(lastUrl); openURL(); } isInitNow = false; urlField.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // TODO Auto-generated method stub /*String item = (String)parent.getItemAtPosition(position); Toast.makeText( getApplicationContext(), " " + item, Toast.LENGTH_SHORT).show();*/ openURL(); } }); urlField.addTextChangedListener(this); parent = prefs.getString("remFolderId", "default"); /*ListView listView = (ListView) findViewById(R.id.left_drawer); listView.setAdapter(new DrawerMenuAdapter(this,getResources().getStringArray(R.array.lmenu_browser))); listView.setOnItemClickListener(this);*/ }
From source file:com.lge.friendsCamera.MainActivity.java
/** * Update the fingerprint to reflect the current camera state by comparing it with the * fingerprint held by the client.//from w w w .ja va 2 s . c o m * API : /osc/checkForUpdate */ private void getCameraCheckForUpdate() { final String title = getString(R.string.check_update); mProgressDialog = ProgressDialog.show(mContext, null, "Checking...", true, false); final OSCCheckForUpdates oscCheckForUpdates = new OSCCheckForUpdates(fingerPrint, 1); oscCheckForUpdates.setListener(new HttpAsyncTask.OnHttpListener() { @Override public void onResponse(OSCReturnType type, Object response) { if (type == OSCReturnType.SUCCESS) { JSONObject jObject = null; try { mProgressDialog.cancel(); jObject = new JSONObject(response.toString()); String responseFingerprint = jObject.getString(OSCParameterNameMapper.LOCAL_FINGERPRINT); if (fingerPrint.equals(responseFingerprint)) { Utils.showAlertDialog(mContext, title, "State is same\n\n" + Utils.parseString(response), null); } else { Utils.showAlertDialog(mContext, title, "State is updated, Please check state by /osc/state\n\n" + Utils.parseString(response), null); } } catch (JSONException e) { e.printStackTrace(); } } else { Utils.showTextDialog(mContext, title, Utils.parseString(response)); } } }); oscCheckForUpdates.execute(); }
From source file:at.alladin.rmbt.android.test.RMBTTestFragment.java
/** * /* www . ja va 2s . co m*/ * @param view * @param inflater * @return */ private View createView(final View view, final LayoutInflater inflater, final Bundle savedInstanceState) { testView = (TestView) view.findViewById(R.id.test_view); graphView = (GraphView) view.findViewById(R.id.test_graph); infoView = (ViewGroup) view.findViewById(R.id.test_view_info_container); textView = (TextView) view.findViewById(R.id.test_text); qosProgressView = (ViewGroup) view.findViewById(R.id.test_view_qos_container); groupCountContainerView = (ViewGroup) view.findViewById(R.id.test_view_group_count_container); if (savedInstanceState != null) { if (testView != null) { testView.setHeaderString(savedInstanceState.getString("header_string")); testView.setSubHeaderString( savedInstanceState.getString("sub_header_string", testView.getSubHeaderString())); testView.setResultPingString( savedInstanceState.getString("ping_string", testView.getResultPingString())); testView.setResultDownString( savedInstanceState.getString("down_string", testView.getResultDownString())); testView.setResultUpString(savedInstanceState.getString("up_string", testView.getResultUpString())); } if (textView != null) { textView.setText(savedInstanceState.getString("test_info")); } } else { if (textView != null) { textView.setText("\n\n\n"); } } if (graphView != null) { if (speedGraphData == null) { speedGraph = SmoothGraph.addGraph(graphView, Color.parseColor("#00f940"), SMOOTHING_DATA_AMOUNT, SMOOTHING_FUNCTION, false); } else { speedGraph = SmoothGraph.addGraph(graphView, SMOOTHING_DATA_AMOUNT, SMOOTHING_FUNCTION, false, speedGraphData); } speedGraph.setMaxTime(GRAPH_MAX_NSECS); if (signalGraphData == null) { signalGraph = SimpleGraph.addGraph(graphView, Color.parseColor("#f8a000"), GRAPH_MAX_NSECS); } else { signalGraph = SimpleGraph.addGraph(graphView, GRAPH_MAX_NSECS, signalGraphData); } //graphView.getLabelInfoVerticalList().add(new GraphLabel(getActivity().getString(R.string.test_dbm), "#f8a000")); graphView.setRowLinesLabelList(ResultGraphView.SPEED_LABELS); } //uploadGraph = false; graphStarted = false; final Resources res = getActivity().getResources(); final String progressTitle = res.getString(R.string.test_progress_title); final String progressText = res.getString(R.string.test_progress_text); lastShownWaitTime = -1; if (progressDialog == null) { progressDialog = ProgressDialog.show(getActivity(), progressTitle, progressText, true, false); progressDialog.setOnKeyListener(backKeyListener); } return view; }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Random r=new Random(); // int uniqueNumber =(r.nextInt(999) + 100); // uniqueId = Integer.toString(uniqueNumber); // ?uniqueId//from ww w . j a va2 s. c o m UUID uuid = UUID.randomUUID(); uniqueId = uuid.toString(); this.inflater = inflater; rootView = inflater.inflate(R.layout.fragment_car_check_basic_info, container, false); // <editor-fold defaultstate="collapsed" desc="??View?"> tableLayout = (TableLayout) rootView.findViewById(R.id.bi_content_table); contentLayout = (LinearLayout) rootView.findViewById(R.id.brand_input); Button vinButton = (Button) rootView.findViewById(R.id.bi_vin_button); vinButton.setOnClickListener(this); brandOkButton = (Button) rootView.findViewById(R.id.bi_brand_ok_button); brandOkButton.setEnabled(false); brandOkButton.setOnClickListener(this); brandSelectButton = (Button) rootView.findViewById(R.id.bi_brand_select_button); brandSelectButton.setEnabled(false); brandSelectButton.setOnClickListener(this); // ?? sketchPhotoEntities = new ArrayList<PhotoEntity>(); // Button matchButton = (Button) rootView.findViewById(R.id.ct_licencePhotoMatch_button); matchButton.setOnClickListener(this); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; vin_edit = (EditText) rootView.findViewById(R.id.bi_vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps() }); brandEdit = (EditText) rootView.findViewById(R.id.bi_brand_edit); displacementEdit = (EditText) rootView.findViewById(R.id.csi_displacement_edit); transmissionEdit = (EditText) rootView.findViewById(R.id.csi_transmission_edit); runEdit = (EditText) rootView.findViewById(R.id.bi_mileage_edit); // // transmissionSpinner = (Spinner)rootView.findViewById(R.id.csi_transmission_spinner); // transmissionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // @Override // public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { // transmissionEdit.setText(adapterView.getSelectedItem().toString()); // } // // @Override // public void onNothingSelected(AdapterView<?> adapterView) { // // } // }); // ?????? ScrollView view = (ScrollView) rootView.findViewById(R.id.root); view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); view.setFocusable(true); view.setFocusableInTouchMode(true); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.requestFocusFromTouch(); return false; } }); // ????????2? runEdit.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable edt) { String temp = edt.toString(); if (temp.contains(".")) { int posDot = temp.indexOf("."); if (posDot <= 0) return; if (temp.length() - posDot - 1 > 2) { edt.delete(posDot + 3, posDot + 4); } } else { if (temp.length() > 2) { edt.clear(); edt.append(temp.substring(0, 2)); } } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); licencePhotoMatchEdit = (EditText) rootView.findViewById(R.id.ct_licencePhotoMatch_edit); licencePhotoMatchEdit.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { licencePhotoMatchEdit.setError(null); } @Override public void afterTextChanged(Editable editable) { licencePhotoMatchEdit.setError(null); } }); // ?? carNumberEdit = (EditText) rootView.findViewById(R.id.ci_plateNumber_edit); carNumberEdit.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); // ? portedProcedureRow = (TableRow) rootView.findViewById(R.id.ct_ported_procedure); // ?Spinner setRegLocationSpinner(); setCarColorSpinner(); setFirstLogTimeSpinner(); setManufactureTimeSpinner(); setTransferCountSpinner(); setLastTransferTimeSpinner(); setYearlyCheckAvailableDateSpinner(); setAvailableDateYearSpinner(); setBusinessInsuranceAvailableDateYearSpinner(); setOtherSpinners(); // </editor-fold> mCarSettings = new CarSettings(); // ??xml if (vehicleModel == null) { mProgressDialog = ProgressDialog.show(rootView.getContext(), null, "?..", false, false); Thread thread = new Thread(new Runnable() { @Override public void run() { try { ParseXml(); // jsonData?? if (!jsonData.equals("")) { modifyMode = true; letsEnterModifyMode(); } } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } return rootView; }
From source file:com.commonsware.android.EMusicDownloader.SingleBook.java
public void sampleButtonPressed(View button) { Log.d("EMD - ", "Attempting to play sample"); if (sampleURL.contains("sample")) { final ProgressDialog dialog = ProgressDialog.show(this, "", getString(R.string.getting_sample_loation), true, true);/*from w ww . j av a 2 s . c om*/ Thread t5 = new Thread() { public void run() { String addresstemp = ""; try { URL u = new URL(sampleURL); HttpURLConnection c = (HttpURLConnection) u.openConnection(); c.setRequestMethod("GET"); //c.setDoOutput(true); c.setFollowRedirects(true); c.setInstanceFollowRedirects(true); c.connect(); InputStream in = c.getInputStream(); InputStreamReader inputreader = new InputStreamReader(in); BufferedReader buffreader = new BufferedReader(inputreader); String line; // read every line of the file into the line-variable, on line at the time while ((line = buffreader.readLine()).length() > 0) { //Log.d("EMD - ","Read line"+line); if (line.contains(".mp3") || line.contains("samples.emusic") || line.contains("samples.nl.emusic")) { addresstemp = line; //Log.d("EMD - ","Found MP3 Address "+addresstemp); mp3Address = addresstemp; if (!vKilled && dialog.isShowing()) { handlerPlay.sendEmptyMessage(0); } if (dialog.isShowing()) { dialog.dismiss(); } } } in.close(); c.disconnect(); if (dialog.isShowing()) { dialog.dismiss(); } } catch (Exception ef) { Log.d("EMD - ", "Getting mp3 address failed "); if (dialog.isShowing()) { dialog.dismiss(); } } } }; t5.start(); } else { Toast.makeText(thisActivity, R.string.no_sample_available, Toast.LENGTH_SHORT).show(); } }
From source file:com.nonstop.android.SoC.BluetoothChat.BluetoothChat.java
private void setupChat() { Log.d(TAG, "setupChat()"); // Initialize the array adapter for the conversation thread mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message); mConversationView = (ListView) findViewById(R.id.in); mConversationView.setAdapter(mConversationArrayAdapter); // Initialize the compose field with a listener for the return key mOutEditText = (EditText) findViewById(R.id.edit_text_out); mOutEditText.setOnEditorActionListener(mWriteListener); // Initialize the send button with a listener that for click events mSendButton = (Button) findViewById(R.id.button_send); mSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Send a message using content of the edit text widget TextView view = (TextView) findViewById(R.id.edit_text_out); String message = view.getText().toString(); sendMessage(message);/*from w w w.ja va2 s . co m*/ } }); mTurnLeftButton = (Button) findViewById(R.id.button_turnleft); mTurnLeftButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setDirection(Direction.LEFT); sendMessage(mChatService.mGlasOData.makePacket()); } }); mTurnRightButton = (Button) findViewById(R.id.button_turnright); mTurnRightButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setDirection(Direction.RIGHT); sendMessage(mChatService.mGlasOData.makePacket()); } }); mNormalButton = (Button) findViewById(R.id.button_normal); mNormalButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setDirection(Direction.NORMAL); sendMessage(mChatService.mGlasOData.makePacket()); } }); mNoAlarmButton = (Button) findViewById(R.id.button_no_alarm); mNoAlarmButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setAlarm_(Alarm.NOUSE); sendMessage(mChatService.mGlasOData.makePacket()); } }); mAroundAlarmButton = (Button) findViewById(R.id.button_around_alarm); mAroundAlarmButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setAlarm_(Alarm.AROUND); sendMessage(mChatService.mGlasOData.makePacket()); } }); mOnAlarmButton = (Button) findViewById(R.id.button_on_alarm); mOnAlarmButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setAlarm_(Alarm.ONTIME); sendMessage(mChatService.mGlasOData.makePacket()); } }); mOnTimeButton = (Button) findViewById(R.id.button_ontime); mOnTimeButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mChatService.mGlasOData.setOnTime(OnTime.ON); sendMessage(mChatService.mGlasOData.makePacket()); mChatService.mGlasOData.setOnTime(OnTime.OFF); } }); mPhotoButton = (Button) findViewById(R.id.button_photo); mPhotoButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!Utility.mFacebook.isSessionValid()) { // Util.showAlert(this, "Warning", // "You must first log in."); } else { /* * Source tag: upload_photo_tag */ dialog = ProgressDialog.show(BluetoothChat.this, "", getString(R.string.please_wait), true, true); Bundle params = new Bundle(); params.putString("url", "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); params.putString("caption", "FbAPIs Sample App photo upload"); Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(), null); } } }); mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup1); mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup arg0, int arg1) { if (arg1 == R.id.radio_exceed) { mChatService.mGlasOData.setExceed(Exceed.EXCEED); } else if (arg1 == R.id.radio_exceedhigh) { mChatService.mGlasOData.setExceed(Exceed.EXCEEDHIGH); } else if (arg1 == R.id.radio_normalspeed) { mChatService.mGlasOData.setExceed(Exceed.NORMALSPEED); } sendMessage(mChatService.mGlasOData.makePacket()); } }); mStatusCheckBox = (CheckBox) findViewById(R.id.checkBox_status); mStatusCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mChatService.mGlasOData.setStatus(Status.WRONG); } else { mChatService.mGlasOData.setStatus(Status.NORMAL); } } }); mNaviToggle = (ToggleButton) findViewById(R.id.toggle_navi); mNaviToggle.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (D) Log.e(TAG, "++ NAVI ON ++"); mChatService.navi_stat_ = 1; } else { if (D) Log.e(TAG, "++ NAVI OFF ++"); mChatService.navi_stat_ = 0; } } }); mHeartbeatToggle = (ToggleButton) findViewById(R.id.toggle_Heartbeat); mHeartbeatToggle.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (D) Log.e(TAG, "++ HEARTBEAT ON ++"); mChatService.heartbeat_stat_ = 1; } else { if (D) Log.e(TAG, "++ HEARTBEAT OFF ++"); mChatService.heartbeat_stat_ = 0; } if (mChatService.heartbeat_stat_ == 0 && mChatService.distance_stat_ == 0 && mChatService.speed_stat_ == 0) { mChatService.sens_stat_ = 0; } else { mChatService.sens_stat_ = 1; } } }); mHeartbeat = (SeekBar) findViewById(R.id.seekBar_Heartbeat); mHeartbeat.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mChatService.mGlasOData.setHeartbeat_(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mSpeedToggle = (ToggleButton) findViewById(R.id.toggle_Velocity); mSpeedToggle.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (D) Log.e(TAG, "++ SpeedSens ON ++"); mChatService.speed_stat_ = 1; } else { if (D) Log.e(TAG, "++ SpeedSens OFF ++"); mChatService.speed_stat_ = 0; } if (mChatService.heartbeat_stat_ == 0 && mChatService.distance_stat_ == 0 && mChatService.speed_stat_ == 0) { mChatService.sens_stat_ = 0; } else { mChatService.sens_stat_ = 1; } } }); mSpeed = (SeekBar) findViewById(R.id.seekBar_Velocity); mSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mChatService.mGlasOData.setVelocity_(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mDistanceToggle = (ToggleButton) findViewById(R.id.toggle_Distance); mDistanceToggle.setOnCheckedChangeListener(new ToggleButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (D) Log.e(TAG, "++ Distance ON ++"); mChatService.distance_stat_ = 1; } else { if (D) Log.e(TAG, "++ Distance OFF ++"); mChatService.distance_stat_ = 0; } if (mChatService.heartbeat_stat_ == 0 && mChatService.distance_stat_ == 0 && mChatService.speed_stat_ == 0) { mChatService.sens_stat_ = 0; } else { mChatService.sens_stat_ = 1; } } }); mDiatance = (SeekBar) findViewById(R.id.seekBar_Distance); mDiatance.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mChatService.mGlasOData.setDistance_(progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // Initialize the BluetoothChatService to perform bluetooth connections mChatService = new BluetoothChatService(this, mHandler); // Initialize the buffer for outgoing messages mOutStringBuffer = new StringBuffer(""); }
From source file:com.example.research.whatis.MainActivity.java
public String invokeSynonymsAPI() throws IOException, JSONException { if (OCRedText.length() > 0) { final ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "Loading ...", "Fetching synonym for " + OCRedText, true, false); final Thread thread = new Thread(new Runnable() { @Override/*from w w w . ja va2 s .c o m*/ public void run() { String synonymURL = "http://words.bighugelabs.com/api/2/4bbcc4ae52f1e82bd08e683a72665f7b/"; synonymURL += OCRedText.toString() + "/json"; synonymURL = synonymURL.replaceAll("\\s", ""); Log.d("API", "Invokes Synonyms" + synonymURL); URL url = null; try { url = new URL(synonymURL); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "application/json"); //connection.setRequestProperty("Content-Length", Integer.toString(OCRedText.length())); OutputStream stream = connection.getOutputStream(); stream.close(); //fabulous/json httpCode = connection.getResponseCode(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Doing UI related code in UI thread runOnUiThread(new Runnable() { @Override public void run() { dialog.dismiss(); // Success request try { if (httpCode == HttpURLConnection.HTTP_OK) { // Get response stream String jsonResponse = GetResponseToString(connection.getInputStream()); JSONObject reader = new JSONObject(jsonResponse); Log.d("Synonyms JSONResp ", jsonResponse.toString()); Log.d("Synonyms Reader", reader.toString()); JSONArray text = null; try { JSONObject obj = reader.getJSONObject("adjective"); text = obj.getJSONArray("syn"); } catch (JSONException e) { e.printStackTrace(); try { JSONObject obj = reader.getJSONObject("noun"); text = obj.getJSONArray("syn"); } catch (JSONException e1) { JSONObject obj = reader.getJSONObject("verb"); text = obj.getJSONArray("syn"); } } if (text != null) { synonym = text.get(0).toString(); } else { synonym = "<ERROR IN API>"; } FileOutputStream fos = openFileOutput("synonym.txt", Context.MODE_APPEND); fos.write(synonym.getBytes()); fos.close(); } else { // Error occurred String jsonResponse = GetResponseToString(connection.getErrorStream()); JSONObject reader = new JSONObject(jsonResponse); JSONArray text = reader.getJSONArray("ErrorMessage"); synonym = text.get(0).toString(); // Error message // Toast.makeText(MainActivity.this, "Error Message: " + synonym, Toast.LENGTH_LONG).show(); System.out.println(); } connection.disconnect(); TextView view = (TextView) findViewById(R.id.textView); view.setVisibility(View.VISIBLE); ListView lView = (ListView) findViewById(R.id.listView); lView.setVisibility(View.GONE); view.setText(OCRedText + ":" + synonym); dbHelper.insertWord(OCRedText, synonym, "", "http://words.bighugelabs.com"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); } }); thread.start(); } else { synonym = ""; } return synonym; }
From source file:com.timemachine.controller.ControllerActivity.java
public void showProcessDialog(String newTitle) { processDialogTitle = newTitle;//from ww w. j a va2 s.com runOnUiThread(new Runnable() { public void run() { System.out.println("showProcessDialog"); processDialog = ProgressDialog.show(ControllerActivity.this, "", processDialogTitle, true, false); } }); }
From source file:org.ueu.uninet.it.IragarkiOholaKontaktua.java
private void postData() { // Sortu HttpClient berria eta goiburuak bidali final HttpClient httpclient = new DefaultHttpClient(); // prestatu bidalketarako URLa final String url_bidalketa = this.url + Konstanteak.URL_IRAGARKIA_ERANTZUN; // Lokalean frogak egiteko //final String url_bidalketa = "http://10.0.2.2/uninet_zini/it_iragarki_ohola.php"; this.progressDialog = ProgressDialog.show(this, " Lanean...", " Mezua bidaltzen", true, false); new Thread() { @Override//from ww w . jav a 2 s . c om public void run() { // hasi int what = 0; try { HttpPost httppost = new HttpPost(url_bidalketa); // Formularioko eremuak POST moduan kargatu List<NameValuePair> nameValuePairs; if (telefonoa.getText() != null) { // Telefonoa ez da derrigorrezkoa nameValuePairs = new ArrayList<NameValuePair>(6); nameValuePairs.add(new BasicNameValuePair("name", izena.getText().toString())); nameValuePairs.add(new BasicNameValuePair("eposta", eposta.getText().toString())); nameValuePairs.add(new BasicNameValuePair("telefonoa", telefonoa.getText().toString())); nameValuePairs.add(new BasicNameValuePair("text", mezua.getText().toString() + "\n" + url)); nameValuePairs.add(new BasicNameValuePair("galdera", "12")); nameValuePairs.add(new BasicNameValuePair("legalAdvice", "accept")); } else { nameValuePairs = new ArrayList<NameValuePair>(5); nameValuePairs.add(new BasicNameValuePair("name", izena.getText().toString())); nameValuePairs.add(new BasicNameValuePair("eposta", eposta.getText().toString())); nameValuePairs.add(new BasicNameValuePair("text", mezua.getText().toString() + "\n" + url)); nameValuePairs.add(new BasicNameValuePair("galdera", "12")); nameValuePairs.add(new BasicNameValuePair("legalAdvice", "accept")); } httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Exekutatu HTTP Post eskaera HttpResponse response = httpclient.execute(httppost); //Dena ondo joanez gero if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { // Handler-era mezua bidali bertan akatsaren berri // emateko what = 0; } else { // Errorea egon da what = 1; } } catch (IllegalArgumentException e) { // Handler-i mezua bidali // Errorea egon da what = 1; } catch (ClientProtocolException e) { what = 1; } catch (IOException e) { what = 1; } finally { //Edozelan konexioa itxi eta bukaera adierazi handler-i, errorea edo errorerik gabe httpclient.getConnectionManager().shutdown(); handler_bidalketa.sendEmptyMessage(what); //what-en adierazten da errorea egon den edo dena ondo joan den } } }.start(); }