List of usage examples for android.os Handler Handler
@UnsupportedAppUsage public Handler(boolean async)
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 www . 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; } }
From source file:com.hybris.mobile.activity.StoreLocatorActivity.java
/** * View lifecycle methods//from w w w .java 2 s . c om */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.store_finder); setTitle(R.string.store_title); //controller setup mHandler = new Handler(this); controller = new StoreLocatorController(); controller.addOutboxHandler(mHandler); //adapter setup mAdapter = new StoreLocatorAdapter(this, controller.getModel()); setListAdapter(mAdapter); //listview getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long l) { // Disable the click on the loading spin image if (!isLoading || (isLoading && position < mAdapter.getCount() - 1)) { Intent intent = null; intent = new Intent(StoreLocatorActivity.this, StoreLocatorDetailActivity.class); IntentHelper.addObjectForKey(controller.getModel().get(position), DataConstants.INTENT_OBJECT_STORE); startActivity(intent); } } }); getListView().setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (!isLoading) { //what is the bottom iten that is visible int lastInScreen = firstVisibleItem + visibleItemCount; // //is the bottom item visible & not loading more already ? Load more ! if (lastInScreen >= totalItemCount - 1) { fetchMoreStores(); } } } }); }
From source file:com.sibext.android.activity.RedmineReportActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tryGetArgumentsFromManifest();// w w w .j av a2s. c o m if (invalidArguments()) { tryGetArgumentsFromResources(); } if (invalidArguments()) { throw new RuntimeException("Please setup readmine in your manifest or in your resources!"); } thread = new HandlerThread(TAG); thread.start(); handler = new Handler(thread.getLooper()); manager = new RedmineManager(redmineHost, redmineKey); }
From source file:de.schildbach.wallet.ui.send.RequestWalletBalanceTask.java
public RequestWalletBalanceTask(final Handler backgroundHandler, final ResultCallback resultCallback, @Nullable final String userAgent) { this.backgroundHandler = backgroundHandler; this.callbackHandler = new Handler(Looper.myLooper()); this.resultCallback = resultCallback; this.userAgent = userAgent; }
From source file:com.iiitd.networking.UDPMessenger.java
/** * Class constructor//from ww w. ja va2s. com * @param context the application's context * @param tag a valid string, used to filter the UDP broadcast messages (in and out). It can't be null or 0-characters long. * @param multicastPort the port to multicast to. Must be between 1025 and 49151 (inclusive) * @param connectionPort the port to get the connection back. Must be between 1025 and 49151 */ public UDPMessenger(Context context, String tag, int multicastPort) throws IllegalArgumentException { if (context == null || tag == null || tag.length() == 0 || multicastPort <= 1024 || multicastPort > 49151) throw new IllegalArgumentException(); this.context = context.getApplicationContext(); TAG = tag; MULTICAST_PORT = multicastPort; incomingMessageHandler = new Handler(Looper.getMainLooper()); }
From source file:com.kescoode.android.yong.volley.toolbox.HurlStack.java
/** * @param urlRewriter Rewriter to use for request URLs *//*from w w w. ja v a 2 s .co m*/ public HurlStack(UrlRewriter urlRewriter) { this(urlRewriter, null, new ExecutorDelivery(new Handler(Looper.getMainLooper()))); }
From source file:com.nuvolect.securesuite.data.SqlIncSync.java
public SqlIncSync() { /**//w w w . j a va 2 s . c o m * Use the main looper to create the handler. Without the main looper * the handler will fail when initialized from a non-UI thread, such as when * called from the web server. */ mHandler = new Handler(Looper.getMainLooper()); mSyncSuspended = false; mSyncEnabled = WebUtil.companionServerAssigned(); }
From source file:com.vk.sdk.api.httpClient.VKImageOperation.java
/** * Set listener for current operation//w w w . j a va2 s . c om * @param listener Listener subclasses VKHTTPOperationCompleteListener */ public void setImageOperationListener(final VKImageOperationListener listener) { this.setCompleteListener(new VKOperationCompleteListener() { @Override public void onComplete() { if (VKImageOperation.this.state() != VKOperationState.Finished || mLastException != null) { listener.onError(VKImageOperation.this, generateError(mLastException)); } else { byte[] response = getResponseData(); Bitmap captchaImage = BitmapFactory.decodeByteArray(response, 0, response.length); if (imageDensity > 0) { captchaImage = Bitmap.createScaledBitmap(captchaImage, (int) (captchaImage.getWidth() * imageDensity), (int) (captchaImage.getHeight() * imageDensity), true); } final Bitmap result = captchaImage; new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { listener.onComplete(VKImageOperation.this, result); } }); } } }); }
From source file:de.langerhans.wallet.ui.send.RequestWalletBalanceTask.java
public RequestWalletBalanceTask(@Nonnull final Handler backgroundHandler, @Nonnull final ResultCallback resultCallback, @Nullable final String userAgent) { this.backgroundHandler = backgroundHandler; this.callbackHandler = new Handler(Looper.myLooper()); this.resultCallback = resultCallback; this.userAgent = userAgent; }
From source file:com.hybris.mobile.activity.StoreLocatorDetailActivity.java
@Override protected void onResume() { super.onResume(); if (GeolocationUtil.isLocationActivated()) { // We run the service that tries to geolocate the user GeolocationUtil.getLocation(new Handler(this), StoreLocatorController.MESSAGE_GEOLOCATION_SUCCESS, StoreLocatorController.MESSAGE_GEOLOCATION_ERROR); } else {//from w ww.ja v a 2s. co m GeolocationUtil.showDialogEnableLocationServices(this); } // Trying to find if we have a store id coming from a geofence notification if (getIntent() != null && getIntent().getExtras() != null && StringUtils.isNotEmpty(getIntent().getExtras().getString(DataConstants.INTENT_OBJECT_STORE))) { String storeId = getIntent().getExtras().getString(DataConstants.INTENT_OBJECT_STORE); GeofenceObject geofenceObject = geofenceJsonSharedPreferences.getGeofenceObject(storeId); // We get the store from the cache with the specified id store = (Store) geofenceObject.getAssociatedObject(); } else { // We get the cached store store = (Store) IntentHelper.getObjectForKey(DataConstants.INTENT_OBJECT_STORE); // We re-save the object again because the above method removes it and in case of coming back to this activity we need to retrieve the store IntentHelper.addObjectForKey(store, DataConstants.INTENT_OBJECT_STORE); } loadData(); }