use of in.srain.cube.views.ptr.PtrFrameLayout in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class HideHeader method setupViews.
@Override
protected void setupViews(final PtrClassicFrameLayout ptrFrame) {
setHeaderTitle(R.string.ptr_demo_block_hide_header);
ptrFrame.setKeepHeaderWhenRefresh(false);
final View loading = Utils.createSimpleLoadingTip(getContext());
mTitleHeaderBar.getRightViewContainer().addView(loading);
ptrFrame.setPtrHandler(new PtrDefaultHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
loading.setVisibility(View.VISIBLE);
frame.postDelayed(new Runnable() {
@Override
public void run() {
loading.setVisibility(View.INVISIBLE);
ptrFrame.refreshComplete();
}
}, 1500);
}
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return true;
}
});
}
use of in.srain.cube.views.ptr.PtrFrameLayout 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;
}
use of in.srain.cube.views.ptr.PtrFrameLayout in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class WithTextViewInFrameLayoutFragment method createView.
@Override
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHeaderTitle(R.string.ptr_demo_block_frame_layout);
final View contentView = inflater.inflate(R.layout.fragment_classic_header_with_viewgroup, container, false);
final PtrClassicFrameLayout ptrFrame = (PtrClassicFrameLayout) contentView.findViewById(R.id.fragment_rotate_header_with_view_group_frame);
ptrFrame.setPtrHandler(new PtrHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
frame.postDelayed(new Runnable() {
@Override
public void run() {
ptrFrame.refreshComplete();
}
}, 1800);
}
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return true;
}
});
ptrFrame.setLastUpdateTimeRelateObject(this);
// the following are default settings
ptrFrame.setResistance(1.7f);
ptrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
ptrFrame.setDurationToClose(200);
ptrFrame.setDurationToCloseHeader(1000);
// default is false
ptrFrame.setPullToRefresh(false);
// default is true
ptrFrame.setKeepHeaderWhenRefresh(true);
// scroll then refresh
// comment in base fragment
ptrFrame.postDelayed(new Runnable() {
@Override
public void run() {
// ptrFrame.autoRefresh();
}
}, 150);
setupViews(ptrFrame);
return contentView;
}
use of in.srain.cube.views.ptr.PtrFrameLayout in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class StoreHouseUsingPointList method createView.
@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHeaderTitle(R.string.ptr_demo_storehouse_header_using_point_list);
View view = inflater.inflate(R.layout.fragment_storehouse_header, null);
CubeImageView imageView = (CubeImageView) view.findViewById(R.id.store_house_ptr_image);
ImageLoader imageLoader = ImageLoaderFactory.create(getContext());
String pic = "http://img5.duitang.com/uploads/item/201406/28/20140628122218_fLQyP.thumb.jpeg";
imageView.loadImage(imageLoader, pic);
final PtrFrameLayout frame = (PtrFrameLayout) view.findViewById(R.id.store_house_ptr_frame);
// header
final StoreHouseHeader header = new StoreHouseHeader(getContext());
header.setPadding(0, LocalDisplay.dp2px(15), 0, 0);
header.initWithPointList(getPointList());
frame.setDurationToCloseHeader(3000);
frame.setHeaderView(header);
frame.addPtrUIHandler(header);
frame.postDelayed(new Runnable() {
@Override
public void run() {
frame.autoRefresh(false);
}
}, 100);
frame.setPtrHandler(new PtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return true;
}
@Override
public void onRefreshBegin(final PtrFrameLayout frame) {
frame.postDelayed(new Runnable() {
@Override
public void run() {
frame.refreshComplete();
}
}, 2000);
}
});
return view;
}
use of in.srain.cube.views.ptr.PtrFrameLayout in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class StoreHouseUsingString method createView.
@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_storehouse_header, null);
mTitlePre = getString(R.string.ptr_demo_storehouse_header_using_string_in_title);
CubeImageView imageView = (CubeImageView) view.findViewById(R.id.store_house_ptr_image);
ImageLoader imageLoader = ImageLoaderFactory.create(getContext());
String pic = "http://img5.duitang.com/uploads/item/201406/28/20140628122218_fLQyP.thumb.jpeg";
imageView.loadImage(imageLoader, pic);
final PtrFrameLayout frame = (PtrFrameLayout) view.findViewById(R.id.store_house_ptr_frame);
// header
final StoreHouseHeader header = new StoreHouseHeader(getContext());
header.setPadding(0, LocalDisplay.dp2px(15), 0, 0);
/**
* using a string, support: A-Z 0-9 - .
* you can add more letters by {@link in.srain.cube.views.ptr.header.StoreHousePath#addChar}
*/
header.initWithString(mStringList[0]);
setHeaderTitle(mTitlePre + mStringList[0]);
// for changing string
frame.addPtrUIHandler(new PtrUIHandler() {
private int mLoadTime = 0;
@Override
public void onUIReset(PtrFrameLayout frame) {
mLoadTime++;
String string = mStringList[mLoadTime % mStringList.length];
header.initWithString(string);
}
@Override
public void onUIRefreshPrepare(PtrFrameLayout frame) {
String string = mStringList[mLoadTime % mStringList.length];
setHeaderTitle(mTitlePre + string);
}
@Override
public void onUIRefreshBegin(PtrFrameLayout frame) {
}
@Override
public void onUIRefreshComplete(PtrFrameLayout frame) {
}
@Override
public void onUIPositionChange(PtrFrameLayout frame, boolean isUnderTouch, byte status, PtrIndicator ptrIndicator) {
}
});
frame.setDurationToCloseHeader(3000);
frame.setHeaderView(header);
frame.addPtrUIHandler(header);
frame.postDelayed(new Runnable() {
@Override
public void run() {
frame.autoRefresh(false);
}
}, 100);
frame.setPtrHandler(new PtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return true;
}
@Override
public void onRefreshBegin(final PtrFrameLayout frame) {
frame.postDelayed(new Runnable() {
@Override
public void run() {
frame.refreshComplete();
}
}, 2000);
}
});
return view;
}
Aggregations