List of usage examples for android.os Handler Handler
public Handler()
From source file:com.dimasdanz.kendalipintu.BarcodeOpenDoorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_barcode_open_door); autoFocusHandler = new Handler(); mCamera = getCameraInstance();//from ww w. j av a 2s . co m scanner = new ImageScanner(); scanner.setConfig(0, Config.X_DENSITY, 3); scanner.setConfig(0, Config.Y_DENSITY, 3); mPreview = new BarcodePreview(this, mCamera, previewCb, autoFocusCB); FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview); preview.addView(mPreview); }
From source file:com.linkbubble.util.PageInspector.java
public PageInspector(Context context, WebView webView, OnItemFoundListener listener) { mContext = context;//from w ww.j a v a 2s . c om mWebView = webView; mHandler = new Handler(); mJSEmbedHandler = new JSEmbedHandler(); mOnItemFoundListener = listener; webView.addJavascriptInterface(mJSEmbedHandler, JS_VARIABLE); }
From source file:it.scoppelletti.mobilepower.app.data.DatabaseConnectionManager.java
/** * Costruttore./* ww w . j a va 2 s .c o m*/ * * @param activity Attività. * @param dbName Nome del database. * @param version Numero di versione del database. * @param upgrader Procedura di aggiornamento. */ public DatabaseConnectionManager(ActivitySupport activity, String dbName, int version, DatabaseUpgrader upgrader) { if (activity == null) { throw new NullPointerException("Argument activity is null."); } if (StringUtils.isBlank(dbName)) { throw new NullPointerException("Argument dbName is null."); } if (version < 1) { throw new IllegalArgumentException("Argument versione < 1."); } if (upgrader == null) { throw new NullPointerException("Argument upgrader is null."); } myActivity = activity; myDbName = dbName; myVersion = version; myUpgrader = upgrader; myHandler = new Handler(); myOnDbListeners = new ArrayList<OnDatabaseConnectionListener>(1); myUpgraded = false; }
From source file:com.uwindsor.elgg.project.http.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//*from w ww .j ava2s. c om*/ public AsyncHttpResponseHandler() { // Set up a handler to post events back to the correct thread if possible if (Looper.myLooper() != null) { handler = new Handler() { @Override public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:com.example.android.wearable.wcldemo.pages.StockActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.stock);//w ww . jav a 2 s . co m setAmbientEnabled(); mWearManager = WearManager.getInstance(); mConsumer = new AbstractWearConsumer() { @Override public void onWearableApiConnected() { updateButton(true); } @Override public void onWearableApiConnectionFailed() { Log.d(TAG, "Connection failed"); updateButton(false); } @Override public void onWearableApiConnectionSuspended() { Log.d(TAG, "Connection suspended"); updateButton(false); } }; setupViews(); updateButton(mWearManager.isConnected()); mSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { clearValues(); Set<Node> nodes = mWearManager.getNodesForCapability(Constants.CAPABILITY_HTTP_HANDLER); Log.d(TAG, "available http handler nodes: " + nodes); String nodeId = null; Node node = Utils.filterForNearby(nodes); if (node != null) { nodeId = node.getId(); } else { Toast.makeText(StockActivity.this, R.string.no_node_available, Toast.LENGTH_SHORT).show(); return; } mProgressBar.setVisibility(View.VISIBLE); try { new WearHttpHelper.Builder(url, StockActivity.this).setHttpMethod(WearHttpHelper.METHOD_GET) // optional, GET is default .setTargetNodeId(nodeId).setHttpResponseListener(StockActivity.this) // default timeout is 15000 ms = 15 seconds .setTimeout(TimeUnit.SECONDS.toMillis(10)).build().makeHttpRequest(); } catch (IllegalStateException e) { Log.e(TAG, "No Api Client Connection"); mProgressBar.setVisibility(View.GONE); } catch (IllegalArgumentException e) { Log.e(TAG, "Arguments are missing for the http call", e); mProgressBar.setVisibility(View.GONE); } } }); }
From source file:org.chromium.media.MediaDrmBridge.java
private MediaDrmBridge(UUID schemeUUID, String securityLevel, int nativeMediaDrmBridge) throws android.media.UnsupportedSchemeException { mSchemeUUID = schemeUUID;/* w ww . j av a2 s . c o m*/ mMediaDrm = new MediaDrm(schemeUUID); mHandler = new Handler(); mNativeMediaDrmBridge = nativeMediaDrmBridge; mResetDeviceCredentialsPending = false; mMediaDrm.setOnEventListener(new MediaDrmListener()); mMediaDrm.setPropertyString(PRIVACY_MODE, "enable"); String currentSecurityLevel = mMediaDrm.getPropertyString(SECURITY_LEVEL); Log.e(TAG, "Security level: current " + currentSecurityLevel + ", new " + securityLevel); if (!securityLevel.equals(currentSecurityLevel)) mMediaDrm.setPropertyString(SECURITY_LEVEL, securityLevel); }
From source file:be.vbsteven.bmtodesk.RegistrationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(android.R.style.Theme_Light_NoTitleBar); super.onCreate(savedInstanceState); setContentView(R.layout.registration); handler = new Handler(); button = (Button) findViewById(R.id.but_create); button.setOnClickListener(new OnClickListener() { @Override//from ww w .ja va 2 s. c o m public void onClick(View v) { register(); } }); button = (Button) findViewById(R.id.but_login); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { checkLogin(); } }); CheckBox cb = (CheckBox) findViewById(R.id.cb_password); cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { EditText password = (EditText) findViewById(R.id.et_password); if (isChecked) { password.setTransformationMethod(null); } else { password.setTransformationMethod(new PasswordTransformationMethod()); } } }); }
From source file:br.com.agendatech.cadastro.DrawableManager.java
public void fetchDrawableOnThread(final String urlString, final ImageView imageView) { if (drawableMap.containsKey(urlString)) { imageView.setImageDrawable(drawableMap.get(urlString)); }// w ww .j av a 2 s . co m final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageView.setImageDrawable((Drawable) message.obj); } }; Thread thread = new Thread() { @Override public void run() { //TODO : set imageView to a "pending" image Drawable drawable = fetchDrawable(urlString); Message message = handler.obtainMessage(1, drawable); handler.sendMessage(message); } }; thread.start(); }
From source file:com.pdfread.standardreader.net.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler */// w w w . jav a 2 s .c o m public AsyncHttpResponseHandler() { if (Looper.myLooper() != null) { handler = new Handler() { @Override public void handleMessage(Message msg) { AsyncHttpResponseHandler.this.handleMessage(msg); } }; } }
From source file:com.bellman.bible.android.view.activity.base.ProgressActivityBase.java
private void initialiseView() { // prepare to show no tasks msg noTasksMessageView = (TextView) findViewById(R.id.noTasksRunning); taskKillWarningView = (TextView) findViewById(R.id.progressStatusMessage); Iterator<Progress> jobsIterator = JobManager.iterator(); while (jobsIterator.hasNext()) { Progress job = jobsIterator.next(); findOrCreateUIControl(job);//from w w w . ja v a2s . c o m } // allow call back and continuation in the ui thread after JSword has been initialised final Handler uiHandler = new Handler(); final Runnable uiUpdaterRunnable = new Runnable() { @Override public void run() { Progress prog = progressNotificationQueue.poll(); if (prog != null) { updateProgress(prog); } } }; // listen for Progress changes and call the above Runnable to update the ui workListener = new WorkListener() { @Override public void workProgressed(WorkEvent ev) { callUiThreadUpdateHandler(ev); } @Override public void workStateChanged(WorkEvent ev) { callUiThreadUpdateHandler(ev); } private void callUiThreadUpdateHandler(WorkEvent ev) { Progress prog = ev.getJob(); progressNotificationQueue.offer(prog); // switch back to ui thread to continue uiHandler.post(uiUpdaterRunnable); } }; JobManager.addWorkListener(workListener); // give new jobs a chance to start then show 'No Job' msg if nothing running uiHandler.postDelayed(new Runnable() { @Override public void run() { if (!JobManager.iterator().hasNext()) { showNoTaskMsg(true); } } }, 4000); }