Ejemplo n.º 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (rootView == null) {
      rootView = inflater.inflate(R.layout.encircle_list_fragment_layout, container, false);

      listView = (GridView) rootView.findViewById(R.id.rotate_header_grid_view);
      listView.setOnItemClickListener(new NearListOnItemClickListener());

      mListItems = new LinkedList<String>();
      mListItems.addAll(Arrays.asList(Global.mStrings));
      mAdapter = new EncircleListAdapter(getActivity(), mListItems);

      listView.setAdapter(mAdapter);

      mPtrFrame = (PtrClassicFrameLayout) rootView.findViewById(R.id.rotate_header_grid_view_frame);
      mPtrFrame.setLastUpdateTimeRelateObject(this);
      mPtrFrame.setPtrHandler(
          new PtrHandler() {
            @Override
            public void onRefreshBegin(PtrFrameLayout frame) {
              new GetDataTask().execute();
            }

            @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);
      //			Toast.makeText(activity, TAG, 1000).show();
      startGetData();
    }

    // 缓存的rootView需要判断是否已经被加过parent,如果有parent需要从parent删除,要不然会发生这个rootview已经有parent的错误。
    ViewGroup parent = (ViewGroup) rootView.getParent();
    if (parent != null) {
      parent.removeView(rootView);
    }

    return rootView;
  }
Ejemplo n.º 2
0
  private void initFefushView() {
    mPtrFrame = (PtrClassicFrameLayout) getView().findViewById(R.id.rotate_header_grid_view_frame);
    mPtrFrame.setLastUpdateTimeRelateObject(this);
    mPtrFrame.setPtrHandler(
        new PtrHandler() {
          @Override
          public void onRefreshBegin(PtrFrameLayout frame) {
            getPictureList();
          }

          @Override
          public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
          }
        });
    StoreHouseHeader header = new StoreHouseHeader(getActivity());
    // header.setPadding(0, LocalDisplay.dp2px(20), 0,
    // LocalDisplay.dp2px(20));
    header.setPadding(0, 40, 0, 40);
    header.initWithString("Loading...");
    mPtrFrame.setHeaderView(header);
    mPtrFrame.addPtrUIHandler(header);
    // the following are default settings
    mPtrFrame.setResistance(1.7f);
    mPtrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
    mPtrFrame.setDurationToClose(500);
    mPtrFrame.setDurationToCloseHeader(2000);
    // default is false
    mPtrFrame.setPullToRefresh(true);
    // default is true
    mPtrFrame.setKeepHeaderWhenRefresh(true);
    // mPtrFrame.postDelayed(new Runnable() {
    // @Override
    // public void run() {
    // mPtrFrame.autoRefresh();
    // }
    // }, 100);
  }