private void notifyChange() {
   mNotifyHandler.removeCallbacks(mNotifyChange);
   long ts = System.currentTimeMillis();
   if (ts > last_notify + 500) mNotifyChange.run();
   else mNotifyHandler.postDelayed(mNotifyChange, 200);
   last_notify = ts;
 }
Exemple #2
1
  public void alarmFacebookUserComming(Message callbackMessage) {
    Log.d(TAG, "alarmFacebookUserComming");

    Message msg = handler.obtainMessage(FACEBOOK_FRIENDS_GET);
    if (callbackMessage != null) {
      msg.getData().putParcelable(CALLBACK, callbackMessage);
      msg.getData().putLong("hisuid", callbackMessage.getData().getLong("hisuid", -1));
    }
    handler.sendMessageDelayed(msg, 1 * 1000);

    long nexttime = System.currentTimeMillis() + getFriendsTimeout() * 1000L;

    if (SNSService.TEST_LOOP) {
      nexttime = System.currentTimeMillis() + 90 * 1000;
    }

    AlarmManager alarmMgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);

    Intent i = new Intent();
    i.setClassName("com.ast.free", "com.ast.free.service.SNSService");
    i.setAction("com.ast.free.intent.action.FACEBOOK_USER");
    PendingIntent userpi =
        PendingIntent.getService(
            mContext.getApplicationContext(), 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    alarmMgr.set(AlarmManager.RTC_WAKEUP, nexttime, userpi);
  }
 private void updateRingtoneName(int type, Preference preference, int msg) {
   if (preference == null) return;
   Context context = getActivity();
   if (context == null) return;
   Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
   CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown);
   // Is it a silent ringtone?
   if (ringtoneUri == null) {
     summary = context.getString(com.android.internal.R.string.ringtone_silent);
   } else {
     // Fetch the ringtone title from the media provider
     try {
       Cursor cursor =
           context
               .getContentResolver()
               .query(ringtoneUri, new String[] {MediaStore.Audio.Media.TITLE}, null, null, null);
       if (cursor != null) {
         if (cursor.moveToFirst()) {
           summary = cursor.getString(0);
         }
         cursor.close();
       }
     } catch (SQLiteException sqle) {
       // Unknown title for the ringtone
     }
   }
   mHandler.sendMessage(mHandler.obtainMessage(msg, summary));
 }
        public void run() {
          timeInMilliseconds = SystemClock.uptimeMillis() - startTime;
          updatedTime = timeSwapBuff + timeInMilliseconds;

          updatedTime = maxTimeMilliseconds - timeInMilliseconds;

          if (updatedTime > 5) {
            int secs = (int) (updatedTime / 1000);
            int mins = secs / 60;
            secs = secs % 60;
            int milliseconds = (int) (updatedTime % 1000);
            timerValue.setText(
                String.format("%02d", mins)
                    + ":"
                    + String.format("%02d", secs)
                    + ":"
                    + String.format("%03d", milliseconds));
            customHandler.postDelayed(this, 0);
          } else {
            customHandler.removeCallbacks(updateTimerThread);
            timerValue.setText(
                String.format("%02d", 0)
                    + ":"
                    + String.format("%02d", 0)
                    + ":"
                    + String.format("%03d", 0));
          }
        }
  @Override
  public boolean onMenuItemClicked(
      MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) {
    // TODO Auto-generated method stub
    switch (pMenuItem.getID()) {
      case MENU_PLAY:
        mainMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mStaticMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mHandler.postDelayed(mLaunchLevel1Task, 1000);
        return true;

      case MENU_OPTIONS:
        mainMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mStaticMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mHandler.postDelayed(mLaunchOptionsTask, 1000);
        return true;

      case MENU_HELP:
        mHandler.postDelayed(mLaunchHelp, 1000);
        return true;

      default:
        return false;
    }
  }
  public boolean handleHardwareButtons(int keyCode, KeyEvent evt, int combinedMetastate) {
    boolean down =
        (evt.getAction() == KeyEvent.ACTION_DOWN) || (evt.getAction() == KeyEvent.ACTION_MULTIPLE);

    int mouseChange =
        keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
            ? RemoteVncPointer.MOUSE_BUTTON_SCROLL_DOWN
            : RemoteVncPointer.MOUSE_BUTTON_SCROLL_UP;
    if (keyCode == KeyEvent.KEYCODE_CAMERA
        || keyCode == KeyEvent.KEYCODE_BACK && evt.getScanCode() == 0) {
      if (keyCode == KeyEvent.KEYCODE_CAMERA) cameraButtonDown = down;

      if (down) pointerMask = RemoteVncPointer.MOUSE_BUTTON_RIGHT;
      else pointerMask = 0;
      rfb.writePointerEvent(getX(), getY(), combinedMetastate, pointerMask);
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
      if (evt.getAction() == KeyEvent.ACTION_DOWN) {
        // If not auto-repeat
        if (scrollRunnable.scrollButton != mouseChange) {
          pointerMask |= mouseChange;
          scrollRunnable.scrollButton = mouseChange;
          handler.postDelayed(scrollRunnable, 200);
        }
      } else {
        handler.removeCallbacks(scrollRunnable);
        scrollRunnable.scrollButton = 0;
        pointerMask &= ~mouseChange;
      }
      rfb.writePointerEvent(getX(), getY(), combinedMetastate, pointerMask);
      return true;
    }
    return false;
  }
  private void startLoading(Request request, boolean skipRoundtripIfCached, long afterDelay) {
    this.skipRoundtripIfCached = skipRoundtripIfCached;
    appendResults = false;
    nextRequest = null;
    currentRequest = request;
    currentRequest.setCallback(
        new Request.Callback() {
          @Override
          public void onCompleted(Response response) {
            requestCompleted(response);
          }
        });

    // We are considered loading even if we have a delay.
    loading = true;

    final RequestBatch batch = putRequestIntoBatch(request, skipRoundtripIfCached);
    Runnable r =
        new Runnable() {
          @Override
          public void run() {
            Request.executeBatchAsync(batch);
          }
        };
    if (afterDelay == 0) {
      r.run();
    } else {
      Handler handler = new Handler();
      handler.postDelayed(r, afterDelay);
    }
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_start);
   Message msg = handler.obtainMessage();
   handler.sendMessageDelayed(msg, 1000);
 }
