示例#1
0
  @Override
  public void initData() {
    long startTime = SystemClock.currentThreadTimeMillis();

    //        ApiManager.getObGithub(new MyObserver<List<GithubCollect>>() {
    //            @Override
    //            public void onNext(List<GithubCollect> datas) {
    //                Logger.d(datas);
    //            }
    //        });

    saveCache();

    long endTime = SystemClock.currentThreadTimeMillis();
    long d = endTime - startTime;

    if (d > TIME_OUT) {
      Intent intent = new Intent(SplashActivity.this, MainActivity.class);
      startActivity(intent);
      finish();
    } else {
      new Handler()
          .postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                  startActivity(intent);
                  finish();
                }
              },
              TIME_OUT - d);
    }
  }
示例#2
0
 // 打印距离上次记录系统时间至今的消耗时间
 public static void printTime(Object o, String msg) {
   if (ENABLE_LOG && ENABLE_LOG_PROFILE) {
     long currentTime = SystemClock.currentThreadTimeMillis();
     String tag = getTag(o);
     i(
         tag,
         msg
             + " -> cost time = "
             + (currentTime - mLastTime)
             + ", total time = "
             + (currentTime - mInitTime));
     mLastTime = SystemClock.currentThreadTimeMillis();
   }
 }
  /**
   * Initialize secret key for encrypting user password
   *
   * @throws RuntimeException
   */
  private void initializeSecretKey() {
    // Random string
    String baseKey = "" + SystemClock.currentThreadTimeMillis() + new Random().nextInt();

    // md5 random string
    MessageDigest digest;
    String secretKey;
    try {
      digest = java.security.MessageDigest.getInstance("MD5");
      digest.reset();
      digest.update(baseKey.getBytes());
      byte messageDigest[] = digest.digest();
      int len = messageDigest.length;
      StringBuilder sb = new StringBuilder(len << 1);
      for (int i = 0; i < len; i++) {
        sb.append(Character.forDigit((messageDigest[i] & 0xf0) >> 4, 16));
        sb.append(Character.forDigit(messageDigest[i] & 0x0f, 16));
      }
      secretKey = sb.substring(0, 32);
    } catch (NoSuchAlgorithmException e) {
      throw new RuntimeException(e);
    }

    // Set secret key
    this.setSecretKey(secretKey);
  }
 public void finishTiming(boolean realTime) {
   if (realTime) {
     mEndTime = System.currentTimeMillis();
   } else {
     mEndTime = SystemClock.currentThreadTimeMillis();
   }
 }
 public void startTiming(boolean realTime) {
   if (realTime) {
     mStartTime = System.currentTimeMillis();
   } else {
     mStartTime = SystemClock.currentThreadTimeMillis();
   }
 }
示例#6
0
 /**
  * 设置图片的URI和其他的信息
  *
  * @param uri 图片的URI
  * @param bitmap 图片的Bitmap
  */
 private void setImageURI(final Uri uri, final Bitmap bitmap) {
   btn_weibowrite_imageok.setEnabled(true);
   iv_weibowrite_image.setImageBitmap(bitmap);
   imageUri = uri;
   imagePath =
       CacheUtil.PICTURE_CACHE_PATH + "tmppic_" + SystemClock.currentThreadTimeMillis() + ".jpg";
   CacheUtil.saveImageToPath(bitmap, imagePath); // save the image
 }
示例#7
0
 // 初始化记录消耗的系统初始时间
 public static long initTime() {
   if (ENABLE_LOG && ENABLE_LOG_PROFILE) {
     mLastTime = SystemClock.currentThreadTimeMillis();
     mInitTime = mLastTime;
     return mLastTime;
   }
   return 0;
 }
