Java Code Examples for android.os.Handler

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/controller/.

Source file: MusicPlaylistController.java

  34 
vote

SongAdapter(Activity activity,ArrayList<PlaylistItem> items){
  super(activity,0,items);
  Handler handler=mNowPlayingHandler;
  if (handler != null) {
    Message msg=Message.obtain();
    Bundle bundle=msg.getData();
    bundle.putInt(BUNDLE_PLAYLIST_SIZE,items.size());
    msg.what=MESSAGE_PLAYLIST_SIZE;
    handler.sendMessage(msg);
  }
}
 

Example 2

From project Airports, under directory /src/com/nadmm/airports/donate/.

Source file: DonateActivity.java

  33 
vote

@Override public void onActivityCreated(Bundle savedInstanceState){
  mDonateDb=new DonateDatabase(getActivity());
  Handler handler=new Handler();
  mDonationsObserver=new DonationsObserver(handler);
  mBillingService=new BillingService();
  mBillingService.setContext(getActivity());
  super.onActivityCreated(savedInstanceState);
}
 

Example 3

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/camera/.

Source file: PreviewCallback.java

  32 
vote

@Override public void onPreviewFrame(byte[] data,Camera camera){
  Point cameraResolution=configManager.getCameraResolution();
  Handler thePreviewHandler=previewHandler;
  if (cameraResolution != null && thePreviewHandler != null) {
    Message message=thePreviewHandler.obtainMessage(previewMessage,cameraResolution.x,cameraResolution.y,data);
    message.sendToTarget();
    previewHandler=null;
  }
 else {
    Log.d(TAG,"Got preview callback, but no handler or resolution available");
  }
}
 

Example 4

From project Android-Terminal-Emulator, under directory /libraries/emulatorview/src/jackpal/androidterm/emulatorview/.

Source file: TermSession.java

  32 
vote

private void notifyNewOutput(){
  Handler writerHandler=mWriterHandler;
  if (writerHandler == null) {
    return;
  }
  writerHandler.sendEmptyMessage(NEW_OUTPUT);
}
 

Example 5

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: ShelvesActivity.java

  32 
vote

private void postUpdateBookCovers(){
  Handler handler=mScrollHandler;
  Message message=handler.obtainMessage(MESSAGE_UPDATE_BOOK_COVERS,ShelvesActivity.this);
  handler.removeMessages(MESSAGE_UPDATE_BOOK_COVERS);
  mPendingCoversUpdate=true;
  handler.sendMessage(message);
}
 

Example 6

From project android_8, under directory /src/com/defuzeme/gui/.

Source file: Gui.java

  32 
vote

public void timerDelayRemoveDialog(float time,final ProgressDialog progress){
  Handler handler=new Handler();
  handler.postDelayed(new Runnable(){
    public void run(){
      progress.dismiss();
    }
  }
,(long)time);
}
 

Example 7

From project android_packages_apps_QuickSearchBox, under directory /tests/src/com/android/quicksearchbox/.

Source file: SuggestionsProviderImplTest.java

  32 
vote

@Override protected void setUp() throws Exception {
  Config config=new Config(getContext());
  mTaskExecutor=new MockNamedTaskExecutor();
  Handler publishThread=new MockHandler();
  ShortcutRepository shortcutRepo=new MockShortcutRepository();
  mCorpora=new MockCorpora();
  mCorpora.addCorpus(MockCorpus.CORPUS_1);
  mCorpora.addCorpus(MockCorpus.CORPUS_2);
  CorpusRanker corpusRanker=new LexicographicalCorpusRanker(mCorpora);
  Logger logger=new NoLogger();
  mProvider=new SuggestionsProviderImpl(config,mTaskExecutor,publishThread,shortcutRepo,mCorpora,corpusRanker,logger);
  mProvider.setAllPromoter(new ConcatPromoter());
  mProvider.setSingleCorpusPromoter(new ConcatPromoter());
}
 

Example 8

From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/beintoosdkutility/.

Source file: ErrorDisplayer.java

  32 
vote

public static void showConnectionError(String Message,final Context ctx,Exception e){
  Handler handler=new Handler(){
    public void handleMessage(    Message msg){
      Toast.makeText(ctx,msg.getData().getString("SOMETHING"),Toast.LENGTH_SHORT).show();
    }
  }
;
  Message status=handler.obtainMessage();
  Bundle data=new Bundle();
  data.putString("SOMETHING",Message);
  status.setData(data);
  handler.sendMessage(status);
}
 

Example 9

From project AlarmApp-Android, under directory /src/org/alarmapp/util/.

Source file: LooperThread.java

  31 
vote

public void run(){
  try {
    Looper.prepare();
    handler=new Handler();
    latch.countDown();
    Looper.loop();
  }
 catch (  Throwable t) {
    LogEx.exception("halted due to an error",t);
  }
}
 

Example 10

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/navigation/.

Source file: ChooseDictionaryWord.java

  31 
vote

/** 
 * init the list adapter for the current list activity
 * @return
 */
protected void initialise(){
  Log.d(TAG,"Initialising");
  mMatchingKeyList=new ArrayList<Key>();
  setListAdapter(new ArrayAdapter<Key>(ChooseDictionaryWord.this,LIST_ITEM_TYPE,mMatchingKeyList));
  final Handler uiHandler=new Handler();
  Dialogs.getInstance().showHourglass();
  new Thread(new Runnable(){
    @Override public void run(){
      try {
        mDictionaryGlobalList=CurrentPageManager.getInstance().getCurrentDictionary().getCachedGlobalKeyList();
        Log.d(TAG,"Finished Initialising");
      }
 catch (      Throwable t) {
        Log.e(TAG,"Error creating dictionary key list");
        uiHandler.post(new Runnable(){
          @Override public void run(){
            showErrorMsg("Error preparing dictionary for use.");
          }
        }
);
      }
 finally {
        uiHandler.post(new Runnable(){
          @Override public void run(){
            dismissHourglass();
          }
        }
);
      }
    }
  }
).start();
}
 

Example 11

From project android-async-http, under directory /src/com/loopj/android/http/.

Source file: AsyncHttpResponseHandler.java

  31 
vote

/** 
 * Creates a new AsyncHttpResponseHandler
 */
public AsyncHttpResponseHandler(){
  if (Looper.myLooper() != null) {
    handler=new Handler(){
      public void handleMessage(      Message msg){
        AsyncHttpResponseHandler.this.handleMessage(msg);
      }
    }
;
  }
}
 

Example 12

From project android-bankdroid, under directory /src/com/liato/bankdroid/appwidget/.

Source file: BankdroidWidgetProvider.java

  31 
vote

