Java Code Examples for android.os.SystemClock#currentThreadTimeMillis()

The following examples show how to use android.os.SystemClock#currentThreadTimeMillis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PullToZoomListViewEx.java    From PullZoomView with Apache License 2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example 2
Source File: PullToZoomListView.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
public void run() {
    if (mHeaderView != 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) * PullToZoomListView.sInterpolator.getInterpolation(f1);
            localLayoutParams = mHeaderContainer.getLayoutParams();
            if (f2 > 1.0F) {
                Log.d(TAG, "f2>1.0");
                localLayoutParams.height = ((int) (f2 * mHeaderHeight));
                mHeaderContainer.setLayoutParams(localLayoutParams);
                post(this);
                return;
            }
            mIsFinished = true;
        }
    }
}
 
Example 3
Source File: DownloadService.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
public void startForeground() {
    if (mPosted) {
        mOps = OPS_START_FOREGROUND;
    } else {
        long now = SystemClock.currentThreadTimeMillis();
        if (now - mLastTime > DELAY) {
            // Wait long enough, do it now
            if (mService != null) {
                mService.startForeground(mId, mBuilder.build());
            }
        } else {
            // Too quick, post delay
            mOps = OPS_START_FOREGROUND;
            mPosted = true;
            SimpleHandler.getInstance().postDelayed(this, DELAY);
        }
    }
}
 
Example 4
Source File: PullToZoomScrollViewEx.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
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) * PullToZoomScrollViewEx.sInterpolator.getInterpolation(f1);
            localLayoutParams = mHeaderContainer.getLayoutParams();
            Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
            if (f2 > 1.0F) {
                localLayoutParams.height = ((int) (f2 * mHeaderHeight));
                mHeaderContainer.setLayoutParams(localLayoutParams);
                if (isCustomHeaderHeight) {
                    ViewGroup.LayoutParams zoomLayoutParams;
                    zoomLayoutParams = mZoomView.getLayoutParams();
                    zoomLayoutParams.height = ((int) (f2 * mHeaderHeight));
                    mZoomView.setLayoutParams(zoomLayoutParams);
                }
                post(this);
                return;
            }
            mIsFinished = true;
        }
    }
}
 
Example 5
Source File: PullToZoomScrollViewEx.java    From likequanmintv with Apache License 2.0 6 votes vote down vote up
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) * PullToZoomScrollViewEx.sInterpolator.getInterpolation(f1);
            localLayoutParams = mHeaderContainer.getLayoutParams();
            Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
            if (f2 > 1.0F) {
                localLayoutParams.height = ((int) (f2 * mHeaderHeight));
                mHeaderContainer.setLayoutParams(localLayoutParams);
                if (isCustomHeaderHeight) {
                    ViewGroup.LayoutParams zoomLayoutParams;
                    zoomLayoutParams = mZoomView.getLayoutParams();
                    zoomLayoutParams.height = ((int) (f2 * mHeaderHeight));
                    mZoomView.setLayoutParams(zoomLayoutParams);
                }
                post(this);
                return;
            }
            mIsFinished = true;
        }
    }
}
 
Example 6
Source File: PullToZoomScrollViewEx.java    From PullZoomView with Apache License 2.0 6 votes vote down vote up
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) * PullToZoomScrollViewEx.sInterpolator.getInterpolation(f1);
            localLayoutParams = mHeaderContainer.getLayoutParams();
            Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
            if (f2 > 1.0F) {
                localLayoutParams.height = ((int) (f2 * mHeaderHeight));
                mHeaderContainer.setLayoutParams(localLayoutParams);
                if (isCustomHeaderHeight) {
                    ViewGroup.LayoutParams zoomLayoutParams;
                    zoomLayoutParams = mZoomView.getLayoutParams();
                    zoomLayoutParams.height = ((int) (f2 * mHeaderHeight));
                    mZoomView.setLayoutParams(zoomLayoutParams);
                }
                post(this);
                return;
            }
            mIsFinished = true;
        }
    }
}
 
Example 7
Source File: Benchmark.java    From android-database-performance with Apache License 2.0 6 votes vote down vote up
public void stop(Type type) {
    long time = SystemClock.elapsedRealtime() - timeMillis;
    long timeThread = SystemClock.currentThreadTimeMillis() - threadTimeMillis;
    if (!started) {
        throw new RuntimeException("Not started");
    }
    started = false;

    String name = type.name();
    log(String.format(Locale.US, "%s: %d ms (thread: %d ms)", name, time, timeThread));
    values.add(new Pair<>(name, Long.toString(time)));
    if (storeThreadTime) {
        values.add(new Pair<>(name + "-thread", Long.toString(timeThread)));
    }

    List<Long> typeMeasurements = measurements.get(type.ordinal());
    if (typeMeasurements == null) {
        typeMeasurements = new ArrayList<>();
        measurements.put(type.ordinal(), typeMeasurements);
    }
    typeMeasurements.add(time);
}
 
