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();
}
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;
}
Aggregations