示例#8
0
 public void startAnimation(long paramLong) {
   this.mStartTime = SystemClock.currentThreadTimeMillis();
   this.mDuration = paramLong;
   this.mScale =
       ((float) (PullToZoomListView.this.mHeaderContainer.getBottom())
           / PullToZoomListView.this.mHeaderHeight);
   this.mIsFinished = false;
   PullToZoomListView.this.post(this);
 }
 public void startAnimation(long paramLong) {
   if (mZoomView != null) {
     mStartTime = SystemClock.currentThreadTimeMillis();
     mDuration = paramLong;
     mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
     mIsFinished = false;
     post(this);
   }
 }
 public void onPageStarted(String url, Bitmap favicon) {
   // Do an unsynchronized quick check to avoid posting if no callback has
   // been set.
   if (mWebViewClient == null) {
     return;
   }
   // Performance probe
   if (false) {
     mWebCoreThreadTime = SystemClock.currentThreadTimeMillis();
     Network.getInstance(mContext).startTiming();
   }
   Message msg = obtainMessage(PAGE_STARTED);
   msg.obj = favicon;
   msg.getData().putString("url", url);
   sendMessage(msg);
 }
 public void onPageFinished(String url) {
   // Do an unsynchronized quick check to avoid posting if no callback has
   // been set.
   if (mWebViewClient == null) {
     return;
   }
   // Performance probe
   if (false) {
     Log.d(
         "WebCore",
         "WebCore thread used "
             + (SystemClock.currentThreadTimeMillis() - mWebCoreThreadTime)
             + " ms");
     Network.getInstance(mContext).stopTiming();
   }
   Message msg = obtainMessage(PAGE_FINISHED, url);
   sendMessage(msg);
 }
 public Cell(int cid, int lac, int signal, int psc, int netType, boolean dbm) {
   this.cid = cid;
   this.lac = lac;
   mcc = Integer.MAX_VALUE;
   mnc = Integer.MAX_VALUE;
   if (dbm) {
     this.dbm = signal;
   } else {
     this.rssi = signal;
   }
   this.psc = psc;
   this.netType = netType;
   timingAdvance = Integer.MAX_VALUE;
   sid = Integer.MAX_VALUE;
   lon = 0.0;
   lat = 0.0;
   speed = 0.0;
   accuracy = 0.0;
   bearing = 0.0;
   this.timestamp = SystemClock.currentThreadTimeMillis();
 }
示例#13
0
 public static int i(Object o, String msg) {
   if (ENABLE_LOG) {
     String tag = getTag(o);
     if (msg.contains("BEGIN")) {
       LogUtil.initTime();
     } else if (msg.contains("END")) {
       msg = genenateLogPrefix(tag) + msg;
       long currentTime = SystemClock.currentThreadTimeMillis();
       return Log.i(
           tag,
           msg
               + " -> cost time = "
               + (currentTime - mLastTime)
               + ", total time = "
               + (currentTime - mInitTime));
     }
     msg = genenateLogPrefix(tag) + msg;
     return Log.i(tag, msg);
   }
   return 0;
 }
 public void run() {
   if (mZoomView != null) {
     float f2;
     ViewGroup.LayoutParams localLayoutParams;
     if ((!mIsFinished) && (mScale > 1.0D)) {
       float f1 =
           ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime)
               / (float) mDuration;
       f2 = mScale - (mScale - 1.0F) * PullToZoomListViewEx.sInterpolator.getInterpolation(f1);
       localLayoutParams = mHeaderContainer.getLayoutParams();
       Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
       if (f2 > 1.0F) {
         localLayoutParams.height = ((int) (f2 * mHeaderHeight));
         mHeaderContainer.setLayoutParams(localLayoutParams);
         post(this);
         return;
       }
       mIsFinished = true;
     }
   }
 }
示例#15
0
 public void run() {
   float f2;
   ViewGroup.LayoutParams localLayoutParams;
   if ((!this.mIsFinished) && (this.mScale > 1.0D)) {
     float f1 =
         ((float) SystemClock.currentThreadTimeMillis() - (float) this.mStartTime)
             / (float) this.mDuration;
     f2 =
         this.mScale
             - (this.mScale - 1.0F) * PullToZoomListView.sInterpolator.getInterpolation(f1);
     localLayoutParams = PullToZoomListView.this.mHeaderContainer.getLayoutParams();
     if (f2 > 1.0F) {
       Log.d("mmm", "f2>1.0");
       localLayoutParams.height = PullToZoomListView.this.mHeaderHeight;
       localLayoutParams.height = ((int) (f2 * PullToZoomListView.this.mHeaderHeight));
       PullToZoomListView.this.mHeaderContainer.setLayoutParams(localLayoutParams);
       PullToZoomListView.this.post(this);
       return;
     }
     this.mIsFinished = true;
   }
 }
 private void addPeriodic(
     long periodSecs, long flexSecs, int connectivity, boolean charging, boolean persistence) {
   if (flexSecs > periodSecs) {
     Toast.makeText(getActivity(), getString(R.string.scheduler_error_flex), Toast.LENGTH_SHORT)
         .show();
     return;
   }
   String tag = Long.toString(SystemClock.currentThreadTimeMillis());
   final TaskTracker taskTracker = TaskTracker.createPeriodic(tag, periodSecs, flexSecs);
   PeriodicTask periodic =
       new PeriodicTask.Builder()
           .setService(TaskSchedulerService.class)
           .setPeriod(periodSecs)
           .setFlex(flexSecs)
           .setTag(tag)
           .setRequiredNetwork(connectivity)
           .setRequiresCharging(charging)
           .setPersisted(persistence)
           .build();
   mScheduler.schedule(periodic);
   mTasks.updateTask(taskTracker);
 }
 private void addOneOff(long winStartSecs, long winEndSecs, int connectivity, boolean charging) {
   if (winStartSecs > winEndSecs) {
     Toast.makeText(getActivity(), getString(R.string.scheduler_error_window), Toast.LENGTH_SHORT)
         .show();
     return;
   }
   String tag = Long.toString(SystemClock.currentThreadTimeMillis());
   final long elapsedNowSeconds = SystemClock.elapsedRealtime() / 1000;
   final TaskTracker taskTracker =
       TaskTracker.createOneoff(
           tag, elapsedNowSeconds + winStartSecs, elapsedNowSeconds + winEndSecs);
   OneoffTask oneOff =
       new OneoffTask.Builder()
           .setService(TaskSchedulerService.class)
           .setTag(tag)
           .setExecutionWindow(winStartSecs, winEndSecs)
           .setRequiredNetwork(connectivity)
           // Persistence not yet support for Oneoffs.
           .setRequiresCharging(charging)
           .build();
   mScheduler.schedule(oneOff);
   mTasks.updateTask(taskTracker);
 }
