首页

android帧率测试

java

2020-8-25

android帧率测试,源码,测试apk的刷新率。
FpsService-帧率测试.zip

package com.example.fps;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;

import com.baidu.fps.FpsService;

public class MainActivity extends Activity implements AdapterView.OnItemClickListener,
    View.OnClickListener
{
    private final Handler mHandler = new Handler()
    {
        public void handleMessage(android.os.Message msg) 
        {
            
        };
    };
    
    private ListView mPhotosList;
    private ViewGroup mContainer;
    private ImageView mImageView;

    // Names of the photos we show in the list
    private static final String[] PHOTOS_NAMES = new String[] {
            "Lyon",
            "Livermore",
            "Tahoe Pier",
            "Lake Tahoe",
            "Grand Canyon",
            "Bodie"
    };

    // Resource identifiers for the photos we want to display
    private static final int[] PHOTOS_RESOURCES = new int[] {
            R.drawable.photo1,
            R.drawable.photo2,
            R.drawable.photo3,
            R.drawable.photo4,
            R.drawable.photo5,
            R.drawable.photo6
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.animations_main_screen);

        mPhotosList = (ListView) findViewById(android.R.id.list);
        mImageView = (ImageView) findViewById(R.id.picture);
        mContainer = (ViewGroup) findViewById(R.id.container);

        // Prepare the ListView
        final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, PHOTOS_NAMES);

        mPhotosList.setAdapter(adapter);
        mPhotosList.setOnItemClickListener(this);

        // Prepare the ImageView
        mImageView.setClickable(true);
        mImageView.setFocusable(true);
        mImageView.setOnClickListener(this);

        // Since we are caching large views, we want to keep their cache
        // between each animation
        mContainer.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
        
        showFps(true);
    }

    /**
     * Setup a new 3D rotation on the container view.
     *
     * @param position the item that was clicked to show a picture, or -1 to show the list
     * @param start the start angle at which the rotation must begin
     * @param end the end angle of the rotation
     */
    private void applyRotation(int position, float start, float end) {
        // Find the center of the container
        final float centerX = mContainer.getWidth() / 2.0f;
        final float centerY = mContainer.getHeight() / 2.0f;

        // Create a new 3D rotation with the supplied parameter
        // The animation listener is used to trigger the next animation
        final Rotate3dAnimation rotation =
                new Rotate3dAnimation(start, end, centerX, centerY, 310.0f, true);
        rotation.setDuration(500);
        rotation.setFillAfter(true);
        rotation.setInterpolator(new AccelerateInterpolator());
        rotation.setAnimationListener(new DisplayNextView(position));

        mContainer.startAnimation(rotation);
    }

    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        // Pre-load the image then start the animation
        mImageView.setImageResource(PHOTOS_RESOURCES[position]);
        applyRotation(position, 0, 90);
    }

    public void onClick(View v) {
        applyRotation(-1, 180, 90);
    }

    /**
     * This class listens for the end of the first half of the animation.
     * It then posts a new action that effectively swaps the views when the container
     * is rotated 90 degrees and thus invisible.
     */
    private final class DisplayNextView implements Animation.AnimationListener {
        private final int mPosition;

        private DisplayNextView(int position) {
            mPosition = position;
        }

        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            mContainer.post(new SwapViews(mPosition));
        }

        public void onAnimationRepeat(Animation animation) {
        }
    }

    /**
     * This class is responsible for swapping the views and start the second
     * half of the animation.
     */
    private final class SwapViews implements Runnable {
        private final int mPosition;

        public SwapViews(int position) {
            mPosition = position;
        }

        public void run() {
            final float centerX = mContainer.getWidth() / 2.0f;
            final float centerY = mContainer.getHeight() / 2.0f;
            Rotate3dAnimation rotation;
            
            if (mPosition > -1) {
                mPhotosList.setVisibility(View.GONE);
                mImageView.setVisibility(View.VISIBLE);
                mImageView.requestFocus();

                rotation = new Rotate3dAnimation(90, 180, centerX, centerY, 310.0f, false);
            } else {
                mImageView.setVisibility(View.GONE);
                mPhotosList.setVisibility(View.VISIBLE);
                mPhotosList.requestFocus();

                rotation = new Rotate3dAnimation(90, 0, centerX, centerY, 310.0f, false);
            }

            rotation.setDuration(500);
            rotation.setFillAfter(true);
            rotation.setInterpolator(new DecelerateInterpolator());

            mContainer.startAnimation(rotation);
        }
    }
    
    
    @Override
    protected void onDestroy()
    {
        
        super.onDestroy();
        showFps(false);
    }
    
    private void showFps(boolean show)
    {
        if(show)
        {
            Intent intent = new Intent(this, FpsService.class);
            startService(intent);
        }
        else
        {
            Intent intent = new Intent(this, FpsService.class);
            stopService(intent);
        }
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}