@Override public void onStart(Intent intent,int startId){
  int appWidgetId=intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,-1);
  Context context=getApplicationContext();
  String action=intent.getAction();
  if (action == null)   return;
  if (action.equals(AutoRefreshService.BROADCAST_WIDGET_REFRESH)) {
    new WidgetUpdateTask(context,AppWidgetManager.getInstance(context),appWidgetId).execute();
  }
 else   if (action.equals(BankdroidWidgetProvider.ACTION_WIDGET_UNBLUR)) {
    unblurAppWidget(context,AppWidgetManager.getInstance(context),appWidgetId);
    Handler blurHandler=new Handler();
class BlurRunnable implements Runnable {
      private int mAppWidgetId;
      public BlurRunnable(      int appWidgetId){
        this.mAppWidgetId=appWidgetId;
      }
      @Override public void run(){
        Context context=getApplicationContext();
        blurAppWidget(context,AppWidgetManager.getInstance(context),mAppWidgetId);
      }
    }
    SharedPreferences defprefs=PreferenceManager.getDefaultSharedPreferences(context);
    Integer unblurTimeout=1000 * Integer.parseInt(defprefs.getString("widget_blur_balance_timeout","5"));
    blurHandler.postDelayed(new BlurRunnable(appWidgetId),unblurTimeout);
  }
 else   if (action.equals(BankdroidWidgetProvider.ACTION_WIDGET_BLUR)) {
    blurAppWidget(context,AppWidgetManager.getInstance(context),appWidgetId);
  }
}
 

Example 13

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/synchronisation/tracks/service/.

Source file: SynchronizationService.java

  31 
vote

@Override public void onCreate(){
  String ns=Context.NOTIFICATION_SERVICE;
  mNotificationManager=(NotificationManager)getSystemService(ns);
  contentView=new RemoteViews(getPackageName(),R.layout.synchronize_notification_layout);
  contentView.setProgressBar(R.id.progress_horizontal,100,50,true);
  contentView.setImageViewResource(R.id.image,R.drawable.shuffle_icon);
  mHandler=new Handler();
  mCheckTimer=new CheckTimer();
  mPerformSynch=new PerformSynch();
  mHandler.post(mCheckTimer);
}
 

Example 14

From project android-thaiime, under directory /common/src/com/android/common/contacts/.

Source file: BaseEmailAddressAdapter.java

  31 
vote

public BaseEmailAddressAdapter(Context context,int preferredMaxResultCount){
  super(context);
  mContentResolver=context.getContentResolver();
  mPreferredMaxResultCount=preferredMaxResultCount;
  mHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
      showSearchPendingIfNotComplete(msg.arg1);
    }
  }
;
}
 

Example 15

From project android-voip-service, under directory /src/main/java/net/chrislehmann/sipservice/service/.

Source file: SipService.java

  31 
vote

public void run(){
  Looper.prepare();
  mHandler=new Handler(){
    public void handleMessage(    Message msg){
      Intent intent=(Intent)msg.obj;
      handleIntent(intent);
    }
  }
;
  Looper.loop();
}
 

Example 16

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/remotesandbox/ui/base/.

Source file: ReloadableActionBarActivity.java

  31 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.menu_refresh:
    getSyncBridge().sync(new Handler());
  break;
}
return super.onOptionsItemSelected(item);
}
 

Example 17

From project androidquery, under directory /src/com/androidquery/util/.

Source file: AQUtility.java

  31 
vote

public static Handler getHandler(){
  if (handler == null) {
    handler=new Handler(Looper.getMainLooper());
  }
  return handler;
}
 

Example 18

From project android_7, under directory /src/org/immopoly/android/app/.

Source file: UserLoginActivity.java

  31 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  tracker=GoogleAnalyticsTracker.getInstance();
  tracker.startNewSession(TrackingManager.UA_ACCOUNT,Const.ANALYTICS_INTERVAL,getApplicationContext());
  tracker.trackPageView(TrackingManager.VIEW_LOGIN);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  toggleProgressHandler=new Handler();
  setContentView(R.layout.user_login_activity);
}
 

Example 19

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/bluetooth/.

Source file: BluetoothDiscoverableEnabler.java

  31 
vote

public BluetoothDiscoverableEnabler(Context context,CheckBoxPreference checkBoxPreference){
  mContext=context;
  mUiHandler=new Handler();
  mCheckBoxPreference=checkBoxPreference;
  checkBoxPreference.setPersistent(false);
  mLocalManager=LocalBluetoothManager.getInstance(context);
  if (mLocalManager == null) {
    checkBoxPreference.setEnabled(false);
  }
}
 

Example 20

From project android_frameworks_ex, under directory /common/java/com/android/common/.

Source file: NetworkConnectivityListener.java

  31 
vote

@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION) || mListening == false) {
    Log.w(TAG,"onReceived() called with " + mState.toString() + " and "+ intent);
    return;
  }
  boolean noConnectivity=intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,false);
  if (noConnectivity) {
    mState=State.NOT_CONNECTED;
  }
 else {
    mState=State.CONNECTED;
  }
  mNetworkInfo=(NetworkInfo)intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
  mOtherNetworkInfo=(NetworkInfo)intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
  mReason=intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
  mIsFailover=intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER,false);
  if (DBG) {
    Log.d(TAG,"onReceive(): mNetworkInfo=" + mNetworkInfo + " mOtherNetworkInfo = "+ (mOtherNetworkInfo == null ? "[none]" : mOtherNetworkInfo + " noConn=" + noConnectivity)+ " mState="+ mState.toString());
  }
  Iterator<Handler> it=mHandlers.keySet().iterator();
  while (it.hasNext()) {
    Handler target=it.next();
    Message message=Message.obtain(target,mHandlers.get(target));
    target.sendMessage(message);
  }
}
 

Example 21

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/data/.

Source file: LocalAlbumSet.java

  31 
vote

public LocalAlbumSet(Path path,GalleryApp application){
  super(path,nextVersionNumber());
  mApplication=application;
  mHandler=new Handler(application.getMainLooper());
  mType=getTypeFromPath(path);
  mNotifierImage=new ChangeNotifier(this,mWatchUriImage,application);
  mNotifierVideo=new ChangeNotifier(this,mWatchUriVideo,application);
  mName=application.getResources().getString(R.string.set_label_local_albums);
}
 

Example 22

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: MediaFeed.java

  31 
vote

public void onResume(){
  final Context context=mContext;
  final DataSource dataSource=mDataSource;
  if (context == null || dataSource == null)   return;
  final String[] uris=dataSource.getDatabaseUris();
  final HashMap<String,ContentObserver> observers=mContentObservers;
  if (context instanceof Gallery) {
    final Gallery gallery=(Gallery)context;
    final ContentResolver cr=context.getContentResolver();
    if (uris != null) {
      final int numUris=uris.length;
      for (int i=0; i < numUris; ++i) {
        final String uri=uris[i];
        final ContentObserver presentObserver=observers.get(uri);
        if (presentObserver == null) {
          final Handler handler=App.get(context).getHandler();
          final ContentObserver observer=new ContentObserver(handler){
            public void onChange(            boolean selfChange){
              if (!mWaitingForMediaScanner) {
                MediaFeed.this.refresh(new String[]{uri});
              }
            }
          }
;
          cr.registerContentObserver(Uri.parse(uri),true,observer);
          observers.put(uri,observer);
        }
      }
    }
  }
  refresh();
}
 

Example 23

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/echoserver/.

Source file: EchoServer.java

  31 
vote

EchoMachine(WriteCallback callback,boolean dumpWhenFull){
  this.callback=callback;
  this.dumpWhenFull=dumpWhenFull;
  dataQueue=new LinkedBlockingQueue<byte[]>(QUEUE_SIZE);
  handler=new Handler(this);
}
 