Example 8
Source File: TaskGuide.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void a(boolean flag)
{
    H = SystemClock.currentThreadTimeMillis();
    android.view.WindowManager.LayoutParams layoutparams;
    if (flag)
    {
        F = true;
    } else
    {
        G = true;
    }
    I = d.height;
    J = d.y;
    layoutparams = d;
    layoutparams.flags = 0x10 | layoutparams.flags;
    f.updateViewLayout(e, d);
}
 
Example 9
Source File: HttpBitmapUtils.java    From long_picture_view with Apache License 2.0 5 votes vote down vote up
/**
 * 保存文件
 * @param bm
 * @throws IOException
 */
public static String saveFile(Bitmap bm) throws IOException {
    File dirFile = new File(ALBUM_PATH);
    if(!dirFile.exists()){
        dirFile.mkdir();
    }
    File myCaptureFile = new File(ALBUM_PATH + SystemClock.currentThreadTimeMillis() +".png");
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
    bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
    bos.flush();
    bos.close();
    return myCaptureFile.getAbsolutePath();
}
 
Example 10
Source File: PullToZoomListView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void startAnimation(long paramLong) {
    if (mHeaderView != null) {
        mStartTime = SystemClock.currentThreadTimeMillis();
        mDuration = paramLong;
        mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
        mIsFinished = false;
        post(this);
    }
}
 
Example 11
Source File: PullToZoomRecyclerViewEx.java    From PullZoomView with Apache License 2.0 5 votes vote down vote up
public void startAnimation(long paramLong) {
    if (mZoomView != null) {
        mStartTime = SystemClock.currentThreadTimeMillis();
        mDuration = paramLong;
        mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
        mIsFinished = false;
        post(this);
    }
}
 
Example 12
Source File: PullToZoomScrollViewEx.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
public void startAnimation(long paramLong) {
    if (mZoomView != null) {
        mStartTime = SystemClock.currentThreadTimeMillis();
        mDuration = paramLong;
        mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
        mIsFinished = false;
        post(this);
    }
}
 
Example 13
Source File: PullToZoomListViewEx.java    From PullZoomView with Apache License 2.0 5 votes vote down vote up
public void startAnimation(long paramLong) {
    if (mZoomView != null) {
        mStartTime = SystemClock.currentThreadTimeMillis();
        mDuration = paramLong;
        mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
        mIsFinished = false;
        post(this);
    }
}
 
Example 14
Source File: PullToZoomViewEx.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
public void startAnimation(long paramLong) {
    if (mZoomView != null) {
        mStartTime = SystemClock.currentThreadTimeMillis();
        mDuration = paramLong;
        mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
        mIsFinished = false;
        post(this);
    }
}
 
Example 15
Source File: PullToZoomScrollViewEx.java    From PullZoomView with Apache License 2.0 5 votes vote down vote up
public void startAnimation(long paramLong) {
    if (mZoomView != null) {
        mStartTime = SystemClock.currentThreadTimeMillis();
        mDuration = paramLong;
        mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
        mIsFinished = false;
        post(this);
    }
}
 
Example 16
Source File: HNRenderer.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
@MainThread
final View render(@NonNull Context context, @NonNull HNSegment segment) throws
        HNRenderException {

    Trace.beginSection("NHRenderer render start");

    mTracker.reset();

    HNLog.d(HNLog.RENDER, "start to render " + segment.toString());
    HNRootView rootViewGroup = new HNRootView(context);

    HNSandBoxContext sandBoxContext = HNSandBoxContextImpl.createContext(rootViewGroup,
            segment, context);


    mInheritStyleStack.reset();

    LayoutParamsCreator rootCreator = new LayoutParamsCreator();

    long renderStartTime = SystemClock.currentThreadTimeMillis();
    View v = renderInternal(context, sandBoxContext, segment.getDom(), segment,
            rootViewGroup, rootCreator, rootViewGroup, segment.getStyleSheet());


    if (v != null) {
        rootViewGroup.addContent(v, LayoutParamsCreator.createLayoutParams(rootViewGroup,
                rootCreator));
        mTracker.record("Render View", SystemClock.currentThreadTimeMillis() - renderStartTime);

        long createTime = SystemClock.currentThreadTimeMillis();
        this.performCreate(sandBoxContext);
        mTracker.record("Create View", SystemClock.currentThreadTimeMillis() - createTime);

        long afterCreate = SystemClock.currentThreadTimeMillis();
        this.performCreated(sandBoxContext);
        mTracker.record("After View Created", SystemClock.currentThreadTimeMillis() -
                afterCreate);

        Log.i(PERFORMANCE_TAG, mTracker.dump());

        HNLog.d(HNLog.RENDER, sandBoxContext.allIdTag());
        Trace.endSection();
        return rootViewGroup;
    }

    Trace.endSection();
    return null;
}
 
