package com.grumoon.androidultrapulltorefreshdemo.ui;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.grumoon.androidultrapulltorefreshdemo.R;
import in.srain.cube.views.ptr.PtrClassicFrameLayout;
import in.srain.cube.views.ptr.PtrDefaultHandler;
import in.srain.cube.views.ptr.PtrFrameLayout;
/**
* A simple {@link Fragment} subclass.
*/
public class ContentScrollViewFragment extends Fragment {
private PtrClassicFrameLayout ptr;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_content_scroll_view, container, false);
initView(v);
return v;
}
private void initView(View v) {
ptr = (PtrClassicFrameLayout) v.findViewById(R.id.ptr_main);
ptr.setPtrHandler(new PtrDefaultHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ptr.refreshComplete();
}
}, 2000);
}
});
}
}