Exemple #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_result);

    final ProgressDialog progressDialog;

    progressDialog = new ProgressDialog(ResultActivity.this);
    progressDialog.setMessage("Please wait...");
    progressDialog.setCancelable(false);
    progressDialog.show();

    Handler handler = new Handler();
    handler.postDelayed(
        new Runnable() {
          public void run() {
            progressDialog.dismiss();

            ImageView imageView = (ImageView) findViewById(R.id.imageView2);
            imageView.setImageResource(R.drawable.lol);

            TextView name = (TextView) findViewById(R.id.textView3);
            name.setText("{commonAtr: \"banana\"  }"); // Brian Comment: Dummy for presentation
          }
        },
        5500);
  }
  public void init() {
    context = ZhaopinDetailActivity.this;

    title_left = (ImageView) findViewById(R.id.common_title_left);
    title_right = (ImageView) findViewById(R.id.common_title_right);
    title_mid = (TextView) findViewById(R.id.common_title_mid);
    title_left.setOnClickListener(this);
    title_right.setOnClickListener(this);

    wv = (WebView) findViewById(R.id.wv);

    progress = (ProgressBar) findViewById(R.id.progress);

    ZhaopinDetailBean temp =
        ZhaopinDBHelper.getInstance(context).getZhaopin(zhaopinbasebean.getUrl());
    if (temp == null) {
      store = false;
      handler.sendEmptyMessage(UNCHOOSE);
    } else {
      store = true;
      handler.sendEmptyMessage(CHOOSE);
      zhaopindetailbean = temp;
    }
    if (store) {
      wv.loadData(zhaopindetailbean.getContent(), "text/html", "UTF-8");
    } else {
      getData(zhaopinbasebean);
    }
  }
    @Override
    public void run() {
      try {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        String searchLanguageKey = getContext().getString(R.string.search_language_key);
        String searchLanguage =
            sp.getString(searchLanguageKey, getString(R.string.default_language_value));
        SearchEngine.Result result = engine.search(query, page, searchLanguage);

        Log.i(TAG, "language code passed:\"" + searchLanguage + "\"");
        if (runs) {
          h.post(new ResultRunnable(result, requestId));
        }
      } catch (Exception e) {
        e.printStackTrace();

        h.post(
            new Runnable() {
              @Override
              public void run() {
                setListShown(true);
                Toast.makeText(getActivity(), getString(R.string.network_error), Toast.LENGTH_SHORT)
                    .show();
              }
            });
      }
    }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.address_tv:
       break;
     case R.id.priceinfo_tv:
       break;
     case R.id.bedinfo_tv:
       break;
     case R.id.infolong_tv:
       break;
     case R.id.service_tv:
       break;
     case R.id.contactway_tv:
       break;
     case R.id.common_title_left:
       finish();
       break;
     case R.id.common_title_right:
       // 收藏或者已收藏
       if (store) {
         // 删除数据库保存
         ZhaopinDBHelper.getInstance(context).deleteZhaopin(zhaopindetailbean);
         handler.sendEmptyMessage(UNCHOOSE);
       } else {
         //  插入数据库
         ZhaopinDBHelper.getInstance(context).addZhaopin(zhaopindetailbean);
         handler.sendEmptyMessage(CHOOSE);
       }
       break;
     default:
       break;
   }
 }
 @Override
 public void onDestroyView() {
   mList = null;
   mHandler.removeCallbacks(mRequestFocus);
   mHandler.removeMessages(MSG_BIND_PREFERENCES);
   super.onDestroyView();
 }