示例#18
0
 @TesterDebugLog
 private boolean ranaGicikOldumu2(String str1, String str2) {
   if (SystemClock.currentThreadTimeMillis() % 2 == 0) return true;
   else return false;
 }
  public void runInPerformanceMode(
      Object testCase, String className, boolean junitTest, String testNameInDb) throws Exception {
    boolean increaseIterations = true;
    int iterations = 1;
    long duration = 0;
    mIntermediates = null;

    mInternalIterations = 1;
    Class clazz = mContext.getClassLoader().loadClass(className);
    Object perftest = clazz.newInstance();

    PerformanceTestCase perftestcase = null;
    if (perftest instanceof PerformanceTestCase) {
      perftestcase = (PerformanceTestCase) perftest;
      // only run the test if it is not marked as a performance only test
      if (mMode == REGRESSION && perftestcase.isPerformanceOnly()) return;
    }

    // First force GCs, to avoid GCs happening during out
    // test and skewing its time.
    Runtime.getRuntime().runFinalization();
    Runtime.getRuntime().gc();

    if (perftestcase != null) {
      mIntermediates = new ArrayList<IntermediateTime>();
      iterations = perftestcase.startPerformance(this);
      if (iterations > 0) {
        increaseIterations = false;
      } else {
        iterations = 1;
      }
    }

    // Pause briefly to let things settle down...
    Thread.sleep(1000);
    do {
      mEndTime = 0;
      if (increaseIterations) {
        // Test case does not implement
        // PerformanceTestCase or returned 0 iterations,
        // so we take care of measure the whole test time.
        mStartTime = SystemClock.currentThreadTimeMillis();
      } else {
        // Try to make it obvious if the test case
        // doesn't call startTiming().
        mStartTime = 0;
      }

      if (junitTest) {
        for (int i = 0; i < iterations; i++) {
          junit.textui.TestRunner.run((junit.framework.Test) testCase);
        }
      } else {
        Runnable test = (Runnable) testCase;
        for (int i = 0; i < iterations; i++) {
          test.run();
        }
      }

      long endTime = mEndTime;
      if (endTime == 0) {
        endTime = SystemClock.currentThreadTimeMillis();
      }

      duration = endTime - mStartTime;
      if (!increaseIterations) {
        break;
      }
      if (duration <= 1) {
        iterations *= 1000;
      } else if (duration <= 10) {
        iterations *= 100;
      } else if (duration < 100) {
        iterations *= 10;
      } else if (duration < 1000) {
        iterations *= (int) ((1000 / duration) + 2);
      } else {
        break;
      }
    } while (true);

    if (duration != 0) {
      iterations *= mInternalIterations;
      performance(testNameInDb, (duration * 1000000) / iterations, iterations, mIntermediates);
    }
  }
示例#20
0
 public static String a(String str) {
   int nextInt = new Random(SystemClock.currentThreadTimeMillis()).nextInt(90) + 10;
   return b(nextInt + str) + a.ci + nextInt;
 }
