use of in.srain.cube.views.list.ViewHolderCreator in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class WithGridView method createView.
@Override
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHeaderTitle(R.string.ptr_demo_block_grid_view);
mImageLoader = ImageLoaderFactory.create(getContext());
final View contentView = inflater.inflate(R.layout.fragment_classic_header_with_gridview, null);
final GridView gridListView = (GridView) contentView.findViewById(R.id.rotate_header_grid_view);
gridListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position >= 0) {
final String url = mAdapter.getItem(position).optString("pic");
if (!TextUtils.isEmpty(url)) {
getContext().pushFragmentToBackStack(MaterialStyleFragment.class, url);
}
}
}
});
mAdapter = new ListViewDataAdapter<JsonData>(new ViewHolderCreator<JsonData>() {
@Override
public ViewHolderBase<JsonData> createViewHolder(int position) {
return new ViewHolder();
}
});
gridListView.setAdapter(mAdapter);
mPtrFrame = (PtrClassicFrameLayout) contentView.findViewById(R.id.rotate_header_grid_view_frame);
mPtrFrame.setLastUpdateTimeRelateObject(this);
mPtrFrame.setPtrHandler(new PtrHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
updateData();
}
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
}
});
// the following are default settings
mPtrFrame.setResistance(1.7f);
mPtrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
mPtrFrame.setDurationToClose(200);
mPtrFrame.setDurationToCloseHeader(1000);
// default is false
mPtrFrame.setPullToRefresh(false);
// default is true
mPtrFrame.setKeepHeaderWhenRefresh(true);
mPtrFrame.postDelayed(new Runnable() {
@Override
public void run() {
// mPtrFrame.autoRefresh();
}
}, 100);
// updateData();
setupViews(mPtrFrame);
return contentView;
}
Aggregations