Esempio n. 1
0
 public void setOverlay(MapOverlay overlay) {
   useOverlay = overlay;
   if (!mapThreadRunning) {
     mapThread = new Thread(this);
     mapThread.start();
   }
 }
Esempio n. 2
0
 @Override
 public void surfaceCreated(SurfaceHolder holder) {
   Thread thread = null;
   thread = new Thread(this);
   flag = true;
   thread.start();
 }
Esempio n. 3
0
 private void downloadImageThread() {
   Thread thread = new Thread(null, runInBackground, "Background");
   thread.start();
   try {
     thread.join();
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
Esempio n. 4
0
  private void restartMap() {
    breakMapThread = true;
    postInvalidate();
    if (mapThread != null)
      try {
        mapThread.join(1500);
      } catch (InterruptedException ie) {

      }
    mapThread = new Thread(this);
    mapThread.start();
  }
Esempio n. 5
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.contactslist);
    contactsList = new ArrayList<String>();
    getcontactsList = new ArrayList<String>();

    final ListView listView = getListView();
    listView.setItemsCanFocus(false);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    okbtn = (Button) findViewById(R.id.contacts_done_button);
    cancelbtn = (Button) findViewById(R.id.contact_back_button);
    okbtn.setOnClickListener(this);
    cancelbtn.setOnClickListener(this);

    getcontacts = new Thread(new GetContacts());
    getcontacts.start();
    proDialog = ProgressDialog.show(ContactsListMultiple.this, "loading", "loading", true, true);
  }
  void requestAccountList() {
    prog =
        ProgressDialog.show(
            this,
            null,
            getString(R.string.account_list_progress),
            false,
            true,
            new DialogInterface.OnCancelListener() {
              public void onCancel(DialogInterface dialog) {
                cancel();
              }
            });

    queryThread = new Thread(this, "Requestor Thread");
    queryThread.setDaemon(true);
    queryThread.start();
  }
Esempio n. 7
0
  /** 当SurfaceView创建的时候调用 */
  @Override
  public void surfaceCreated(SurfaceHolder holder) {

    // 获得屏幕的宽和高
    screenW = this.getWidth();
    screenH = this.getHeight();

    qEndX = screenW - 10; // 设置贝塞尔曲线的终点横坐标为屏幕宽度减10
    qEndY = qStartY; // 设置贝塞尔曲线的终点纵坐标和起点纵坐标一样

    // 设置贝塞尔曲线的控制点坐标为终点坐标与起点坐标对应的差值的一半,注意这里不是曲线的中点
    qControlX = (qEndX - qStartX) / 2;
    qCOntrolY = (qEndY - qStartY) / 2;

    mThread = new Thread(this); // 创建线程对象
    flag = true; // 设置线程标识为true
    xReturn = false; // 设置图形坐标不返回
    cReturn = false; // 设置贝塞尔曲线控制点坐标不返回
    mThread.start(); // 启动线程
  }
 private void RunDisConnectionInThread() {
   Thread thread =
       new Thread(
           new Runnable() {
             public void run() {
               int pid = getPIDof("pppd");
               String killPPPD = "";
               if (pid != -1) {
                 killPPPD = "kill " + pid;
               }
               String output =
                   Commands2script(
                       new String[] {
                         killPPPD, "sleep 1", mRFCOMM + " release " + myDigit,
                       });
               outputInfo(output);
             }
           });
   thread.start();
 }