Example 24

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: EmergencyCallbackModeExitDialog.java

  31 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (!Boolean.parseBoolean(SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
    finish();
  }
  mHandler=new Handler();
  Thread waitForConnectionCompleteThread=new Thread(null,mTask,"EcmExitDialogWaitThread");
  waitForConnectionCompleteThread.start();
  mPhone=PhoneFactory.getDefaultPhone();
  mPhone.registerForEcmTimerReset(mTimerResetHandler,ECM_TIMER_RESET,null);
  IntentFilter filter=new IntentFilter();
  filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
  registerReceiver(mEcmExitReceiver,filter);
}
 

Example 25

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.

Source file: TagService.java

  31 
vote

public static void saveMyMessage(final Context context,final NdefMessage msg,final SaveCallbacks callbacks){
  final Handler handler=new Handler();
  Thread thread=new Thread(){
    @Override public void run(){
      context.startService(new Intent(context,EmptyService.class));
      ContentValues values=NdefMessages.toValues(context,msg,false,true,System.currentTimeMillis());
      context.startService(new Intent(context,EmptyService.class));
      final Uri result=context.getContentResolver().insert(NdefMessages.CONTENT_URI,values);
      handler.post(new Runnable(){
        @Override public void run(){
          callbacks.onSaveComplete(result);
        }
      }
);
      context.stopService(new Intent(context,EmptyService.class));
    }
  }
;
  thread.setPriority(Thread.MIN_PRIORITY);
  thread.start();
}
 

Example 26

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/deprecated/voice/.

Source file: SoundIndicator.java

  31 
vote

public SoundIndicator(Context context,AttributeSet attrs){
  super(context,attrs);
  mFrontDrawable=getDrawable();
  BitmapDrawable edgeDrawable=(BitmapDrawable)context.getResources().getDrawable(R.drawable.vs_popup_mic_edge);
  mEdgeBitmap=edgeDrawable.getBitmap();
  mEdgeBitmapOffset=mEdgeBitmap.getHeight() / 2;
  mDrawingBuffer=Bitmap.createBitmap(mFrontDrawable.getIntrinsicWidth(),mFrontDrawable.getIntrinsicHeight(),Config.ARGB_8888);
  mBufferCanvas=new Canvas(mDrawingBuffer);
  mClearPaint=new Paint();
  mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  mMultPaint=new Paint();
  mMultPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
  mHandler=new Handler();
}
 

Example 27

From project android_wallpaper_flier, under directory /src/fi/harism/wallpaper/flier/.

Source file: FlierRenderer.java

  31 
vote

@Override public void onSurfaceCreated(GL10 unused,EGLConfig config){
  GLES20.glGetBooleanv(GLES20.GL_SHADER_COMPILER,mShaderCompilerSupported,0);
  if (mShaderCompilerSupported[0] == false) {
    Handler handler=new Handler(mContext.getMainLooper());
    handler.post(new Runnable(){
      @Override public void run(){
        Toast.makeText(mContext,R.string.error_shader_compiler,Toast.LENGTH_LONG).show();
      }
    }
);
    return;
  }
  mShaderCopy.setProgram(mContext.getString(R.string.shader_copy_vs),mContext.getString(R.string.shader_copy_fs));
  mShaderFill.setProgram(mContext.getString(R.string.shader_fill_vs),mContext.getString(R.string.shader_fill_fs));
  mFlierWaves.onSurfaceCreated(mContext);
  mFlierPlane.onSurfaceCreated(mContext);
  mFlierClouds.onSurfaceCreated(mContext);
}
 

Example 28

From project android_wallpaper_flowers, under directory /src/fi/harism/wallpaper/flowers/.

Source file: FlowerRenderer.java

  31 
vote

@Override public void onSurfaceCreated(GL10 unused,EGLConfig config){
  GLES20.glGetBooleanv(GLES20.GL_SHADER_COMPILER,mShaderCompilerSupported,0);
  if (mShaderCompilerSupported[0] == false) {
    Handler handler=new Handler(mContext.getMainLooper());
    handler.post(new Runnable(){
      @Override public void run(){
        Toast.makeText(mContext,R.string.error_shader_compiler,Toast.LENGTH_LONG).show();
      }
    }
);
    return;
  }
  mShaderCopy.setProgram(mContext.getString(R.string.shader_copy_vs),mContext.getString(R.string.shader_copy_fs));
  mShaderBackground.setProgram(mContext.getString(R.string.shader_background_vs),mContext.getString(R.string.shader_background_fs));
  mFlowerObjects.onSurfaceCreated(mContext);
}
 

Example 29

From project apps-for-android, under directory /RingsExtended/src/com/example/android/rings_extended/.

Source file: FastScrollView.java

  31 
vote

@Override public boolean onTouchEvent(MotionEvent me){
  if (me.getAction() == MotionEvent.ACTION_DOWN) {
    if (me.getX() > getWidth() - mThumbW && me.getY() >= mThumbY && me.getY() <= mThumbY + mThumbH) {
      mDragging=true;
      if (mListAdapter == null && mList != null) {
        getSections();
      }
      cancelFling();
      return true;
    }
  }
 else   if (me.getAction() == MotionEvent.ACTION_UP) {
    if (mDragging) {
      mDragging=false;
      final Handler handler=mHandler;
      handler.removeCallbacks(mScrollFade);
      handler.postDelayed(mScrollFade,1000);
      return true;
    }
  }
 else   if (me.getAction() == MotionEvent.ACTION_MOVE) {
    if (mDragging) {
      final int viewHeight=getHeight();
      mThumbY=(int)me.getY() - mThumbH + 10;
      if (mThumbY < 0) {
        mThumbY=0;
      }
 else       if (mThumbY + mThumbH > viewHeight) {
        mThumbY=viewHeight - mThumbH;
      }
      if (mScrollCompleted) {
        scrollTo((float)mThumbY / (viewHeight - mThumbH));
      }
      return true;
    }
  }
  return super.onTouchEvent(me);
}
 

Example 30

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/.

Source file: ScheduleFragment.java

  31 
vote

@Override public void onResume(){
  super.onResume();
  requery();
  getActivity().getContentResolver().registerContentObserver(ScheduleContract.Sessions.CONTENT_URI,true,mSessionChangesObserver);
  final IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_TIME_TICK);
  filter.addAction(Intent.ACTION_TIME_CHANGED);
  filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
  getActivity().registerReceiver(mReceiver,filter,null,new Handler());
}
 

Example 31

From project BazaarUtils, under directory /src/com/android/vending/licensing/.

Source file: LicenseChecker.java

  31 
vote

/** 
 * @param context a Context
 * @param policy implementation of Policy
 * @param encodedPublicKey Base64-encoded RSA public key
 * @throws IllegalArgumentException if encodedPublicKey is invalid
 */
public LicenseChecker(Context context,Policy policy,String encodedPublicKey){
  mContext=context;
  mPolicy=policy;
  mPublicKey=generatePublicKey(encodedPublicKey);
  mPackageName=mContext.getPackageName();
  mVersionCode=getVersionCode(context,mPackageName);
  HandlerThread handlerThread=new HandlerThread("background thread");
  handlerThread.start();
  mHandler=new Handler(handlerThread.getLooper());
}
 

Example 32

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/controls/.

Source file: ReaderWebView.java

  31 
vote