Exemple #14
0
  /** Stops the ringtone and/or vibrator if any of these are actually ringing/vibrating. */
  void stopRing() {
    synchronized (this) {
      if (DBG) log("stopRing()...");

      try {
        mHardwareService.setAttentionLight(false);
      } catch (RemoteException ex) {
        // the other end of this binder call is in the system process.
      }

      if (mRingHandler != null) {
        mRingHandler.removeCallbacksAndMessages(null);
        Message msg = mRingHandler.obtainMessage(STOP_RING);
        msg.obj = mRingtone;
        mRingHandler.sendMessage(msg);
        PhoneUtils.setAudioMode(mContext, AudioManager.MODE_NORMAL);
        mRingThread = null;
        mRingHandler = null;
        mRingtone = null;
        mFirstRingEventTime = -1;
        mFirstRingStartTime = -1;
      } else {
        if (DBG) log("- stopRing: null mRingHandler!");
      }

      if (mVibratorThread != null) {
        if (DBG) log("- stopRing: cleaning up vibrator thread...");
        mContinueVibrating = false;
        mVibratorThread = null;
      }
      // Also immediately cancel any vibration in progress.
      mVibrator.cancel();
    }
  }
  /**
   * Sets the current state and notifies listeners, if necessary.
   *
   * @param stateFlags The state flags.
   */
  private void setStateLocked(int stateFlags) {
    final boolean enabled = (stateFlags & STATE_FLAG_ACCESSIBILITY_ENABLED) != 0;
    final boolean touchExplorationEnabled =
        (stateFlags & STATE_FLAG_TOUCH_EXPLORATION_ENABLED) != 0;
    final boolean highTextContrastEnabled =
        (stateFlags & STATE_FLAG_HIGH_TEXT_CONTRAST_ENABLED) != 0;

    final boolean wasEnabled = mIsEnabled;
    final boolean wasTouchExplorationEnabled = mIsTouchExplorationEnabled;
    final boolean wasHighTextContrastEnabled = mIsHighTextContrastEnabled;

    // Ensure listeners get current state from isZzzEnabled() calls.
    mIsEnabled = enabled;
    mIsTouchExplorationEnabled = touchExplorationEnabled;
    mIsHighTextContrastEnabled = highTextContrastEnabled;

    if (wasEnabled != enabled) {
      mHandler.sendEmptyMessage(MyHandler.MSG_NOTIFY_ACCESSIBILITY_STATE_CHANGED);
    }

    if (wasTouchExplorationEnabled != touchExplorationEnabled) {
      mHandler.sendEmptyMessage(MyHandler.MSG_NOTIFY_EXPLORATION_STATE_CHANGED);
    }

    if (wasHighTextContrastEnabled != highTextContrastEnabled) {
      mHandler.sendEmptyMessage(MyHandler.MSG_NOTIFY_HIGH_TEXT_CONTRAST_STATE_CHANGED);
    }
  }
