List of usage examples for android.os Message obtain
public static Message obtain(Handler h, int what, Object obj)
From source file:org.altusmetrum.AltosDroid.AltosDroid.java
void setFrequency(double freq) { try {//from w w w . ja va 2 s . c om mService.send(Message.obtain(null, TelemetryService.MSG_SETFREQUENCY, freq)); } catch (RemoteException e) { } }
From source file:com.harshad.linconnectclient.SettingsActivity.java
@SuppressLint("SimpleDateFormat") private void setupSimplePreferencesScreen() { // Load preferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(SettingsActivity.this); // Add preferences from XML addPreferencesFromResource(R.xml.pref_general); bindPreferenceSummaryToValue(findPreference("pref_ip")); // Preference Categories serverCategory = ((PreferenceCategory) findPreference("cat_servers")); // Preferences refreshPreference = ((Preference) findPreference("pref_refresh")); serverCategory.removePreference(refreshPreference); loadingPreference = ((Preference) findPreference("pref_loading")); serverCategory.removePreference(loadingPreference); Preference prefEnable = findPreference("pref_enable"); prefEnable.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override//from w w w.j av a2s . co m public boolean onPreferenceClick(Preference arg0) { // If Android 4.3+, open Notification Listener settings, // otherwise open accessibility settings if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { startActivityForResult(new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS), 0); } else { Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); startActivity(intent); } return true; } }); ((Preference) findPreference("pref_ip")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference arg0, Object arg1) { // Update Custom IP address summary arg0.setSummary((String) arg1); refreshServerList(); // Create and send test notification SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss"); Object[] notif = new Object[3]; notif[0] = "Hello from Android!"; notif[1] = "Test succesful @ " + sf.format(new Date()); notif[2] = SettingsActivity.this.getResources().getDrawable(R.drawable.ic_launcher); new TestTask().execute(notif); return true; } }); Preference prefDownload = findPreference("pref_download"); prefDownload.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { // Create share dialog with server download URL Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "Download LinConnect server @ https://github.com/hauckwill/linconnect-server"); sendIntent.setType("text/plain"); startActivity(sendIntent); return true; } }); Preference prefApplication = findPreference("pref_application"); prefApplication.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { // Open application settings screen Intent intent = new Intent(getApplicationContext(), ApplicationSettingsActivity.class); startActivity(intent); return true; } }); // Preference prefDonateBitcoin = findPreference("pref_donate_btc"); // prefDonateBitcoin // .setOnPreferenceClickListener(new OnPreferenceClickListener() { // @Override // public boolean onPreferenceClick(Preference arg0) { // try { // Open installed Bitcoin wallet if possible // Intent intent = new Intent(Intent.ACTION_VIEW); // intent.setData(Uri // .parse("bitcoin:1125MguyS1feaop99bCDPQG6ukUcMuvVBo?label=Will%20Hauck&message=Donation%20for%20LinConnect")); // startActivity(intent); // } catch (Exception e) { // Otherwise, show dialog with Bitcoin address // EditText input = new EditText(SettingsActivity.this); // input.setText("1125MguyS1feaop99bCDPQG6ukUcMuvVBo"); // input.setEnabled(false); // new AlertDialog.Builder(SettingsActivity.this) // .setTitle("Bitcoin Address") // .setMessage( // "Please donate to the following Bitcoin address. Thank you for the support.") // .setView(input) // .setPositiveButton( // "Copy Address", // new DialogInterface.OnClickListener() { // public void onClick( // DialogInterface dialog, // int whichButton) { // android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); // clipboard // .setText("1125MguyS1feaop99bCDPQG6ukUcMuvVBo"); // } // }) // .setNegativeButton( // "Okay", // new DialogInterface.OnClickListener() { // public void onClick( // DialogInterface dialog, // int whichButton) { // } // }).show(); // } // return true; // } // }); // Preference prefGooglePlus = findPreference("pref_google_plus"); // prefGooglePlus // .setOnPreferenceClickListener(new OnPreferenceClickListener() { // @Override // public boolean onPreferenceClick(Preference arg0) { // // Open Google Plus page // Intent intent = new Intent(Intent.ACTION_VIEW); // intent.setData(Uri // .parse("https://plus.google.com/114633032648182423928/posts")); // startActivity(intent); // return true; // } // }); // Preference prefDonatePlay = findPreference("pref_donate_play"); // prefDonatePlay // .setOnPreferenceClickListener(new OnPreferenceClickListener() { // @Override // public boolean onPreferenceClick(Preference arg0) { // Open Donation Key app on Play Store // Intent intent = new Intent(Intent.ACTION_VIEW); // intent.setData(Uri // .parse("market://details?id=com.willhauck.donation")); // startActivity(intent); // return true; // } // }); // Create handler to process a detected server serverFoundHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { if (msg.obj != null) { javax.jmdns.ServiceInfo serviceInfo = mJmDNS.getServiceInfo(jmDnsServiceType, (String) msg.obj); // Get info about server String name = serviceInfo.getName(); String port = String.valueOf(serviceInfo.getPort()); String ip = serviceInfo.getHostAddresses()[0]; // Create a preference representing the server Preference p = new Preference(SettingsActivity.this); p.setTitle(name); p.setSummary(ip + ":" + port); p.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { refreshServerList(); // Save IP address in preferences Editor e = sharedPreferences.edit(); e.putString("pref_ip", arg0.getSummary().toString()); e.apply(); // Create and send test notification SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss"); Object[] notif = new Object[3]; notif[0] = "Hello from Android!"; notif[1] = "Test succesful @ " + sf.format(new Date()); notif[2] = SettingsActivity.this.getResources().getDrawable(R.drawable.ic_launcher); new TestTask().execute(notif); return true; } }); // Add preference to server list if it doesn't already exist boolean found = false; for (int i = 0; i < serverCategory.getPreferenceCount(); i++) { if (serverCategory.getPreference(i) != null && serverCategory.getPreference(i).getTitle() != null && serverCategory.getPreference(i).getTitle().equals(p.getTitle())) { found = true; } } if (!found) { serverCategory.addPreference(p); } refreshServerList(); // Remove loading indicator, add refresh indicator if it // isn't already there if (findPreference("pref_loading") != null) serverCategory.removePreference(findPreference("pref_loading")); if (findPreference("pref_refresh") == null) serverCategory.addPreference(refreshPreference); } return true; } }); // Create task to scan for servers class ServerScanTask extends AsyncTask<String, ServiceEvent, Boolean> { @Override protected void onPreExecute() { // Remove refresh preference, add loading preference if (findPreference("pref_refresh") != null) serverCategory.removePreference(refreshPreference); serverCategory.addPreference(loadingPreference); try { mJmDNS.removeServiceListener(jmDnsServiceType, ServerListener); } catch (Exception e) { } refreshServerList(); } @Override protected Boolean doInBackground(String... notif) { WifiInfo wifiinfo = mWifiManager.getConnectionInfo(); int intaddr = wifiinfo.getIpAddress(); // Ensure there is an active Wifi connection if (intaddr != 0) { byte[] byteaddr = new byte[] { (byte) (intaddr & 0xff), (byte) (intaddr >> 8 & 0xff), (byte) (intaddr >> 16 & 0xff), (byte) (intaddr >> 24 & 0xff) }; InetAddress addr = null; try { addr = InetAddress.getByAddress(byteaddr); } catch (UnknownHostException e1) { } // Create Multicast lock (required for JmDNS) mMulticastLock = mWifiManager.createMulticastLock("LinConnect"); mMulticastLock.setReferenceCounted(true); mMulticastLock.acquire(); try { mJmDNS = JmDNS.create(addr, "LinConnect"); } catch (IOException e) { } // Create listener for detected servers ServerListener = new ServiceListener() { @Override public void serviceAdded(ServiceEvent arg0) { final String name = arg0.getName(); // Send the server data to the handler, delayed by // 500ms to ensure all information is read serverFoundHandler.sendMessageDelayed(Message.obtain(serverFoundHandler, -1, name), 500); } @Override public void serviceRemoved(ServiceEvent arg0) { } @Override public void serviceResolved(ServiceEvent arg0) { mJmDNS.requestServiceInfo(arg0.getType(), arg0.getName(), 1); } }; mJmDNS.addServiceListener(jmDnsServiceType, ServerListener); return true; } return false; } @Override protected void onPostExecute(Boolean result) { if (!result) { // Notify user if there is no connection if (findPreference("pref_loading") != null) { serverCategory.removePreference(findPreference("pref_loading")); serverCategory.addPreference(refreshPreference); } Toast.makeText(getApplicationContext(), "Error: no connection.", Toast.LENGTH_LONG).show(); } } } refreshPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { new ServerScanTask().execute(); return true; } }); // Start scanning for servers new ServerScanTask().execute(); }
From source file:net.gaast.giggity.ScheduleViewActivity.java
/** Open a link object, either just through the browser or by downloading locally and using a * dedicated viewer.//from w w w . j a va 2s.c o m * @param link Link object - if type is set we'll try to download and use a viewer, unless: * @param allowDownload is set. This also used to avoid infinite loops in case of bugs. */ private void openLink(final Schedule.Link link, boolean allowDownload) { if (link.getType() != null) { Fetcher f = null; try { f = new Fetcher(app, link.getUrl(), Fetcher.Source.CACHE, link.getType()); } catch (IOException e) { // Failure is ~expected so don't make a fuss about it at this stage. :-) } if (f != null) { Uri cached = f.cacheUri(); try { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(cached, link.getType()); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Log.d("ScheduleViewActivity", "Viewing content externally: " + intent); startActivity(intent); } catch (ActivityNotFoundException e) { new AlertDialog.Builder(ScheduleViewActivity.this).setTitle(R.string.loading_error).setMessage( getString(R.string.no_viewer_error) + " " + link.getType() + ": " + e.getMessage()) .show(); } return; } else if (allowDownload) { final LoadProgress prog = new LoadProgress(this, false); prog.setMessage(getResources().getString(R.string.loading_image)); prog.setDone(new LoadProgressDoneInterface() { @Override public void done() { /* Try again, avoiding inifite-looping on this download just in case. */ openLink(link, false); } }); prog.show(); Thread loader = new Thread() { @Override public void run() { try { Fetcher f = app.fetch(link.getUrl(), Fetcher.Source.ONLINE, link.getType()); f.setProgressHandler(prog.getHandler()); /* Just slurp the entire file into a bogus buffer, what we need is the file in ExternalCacheDir */ byte[] buf = new byte[1024]; //noinspection StatementWithEmptyBody while (f.getStream().read(buf) != -1) { } f.keep(); /* Will trigger the done() above back in the main thread. */ prog.getHandler().sendEmptyMessage(LoadProgress.DONE); } catch (IOException e) { e.printStackTrace(); prog.getHandler().sendMessage(Message.obtain(prog.getHandler(), 0, e)); } } }; loader.start(); return; } } /* If type was not set, or if neither of the two inner ifs were true (do we have the file, or, are we allowed to download it?), fall back to browser. */ Uri uri = Uri.parse(link.getUrl()); Intent browser = new Intent(Intent.ACTION_VIEW, uri); browser.addCategory(Intent.CATEGORY_BROWSABLE); startActivity(browser); }
From source file:eu.davidea.flexibleadapter.FlexibleAdapter.java
/** * This method will refresh the entire DataSet content. * <p>Optionally all changes can be animated, limited by the value previously set with * {@link #setAnimateToLimit(int)} to improve performance on big list.</p> * Pass {@code animate = false} to directly invoke {@link #notifyDataSetChanged()} * without any animations./* www . j a v a 2s . c om*/ * <p><b>Note:</b> This methods calls {@link #expandItemsAtStartUp()} and * {@link #showAllHeaders()} if headers are shown.</p> * * @param items the new data set * @param animate true to animate the changes, false for a quick refresh * @see #updateDataSet(List) * @see #setAnimateToLimit(int) * @since 5.0.0-b7 Created * <br/>5.0.0-b8 Synchronization animations limit */ @CallSuper public void updateDataSet(@Nullable List<T> items, boolean animate) { if (animate) { mHandler.removeMessages(UPDATE); mHandler.sendMessage(Message.obtain(mHandler, UPDATE, items)); } else { if (items == null) mItems = new ArrayList<>(); else mItems = new ArrayList<>(items); postUpdate(true); } }
From source file:com.ruesga.rview.MainActivity.java
private void requestAccountDeletion(Account account) { AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.account_deletion_title) .setMessage(R.string.account_deletion_message) .setPositiveButton(R.string.action_delete, (dialogInterface, i) -> Message .obtain(mUiHandler, MESSAGE_DELETE_ACCOUNT, account.getAccountHash()).sendToTarget()) .setNegativeButton(R.string.action_cancel, null).create(); dialog.show();/* w w w . j a va2 s . co m*/ }
From source file:com.bookkos.bircle.CaptureActivity.java
private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) { if (handler == null) { savedResultToShow = result;// w w w . ja v a 2 s .c om } else { if (result != null) { savedResultToShow = result; } if (savedResultToShow != null) { Message message = Message.obtain(handler, R.id.decode_succeeded, savedResultToShow); handler.sendMessage(message); } savedResultToShow = null; } }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
private void sendReplyMessage(int id, Object arg, long delayMS) { if (handler != null) { Message message = Message.obtain(handler, id, arg); if (delayMS > 0L) { handler.sendMessageDelayed(message, delayMS); } else {/*ww w. j a v a2s .c o m*/ handler.sendMessage(message); } } }
From source file:com.kmshack.BusanBus.activity.SearchMainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_common); setTitle(""); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerListener(new DrawerListener() { public void onDrawerOpened(View drawerView) { mDrawerToggle.onDrawerOpened(drawerView); getActionBarHelper().onDrawerOpened(); }//ww w .j a va2 s .c om public void onDrawerClosed(View drawerView) { mDrawerToggle.onDrawerClosed(drawerView); getActionBarHelper().onDrawerClosed(); } public void onDrawerSlide(View drawerView, float slideOffset) { mDrawerToggle.onDrawerSlide(drawerView, slideOffset); } public void onDrawerStateChanged(int newState) { mDrawerToggle.onDrawerStateChanged(newState); } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerToggle = new SherlockActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_dark, R.string.drawer_open, R.string.drawer_close); mDrawerToggle.syncState(); mBusDb = BusDb.getInstance(getApplicationContext()); mUserDb = UserDb.getInstance(getApplicationContext()); mBusanBusPrefrence = BusanBusPrefrence.getInstance(getApplicationContext()); mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case TAB_NOSUN: searchNosun((String) msg.obj); break; case TAB_BUSSTOP: searchBusStop((String) msg.obj); break; } } }; mImageFavorite = (ImageView) findViewById(R.id.main_tap_favorite_image); mImageNosun = (ImageView) findViewById(R.id.main_tap_nosun_image); mImageBusstop = (ImageView) findViewById(R.id.main_tap_busstop_image); mImageLocation = (ImageView) findViewById(R.id.main_tap_setting_image); mFavoriteImageNosun = (TextView) findViewById(R.id.favorite_tab_nosun); mFavoriteImageBusstop = (TextView) findViewById(R.id.favorite_tab_busstop); mTextFavorite = (TextView) findViewById(R.id.main_tap_favorite_text); mTextNosun = (TextView) findViewById(R.id.main_tap_nosun_text); mTextBusstop = (TextView) findViewById(R.id.main_tap_busstop_text); mTextSetting = (TextView) findViewById(R.id.main_tap_setting_text); mNosunListView = (ListView) findViewById(R.id.lv_nosun); mBusStopListView = (ListView) findViewById(R.id.lv_busstop); mFavoriteListView = (DragSortListView) findViewById(R.id.lv_favorite); mNosunListView.setEmptyView((TextView) findViewById(R.id.nosun_empty)); mBusStopListView.setEmptyView((TextView) findViewById(R.id.busstop_empty)); mFavoriteListView.setEmptyView((TextView) findViewById(R.id.favorite_empty)); mFavoriteListView.setDropListener(mOnDrop); mFavoriteListView.setRemoveListener(mOnRemove); mTextSettingNotice = (TextView) findViewById(R.id.setting_notice); mTextSettingUpdate = (TextView) findViewById(R.id.setting_update); mLayoutSettingTextSize = (LinearLayout) findViewById(R.id.setting_textsize_sun); mLayoutSettingArrive = (LinearLayout) findViewById(R.id.setting_arrive_sun); mLayoutSettingFavorite = (LinearLayout) findViewById(R.id.setting_favorite_start); mLayoutSettingFavoriteLocation = (LinearLayout) findViewById(R.id.setting_favorite_location); mTextViewSettingTextSize = (TextView) findViewById(R.id.setting_textsize_value); mCheckSettingArrive = (ImageView) findViewById(R.id.setting_check_arrive_sun); mCheckSettingFavorite = (ImageView) findViewById(R.id.setting_check_favorite_start); mCheckSettingFavoriteLocation = (ImageView) findViewById(R.id.setting_check_favorite_location); mTextSettingNotice.setOnClickListener(mSettingClick); mTextSettingUpdate.setOnClickListener(mSettingClick); mLayoutSettingTextSize.setOnClickListener(mSettingClick); mLayoutSettingArrive.setOnClickListener(mSettingClick); mLayoutSettingFavorite.setOnClickListener(mSettingClick); mLayoutSettingFavoriteLocation.setOnClickListener(mSettingClick); findViewById(R.id.setting_opensource).setOnClickListener(mSettingClick); findViewById(R.id.setting_bin).setOnClickListener(mSettingClick); if (mBusanBusPrefrence.getIsArriveSort()) mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_check); else mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_uncheck); if (mBusanBusPrefrence.getIsFavoriteStart()) mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_check); else mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_uncheck); if (mBusanBusPrefrence.getIsFavoriteLocation()) mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_check); else mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_uncheck); mNosunSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext()) .inflate(R.layout.search_bar_nosun, null); mNosunSearchView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mNosunEditText = (EditText) mNosunSearchView.findViewById(R.id.et_search_nosun); mNosunEditText.setHint(" "); mNosunEditText.setInputType(InputType.TYPE_CLASS_NUMBER); mNosunEditText.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { mHandler.removeMessages(TAB_NOSUN); Message msg = Message.obtain(mHandler, TAB_NOSUN, s.toString()); mHandler.sendMessageDelayed(msg, 200); } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); ((LinearLayout) findViewById(R.id.search_nosun)).addView(mNosunSearchView); mNosunListView.setOnScrollListener(new OnScrollListener() { public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) { } public void onScrollStateChanged(AbsListView arg0, int arg1) { mInputMethodManager.hideSoftInputFromWindow(mNosunEditText.getWindowToken(), 0); } }); mNosunListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Cursor cursor = mMainNosunSearchAdapter.getCursor(); cursor.moveToPosition(position); String nosun = cursor.getString(1); String realtime = cursor.getString(cursor.getColumnIndexOrThrow("WEBREALTIME")); String up = cursor.getString(2); String down = cursor.getString(3); Intent intent = new Intent(getApplicationContext(), NosunDetailActivity.class); intent.putExtra("NoSun", nosun); intent.putExtra("RealTimeNoSun", realtime); intent.putExtra("Up", up); intent.putExtra("Down", down); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); mBusstopSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext()) .inflate(R.layout.search_bar_busstop, null); mBusStopEditText = (EditText) mBusstopSearchView.findViewById(R.id.et_search_busstop); mBusStopEditText.setHint("/ "); mBusStopEditText.setInputType(InputType.TYPE_CLASS_TEXT); mBusStopEditText.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { mHandler.removeMessages(TAB_BUSSTOP); Message msg = Message.obtain(mHandler, TAB_BUSSTOP, s.toString()); mHandler.sendMessageDelayed(msg, 200); } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); ((LinearLayout) findViewById(R.id.search_busstop)).addView(mBusstopSearchView); mBusStopListView.setOnScrollListener(new OnScrollListener() { public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) { } public void onScrollStateChanged(AbsListView arg0, int arg1) { mInputMethodManager.hideSoftInputFromWindow(mBusStopEditText.getWindowToken(), 0); } }); mBusStopListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Cursor cursor = mMainStopSearchAdapter.getCursor(); cursor.moveToPosition(position); String busStop = cursor.getString(2).toString(); Intent intent = new Intent(getApplicationContext(), BusstopDetailActivity.class); intent.putExtra("BusStop", busStop); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); mFavoriteListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Cursor cursor = null; switch (mFavoriteMode) { case FAVORITE_TAB_NOSUN: cursor = mMainNosunFavoriteAdapter.getCursor(); break; default: cursor = mMainStopFavoriteAdapter.getCursor(); break; } if (cursor.getCount() > 0) { cursor.moveToPosition(position); Intent intent = null; switch (mFavoriteMode) { case FAVORITE_TAB_NOSUN: intent = new Intent(getApplicationContext(), BusArriveActivity.class); intent.putExtra("NOSUN", cursor.getString(1)); intent.putExtra("UNIQUEID", cursor.getString(2)); intent.putExtra("BUSSTOPNAME", cursor.getString(3)); intent.putExtra("UPDOWN", cursor.getString(4)); intent.putExtra("ORD", cursor.getString(6)); break; case FAVORITE_TAB_BUSSTOP: intent = new Intent(getApplicationContext(), BusstopDetailActivity.class); intent.putExtra("BusStop", cursor.getString(2)); break; } if (intent != null) { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } } } }); mTabFavorite = (LinearLayout) findViewById(R.id.main_tap_favorite); mTabNosun = (LinearLayout) findViewById(R.id.main_tap_nosun); mTabBusstop = (LinearLayout) findViewById(R.id.main_tap_busstop); mTabLocation = (LinearLayout) findViewById(R.id.main_tap_location); mLayoutFavorite = (LinearLayout) findViewById(R.id.layout_main_favorite); mLayoutNosun = (LinearLayout) findViewById(R.id.layout_main_nosun_search); mLayoutBusstop = (LinearLayout) findViewById(R.id.layout_main_busstop_search); mLayoutLocation = (LinearLayout) findViewById(R.id.layout_main_location); mTabFavorite.setOnClickListener(mTabClickListener); mTabNosun.setOnClickListener(mTabClickListener); mTabBusstop.setOnClickListener(mTabClickListener); mTabLocation.setOnClickListener(mTabClickListener); mFavoriteImageNosun.setOnClickListener(mTabClickListener); mFavoriteImageBusstop.setOnClickListener(mTabClickListener); searchNosun(""); searchBusStop(""); if (mBusanBusPrefrence.getIsFavoriteStart()) { setTabChange(TAB_FAVORITE); } else { setTabChange(DEFAULT_TAB); } tracker.trackPageView("/SearchMain"); loadSettingTextSizeSelect(); }
From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java
private void sendReplyMessage(int id, Object arg, long delayMS) { Message message = Message.obtain(handler, id, arg); if (delayMS > 0L) { handler.sendMessageDelayed(message, delayMS); } else {//from w w w . j a va 2s.c om handler.sendMessage(message); } }
From source file:com.freerdp.freerdpcore.presentation.SessionActivity.java
@Override public void OnSettingsChanged(int width, int height, int bpp) { if (bpp > 16) bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); else/*w ww . j ava2 s . c o m*/ bitmap = Bitmap.createBitmap(width, height, Config.RGB_565); session.setSurface(new BitmapDrawable(bitmap)); // check this settings and initial settings - if they are not equal the server doesn't support our settings // FIXME: the additional check (settings.getWidth() != width + 1) is for the RDVH bug fix to avoid accidental notifications // (refer to android_freerdp.c for more info on this problem) BookmarkBase.ScreenSettings settings = session.getBookmark().getActiveScreenSettings(); if ((settings.getWidth() != width && settings.getWidth() != width + 1) || settings.getHeight() != height || settings.getColors() != bpp) uiHandler.sendMessage(Message.obtain(null, UIHandler.DISPLAY_TOAST, getResources().getText(R.string.info_capabilities_changed))); }