public void onClickVerse(String id){
  if (!isStudyMode || !id.contains("verse")) {
    return;
  }
  Integer verse=Integer.parseInt(id.split("_")[1]);
  if (verse == null) {
    return;
  }
  if (selectedVerse.contains(verse)) {
    selectedVerse.remove(verse);
    loadUrl("javascript: deselectVerse('verse_" + verse + "');");
  }
 else {
    selectedVerse.add(verse);
    loadUrl("javascript: selectVerse('verse_" + verse + "');");
  }
  try {
    Handler mHandler=getHandler();
    mHandler.post(new Runnable(){
      public void run(){
        notifyListeners(ChangeCode.onChangeSelection);
      }
    }
);
  }
 catch (  NullPointerException e) {
    Log.e(TAG,e.getMessage());
  }
}
 

Example 33

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/ui/.

Source file: StockPhotoLoader.java

  31 
vote

/** 
 * Sends a message to this thread to load requested photos.
 */
public void requestLoading(){
  if (mLoaderThreadHandler == null) {
    mLoaderThreadHandler=new Handler(getLooper(),this);
  }
  mLoaderThreadHandler.sendEmptyMessage(0);
}
 

Example 34

From project bookmarktodesktop-android-application, under directory /src/be/vbsteven/bmtodesk/.

Source file: SendAllCurrentBookmarksActivity.java

  31 
vote

@Override protected void onCreate(final Bundle savedInstanceState){
  setTheme(android.R.style.Theme_Light_NoTitleBar);
  super.onCreate(savedInstanceState);
  handler=new Handler();
  setContentView(R.layout.sendallcurrent);
  final Button button=(Button)findViewById(R.id.but_sendall);
  button.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    final View v){
      sendAllBookmarks();
    }
  }
);
}
 

Example 35

From project box-android-sdk, under directory /BoxAndroidLibrary/src/com/box/androidlib/activities/.

Source file: BoxAuthentication.java

  31 
vote

/** 
 * Try to get an auth token. Due to a bug with Android webviews, it is possible for WebViewClient.onPageFinished to be called before the page has actually loaded. So we may have to try the getAuthToken request several times. http://stackoverflow.com/questions/3702627/onpagefinished-not-firing-correctly-when-rendering-web-page
 * @param ticket Box ticket
 * @param tries the number of attempts that have been made
 */
private void getAuthToken(final String ticket,final int tries){
  if (tries >= GET_AUTH_TOKEN_MAX_RETRIES) {
    return;
  }
  final Handler handler=new Handler();
  box.getAuthToken(ticket,new GetAuthTokenListener(){
    @Override public void onComplete(    final User user,    final String status){
      if (status.equals("get_auth_token_ok") && user != null) {
        onAuthTokenRetreived(user.getAuthToken());
      }
 else       if (status.equals("error_unknown_http_response_code")) {
        handler.postDelayed(new Runnable(){
          @Override public void run(){
            getAuthToken(ticket,tries + 1);
          }
        }
,GET_AUTH_TOKEN_INTERVAL);
      }
    }
    @Override public void onIOException(    final IOException e){
    }
  }
);
}
 

Example 36

From project BSPAN---Bluetooth-Sensor-Processing-for-Android, under directory /AndroidBTService/src/com/t2/biofeedback/device/zephyr/.

Source file: ZephyrDevice.java

  31 
vote

@Override protected void onDeviceConnected(){
  super.onDeviceConnected();
  Handler handler=new Handler();
  handler.postDelayed(new Runnable(){
    public void run(){
      Log.v(TAG,"Tell the device to start sending periodic data.");
      ZephyrMessage m=new ZephyrMessage(0xA4,new byte[]{(byte)0,(byte)0,(byte)0x10,(byte)0x27},ZephyrMessage.ETX);
      instance.write(m);
      Handler handler1=new Handler();
      handler1.postDelayed(new Runnable(){
        public void run(){
          ZephyrMessage m=new ZephyrMessage(0x14,new byte[]{0x01},ZephyrMessage.ETX);
          instance.write(m);
        }
      }
,1000);
    }
  }
,1000);
}
 

Example 37

From project btmidi, under directory /BluetoothMidiPlayer/src/com/noisepages/nettoyeur/midi/player/.

Source file: BluetoothMidiPlayerService.java

  31 
vote

MidiRunnable(Iterator<CompoundMidiEvent> events,HandlerThread thread){
  this.handler=new Handler(thread.getLooper());
  this.events=events;
  currentEvent=events.next();
  t0=SystemClock.uptimeMillis() - currentEvent.timeInMillis + 250;
}
 

Example 38

From project AChartEngine, under directory /achartengine/src/org/achartengine/.

Source file: GraphicalView.java

  30 
vote

/** 
 * Creates a new graphical view.
 * @param context the context
 * @param chart the chart to be drawn
 */
public void setup(Context context){
  AbstractChart chart=buildChart();
  mChart=chart;
  mHandler=new Handler();
  if (mChart instanceof XYChart) {
    mRenderer=((XYChart)mChart).getRenderer();
  }
 else {
    mRenderer=((RoundChart)mChart).getRenderer();
  }
  if (mRenderer.isZoomButtonsVisible()) {
    zoomInImage=BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom_in.png"));
    zoomOutImage=BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom_out.png"));
    fitZoomImage=BitmapFactory.decodeStream(GraphicalView.class.getResourceAsStream("image/zoom-1.png"));
  }
  if (mRenderer instanceof XYMultipleSeriesRenderer && ((XYMultipleSeriesRenderer)mRenderer).getMarginsColor() == XYMultipleSeriesRenderer.NO_COLOR) {
    ((XYMultipleSeriesRenderer)mRenderer).setMarginsColor(mPaint.getColor());
  }
  if (mRenderer.isZoomEnabled() && mRenderer.isZoomButtonsVisible() || mRenderer.isExternalZoomEnabled()) {
    mZoomIn=new Zoom(mChart,true,mRenderer.getZoomRate());
    mZoomOut=new Zoom(mChart,false,mRenderer.getZoomRate());
    mFitZoom=new FitZoom(mChart);
  }
  int version=7;
  try {
    version=Integer.valueOf(Build.VERSION.SDK);
  }
 catch (  Exception e) {
  }
  if (version < 7) {
    mTouchHandler=new TouchHandlerOld(this,mChart);
  }
 else {
    mTouchHandler=new TouchHandler(this,mChart);
  }
}
 

Example 39

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/.

Source file: SelectZoomDetail.java

  30 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
  setContentView(R.layout.layout_report_picture_zoom);
  photo=((ImageView)findViewById(R.id.ImageViewPictoBG));
  picto=((PictoView)findViewById(R.id.ViewPicto));
  setPictureToImageView(ReportDetailsActivity.CAPTURE_FAR,photo);
  getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.icon_nouveau_rapport);
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      LayoutParams params=picto.getLayoutParams();
      params.width=photo.getWidth();
      params.height=photo.getHeight();
      picto.setLayoutParams(params);
    }
  }