Exemple #16
0
  /**
   * This method should not be overridden, will pre-process a SOAP reply and coordinate callbacks
   * and direct processing output to the appropriate {@link Handler}
   */
  @Override
  public void processWebReply(Context c, ReplyAdapter r, Handler handler) {
    if (r.getStatus() == Status.OK) {
      LOGGER.debug("processing SoapReply");
      SoapReply soapReply = new SoapReplyAdapter((WebReply) r.getReply()).getReply();
      SoapSerializationEnvelope e = soapReply.getEnvelope();
      SoapUtil.printSoapEnvelopeToStdout(e);
      Object result = null;
      try {
        result = e.getResponse();
      } catch (Throwable tr) {
        LOGGER.warn("Problem while getting soap result.", tr);
        return;
      }

      if (result == null) {
        LOGGER.debug("processSoapNull");
        handler.sendMessage(processSoapNull(r));
      } else if (result instanceof SoapFault) {
        LOGGER.debug("processSoapFault");
        handler.sendMessage(processSoapFault(r, (SoapFault) result));
      } else if (result instanceof SoapObject) {
        try {
          LOGGER.debug("processSoapObject");
          handler.sendMessage(createReturnMessage(processSoapReply(c, r, (SoapObject) result)));
        } catch (Exception e2) {
          LOGGER.debug("processSoapObject - failed", e2);
          handler.sendMessage(createErrorMessage(getProcessorID(), (WebRequest) r.getRequest()));
        }
      }
    } else {
      handler.sendMessage(createErrorMessage(getProcessorID(), (WebRequest) r.getRequest()));
    }
  }
Exemple #17
0
  void finish(final String tag) {
    if (mRequestQueue != null) {
      mRequestQueue.finish(this);
    }
    if (MarkerLog.ENABLED) {
      final long threadId = Thread.currentThread().getId();
      if (Looper.myLooper() != Looper.getMainLooper()) {
        Handler mainThread = new Handler(Looper.getMainLooper());
        mainThread.post(
            new Runnable() {
              @Override
              public void run() {
                mEventLog.add(tag, threadId);
                mEventLog.finish(this.toString());
              }
            });
        return;
      }

      mEventLog.add(tag, threadId);
      mEventLog.finish(this.toString());
    } else {
      long requestTime = SystemClock.elapsedRealtime() - mRequestBirthTime;
      if (requestTime >= SLOW_REQUEST_THRESHOLD_MS) {
        VolleyLog.d("%d ms: %s", requestTime, this.toString());
      }
    }
  }
Exemple #18
0
  @Override
  public void run() {
    // TODO Auto-generated method stub

    LognAndSign logn = new LognAndSign();
    ReturnMessage result = logn.Logn(name, password); // 得到登陸的結果
    /*if (result != ReturnMessage.Success) {//如果不成功
    	if (result == ReturnMessage.UserNameRepeat) {//用戶名重複
    		handler.sendEmptyMessage(0x88);
    	} else {
    		handler.sendEmptyMessage(0x99);
    	}
    } else {

    	handler.sendEmptyMessage(0x22);
    }*/
    switch (result) {
      case InternetError:
        handler.sendEmptyMessage(0x11);
        break;
      case ParseError:
        handler.sendEmptyMessage(0x99);
        break;
      case ServerError:
        handler.sendEmptyMessage(0x33);
        break;
      case Success:
        handler.sendEmptyMessage(0x22);
        break;
      case UserNameRepeat:
        handler.sendEmptyMessage(0x88);
        break;
    }
  }
  /**
   * Start the ConnectedThread to begin managing a Bluetooth connection
   *
   * @param socket The BluetoothSocket on which the connection was made
   * @param device The BluetoothDevice that has been connected
   */
  public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
    if (D) Log.d(TAG, "connected");

    // Cancel the thread that completed the connection
    if (mConnectThread != null) {
      mConnectThread.cancel();
      mConnectThread = null;
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
      mConnectedThread.cancel();
      mConnectedThread = null;
    }

    // Cancel the accept thread because we only want to connect to one device
    if (mAcceptThread != null) {
      mAcceptThread.cancel();
      mAcceptThread = null;
    }

    // Start the thread to manage the connection and perform transmissions
    mConnectedThread = new ConnectedThread(socket);
    mConnectedThread.start();

    // Send the name of the connected device back to the UI Activity
    Message msg = mHandler.obtainMessage(BluetoothChat.MESSAGE_DEVICE_NAME);
    Bundle bundle = new Bundle();
    bundle.putString(BluetoothChat.DEVICE_NAME, device.getName());
    msg.setData(bundle);
    mHandler.sendMessage(msg);

    setState(STATE_CONNECTED);
  }
