List of usage examples for android.os Looper getMainLooper
public static Looper getMainLooper()
From source file:com.appsimobile.appsii.module.home.config.HomeItemConfigurationHelper.java
void ensureQueryHandler() { if (Looper.myLooper() != Looper.getMainLooper()) { throw new IllegalStateException("Method can only be called on the main thread"); }//from w ww .ja va 2s . c om mQueryHandler = new QueryHandlerImpl(mContext.getContentResolver()); }
From source file:com.miz.service.DownloadImageService.java
@Override protected void onHandleIntent(Intent intent) { boolean isOnline = MizLib.isOnline(this); final int stringId = isOnline ? R.string.addingCover : R.string.noInternet; new Handler(Looper.getMainLooper()).post(new Runnable() { @Override//from w ww . j a va 2 s .c o m public void run() { Toast.makeText(MizuuApplication.getContext(), stringId, Toast.LENGTH_LONG).show(); } }); if (!isOnline) { // End the download service return; } // Clear /reset all instance variables clear(); // Get the current setup Bundle bundle = intent.getExtras(); mImageUrl = bundle.getString(IMAGE_URL, ""); mContentId = bundle.getString(CONTENT_ID, ""); mImageType = bundle.getInt(IMAGE_TYPE, 0); // Setup... setup(); // Show Notification showNotification(); // Download! download(); // Resize the image resize(); // Broadcast and update widgets update(); // Dismiss the Notification dismiss(); }
From source file:com.massivcode.weatherinfoexam.fragment.CurrentWeatherInfoFragment.java
public void setData(final WeatherInfo weatherInfo) { final WeatherInfo.Weather weather = weatherInfo.weather.get(0); Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override//from w ww . j a v a 2 s. co m public void run() { mSunrise.setText(weatherInfo.sys.sunrise); mSunset.setText(weatherInfo.sys.sunset); mWindSpeed.setText(weatherInfo.wind.speed); mWindDeg.setText(weatherInfo.wind.deg); mWeather.setText(weather.description); mTemp.setText(weatherInfo.main.temp); mPressure.setText(weatherInfo.main.pressure); mHumidity.setText(weatherInfo.main.humidity); mVisibility.setText(weatherInfo.visibility); } }); }
From source file:com.deltadna.android.sdk.net.NetworkManager.java
public NetworkManager(String envKey, String collectUrl, String engageUrl, Settings settings, @Nullable String hash) {/*from w w w . j a va 2 s. c o m*/ this.collectUrl = collectUrl + '/' + envKey; this.engageUrl = engageUrl + '/' + envKey; this.settings = settings; this.hash = hash; MessageDigest md = null; if (hash != null && !hash.isEmpty()) { try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { Log.w(TAG, "Events will not be hashed", e); } } md5 = md; dispatcher = new NetworkDispatcher(new Handler(Looper.getMainLooper())); }
From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingPagerAdapter.java
private MeetingPagerAdapter(FragmentActivity activity, int teamId, MeetingCursorWrapper cursor) { super(activity.getSupportFragmentManager()); Log.v(TAG, "Constructor"); mContext = activity;//from www .j a v a2s .c o m mTeamId = teamId; mMeetingObserver = new MeetingObserver(new Handler(Looper.getMainLooper())); mCursor = cursor; mCursor.registerContentObserver(mMeetingObserver); }
From source file:com.miz.service.IdentifyMovieService.java
@Override protected void onHandleIntent(Intent intent) { if (MizLib.isMovieLibraryBeingUpdated(this)) { Handler mHandler = new Handler(Looper.getMainLooper()); mHandler.post(new Runnable() { @Override//from ww w.j av a2 s. c o m public void run() { Toast.makeText(IdentifyMovieService.this, R.string.cant_identify_while_updating, Toast.LENGTH_LONG).show(); } }); return; } log("clear()"); clear(); log("setup()"); setup(); log("Intent extras"); Bundle b = intent.getExtras(); mMovieId = b.getString("movieId"); mLanguage = b.getString("language", "en"); mFilepath = b.getString("filepath"); mOldMovieId = b.getString("currentMovieId"); log("setupList()"); setupList(); log("start()"); start(); }
From source file:com.massivcode.weatherinfoexam.fragment.ForecastFragment.java
public void setData(List<String> groupList, List<List<ForecastEachInfo>> childList) { mGroupData = groupList;/*from ww w .j a v a 2 s . c om*/ mChildData = childList; Log.d(TAG, "? : " + childList); if (mAdapter == null) { mAdapter = new ExpAdapter(mGroupData, mChildData, getActivity()); } else { mAdapter.notifyDataSetChanged(); } Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { mListView.setAdapter(mAdapter); } }); }
From source file:com.fastbootmobile.encore.app.tv.CardPresenter.java
public CardPresenter() { mHandler = new Handler(Looper.getMainLooper()); }
From source file:com.dishcuss.foodie.hub.GCM.MyGcmListenerService.java
/** * Called when message is received./*from ww w . j av a 2s. c om*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); String title = data.getString("title"); String redirect_type = data.getString("redirect_type"); String redirect_id = data.getString("redirect_id"); Log.d(TAG, "DATA: " + data.toString()); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); Log.d(TAG, "App: " + title); Log.d(TAG, "redirect_type: " + redirect_type); handler = new Handler(Looper.getMainLooper()); int id = Integer.parseInt(redirect_id); Log.d(TAG, "redirect_id: " + id); sendNotification(message, title, redirect_type, id); DishCussApplication app = (DishCussApplication) this.getApplication(); if (!app.isAppIsInBackground(getApplicationContext())) { // NotificationActivity.newNotifications++; // Log.e("Notifications",""+NotificationActivity.newNotifications); // HomeFragment2.ShowNotifications(); handler.post(new Runnable() { @Override public void run() { BusProvider.getInstance().post("Notification"); } }); } }
From source file:com.jerrellmardis.amphitheatre.task.GetFilesTask.java
@Override protected List<SmbFile> doInBackground(Void... params) { mConfig = ApiClient.getInstance().createTMDbClient().getConfig(); ArrayList<SmbFile> myFiles = new ArrayList<SmbFile>(DownloadTaskHelper.getFiles(mUser, mPassword, mPath)); if (myFiles.isEmpty()) { Handler h = new Handler(Looper.getMainLooper()) { @Override//from w ww . j a v a2 s . c o m public void handleMessage(Message msg) { super.handleMessage(msg); Toast.makeText(mContext, "Cannot find any files. Make sure your authentication information is correct.", Toast.LENGTH_SHORT).show(); } }; h.sendEmptyMessage(0); return new ArrayList<SmbFile>(); //Return empty set } else { return myFiles; } }