use of me.dkzwm.widget.srl.sample.header.WaveTextRefreshView in project SmoothRefreshLayout by dkzwm.
the class WithFrameLayoutActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_with_framelayout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.with_frameLayout);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_frameLayout);
mTextView = findViewById(R.id.textView_with_frameLayout_desc);
mTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(WithFrameLayoutActivity.this, "Clicked", Toast.LENGTH_SHORT).show();
}
});
mTextView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(WithFrameLayoutActivity.this, "LongClicked", Toast.LENGTH_SHORT).show();
return true;
}
});
mRefreshView = new WaveTextRefreshView(this);
mRefreshView.setIncrementalY(.5f);
mRefreshView.setTextSize(18);
mRefreshLayout.setHeaderView(mRefreshView);
mRefreshLayout.setRatioToKeep(1);
mRefreshLayout.setRatioOfHeaderToRefresh(1);
mRefreshLayout.setEnableKeepRefreshView(true);
mRefreshLayout.setEnableInterceptEventWhileLoading(true);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.setDisablePerformLoadMore(true);
mRefreshLayout.getFooterView().getView().setVisibility(View.GONE);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
mCount++;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mRefreshLayout.refreshComplete();
String times = getString(R.string.number_of_refresh) + mCount;
mTextView.setText(times);
}
}, 8000);
}
});
mRefreshLayout.addOnStatusChangedListener(new SmoothRefreshLayout.OnStatusChangedListener() {
@Override
public void onStatusChanged(byte old, byte now) {
if (now == SmoothRefreshLayout.SR_STATUS_INIT && old == SmoothRefreshLayout.SR_STATUS_COMPLETE) {
if (mIndex >= NAME_OF_TYPEFACES.length - 1) {
mIndex = 0;
} else {
mIndex++;
}
mRefreshView.setTypeface(Typeface.createFromAsset(getAssets(), NAME_OF_TYPEFACES[mIndex]));
}
}
});
mRefreshLayout.autoRefresh(true);
}
Aggregations