资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
FpsService-╓í┬╩▓Γ╩╘/.classpath , 475
FpsService-╓í┬╩▓Γ╩╘/.project , 813
FpsService-╓í┬╩▓Γ╩╘/AndroidManifest.xml , 1040
FpsService-╓í┬╩▓Γ╩╘/bin/AndroidManifest.xml , 1040
FpsService-╓í┬╩▓Γ╩╘/bin/classes.dex , 707272
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsService$1.class , 801
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsService$FpsRecord.class , 572
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsService$Worker$1.class , 1413
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsService$Worker.class , 3735
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsService.class , 7727
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsView$FpsUpdateListener.class , 236
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/baidu/fps/FpsView.class , 2691
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/BuildConfig.class , 339
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/MainActivity$1.class , 635
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/MainActivity$DisplayNextView.class , 1444
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/MainActivity$SwapViews.class , 1830
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/MainActivity.class , 5514
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$anim.class , 436
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$attr.class , 331
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$dimen.class , 452
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$drawable.class , 578
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$id.class , 448
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$layout.class , 440
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$menu.class , 379
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$string.class , 463
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R$style.class , 422
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/R.class , 686
FpsService-╓í┬╩▓Γ╩╘/bin/classes/com/example/fps/Rotate3dAnimation.class , 1890
FpsService-╓í┬╩▓Γ╩╘/bin/dexedLibs/android-support-v4-7aae28697e2d50ef5beaedd35787b048.jar , 232551
FpsService-╓í┬╩▓Γ╩╘/bin/FpsService.apk , 548941
FpsService-╓í┬╩▓Γ╩╘/bin/jarlist.cache , 120
FpsService-╓í┬╩▓Γ╩╘/bin/resources.ap_ , 304475
FpsService-╓í┬╩▓Γ╩╘/bin/res/crunch/drawable-hdpi/ic_launcher.png , 5964
FpsService-╓í┬╩▓Γ╩╘/bin/res/crunch/drawable-mdpi/ic_launcher.png , 3112
FpsService-╓í┬╩▓Γ╩╘/bin/res/crunch/drawable-xhdpi/ic_launcher.png , 9355
FpsService-╓í┬╩▓Γ╩╘/bin/res/crunch/drawable-xxhdpi/ic_launcher.png , 17889
FpsService-╓í┬╩▓Γ╩╘/device.png , 1300066
FpsService-╓í┬╩▓Γ╩╘/gen/com/example/fps/BuildConfig.java , 157
FpsService-╓í┬╩▓Γ╩╘/gen/com/example/fps/R.java , 3152
FpsService-╓í┬╩▓Γ╩╘/ic_launcher-web.png , 51394
FpsService-╓í┬╩▓Γ╩╘/libs/android-support-v4.jar , 621451
FpsService-╓í┬╩▓Γ╩╘/project.properties , 563
FpsService-╓í┬╩▓Γ╩╘/README.md , 220
FpsService-╓í┬╩▓Γ╩╘/res/anim/layout_bottom_to_top_slide.xml , 869
FpsService-╓í┬╩▓Γ╩╘/res/anim/slide_right.xml , 944
FpsService-╓í┬╩▓Γ╩╘/res/drawable-hdpi/ic_launcher.png , 7658
FpsService-╓í┬╩▓Γ╩╘/res/drawable-mdpi/ic_launcher.png , 3777
FpsService-╓í┬╩▓Γ╩╘/res/drawable-xhdpi/ic_launcher.png , 12516
FpsService-╓í┬╩▓Γ╩╘/res/drawable-xxhdpi/ic_launcher.png , 24777
FpsService-╓í┬╩▓Γ╩╘/res/drawable/photo1.jpg , 41935
FpsService-╓í┬╩▓Γ╩╘/res/drawable/photo2.jpg , 16713
FpsService-╓í┬╩▓Γ╩╘/res/drawable/photo3.jpg , 53979
FpsService-╓í┬╩▓Γ╩╘/res/drawable/photo4.jpg , 47866
FpsService-╓í┬╩▓Γ╩╘/res/drawable/photo5.jpg , 55140
FpsService-╓í┬╩▓Γ╩╘/res/drawable/photo6.jpg , 44168
FpsService-╓í┬╩▓Γ╩╘/res/layout/activity_main.xml , 681
FpsService-╓í┬╩▓Γ╩╘/res/layout/animations_main_screen.xml , 1364
FpsService-╓í┬╩▓Γ╩╘/res/menu/main.xml , 254
FpsService-╓í┬╩▓Γ╩╘/res/values-sw600dp/dimens.xml , 196
FpsService-╓í┬╩▓Γ╩╘/res/values-sw720dp-land/dimens.xml , 269
FpsService-╓í┬╩▓Γ╩╘/res/values-v11/styles.xml , 324
FpsService-╓í┬╩▓Γ╩╘/res/values-v14/styles.xml , 381
FpsService-╓í┬╩▓Γ╩╘/res/values/dimens.xml , 213
FpsService-╓í┬╩▓Γ╩╘/res/values/strings.xml , 218
FpsService-╓í┬╩▓Γ╩╘/res/values/styles.xml , 680
FpsService-╓í┬╩▓Γ╩╘/src/com/baidu/fps/FpsService.java , 11412
FpsService-╓í┬╩▓Γ╩╘/src/com/baidu/fps/FpsView.java , 3071
FpsService-╓í┬╩▓Γ╩╘/src/com/example/fps/MainActivity.java , 6584
FpsService-╓í┬╩▓Γ╩╘/src/com/example/fps/Rotate3dAnimation.java , 3456
没有账号? 忘记密码?

社交账号快速登录