예제 #1
0
  @Override
  protected void initViews() {
    ptrClassicFrameLayout = fv(R.id.ptrFrameLayout);
    loadRecyclerView = fv(R.id.loadRecyclerView);
    ptrClassicFrameLayout.setLastUpdateTimeRelateObject(this);
    ptrClassicFrameLayout.setPtrHandler(
        new PtrDefaultHandler() {
          @Override
          public void onRefreshBegin(PtrFrameLayout frame) {
            initDates();
          }

          @Override
          public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return (UserActivity.verticalOffset == 0)
                && super.checkCanDoRefresh(frame, content, header);
          }
        });
    loadRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    articleAdapter = new ArticleAdapter(loadRecyclerView);
    loadRecyclerView.setAdapter(articleAdapter);
    articleAdapter.setOnRVItemClickListener(this);
    loadRecyclerView.setOnLoadListener(this);
    type = getArguments().getString(TYPE);
    userId = getArguments().getString(USERID, MyUser.fetchCurrentUser().getObjectId());
  }
  public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    setHeaderTitle(R.string.ptr_demo_block_only_text_view);

    final View contentView =
        inflater.inflate(R.layout.fragment_classic_header_with_textview, container, false);

    final PtrClassicFrameLayout ptrFrame =
        (PtrClassicFrameLayout)
            contentView.findViewById(R.id.fragment_rotate_header_with_text_view_frame);
    ptrFrame.setLastUpdateTimeRelateObject(this);
    ptrFrame.setPtrHandler(
        new PtrDefaultHandler() {
          @Override
          public void onRefreshBegin(PtrFrameLayout frame) {
            frame.postDelayed(
                new Runnable() {
                  @Override
                  public void run() {
                    ptrFrame.refreshComplete();
                  }
                },
                1500);
          }

          @Override
          public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return true;
          }
        });
    return contentView;
  }
예제 #3
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;
  }
예제 #4
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);
  }