Exemple #20
0
  public boolean moveTetrominoRight() {
    Log.d(TAG, "move tetromino to right");
    synchronized (lockObj) {
      if (currentTetromino.moveRight(oldMap)) {
        currentMap.copyFrom(oldMap);
        currentTetromino.putOnMap(currentMap);
        lastMoveMap.copyFrom(currentMap);

        // if old position will collision but new moved position will not, then need remove the new
        // tetromino message and send tetromino move message=
        if (!currentTetromino.isCollisionY(
            currentTetromino.getY() + 1, currentTetromino.getSharp(), oldMap)) {
          if (handler.hasMessages(MSG_NEW_TETROMINO)) {
            handler.removeMessages(MSG_NEW_TETROMINO);
            handler.sendEmptyMessageDelayed(MSG_TETROMINO_MOVE, TETROMINO_MOVE_INTERVAL_RESEND);
          }
        }

        for (ITetrisListener listener : customizedListeners) {
          listener.onTetrominoMove();
        }
        return true;
      }
      return false;
    }
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    mPositions.put(mDirectory.getAbsolutePath(), getListView().getFirstVisiblePosition());

    if (position < (mParent == null ? 0 : 1)) {
      mDirectory = mParent;
      mHandler.post(mUpdateFiles);
      return;
    }

    position -= (mParent == null ? 0 : 1);

    if (position < mDirs.length) {
      mDirectory = mDirs[position];
      mHandler.post(mUpdateFiles);
      return;
    }

    position -= mDirs.length;

    Uri uri = Uri.parse(mFiles[position].getAbsolutePath());
    Intent intent = new Intent(this, MuPDFActivity.class);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(uri);
    startActivity(intent);
  }