Example 17
Source File: Parser.java    From HtmlNative with Apache License 2.0 4 votes vote down vote up
public HNSegment process() throws HNSyntaxError {

        long processStartTime = SystemClock.currentThreadTimeMillis();

        HNSegment segment = new HNSegment();
        segment.setDom(new HNDomTree(segment.getInlineStyles(), null, 0, 0));

        try {
            scanFor(StartAngleBracket);

            scan(true);

            /*
             * skip the HTML version information. see https://www.w3.org/TR/html4/struct/global
             * .html#h-7.2
             */
            if (mCurToken.type() == Exclamation) {
                mLexer.skipUntil('>');
                // consume the reserved
                scan();
                scanFor(EndAngleBracket);
                scanFor(StartAngleBracket);
                scan(true);
            }

            if (mCurToken.type() == Html) {
                scan();
                scanFor(EndAngleBracket, StartAngleBracket);
                processHtmlInside(segment);
            } else {
                processHtmlInside(segment);
            }

            scanFor(StartAngleBracket, Slash, Html, EndAngleBracket);
        } catch (EOFException ignored) {
            Log.w(TAG, "Reach the end of file!");
        } finally {
            mLexer.close();
            mTracker.record("Parse Css + Html", SystemClock.currentThreadTimeMillis() -
                    processStartTime);
            Log.i(PERFORMANCE_TAG, mTracker.dump());
            if (mSyntaxErrorHandler.hasError()) {
                Log.e(TAG, mSyntaxErrorHandler.forceDump());
            }
            return segment;
        }
    }
 
Example 18
Source File: w.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void run()
{
    boolean flag = true;
    SystemClock.currentThreadTimeMillis();
    b = (float)(0.10000000000000001D + (double)b);
    float f = b;
    if (f > 1.0F)
    {
        f = 1.0F;
    }
    boolean flag1;
    int i;
    if (f >= 1.0F)
    {
        flag1 = flag;
    } else
    {
        flag1 = false;
    }
    i = (int)(TaskGuide.r(c).getInterpolation(f) * (float)TaskGuide.s(c));
    if (a)
    {
        TaskGuide.k(c).y = i + TaskGuide.t(c);
    } else
    {
        TaskGuide.k(c).y = TaskGuide.t(c) - i;
    }
    Log.d("TAG", (new StringBuilder()).append("mWinParams.y = ").append(TaskGuide.k(c).y).append("deltaDistence = ").append(i).toString());
    if (TaskGuide.a(c))
    {
        TaskGuide.u(c).updateViewLayout(TaskGuide.b(c), TaskGuide.k(c));
        flag = flag1;
    }
    if (flag)
    {
        TaskGuide.v(c);
        return;
    } else
    {
        TaskGuide.x(c).postDelayed(TaskGuide.w(c), 5L);
        return;
    }
}
 
Example 19
Source File: ScanFragment.java    From sdscanner with GNU General Public License v2.0 4 votes vote down vote up
protected void dbOneTry(ScanParameters parameters) {
    Cursor cursor = mApplicationContext.getContentResolver().query(
            MediaStore.Files.getContentUri("external"),
            MEDIA_PROJECTION,
            //STAR,
            null,
            null,
            null);
    int data_column =
            cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
    int modified_column =
            cursor.getColumnIndex(MediaStore.MediaColumns.DATE_MODIFIED);
    int totalSize = cursor.getCount();
    int currentItem = 0;
    int reportFreq = 0;
    // Used to calibrate reporting frequency
    long startTime = SystemClock.currentThreadTimeMillis();
    while (cursor.moveToNext()) {
        currentItem++;
        try {
            File file = new File(cursor.getString(data_column)).getCanonicalFile();
            if ((!file.exists() ||
                     file.lastModified() / 1000L >
                     cursor.getLong(modified_column))
                     && parameters.shouldScan(file, true)) {
                // Media scanner handles these cases.
                // Is a set, so OK if already present.
                mFilesToProcess.add(file);
            }
            else {
                // Don't want to waste time scanning an up-to-date
                // file.
                mFilesToProcess.remove(file);
            }
            if (reportFreq == 0) {
                // Calibration phase
                if (SystemClock.currentThreadTimeMillis() - startTime > 25) {
                    reportFreq = currentItem + 1;
                }
            }
            else if (currentItem % reportFreq == 0) {
                publishProgress(databaseUpdate(file.getPath(),
                                (100 * currentItem) / totalSize));
            }
        }
        catch (IOException ex) {
            // Just ignore it for now.
        }
    }
    // Don't need the cursor any more.
    cursor.close();
}
 
Example 20
Source File: Parser.java    From HtmlNative with Apache License 2.0 3 votes vote down vote up
private void processTemplate(HNDomTree tree) throws HNSyntaxError, EOFException {

        long timeStart = SystemClock.currentThreadTimeMillis();

        if (mCurToken.type() != Template) {
            mSyntaxErrorHandler.throwException("Look for Template, but " + mCurToken.toString());
        }

        tree.setType(mCurToken.stringValue());
        processInternal(tree);

        mTracker.record("Parse Html", SystemClock.currentThreadTimeMillis() - timeStart);
    }