示例#21
0
 @TesterDebugLog
 private boolean cihanAyaktami() {
   if (SystemClock.currentThreadTimeMillis() % 2 == 0) return true;
   else return false;
 }
 public void onPageStarted(WebView paramWebView, String paramString, Bitmap paramBitmap) {
   super.onPageStarted(paramWebView, paramString, paramBitmap);
   WebActivity.a(a, SystemClock.currentThreadTimeMillis());
 }
示例#23
0
 /* (non-Javadoc)
  * @see java.lang.Thread#run()
  *********************************************************************************************
  */
 @Override
 public void run() {
   if (downloadedSize < block) { // 如果没有下载完成
     // 打开连接
     try {
       // 建立一个连接,此时并未真正的开始连接
       HttpURLConnection httpConnection = (HttpURLConnection) downUrl.openConnection();
       httpConnection.setConnectTimeout(5 * 1000);
       // 使用Get方式下载
       httpConnection.setRequestMethod("GET");
       httpConnection.setRequestProperty(
           "Accept",
           "image/gif, image/jpeg, image/pjpeg, "
               + "image/pjpeg, application/x-shockwave-flash,"
               + " application/xaml+xml, application/vnd.ms-xpsdocument, "
               + "application/x-ms-xbap, application/x-ms-application, "
               + "application/vnd.ms-excel, application/vnd.ms-powerpoint,"
               + " application/msword, */*");
       httpConnection.setRequestProperty("Accept-Language", "zh-CN");
       httpConnection.setRequestProperty("Referer", downUrl.toString());
       httpConnection.setRequestProperty("Charset", "UTF-8");
       int startPos = block * (threadId - 1) + downloadedSize; // 开始位置
       int endPos = block * threadId - 1; // 结束位置
       httpConnection.setRequestProperty(
           "Range", "bytes=" + startPos + "-" + endPos); // 设置获取实体数据的范围
       httpConnection.setRequestProperty(
           "User-Agent",
           "Mozilla/4.0 "
               + "(compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; "
               + ".NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; "
               + ".NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");
       httpConnection.setRequestProperty("Connection", "Keep-Alive");
       InputStream inStream = httpConnection.getInputStream(); // 获取远程的输入流
       byte[] buffer = new byte[1024 * 512]; // 设置本地缓存数据位1MB
       int offset = 0; // 设置每次读取的数据量
       long curTime = SystemClock.currentThreadTimeMillis();
       int curSize = downloadedSize;
       Log.i(
           TAG,
           "线程 "
               + this.threadId
               + "  的开始下载位置是:"
               + startPos
               + " B"
               + "  数据库更新时间间隔:"
               + downloader.SqlTime
               + " ms"
               + "  长度间隔:"
               + downloader.Sqlfilesize
               + "  B"); // 打印线程开始的位置
       RandomAccessFile threadFile = new RandomAccessFile(this.saveFile, "rwd");
       threadFile.seek(startPos); // 文件指针指向文件开始的地方
       while (!downloader.getExited() && (offset = inStream.read(buffer, 0, 1024 * 512)) != -1) {
         // 当用户没有要停止下载,同时没有达到文件的末尾的时候会一直循环读取数据
         threadFile.write(buffer, 0, offset); // 直接把数据写到文件中
         downloadedSize += offset; // 新下载的长度加到已下载的长度中
         downloader.updateDownloadSize(this.threadId, downloadedSize); // 更新数据长度
         downloader.appendDownloadSize(offset); // 把新下载的数据长度加到已经下载的数据总长度中
         if ((SystemClock.currentThreadTimeMillis() - curTime) > downloader.SqlTime
             || ((downloadedSize - curSize) > downloader.Sqlfilesize)) {
           curTime = SystemClock.currentThreadTimeMillis();
           curSize = downloadedSize;
           threadFile.close();
           threadFile = null;
           Log.i(TAG, "线程 " + this.threadId + "  数据库更新");
           downloader.updateDownloadSizeSql(this.threadId, downloadedSize); // 写进数据库
           threadFile = new RandomAccessFile(this.saveFile, "rwd");
           threadFile.seek(block * (threadId - 1) + downloadedSize);
         }
       }
       // 当线程下载数据完毕或者用户停止了下载
       threadFile.close();
       inStream.close();
       if (downloader.getExited()) {
         Log.i(TAG, "Thread " + this.threadId + "停止下载");
       } else {
         Log.i(TAG, "Thread " + this.threadId + "下载完成");
       }
       // 设置下载完成标志位true,无论是下载完成还是用户停止下载
       this.finished = true;
     } catch (IOException e) {
       this.downloadedSize = -1; // 设置线程已经下载的长度为-1
       e.printStackTrace();
     }
   }
 }