Esempio n. 9
0
  /**
   * Creates new call to given <tt>destination</tt> using selected <tt>provider</tt>.
   *
   * @param context the android context
   * @param destination target callee name.
   * @param provider the provider that will be used to make a call.
   */
  public static void createCall(
      final Context context, final String destination, final ProtocolProviderService provider) {
    if (createCallThread != null) {
      logger.warn("Another call is already being created");
      return;
    } else if (CallManager.getActiveCallsCount() > 0) {
      logger.warn("Another call is in progress");
      return;
    }

    final long dialogId =
        ProgressDialogFragment.showProgressDialog(
            JitsiApplication.getResString(R.string.service_gui_OUTGOING_CALL),
            JitsiApplication.getResString(R.string.service_gui_OUTGOING_CALL_MSG, destination));

    createCallThread =
        new Thread("Create call thread") {
          public void run() {
            try {
              CallManager.createCall(provider, destination);
            } catch (Throwable t) {
              logger.error("Error creating the call: " + t.getMessage(), t);
              AndroidUtils.showAlertDialog(
                  context, context.getString(R.string.service_gui_ERROR), t.getMessage());
            } finally {
              if (DialogActivity.waitForDialogOpened(dialogId)) {
                DialogActivity.closeDialog(JitsiApplication.getGlobalContext(), dialogId);
              } else {
                logger.error("Failed to wait for the dialog: " + dialogId);
              }
              createCallThread = null;
            }
          }
        };

    createCallThread.start();
  }