,1000);
  ((EditText)SelectZoomDetail.this.findViewById(R.id.Comment_img)).setText(getIntent().getStringExtra("comment"));
  ((EditText)SelectZoomDetail.this.findViewById(R.id.Comment_img)).setVisibility(View.INVISIBLE);
  ((Button)findViewById(R.id.ButtonViewPicto)).setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      try {
        layout_with=picto.getWidth();
        layout_height=picto.getHeight();
        Log.d(Constants.PROJECT_TAG,"Margin: " + (((photo.getWidth() + layout_with) / 2) - photo.getWidth()) * photo.getWidth() / photo_width + "," + (((photo.getHeight() + layout_height) / 2) - photo.getHeight()) * photo.getHeight() / photo_heigth);
        if (Constants.DEBUGMODE)         Log.d(Constants.PROJECT_TAG,"onClick : Photo widht/height" + photo.getWidth() + "/"+ photo.getHeight()+ " ImageView: "+ photo_width+ "/"+ photo_heigth);
        picto.setSupport(picture,photo_width,photo_heigth,getApplicationContext());
        Intent data=new Intent();
        data.putExtra("comment",((EditText)SelectZoomDetail.this.findViewById(R.id.Comment_img)).getText().toString());
        setResult(RESULT_OK,data);
        finish();
      }
 catch (      FileNotFoundException e) {
        Log.e(Constants.PROJECT_TAG,"Picture save error",e);
      }
    }
  }
);
}
 

Example 40

From project alljoyn_java, under directory /ice/org/alljoyn/bus/.

Source file: AllJoynAndroidExt.java

  30 
vote

public AllJoynAndroidExt(Context sContext){
  ctx=sContext;
  wifiMgr=(WifiManager)ctx.getSystemService(Context.WIFI_SERVICE);
  try {
    if (!wifiMgr.startScan()) {
      Log.v(TAG,"startScan() returned error");
    }
    if (tHandler == null) {
      tHandler=new Handler();
    }
    tUpdateTimerRunnable=new Runnable(){
      public void run(){
        updateTimer();
      }
    }
;
    tHandler.postDelayed(tUpdateTimerRunnable,0);
    if (alarmMgr == null) {
      alarmMgr=(AlarmManager)ctx.getSystemService(Context.ALARM_SERVICE);
      Intent alarmIntent=new Intent(ctx,ScanResultsReceiver.class);
      PendingIntent pi=PendingIntent.getBroadcast(ctx,0,alarmIntent,0);
      alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),1000 * 60 * 10,pi);
    }
  }
 catch (  SecurityException se) {
    Log.e(TAG,"Possible missing permissions needed to run ICE over AllJoyn. Discovery over ICE in AllJoyn may not work due to this");
    se.printStackTrace();
  }
}
 

Example 41

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: ScoreBoardActivity.java

  30 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  amenTypeThin=AmenoidApp.getInstance().getAmenTypeThin();
  amenTypeBold=AmenoidApp.getInstance().getAmenTypeBold();
  handler=new Handler();
  errorDialog=new AlertDialog.Builder(this);
  Log.d(TAG,"onCreate");
  service=AmenoidApp.getInstance().getService();
  setContentView(R.layout.score_board);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle("Scorecard");
  progressBar=(ProgressBar)findViewById(R.id.progress_listview);
  list=(ListView)findViewById(android.R.id.list);
  View header=getLayoutInflater().inflate(R.layout.score_header,null,false);
  list.addHeaderView(header);
  Intent startingIntent=getIntent();
  currentTopic=startingIntent.getParcelableExtra(Constants.EXTRA_TOPIC);
  String currentTopicName=startingIntent.getStringExtra(Constants.EXTRA_TOPIC_NAME);
  int currentObjectKind=startingIntent.getIntExtra(Constants.EXTRA_OBJEKT_KIND,0);
  Log.d(TAG,"currentTopic: " + currentTopic);
  Log.d(TAG,"currentTopicName: " + currentTopicName);
  if (currentTopic != null) {
    new TopicStatementsTask(this).executeOnThreadPool(currentTopic.getId() + "");
  }
 else {
    new TopicStatementsTask(this).executeOnThreadPool(currentTopicName);
  }
  adapter=new ScoreBoardAdapter(this,android.R.layout.simple_list_item_1,new ArrayList<RankedStatements>());
  setListAdapter(adapter);
  description=(TextView)findViewById(R.id.description_scope);
  description.setTypeface(amenTypeBold);
  if (currentTopic != null) {
    final String topicAsSentence=topicAsSentence(currentTopic);
    description.setText(topicAsSentence);
    actionBar.setSubtitle(topicAsSentence);
  }
}
 

Example 42

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: ConflictsActivity.java

  30 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onSuccess(){
  final List<ConflictsEntity> newList=Mobeelizer.getDatabase().list(ConflictsEntity.class);
  final List<ConflictsEntity> oldList=mAdapter.getItems();
  boolean showAnim=mergeLists(oldList,newList);
  mAdapter.sort(new ConflictsEntity());
  long conflictsCount=Mobeelizer.getDatabase().find(ConflictsEntity.class).add(MobeelizerRestrictions.isConflicted()).count();
  showWarning(conflictsCount > 0);
  mAdapter.notifyDataSetChanged();
  mList.setSelection(0);
  final UserType loggedUserType=mUserType;
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      if (loggedUserType != mUserType) {
        return;
      }
      mAdapter.clear();
      mAdapter.addAll(newList);
      mAdapter.sort(new ConflictsEntity());
      mAdapter.notifyDataSetChanged();
    }
  }
,showAnim ? 2000 : 0);
  if (mSyncDialog != null) {
    mSyncDialog.dismiss();
  }
}
 

Example 43

From project android-client, under directory /xwiki-android-components/src/org/xwiki/android/components/navigator/.

Source file: XWikiNavigatorActivity.java

  30 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.xwikinavigator);
  if (getIntent().getExtras().getString(INTENT_EXTRA_PUT_USERNAME) != null && getIntent().getExtras().getString(INTENT_EXTRA_PUT_PASSWORD) != null) {
    xwikiExpandListAdapter=new XWikiExpandListAdapter(this,getExpandableListView(),getIntent().getExtras().getString(INTENT_EXTRA_PUT_URL),getIntent().getExtras().getString(INTENT_EXTRA_PUT_USERNAME),getIntent().getExtras().getString(INTENT_EXTRA_PUT_PASSWORD));
  }
  handler=new Handler(){
    @Override public void handleMessage(    Message msg){
      super.handleMessage(msg);
      if (msg.arg1 == 0) {
        if (xwikiExpandListAdapter.getIsSelected()) {
          wikiName=xwikiExpandListAdapter.wikiName;
          spaceName=xwikiExpandListAdapter.spaceName;
          pageName=xwikiExpandListAdapter.pageName;
          getIntent().putExtra(INTENT_EXTRA_GET_WIKI_NAME,wikiName);
          getIntent().putExtra(INTENT_EXTRA_GET_SPACE_NAME,spaceName);
          getIntent().putExtra(INTENT_EXTRA_GET_PAGE_NAME,pageName);
          setResult(Activity.RESULT_OK,getIntent());
          finish();
        }
      }
    }
  }
;
  xwikiExpandListAdapter.setHandler(handler);
  setListAdapter(xwikiExpandListAdapter);
}
 

Example 44

From project android-donations-lib, under directory /org_donations/src/org/donations/.

Source file: DonationsActivity.java

  30 
vote

