Search in sources :

Example 1 with PerfListener

use of com.facebook.samples.comparison.instrumentation.PerfListener in project fresco by facebook.

the class MainActivity method setLoaderAdapter.

private void setLoaderAdapter(int index) {
    FLog.v(TAG, "onImageLoaderSelect: %d", index);
    resetAdapter();
    mCurrentLoaderAdapterIndex = index;
    mPerfListener = new PerfListener();
    switch(index) {
        case FRESCO_INDEX:
        case FRESCO_OKHTTP_INDEX:
            mCurrentAdapter = new FrescoAdapter(this, mPerfListener, index == FRESCO_INDEX ? ImagePipelineConfigFactory.getImagePipelineConfig(this) : ImagePipelineConfigFactory.getOkHttpImagePipelineConfig(this));
            break;
        case GLIDE_INDEX:
            mCurrentAdapter = new GlideAdapter(this, mPerfListener);
            break;
        case PICASSO_INDEX:
            mCurrentAdapter = new PicassoAdapter(this, mPerfListener);
            break;
        case UIL_INDEX:
            mCurrentAdapter = new UilAdapter(this, mPerfListener);
            break;
        case VOLLEY_INDEX:
            mCurrentAdapter = new VolleyAdapter(this, mPerfListener);
            break;
        case AQUERY_INDEX:
            mCurrentAdapter = new AQueryAdapter(this, mPerfListener);
            break;
        default:
            mCurrentAdapter = null;
            return;
    }
    mRecyclerView.setAdapter(mCurrentAdapter);
    updateAdapter(mImageUrls);
    updateStats();
}
Also used : PerfListener(com.facebook.samples.comparison.instrumentation.PerfListener) VolleyAdapter(com.facebook.samples.comparison.adapters.VolleyAdapter) GlideAdapter(com.facebook.samples.comparison.adapters.GlideAdapter) PicassoAdapter(com.facebook.samples.comparison.adapters.PicassoAdapter) AQueryAdapter(com.facebook.samples.comparison.adapters.AQueryAdapter) FrescoAdapter(com.facebook.samples.comparison.adapters.FrescoAdapter) UilAdapter(com.facebook.samples.comparison.adapters.UilAdapter)

Example 2 with PerfListener

use of com.facebook.samples.comparison.instrumentation.PerfListener in project fresco by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRecyclerView = (RecyclerView) findViewById(R.id.image_grid);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, COLS_NUMBER));
    FLog.setMinimumLoggingLevel(FLog.WARN);
    Drawables.init(getResources());
    mPerfListener = new PerfListener();
    mAllowAnimations = true;
    mCurrentLoaderAdapterIndex = 0;
    mCurrentSourceAdapterIndex = 0;
    if (savedInstanceState != null) {
        mAllowAnimations = savedInstanceState.getBoolean(EXTRA_ALLOW_ANIMATIONS);
        mCurrentLoaderAdapterIndex = savedInstanceState.getInt(EXTRA_CURRENT_ADAPTER_INDEX);
        mCurrentSourceAdapterIndex = savedInstanceState.getInt(EXTRA_CURRENT_SOURCE_ADAPTER_INDEX);
    }
    mHandler = new Handler(Looper.getMainLooper());
    mStatsClockTickRunnable = new Runnable() {

        @Override
        public void run() {
            updateStats();
            scheduleNextStatsClockTick();
        }
    };
    mCurrentAdapter = null;
    mStatsDisplay = (TextView) findViewById(R.id.stats_display);
    mLoaderSelect = (Spinner) findViewById(R.id.loader_select);
    mLoaderSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setLoaderAdapter(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mLoaderSelect.setSelection(mCurrentLoaderAdapterIndex);
    mSourceSelect = (Spinner) findViewById(R.id.source_select);
    mSourceSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setSourceAdapter(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mSourceSelect.setSelection(mCurrentSourceAdapterIndex);
    mHasStoragePermissions = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
}
Also used : PerfListener(com.facebook.samples.comparison.instrumentation.PerfListener) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Handler(android.os.Handler) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Point(android.graphics.Point)

Aggregations

PerfListener (com.facebook.samples.comparison.instrumentation.PerfListener)2 Point (android.graphics.Point)1 Handler (android.os.Handler)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 AQueryAdapter (com.facebook.samples.comparison.adapters.AQueryAdapter)1 FrescoAdapter (com.facebook.samples.comparison.adapters.FrescoAdapter)1 GlideAdapter (com.facebook.samples.comparison.adapters.GlideAdapter)1 PicassoAdapter (com.facebook.samples.comparison.adapters.PicassoAdapter)1 UilAdapter (com.facebook.samples.comparison.adapters.UilAdapter)1 VolleyAdapter (com.facebook.samples.comparison.adapters.VolleyAdapter)1