Exemple #22
0
 private void updateCurrentStatus(String txt) {
   Message message = handler.obtainMessage();
   Bundle bundle = new Bundle();
   bundle.putString("status", txt);
   message.setData(bundle);
   handler.sendMessageDelayed(message, 0);
 }
 private void onSearchTextTimerTriggered() {
   if (hasSearchTextChangedSinceLastQuery) {
     Handler handler = new Handler(Looper.getMainLooper());
     handler.post(
         new Runnable() {
           @Override
           public void run() {
             FacebookException error = null;
             try {
               loadData(true);
             } catch (FacebookException fe) {
               error = fe;
             } catch (Exception e) {
               error = new FacebookException(e);
             } finally {
               if (error != null) {
                 OnErrorListener onErrorListener = getOnErrorListener();
                 if (onErrorListener != null) {
                   onErrorListener.onError(PlacePickerFragment.this, error);
                 } else {
                   Logger.log(LoggingBehavior.REQUESTS, TAG, "Error loading data : %s", error);
                 }
               }
             }
           }
         });
   } else {
     // Nothing has changed in 2 seconds. Invalidate and forget about this timer.
     // Next time the user types, we will fire a query immediately again.
     searchTextTimer.cancel();
     searchTextTimer = null;
   }
 }
 private void h()
 {
   if (!B.p())
   {
     l.e(k, "changeToCastMode error, chromecast is not connected");
     return;
   }
   if (p != null) {
     p.hide();
   }
   m();
   A = 1;
   o.setVisibility(0);
   if (q == null)
   {
     q = new kk(this, this);
     if (r == null)
     {
       r = new kt(this);
       B.a(r);
       B.a(r);
       B.a(r);
     }
     q.setMediaPlayer(r);
     q.setAnchorView(o);
   }
   ((ImageView)z.findViewById(2131624054)).setImageResource(2130838531);
   if ((B.r() > 0) && (B.r() != 2)) {
     b.setVisibility(0);
   }
   J.sendMessageDelayed(J.obtainMessage(5), 1000L);
 }
    @Override
    protected void onPostExecute(String s) {
      super.onPostExecute(s);

      // Parse JSON
      try {
        JSONObject jsonObject = new JSONObject(s);
        String status = jsonObject.getString("result");
        if (status.equalsIgnoreCase("success")) {
          errorText.setText("Account Successfully Created!");

          // introduce a small delay to allow for user to know account is created
          Handler h = new Handler();
          h.postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  myDialog.dismiss();
                }
              },
              1500);
        } else {
          String reason = jsonObject.getString("error");
          errorText.setText("Error: " + reason);
        }
      } catch (Exception e) {
        Log.d(TAG, "Parsing JSON Exception " + e.getMessage());
      }
    }
 public void click(int index) {
   switch (index) {
     case 0: // 回复评论
       if (!ReplayPermit.isMayClick) {
         return;
       }
       ReplayPermit.isMayClick = false;
       Message message1 = new Message();
       message1.what = MessageID.MESSAGE_MENUCLICK_COMMENTC_MSG_REPLY;
       Bundle data = new Bundle();
       data.putInt("is_subject", isSubject);
       data.putInt("subjectid", Integer.parseInt(subjectId));
       data.putInt("commentid", commentid);
       data.putInt("touserid", touserid);
       data.putString("tousername", tousername);
       data.putString("cid", cid);
       message1.setData(data);
       //			message1.obj = subjectId;
       //			message1.arg1 = isSubject;
       //			message1.arg2 = commentid;
       handler.sendMessage(message1);
       break;
     case 1: // 查看商品
       Message message2 = new Message();
       message2.what = MessageID.MESSAGE_MENUCLICK_COMMENTC_MSG_COMMODITY;
       Bundle data2 = new Bundle();
       data2.putInt("position", position);
       message2.setData(data2);
       handler.sendMessage(message2);
       break;
   }
 }
    @Override
    public int configureSurface(Surface surface, final int width, final int height, final int hal) {

      if (LibVlcUtil.isICSOrLater() || surface == null) return -1;
      if (width * height == 0) return 0;
      ExoVlcUtil.log(this, "configureSurface: " + width + "x" + height);

      final ConfigureSurfaceHolder holder = new ConfigureSurfaceHolder(surface);

      final Handler handler = new Handler(Looper.getMainLooper());
      handler.post(
          new Runnable() {
            @Override
            public void run() {
              if (mSurface == holder.surface) {
                if (hal != 0) view.getHolder().setFormat(hal);
                view.getHolder().setFixedSize(width, height);
              }

              synchronized (holder) {
                holder.configured = true;
                holder.notifyAll();
              }
            }
          });

      try {
        synchronized (holder) {
          while (!holder.configured) holder.wait();
        }
      } catch (InterruptedException e) {
        return 0;
      }
      return 1;
    }
  protected boolean onTap(int index) {
    // System.out.println("item onTap: "+index);

    Bitmap[] bmps = new Bitmap[3];
    if (index % 2 == 0) {
      try {
        bmps[0] = BitmapFactory.decodeStream(mContext.getAssets().open("marker1.png"));
        bmps[1] = BitmapFactory.decodeStream(mContext.getAssets().open("marker2.png"));
        bmps[2] = BitmapFactory.decodeStream(mContext.getAssets().open("marker3.png"));
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      try {
        bmps[2] = BitmapFactory.decodeStream(mContext.getAssets().open("marker1.png"));
        bmps[1] = BitmapFactory.decodeStream(mContext.getAssets().open("marker2.png"));
        bmps[0] = BitmapFactory.decodeStream(mContext.getAssets().open("marker3.png"));
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    // pop.showPopup(bmps, getItem(index).getPoint(), 32);
    // if (null == mToast)
    //  mToast = Toast.makeText(mContext, getItem(index).getTitle(), Toast.LENGTH_SHORT);
    // else mToast.setText(getItem(index).getTitle());
    // mToast.show();

    if (mH != null) {
      mH.dispatchMessage(mH.obtainMessage(LocationOverlayDemo.MSG_HANDLE_ITEM_TOUCH + index));
    }

    return true;
  }
Exemple #29
0
 public void FoundNameCallback(String busName) {
   Log.e("SimpleClient", String.format("Found name %s", busName));
   Message msg = handler.obtainMessage(0);
   msg.arg1 = BUSNAMEITEM_FOUND;
   msg.obj = new BusNameItem(busName, true);
   handler.sendMessage(msg);
 }
Exemple #30
0
 void requestTimer(boolean on) {
   if (gameWantsTimer && on) return;
   gameWantsTimer = on;
   if (on)
     handler.sendMessageDelayed(handler.obtainMessage(MsgType.TIMER.ordinal()), timerInterval);
   else handler.removeMessages(MsgType.TIMER.ordinal());
 }