/** 
 * Called when the activity is first created.
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.donations__activity);
  if (DonationsUtils.getResourceBoolean(this,"donations__flattr_enabled")) {
    ViewStub flattrViewStub=(ViewStub)findViewById(R.id.donations__flattr_stub);
    flattrViewStub.inflate();
    buildFlattrView();
  }
  mGoogleEnabled=DonationsUtils.getResourceBoolean(this,"donations__google_enabled");
  if (mGoogleEnabled) {
    ViewStub googleViewStub=(ViewStub)findViewById(R.id.donations__google_stub);
    googleViewStub.inflate();
    CATALOG=DonationsUtils.getResourceStringArray(this,"donations__google_catalog");
    mGoogleSpinner=(Spinner)findViewById(R.id.donations__google_android_market_spinner);
    ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this,R.array.donations__google_android_market_promt_array,android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mGoogleSpinner.setAdapter(adapter);
    mHandler=new Handler();
    mDonatePurchaseObserver=new DonatePurchaseObserver(mHandler);
    mBillingService=new BillingService();
    mBillingService.setContext(this);
  }
  if (DonationsUtils.getResourceBoolean(this,"donations__paypal_enabled")) {
    ViewStub paypalViewStub=(ViewStub)findViewById(R.id.donations__paypal_stub);
    paypalViewStub.inflate();
  }
}
 

Example 45

From project android-joedayz, under directory /Proyectos/LectorFeedsJqueryMobile/src/com/mycompany/.

Source file: Inicio.java

  30 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  webView=new WebView(this);
  setContentView(webView);
  webView.getSettings().setJavaScriptEnabled(true);
  webView.getSettings().setDomStorageEnabled(true);
  webView.getSettings().setGeolocationEnabled(true);
  webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
  webView.clearHistory();
  webView.clearCache(true);
  webView.clearFormData();
  final Context myApp=this;
  handler=new Handler();
  webView.addJavascriptInterface(this,"lectorSupport");
  loadPage(VIEW_INTRO);
}
 

Example 46

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: MapView.java

  30 
vote

private void setupZoomControls(){
  this.zoomControls=new ZoomControls(this.activity);
  this.zoomControls.setVisibility(View.GONE);
  this.zoomControls.setOnZoomInClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      zoom((byte)1,1);
    }
  }
);
  this.zoomControls.setOnZoomOutClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      zoom((byte)-1,1);
    }
  }
);
  this.zoomControlsHideHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
      hideZoomZontrols();
    }
  }
;
  addView(this.zoomControls,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));
}
 

Example 47

From project androidpn, under directory /androidpn-client/src/org/androidpn/client/.

Source file: XmppManager.java

  30 
vote

public XmppManager(NotificationService notificationService){
  context=notificationService;
  taskSubmitter=notificationService.getTaskSubmitter();
  taskTracker=notificationService.getTaskTracker();
  sharedPrefs=notificationService.getSharedPreferences();
  xmppHost=sharedPrefs.getString(Constants.XMPP_HOST,"localhost");
  xmppPort=sharedPrefs.getInt(Constants.XMPP_PORT,5222);
  username=sharedPrefs.getString(Constants.XMPP_USERNAME,"");
  password=sharedPrefs.getString(Constants.XMPP_PASSWORD,"");
  connectionListener=new PersistentConnectionListener(this);
  notificationPacketListener=new NotificationPacketListener(this);
  handler=new Handler();
  taskList=new ArrayList<Runnable>();
  reconnection=new ReconnectionThread(this);
}
 

Example 48

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: ThumbnailLoader.java

  30 
vote

/** 
 * Used for loading and decoding thumbnails from files.
 * @author PhilipHayes
 * @param context Current application context.
 */
public ThumbnailLoader(Context context){
  mContext=context;
  purger=new Runnable(){
    @Override public void run(){
      Log.d(TAG,"Purge Timer hit; Clearing Caches.");
      clearCaches();
    }
  }
;
  purgeHandler=new Handler();
  mExecutor=Executors.newFixedThreadPool(POOL_SIZE);
  mBlacklist=new ArrayList<String>();
  mSoftBitmapCache=new ConcurrentHashMap<String,SoftReference<Bitmap>>(MAX_CACHE_CAPACITY / 2);
  mHardBitmapCache=new LinkedHashMap<String,Bitmap>(MAX_CACHE_CAPACITY / 2,0.75f,true){
    /** 
 */
    private static final long serialVersionUID=1347795807259717646L;
    @Override protected boolean removeEldestEntry(    LinkedHashMap.Entry<String,Bitmap> eldest){
      if (size() > MAX_CACHE_CAPACITY) {
        mSoftBitmapCache.put(eldest.getKey(),new SoftReference<Bitmap>(eldest.getValue()));
        return true;
      }
 else {
        return false;
      }
    }
  }
;
}
 

Example 49

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/voice/.

Source file: IntentApiTrigger.java

  30 
vote

public IntentApiTrigger(InputMethodService inputMethodService){
  mInputMethodService=inputMethodService;
  mServiceBridge=new ServiceBridge(new Callback(){
    public void onRecognitionResult(    String recognitionResult){
      postResult(recognitionResult);
    }
  }
);
  mUpperCaseChars=new HashSet<Character>();
  mUpperCaseChars.add('.');
  mUpperCaseChars.add('!');
  mUpperCaseChars.add('?');
  mUpperCaseChars.add('\n');
  mHandler=new Handler();
}
 

Example 50

From project Apertiurm-Androind-app-devlopment, under directory /ApertiumAndroid/src/org/apertium/android/.

Source file: ApertiumActivity.java

  30 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  thisActivity=this;
  getExtrasData();
  appPreference=new AppPreference(thisActivity);
  databaseHandler=new DatabaseHandler(thisActivity);
  rulesHandler=new RulesHandler(thisActivity);
  clipboardHandler=new ClipboardHandler(thisActivity);
  handler=new Handler();
  CrashRecovery();
  FileManager.setDIR();
  updateDirChanges();
  if (currentMode == null) {
    currentMode=rulesHandler.getCurrentMode();
  }
 else {
    rulesHandler.setCurrentMode(currentMode);
  }
  Log.i(TAG,"Current mode = " + currentMode + ", Cache = "+ appPreference.isCacheEnabled()+ ", Clipboard push get = "+ appPreference.isClipBoardPushEnabled()+ appPreference.isClipBoardGetEnabled());
  translationMode=databaseHandler.getMode(currentMode);
  if (translationMode != null && translationMode.isValid()) {
    try {
      Log.i(TAG,"ExtractPath =" + rulesHandler.ExtractPathCurrentPackage() + ", Jar= "+ rulesHandler.PathCurrentPackage());
      Translator.setBase(rulesHandler.ExtractPathCurrentPackage(),rulesHandler.getClassLoader());
      Translator.setDelayedNodeLoadingEnabled(true);
      Translator.setMemmappingEnabled(true);
      Translator.setParallelProcessingEnabled(false);
      Translator.setCacheEnabled(appPreference.isCacheEnabled());
    }
 catch (    Exception e) {
      Log.e(TAG,"Error while loading class" + e);
      e.printStackTrace();
    }
  }
 else {
    rulesHandler.clearCurrentMode();
  }
  initView();
}
 

Example 51

From project blokish, under directory /src/org/scoutant/blokish/.