Esempio n. 10
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    mAppContext = this;
    mMainHandler = new Handler();

    if (!sTryCatchAttached) {
      sTryCatchAttached = true;
      mMainHandler.post(
          new Runnable() {
            public void run() {
              try {
                Looper.loop();
              } catch (Exception e) {
                Log.e(LOG_FILE_NAME, "top level exception", e);
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);
                pw.flush();
                GeckoAppShell.reportJavaCrash(sw.toString());
              }
              // resetting this is kinda pointless, but oh well
              sTryCatchAttached = false;
            }
          });
    }

    SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
    String localeCode = settings.getString(getPackageName() + ".locale", "");
    if (localeCode != null && localeCode.length() > 0) GeckoAppShell.setSelectedLocale(localeCode);

    Log.i(LOG_FILE_NAME, "create");
    super.onCreate(savedInstanceState);

    if (sGREDir == null) sGREDir = new File(this.getApplicationInfo().dataDir);

    getWindow()
        .setFlags(
            mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (cameraView == null) {
      cameraView = new SurfaceView(this);
      cameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    if (surfaceView == null) surfaceView = new GeckoSurfaceView(this);
    else mainLayout.removeAllViews();

    mainLayout = new AbsoluteLayout(this);
    mainLayout.addView(
        surfaceView,
        new AbsoluteLayout.LayoutParams(
            AbsoluteLayout.LayoutParams.MATCH_PARENT, // level 8
            AbsoluteLayout.LayoutParams.MATCH_PARENT,
            0,
            0));

    setContentView(
        mainLayout,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mConnectivityFilter = new IntentFilter();
    mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    mConnectivityReceiver = new GeckoConnectivityReceiver();

    IntentFilter batteryFilter = new IntentFilter();
    batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    mBatteryReceiver = new GeckoBatteryManager();
    registerReceiver(mBatteryReceiver, batteryFilter);

    if (SmsManager.getInstance() != null) {
      SmsManager.getInstance().start();
    }

    GeckoNetworkManager.getInstance().init();

    if (!checkAndSetLaunchState(LaunchState.PreLaunch, LaunchState.Launching)) return;

    checkAndLaunchUpdate();
    mLibLoadThread =
        new Thread(
            new Runnable() {
              public void run() {
                // At some point while loading the gecko libs our default locale gets set
                // so just save it to locale here and reset it as default after the join
                Locale locale = Locale.getDefault();
                GeckoAppShell.loadGeckoLibs(getApplication().getPackageResourcePath());
                Locale.setDefault(locale);
                Resources res = getBaseContext().getResources();
                Configuration config = res.getConfiguration();
                config.locale = locale;
                res.updateConfiguration(config, res.getDisplayMetrics());
              }
            });
    mLibLoadThread.start();
  }
  public void OnResume(final SharedPreferences prefs) {
    super.OnResume();

    if (_seekBar != null) {
      if (prefs.getBoolean("PuzzleShowSeekBar", true)) {
        _seekBar.setVisibility(View.VISIBLE);

      } else {
        _seekBar.setVisibility(View.GONE);
      }
    }

    ChessImageView._colorScheme = prefs.getInt("ColorScheme", 0);

    _view.setFlippedBoard(prefs.getBoolean("flippedBoard", false));

    _iPos = prefs.getInt("puzzlePos", 0);

    getNumPuzzles();

    if (_num == 0) {

      _num = 500; // first puzzle set has fixed amount
      _progressDlg =
          ProgressDialog.show(
              _parent,
              _parent.getString(R.string.title_installing),
              _parent.getString(R.string.msg_wait),
              false,
              false);

      // if(iTmp > 0)
      //	_cr.delete(MyPuzzleProvider.CONTENT_URI_PUZZLES, "1=1", null);

      _thread =
          new Thread(
              new Runnable() {
                public void run() {

                  try {
                    InputStream is = _parent.getAssets().open("puzzles.pgn");

                    StringBuffer sb = new StringBuffer();
                    String s = "", data;
                    int pos1 = 0, pos2 = 0, len;
                    byte[] buffer = new byte[2048];

                    while ((len = is.read(buffer, 0, buffer.length)) != -1) {
                      data = new String(buffer, 0, len);
                      sb.append(data);
                      pos1 = sb.indexOf("[Event \"");
                      while (pos1 >= 0) {
                        pos2 = sb.indexOf("[Event \"", pos1 + 10);
                        if (pos2 == -1) break;
                        s = sb.substring(pos1, pos2);

                        processPGN(s);

                        sb.delete(0, pos2);

                        pos1 = sb.indexOf("[Event \"");
                      }
                      // break;

                      // Log.i("run", "left: " + sb);
                      // break;
                    }
                    processPGN(sb.toString());

                    Log.i("run", "Count " + _cnt);

                    Message msg = new Message();
                    msg.what = 1;
                    m_threadHandler.sendMessage(msg);

                    is.close();

                  } catch (Exception ex) {
                    Log.e("Install", ex.toString());
                  }
                }
              });
      _thread.start();

      return;
    }

    play();
  }
  private void RunConnectionInThread(final String MAC) {
    Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                outputInfo("Executing sdptool...");
                String output = Commands2script(new String[] {"sdptool browse " + MAC});

                String channel = FindChannel(output);
                if (channel == null) {
                  outputInfo("DUN not found");
                  return;
                }
                outputInfo("Channel is " + channel + " executing rfcomm...");

                output =
                    Commands2script(
                        new String[] {
                          mRFCOMM + " bind " + myDigit + " " + MAC + " " + channel,
                          "sleep 1",
                          mRFCOMM,
                          "sleep 1",
                        });
                outputInfo(output);

                String chatFile = GenerateChatFile();
                output =
                    Commands2script(
                        new String[] {
                          mPPPD
                              + " /dev/rfcomm"
                              + myDigit
                              + " "
                              + "defaultroute "
                              + "usepeerdns "
                              + "noauth "
                              + "debug "
                              + "unit "
                              + myDigit
                              + " "
                              +
                              // "nodetach " +
                              "connect "
                              + "\""
                              + mChatName
                              + " -v -f "
                              + chatFile
                              + "\""
                        });

                boolean bEndWhile = true;
                boolean bSuccess = false;
                do {

                  long l = getPIDof("pppd");
                  if (l == -1) {
                    bEndWhile = false;
                  } else {
                    String IP = FindIP();
                    if (IP != null) {
                      bEndWhile = false;
                      bSuccess = true;
                      outputInfo("IP is: " + IP.substring(1));
                    }
                  }
                  try {
                    Thread.sleep(900);
                  } catch (InterruptedException e) {
                    e.printStackTrace();
                  }
                } while (bEndWhile);
                if (bSuccess) {
                  Commands2script(new String[] {"setprop net.dns1 8.8.8.8"});
                }
                File file = new File(chatFile);
                file.delete();
              }
            });
    thread.start();
  }