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;
  }
Пример #2
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());
  }
Пример #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 getParise() {
    if (MyUser.fetchCurrentUser().getObjectId().equals(userId)) {
      articleAdapter.setDatas(Constant.PARISES);
      ptrClassicFrameLayout.refreshComplete();
      articleAdapter.setFootStatus(false);
      return;
    }
    Api.getParises(
        new Subscriber<List<AvArticle>>() {
          @Override
          public void onCompleted() {}

          @Override
          public void onError(Throwable e) {
            ptrClassicFrameLayout.refreshComplete();
            articleAdapter.setFootStatus(false);
          }

          @Override
          public void onNext(List<AvArticle> avArticles) {
            parises = avArticles;
            articleAdapter.setDatas(parises);
            ptrClassicFrameLayout.refreshComplete();
            articleAdapter.setFootStatus(false);
          }
        });
  }
Пример #5
0
  private void init(View view) {
    mNetworkRequest = new NetworkRequestImpl(getContext());
    mRoomIdDB = new RoomIdDatabaseHelper(getContext(), RoomIdDatabaseHelper.HEART_DB_NAME, null, 1);
    mptrClassicFrameLayout = (PtrClassicFrameLayout) view.findViewById(R.id.store_house_ptr_frame);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.store_house_ptr_rv);
    mRoomInfos = new ArrayList<>();
    mAdapter = new RoomInfoAdapter(getContext(), mRoomInfos);
    final GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
    mRecyclerView.setLayoutManager(gridLayoutManager);
    mAdapter.setOnItemClickListener(
        new RoomInfoAdapter.OnItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            mNetworkRequest.getStreamUrl(mRoomInfos.get(position).getRoomId(), mStreamUrlListener);
          }

          @Override
          public void onItemLongClick(View view, int position) {
            mDeletePosition = position;
            new AlertDialog.Builder(getContext())
                .setTitle("收藏")
                .setMessage("确认收藏")
                .setNegativeButton("否", null)
                .setPositiveButton("是", mPositiveClickListener)
                .show();
          }
        });
    setAdapter();
    setPtrHandler();
    mptrClassicFrameLayout.autoRefresh(true);
  }
Пример #6
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);
  }
Пример #7
0
  private void setPtrHandler() {
    mptrClassicFrameLayout.setPtrHandler(
        new PtrHandler() {
          @Override
          public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
          }

          @Override
          public void onRefreshBegin(PtrFrameLayout frame) {
            mptrClassicFrameLayout.post(runnable);
          }
        });
  }
  private void initView(View v) {

    gvMain = (GridView) v.findViewById(R.id.gv_main);
    ptr = (PtrClassicFrameLayout) v.findViewById(R.id.ptr_main);
    ptr.setPtrHandler(
        new PtrDefaultHandler() {
          @Override
          public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
            getData();
            ptr.refreshComplete();
          }
        });

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                ptr.autoRefresh();
              }
            },
            100);
  }
Пример #9
0
 @Override
 public void run() {
   mRoomInfos.clear();
   mNetworkRequest.getHeartRooms(mHeartRoomsListener);
   mptrClassicFrameLayout.refreshComplete();
 }