Source file: BusyIndicator.java

  30 
vote

public BusyIndicator(Context ctx,View view){
  this.view=view;
  view.setVisibility(View.INVISIBLE);
  uiHandler=new Handler();
  this.drawable=ctx.getResources().getDrawable(R.drawable.spinner_blue_76);
  animation=new RotateAnimation(0,360,RotateAnimation.RELATIVE_TO_SELF,0.5f,RotateAnimation.RELATIVE_TO_SELF,0.5f);
  animation.setRepeatCount(Animation.INFINITE);
  final int cycles=12;
  animation.setInterpolator(new Interpolator(){
    public float getInterpolation(    float input){
      return ((int)(input * cycles)) / (float)cycles;
    }
  }
);
  animation.setDuration(1800);
  animation.setStartTime(RotateAnimation.START_ON_FIRST_FRAME);
  animation.setStartOffset(0);
}
 

Example 52

From project agit, under directory /agit/src/main/java/com/madgag/agit/operations/.

Source file: GitAsyncTask.java

  29 
vote

@Inject public GitAsyncTask(Application application,@Named("uiThread") Handler handler,@Assisted GitOperation operation,@Assisted OperationLifecycleSupport lifecycleSupport){
  super(application);
  handler(handler);
  this.operation=operation;
  this.lifecycleSupport=lifecycleSupport;
}
 

Example 53

From project andlytics, under directory /src/com/github/andlyticsproject/admob/.

Source file: AdmobAuthenticationUtilities.java

  29 
vote

/** 
 * Connects to the Voiper server, authenticates the provided username and password.
 * @param username The user's username
 * @param password The user's password
 * @param handler The hander instance from the calling UI thread.
 * @param context The context of the calling Activity.
 * @return boolean The boolean result indicating whether the user wassuccessfully authenticated.
 */
public static String authenticate(String username,String password,Handler handler,final Context context){
  try {
    String token=AdmobRequest.login(username,password);
    sendResult("true",handler,context);
    return token;
  }
 catch (  NetworkException e) {
    Log.e(TAG,"Unsuccessful Admob authentication, network error");
    sendResult(AdmobRequest.ERROR_NETWORK_ERROR,handler,context);
    return AdmobRequest.ERROR_NETWORK_ERROR;
  }
catch (  AdmobInvalidRequestException e) {
    Log.e(TAG,"Unsuccessful Admob authentication, google accounts are not supported");
    sendResult(AdmobRequest.ERROR_REQUESET_INVALID,handler,context);
    return null;
  }
catch (  AdmobRateLimitExceededException e) {
    Log.e(TAG,"Unsuccessful Admob authentication, rate limit excceded");
    sendResult(AdmobRequest.ERROR_RATE_LIMIT_EXCEEDED,handler,context);
    return null;
  }
catch (  Exception e) {
    Log.e(TAG,"Unsuccessful Admob authentication");
    sendResult("false",handler,context);
    return null;
  }
}
 

Example 54

From project android-client_1, under directory /src/com/googlecode/asmack/sync/.

Source file: LoginTestThread.java

  29 
vote

/** 
 * Create a new login test thread for the given credentials.
 * @param username The user jid.
 * @param password The user password.
 * @param handler The result handler.
 * @param authenticatorActivity The authenticator activity.
 */
public LoginTestThread(String username,String password,Handler handler,AuthenticatorActivity authenticatorActivity){
  this.username=username;
  this.password=password;
  this.handler=handler;
  this.authenticatorActivity=authenticatorActivity;
}
 

Example 55

From project android-cropimage, under directory /src/com/android/camera/.

Source file: Util.java

  29 
vote

public BackgroundJob(MonitoredActivity activity,Runnable job,ProgressDialog dialog,Handler handler){
  mActivity=activity;
  mDialog=dialog;
  mJob=job;
  mActivity.addLifeCycleListener(this);
  mHandler=handler;
}
 

Example 56

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: BluetoothActivity.java

  29 
vote

public ClientSocketThread(String device,Handler handle){
  mMACAddres=device.substring(device.lastIndexOf('\n') + 1,device.lastIndexOf(":")).toUpperCase();
  mHandle=handle;
  try {
    mRemoteDevice=mBluetoothAdapter.getRemoteDevice(mMACAddres);
    mSocket=mRemoteDevice.createRfcommSocketToServiceRecord(UUID.fromString(DEV_UUID));
  }
 catch (  IllegalArgumentException e) {
    mSocket=null;
    Message msg=new Message();
    msg.obj=e.getMessage();
    mHandle.sendEmptyMessage(DIALOG_CANCEL);
  }
catch (  IOException e) {
    Message msg=new Message();
    msg.obj=e.getMessage();
    mHandle.sendEmptyMessage(DIALOG_CANCEL);
  }
}
 

Example 57

From project android-service-arch, under directory /ServiceFramework/src/ru/evilduck/framework/.

Source file: SFServiceHelper.java

  29 
vote

private Intent createIntent(final Context context,String actionLogin,final int requestId){
  Intent i=new Intent(context,SFCommandExecutorService.class);
  i.setAction(actionLogin);
  i.putExtra(SFCommandExecutorService.EXTRA_STATUS_RECEIVER,new ResultReceiver(new Handler()){
    @Override protected void onReceiveResult(    int resultCode,    Bundle resultData){
      Intent originalIntent=pendingActivities.get(requestId);
      if (isPending(requestId)) {
        pendingActivities.remove(requestId);
        for (        SFServiceCallbackListener currentListener : currentListeners) {
          if (currentListener != null) {
            currentListener.onServiceCallback(requestId,originalIntent,resultCode,resultData);
          }
        }
      }
    }
  }
);
  return i;
}
 

Example 58

From project Android-SyncAdapter-JSON-Server-Example, under directory /src/com/example/android/samplesync/client/.

Source file: NetworkUtilities.java

  29 
vote

/** 
 * Attempts to authenticate the user credentials on a service.
 * @param username The user's username
 * @param password The user's password to be authenticated
 * @param handler The main UI thread's handler instance.
 * @param context The caller Activity's context
 * @return Thread The thread on which the network mOperations are executed.
 */
public static Thread attemptAuth(final String username,final String password,final Handler handler,final Context context){
  final Runnable runnable=new Runnable(){
    public void run(){
      boolean result=authenticate(username,password,handler,context);
      sendResult(result,handler,context);
    }
  }
;
  return NetworkUtilities.performOnBackgroundThread(runnable);
}
 

Example 59

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/.

Source file: ExchangeService.java

  29 
vote

public AccountObserver(Handler handler){
  super(handler);
  Context context=getContext();
synchronized (mAccountList) {
    try {
      collectEasAccounts(context,mAccountList);
    }
 catch (    ProviderUnavailableException e) {
      return;
    }
    for (    Account account : mAccountList) {
      int cnt=Mailbox.count(context,Mailbox.CONTENT_URI,"accountKey=" + account.mId,null);
      if (cnt == 0) {
        addAccountMailbox(account.mId);
      }
    }
  }
  Utility.runAsync(new Runnable(){
    @Override public void run(){
synchronized (mAccountList) {
        for (        Account account : mAccountList) {
          if ((account.mFlags & Account.FLAGS_SECURITY_HOLD) != 0) {
            if (PolicyServiceProxy.isActive(ExchangeService.this,null)) {
              PolicyServiceProxy.setAccountHoldFlag(ExchangeService.this,account,false);
              log("isActive true; release hold for " + account.mDisplayName);
            }
 else {
              PolicyServiceProxy.policiesRequired(ExchangeService.this,account.mId);
            }
          }
        }
      }
    }
  }
);
}
 

Example 60

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: GridViewSpecial.java

  29 
vote

ImageBlockManager(Handler handler,Runnable redrawCallback,IImageList imageList,ImageLoader loader,GridViewSpecial.DrawAdapter adapter,GridViewSpecial.LayoutSpec spec,int columns,int blockWidth,Bitmap outline){
  mHandler=handler;
  mRedrawCallback=redrawCallback;
  mImageList=imageList;
  mLoader=loader;
  mDrawAdapter=adapter;
  mSpec=spec;
  mColumns=columns;
  mBlockWidth=blockWidth;
  mOutline=outline;
  mBlockHeight=mSpec.mCellSpacing + mSpec.mCellHeight;
  mCount=imageList.getCount();
  mRows=(mCount + mColumns - 1) / mColumns;
  mCache=new HashMap<Integer,ImageBlock>();
  mPendingRequest=0;
  initGraphics();
}
 

Example 61

From project andstatus, under directory /src/org/andstatus/app/.

Source file: MyServiceConnector.java

  29 
vote

/** 
 * Initialize service and bind to it.
 */
public void bindToService(Activity activity,Handler handler){
  if (!mIsBound) {
    mIsBound=true;
    mActivity=activity;
    mHandler=handler;
    Intent serviceIntent=new Intent(IMyService.class.getName());
    if (!MyServiceManager.isStarted()) {
      MyServiceManager.startAndStatusService(MyPreferences.getContext(),new CommandData(CommandEnum.EMPTY,""));
    }
    mActivity.bindService(serviceIntent,mServiceConnection,0);
  }
}
 

Example 62

From project ANE-In-App-Purchase, under directory /NativeAndroid/src/com/freshplanet/inapppurchase/.

Source file: MakePurchaseFunction.java

  29 
vote

@Override public FREObject call(FREContext arg0,FREObject[] arg1){
  Log.d("makePurchase","v2.6");
  String purchaseId=null;
  try {
    purchaseId=arg1[0].getAsString();
  }
 catch (  IllegalStateException e) {
    e.printStackTrace();
  }
catch (  FRETypeMismatchException e) {
    e.printStackTrace();
  }
catch (  FREInvalidObjectException e) {
    e.printStackTrace();
  }
catch (  FREWrongThreadException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  Log.d("makePurchase","purchase id : " + purchaseId);
  BillingService service=new BillingService();
  service.setContext(arg0.getActivity());
  ResponseHandler.register(new CashPurchaseObserver(new Handler()));
  if (purchaseId != null) {
    service.requestPurchase(purchaseId,null);
  }
  return null;
}
 

Example 63

From project anode, under directory /src/net/haltcondition/anode/.

Source file: EditSettings.java

  29 
vote

private void initiateServiceFetch(){
  Log.d(TAG,"Fetching Service ID");
  Account account=new Account(eUsername.getText().toString(),ePassword.getText().toString());
  progress=ProgressDialog.show(this,getResources().getString(R.string.fetching_service),getResources().getString(R.string.starting_worker),false,true);
  HttpWorker<Service> serviceWorker=new HttpWorker<Service>(new Handler(this),account,Common.INODE_URI_BASE,new ServiceParser(),this);
  pool.execute(serviceWorker);
}
 

Example 64

From project AsmackService, under directory /src/com/googlecode/asmack/sync/.

Source file: LoginTestThread.java

  29 
vote

/** 
 * Create a new login test thread for the given credentials.
 * @param username The user jid.
 * @param password The user password.
 * @param handler The result handler.
 * @param authenticatorActivity The authenticator activity.
 */
public LoginTestThread(String username,String password,Handler handler,AuthenticatorActivity authenticatorActivity){
  this.username=username;
  this.password=password;
  this.handler=handler;
  this.authenticatorActivity=authenticatorActivity;
}
 

Example 65

From project AutobahnAndroid, under directory /Autobahn/src/de/tavendo/autobahn/.

Source file: WampReader.java

  29 
vote

/** 
 * A reader object is created in AutobahnConnection.
 * @param calls         The call map created on master.
 * @param subs          The event subscription map created on master.
 * @param master        Message handler of master (used by us to notify the master).
 * @param socket        The TCP socket.
 * @param options       WebSockets connection options.
 * @param threadName    The thread name we announce.
 */
public WampReader(ConcurrentHashMap<String,CallMeta> calls,ConcurrentHashMap<String,SubMeta> subs,Handler master,SocketChannel socket,WebSocketOptions options,String threadName){
  super(master,socket,options,threadName);
  mCalls=calls;
  mSubs=subs;
  mJsonMapper=new ObjectMapper();
  mJsonMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
  mJsonFactory=mJsonMapper.getJsonFactory();
  if (DEBUG)   Log.d(TAG,"created");
}
 

Example 66

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/ui/.

Source file: TwunchesMapActivity.java

  29 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mMapView=new TapControlledMapView(this,BuildProperties.MAPS_KEY);
  mMapView.setClickable(true);
  mMapView.setBuiltInZoomControls(true);
  mMapView.setOnSingleTapListener(new OnSingleTapListener(){
    @Override public boolean onSingleTap(    MotionEvent e){
      mItemizedOverlay.hideAllBalloons();
      return true;
    }
  }
);
  setContentView(mMapView);
  mDrawable=getResources().getDrawable(R.drawable.marker);
  mMyLocationOverlay=new MyLocationOverlay(this,mMapView);
  mObserver=new ContentObserver(new Handler()){
    public void onChange(    boolean selfChange){
      mCursor.requery();
      showOverlays();
    }
  }
;
  mCursor=getContentResolver().query(Twunches.buildFutureTwunchesUri(),TwunchesQuery.PROJECTION,null,null,null);
  startManagingCursor(mCursor);
  showOverlays();
}
 

Example 67

From project Binaural-Beats, under directory /src/com/ihunda/android/binauralbeat/.

Source file: BBeat.java

  29 
vote

public RunProgram(Program pR,Handler h){
  this.pR=pR;
  this.h=h;
  programLength=pR.getLength();
  sProgramLength=getString(R.string.time_format,formatTimeNumberwithLeadingZero((int)programLength / 60),formatTimeNumberwithLeadingZero((int)programLength % 60));
  formatString=getString(R.string.info_timing);
  format_INFO_TIMING_MIN_SEC=getString(R.string.time_format_min_sec);
  startTime=System.currentTimeMillis();
  oldDelta=-1;
  _last_graph_update=0;
  s=eState.START;
  h.postDelayed(this,TIMER_FSM_DELAY);
}
 

Example 68

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: CropUtil.java

  29 
vote

public BackgroundJob(CropMonitoredActivity activity,Runnable job,ProgressDialog dialog,Handler handler){
  mActivity=activity;
  mDialog=dialog;
  mJob=job;
  mActivity.addLifeCycleListener(this);
  mHandler=handler;
}