Java Code Examples for com.handmark.pulltorefresh.library.PullToRefreshBase

The following examples show how to use com.handmark.pulltorefresh.library.PullToRefreshBase. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: imsdk-android   Source File: DailyNoteListActivity.java    License: MIT License 6 votes vote down vote up
private void initView() {
    actionBar = (QtNewActionBar) this.findViewById(R.id.my_action_bar);
    setNewActionBar(actionBar);
    setActionBarTitle(R.string.atom_ui_note_title_notebook);
    setActionBarRightText(R.string.atom_ui_btn_note_new);
    setActionBarRightTextClick(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showNoteDialogDialog();
        }
    });

    notelist_listview = (PullToRefreshListView) findViewById(R.id.note_listview);
    adapter = new DailyNoteListAdapter(this, dailyMindMains, R.layout.atom_ui_item_note);
    notelist_listview.getRefreshableView().setAdapter(adapter);
    notelist_listview.getRefreshableView().setOnItemClickListener(this);
    notelist_listview.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
    notelist_listview.getRefreshableView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            showEditDialog(adapter.getItem(i-1));
            return true;
        }
    });
}
 
Example 2
Source Project: iZhihu   Source File: QuestionsListFragment.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    try {
        if (msg.what > 0) {
            mQuestionsAdapter.notifyDataSetChanged();
        } else {
            Helper.showShortToast(mContext, getString(R.string.nomore_questions));
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } finally {
        mPull2RefreshView.onRefreshComplete();
        if (msg.what <= 0) {
            mPull2RefreshView.setMode(PullToRefreshBase.Mode.DISABLED);
        }
    }
}
 
Example 3
Source Project: SmileEssence   Source File: UserDetailDialogFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) {
    final MainActivity activity = (MainActivity) getActivity();
    final Account account = activity.getAccount();
    final Consumer consumer = activity.getConsumer();
    Twitter twitter = TwitterApi.getTwitter(consumer, account);

    final StatusListAdapter adapter = getListAdapter(activity);
    Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity));
    if (adapter.getCount() > 0) {
        paging.setSinceId(adapter.getTopID());
    }
    new UserTimelineTask(twitter, getUserID(), paging) {
        @Override
        protected void onPostExecute(twitter4j.Status[] statuses) {
            super.onPostExecute(statuses);
            for (int i = statuses.length - 1; i >= 0; i--) {
                twitter4j.Status status = statuses[i];
                adapter.addToTop(new StatusViewModel(status, account));
            }
            updateListView(refreshView.getRefreshableView(), adapter, true);
            refreshView.onRefreshComplete();
        }
    }.execute();
}
 
Example 4
Source Project: SmileEssence   Source File: UserDetailDialogFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) {
    final MainActivity activity = (MainActivity) getActivity();
    final Account account = activity.getAccount();
    final Consumer consumer = activity.getConsumer();
    Twitter twitter = TwitterApi.getTwitter(consumer, account);

    final StatusListAdapter adapter = getListAdapter(activity);
    Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity));
    if (adapter.getCount() > 0) {
        paging.setMaxId(adapter.getLastID() - 1);
    }
    new UserTimelineTask(twitter, getUserID(), paging) {
        @Override
        protected void onPostExecute(twitter4j.Status[] statuses) {
            super.onPostExecute(statuses);
            for (twitter4j.Status status : statuses) {
                adapter.addToBottom(new StatusViewModel(status, account));
            }
            updateListView(refreshView.getRefreshableView(), adapter, false);
            refreshView.onRefreshComplete();
        }
    }.execute();
}
 
Example 5
Source Project: SmileEssence   Source File: MentionsFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) {
    final MainActivity activity = (MainActivity) getActivity();
    final Account account = activity.getAccount();
    final Consumer consumer = activity.getConsumer();
    Twitter twitter = TwitterApi.getTwitter(consumer, account);
    final StatusListAdapter adapter = getListAdapter(activity);
    Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity));
    if (adapter.getCount() > 0) {
        paging.setMaxId(adapter.getLastID() - 1);
    }
    new MentionsTimelineTask(twitter, activity, paging) {
        @Override
        protected void onPostExecute(twitter4j.Status[] statuses) {
            super.onPostExecute(statuses);
            for (twitter4j.Status status : statuses) {
                adapter.addToBottom(new StatusViewModel(status, account));
            }
            updateListViewWithNotice(refreshView.getRefreshableView(), adapter, false);
            refreshView.onRefreshComplete();
        }
    }.execute();
}
 
Example 6
Source Project: BigApp_Discuz_Android   Source File: RefreshListView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onPullEvent(PullToRefreshBase<ListView> refreshView, com.handmark.pulltorefresh.library.PullToRefreshBase.State state,
                        com.handmark.pulltorefresh.library.PullToRefreshBase.Mode direction) {
    refreshView.getLoadingLayoutProxy().setLoadingDrawable(getResources().getDrawable(R.drawable.loading_light_gray));

    if (direction == PullToRefreshBase.Mode.PULL_FROM_END) {
        refreshView.getLoadingLayoutProxy().setPullLabel(mContext.getResources().getString(R.string.pull_to_load));
        refreshView.getLoadingLayoutProxy().setRefreshingLabel(mContext.getResources().getString(R.string.loading));
        refreshView.getLoadingLayoutProxy().setReleaseLabel(mContext.getResources().getString(R.string.release_to_load));

    } else {
        refreshView.getLoadingLayoutProxy().setPullLabel(mContext.getResources().getString(R.string.pull_to_refresh));
        refreshView.getLoadingLayoutProxy().setRefreshingLabel(mContext.getResources().getString(R.string.refreshing));
        refreshView.getLoadingLayoutProxy().setReleaseLabel(mContext.getResources().getString(R.string.release_to_refresh));
    }
}
 
Example 7
Source Project: BigApp_Discuz_Android   Source File: AddFriendsActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    adapter = new FriendsAdapter(this, module, getClanHttpParams());
    listView.setAdapter(adapter);
    listView.setDefaultMode(PullToRefreshBase.Mode.DISABLED);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ZogUtils.printError(FriendsActivity.class, "position=" + position);
            String uid = ((User) adapter.getItem(position)).getUid();
            Bundle b = new Bundle();
            b.putString(Key.KEY_UID, uid);
            IntentUtils.gotoNextActivity(AddFriendsActivity.this, HomePageActivity.class, b);
        }
    });
}
 
Example 8
Source Project: BigApp_Discuz_Android   Source File: ActApplyFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mListView = (RefreshListView) inflater.inflate(R.layout.fragment_list, container, false);
    ViewUtils.inject(this, mListView);
    mListView.setMode(PullToRefreshBase.Mode.DISABLED);

    BundleData bundleData = FragmentUtils.getData(this);

    ZogUtils.printObj(ActApplyFragment.class, bundleData);

    SpecialActivity specialActivity = bundleData.getObject(Key.CLAN_DATA, SpecialActivity.class);
    ArrayList<JoinField> list = specialActivity.getJoinFields();

    ZogUtils.printError(ActApplyFragment.class, "list.size():" + list.size());

    mAdapter = new ActApplyAdapter(getActivity(), list);
    mListView.setAdapter(mAdapter);
    return mListView;
}
 
Example 9
Source Project: BigApp_Discuz_Android   Source File: ActApplyFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mListView = (RefreshListView) inflater.inflate(R.layout.fragment_list, container, false);
    ViewUtils.inject(this, mListView);
    mListView.setMode(PullToRefreshBase.Mode.DISABLED);

    BundleData bundleData = FragmentUtils.getData(this);

    ZogUtils.printObj(ActApplyFragment.class, bundleData);

    SpecialActivity specialActivity = bundleData.getObject(Key.CLAN_DATA, SpecialActivity.class);
    ArrayList<JoinField> list = specialActivity.getJoinFields();

    ZogUtils.printError(ActApplyFragment.class, "list.size():" + list.size());

    mAdapter = new ActApplyAdapter(getActivity(), list);
    mListView.setAdapter(mAdapter);
    return mListView;
}
 
Example 10
Source Project: BigApp_Discuz_Android   Source File: CommentFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mListView = (RefreshListView) inflater.inflate(R.layout.fragment_list, container, false);
    ViewUtils.inject(this, mListView);
    mListView.setMode(PullToRefreshBase.Mode.DISABLED);

    BundleData bundleData = FragmentUtils.getData(this);

    ZogUtils.printObj(CommentFragment.class, bundleData);

    Type type = new TypeToken<ArrayList<CommentField>>() {
    }.getType();
    ArrayList<CommentField> list = bundleData.getArrayList(Key.CLAN_DATA,type);

    ZogUtils.printError(CommentFragment.class, "list.size():" + list.size());

    mAdapter = new CommentAdapter(getActivity(), list);
    mListView.setAdapter(mAdapter);
    return mListView;
}
 
Example 11
Source Project: SmileEssence   Source File: MentionsFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) {
    final MainActivity activity = (MainActivity) getActivity();
    final Account account = activity.getAccount();
    final Consumer consumer = activity.getConsumer();
    Twitter twitter = TwitterApi.getTwitter(consumer, account);
    final StatusListAdapter adapter = getListAdapter(activity);
    Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity));
    if (adapter.getCount() > 0) {
        paging.setSinceId(adapter.getTopID());
    }
    new MentionsTimelineTask(twitter, activity, paging) {
        @Override
        protected void onPostExecute(twitter4j.Status[] statuses) {
            super.onPostExecute(statuses);
            for (int i = statuses.length - 1; i >= 0; i--) {
                twitter4j.Status status = statuses[i];
                adapter.addToTop(new StatusViewModel(status, account));
            }
            updateListViewWithNotice(refreshView.getRefreshableView(), adapter, true);
            refreshView.onRefreshComplete();
        }
    }.execute();
}
 
Example 12
Source Project: zen4android   Source File: SoundPullEventListener.java    License: MIT License 5 votes vote down vote up
@Override
public final void onPullEvent(PullToRefreshBase<V> refreshView, State event, Mode direction) {
	Integer soundResIdObj = mSoundMap.get(event);
	if (null != soundResIdObj) {
		playSound(soundResIdObj.intValue());
	}
}
 
Example 13
Source Project: ONE-Unofficial   Source File: AbsModuleFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(getLayoutId(), null);
    ButterKnife.bind(this, view);
    shareDialog = new ShareDialog(this);
    CallbackManager callbackManager = CallbackManager.Factory.create();
    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
            TextToast.shortShow(getString(R.string.share_fail));
        }
    });
    pager.setOnPageChangeListener(this);
    pager.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ViewPager>() {
        @Override
        public void onRefresh(PullToRefreshBase<ViewPager> refreshView) {
            refresh();
        }
    });
    adapter = new FragmentAdapter(getChildFragmentManager(), new ArrayList<AbsBaseFragment>());
    pager.setAdapter(adapter);
    init();
    instance=this;
    return view;
}
 
Example 14
Source Project: imsdk-android   Source File: DeptFragment.java    License: MIT License 5 votes vote down vote up
void initViews() {
    pullToRefreshView.setVisibility(View.VISIBLE);
    if (mAdapter == null) {
        try {
            mAdapter = new SimpleTreeAdapter<Node>(pullToRefreshView, getActivity());
            mAdapter.setOnTreeNodeClickListener(new TreeListViewAdapter.OnTreeNodeClickListener() {
                @Override
                public void onClick(Node node, int position) {
                    if (!TextUtils.isEmpty(node.getKey())) {
                        if (fromAction == 1) {
                            Intent intent = new Intent();
                            intent.putExtra("userid", node.getKey());
                            getActivity().setResult(Activity.RESULT_OK, intent);
                            getActivity().finish();
                            return;
                        }
                        NativeApi.openUserCardVCByUserId(node.getKey());
                    }
                }

            });
        } catch (IllegalAccessException e) {
            LogUtil.e(TAG,"ERROR",e);
        }

    }
    pullToRefreshView.setAdapter(mAdapter);
    pullToRefreshView.setEmptyView(empty);
    pullToRefreshView.setVisibility(View.VISIBLE);
    pullToRefreshView.setMode(PullToRefreshBase.Mode.MANUAL_REFRESH_ONLY);

    empty.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            presenter.forceUpdateContacts();
        }
    });
}
 
Example 15
Source Project: yiim_v2   Source File: UserInfoSetFragment.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void initDatas() {
	// TODO Auto-generated method stub
	mPullToRefreshScrollView
			.setOnRefreshListener(new OnRefreshListener<ScrollView>() {
				@Override
				public void onRefresh(
						PullToRefreshBase<ScrollView> refreshView) {
					// TODO Auto-generated method stub
					loadVcard(true);
				}
			});
	loadVcard(false);
}
 
Example 16
Source Project: imsdk-android   Source File: PbChatSearchResultActivity.java    License: MIT License 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        chat_region.setMode(PullToRefreshBase.Mode.BOTH);
        chat_region.getRefreshableView().setTranscriptMode(AbsListView.TRANSCRIPT_MODE_DISABLED);
//        searching = true;
    }
 
Example 17
Source Project: imsdk-android   Source File: PbChatSearchResultActivity.java    License: MIT License 5 votes vote down vote up
@Override
    public void addHistoryMessageLast(final List<IMMessage> historyMessage) {
        getHandler().post(new Runnable() {
            @Override
            public void run() {
                chat_region.onRefreshComplete();
                if (historyMessage == null || historyMessage.size() == 0) {
                    return;
                }
                if (historyMessage.size() == 1) {
                    if (TextUtils.isEmpty(historyMessage.get(0).getBody())) {
//                        historyMessage.get(0).setBody(getString(R.string.atom_ui_cloud_record_prompt));
                        pbChatViewAdapter.addNewMsgs(historyMessage);
                        return;
                    }
                    //已经拉取不到消息则不重复提示
                    if(historyMessage.get(0).getMsgType()==-99){
                        chat_region.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
                        searching = false;
                    }
//                    if (lastMessage != null && lastMessage.getMsgType() == MessageType.MSG_TYPE_NO_MORE_MESSAGE &&
//                            historyMessage.get(0).getMsgType() == MessageType.MSG_TYPE_NO_MORE_MESSAGE) {
//
//                        return;
//                    }
                }
                pbChatViewAdapter.addNewMsgs(historyMessage);
//                chat_region.getRefreshableView().setSelection(0);
                chat_region.getRefreshableView().smoothScrollToPosition(pbChatViewAdapter.getCount()-historyMessage.size()+1);
            }
        });
    }
 
Example 18
Source Project: imsdk-android   Source File: CloudChatRecordActivity.java    License: MIT License 5 votes vote down vote up
void initViews()
    {
        QtNewActionBar actionBar = (QtNewActionBar) this.findViewById(R.id.my_action_bar);
        setNewActionBar(actionBar);
        ILoadingLayout startLabels = recors_of_chat
                .getLoadingLayoutProxy();
        startLabels.setPullLabel(getText(R.string.atom_ui_tip_prelode_history));// 刚下拉时,显示的提示
        startLabels.setRefreshingLabel(getText(R.string.atom_ui_tip_loding_history));// 刷新时
        startLabels.setReleaseLabel(getText(R.string.atom_ui_tip_release_load));// 下来达到一定距离时,显示的提示
        if(adapter == null)
        {
            adapter = new ExtendChatViewAdapter(this,toId,getHandler(),isFromGroup);
            adapter.setGravatarHandler(new ChatViewAdapter.GravatarHandler() {
                @Override
                public void requestGravatarEvent(String jid, String imageSrc, SimpleDraweeView view) {

                }

//                @Override
//                public void requestGravatarEvent(final String nickOrUid, final SimpleDraweeView view) {
//                    ProfileUtils.displayGravatarByFullname(nickOrUid,view);
//                }
            });
            adapter.setContextMenuRegister(new ChatViewAdapter.ContextMenuRegister() {
                @Override
                public void registerContextMenu(View v) {
                    registerForContextMenu(v);
                }
            });
            recors_of_chat.getRefreshableView().setAdapter(adapter);
            recors_of_chat.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
                @Override
                public void onRefresh(PullToRefreshBase<ListView> listViewPullToRefreshBase) {
                    loadCloudRecords();
                }
            });
        }
    }
 
Example 19
@Override
public final void onPullEvent(PullToRefreshBase<V> refreshView, State event, Mode direction) {
	Integer soundResIdObj = mSoundMap.get(event);
	if (null != soundResIdObj) {
		playSound(soundResIdObj.intValue());
	}
}
 
Example 20
Source Project: yiim_v2   Source File: UserInfoActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void initDatas() {
	// TODO Auto-generated method stub
	mUser = getIntent().getStringExtra("user");
	mWhich = getIntent().getStringExtra("which");
	mName = getIntent().getStringExtra("name");

	try {
		if (isMySelf()) {
			mSendMsgBtn.setVisibility(View.GONE);
			mUserMemoRootView.setVisibility(View.GONE);
		} else {
			setTitleBarRightImageBtnSrc(R.drawable.mm_title_btn_menu);
		}
	} catch (Exception e) {
		// TODO: handle exception
	}

	mPullToRefreshScrollView
			.setOnRefreshListener(new OnRefreshListener<ScrollView>() {
				@Override
				public void onRefresh(
						PullToRefreshBase<ScrollView> refreshView) {
					// TODO Auto-generated method stub
					loadVcard(true);
				}
			});
	loadVcard(false);
}
 
Example 21
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_android_pull_to_refresh_sample);
    final PullToRefreshListView listView = (PullToRefreshListView) findViewById(R.id.list_view);
    listView.setMode(Mode.PULL_FROM_START);
    final List<String> items = new ArrayList<String>() {
        private static final long serialVersionUID = 1L;
        {
            this.add("red");
            this.add("yellow");
            this.add("green");
        }
    };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, android.R.id.text1, items);
    listView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        @Override
        public void onRefresh(final PullToRefreshBase<ListView> refreshView) {
            // リスト更新処理。一般的には通信処理や、データベースアクセスをする為別スレッドで実行する。
            // ここではHandlerを使って1秒後にリストを更新する様にしている。
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    items.add("No." + (items.size() + 1));
                    refreshView.onRefreshComplete();
                }
            }, 1000);
        }
    });
    listView.setAdapter(adapter);
}
 
Example 22
Source Project: sctalk   Source File: MessageActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public void onPullDownToRefresh(
            final PullToRefreshBase<ListView> refreshView) {
        // 获取消息
        refreshView.postDelayed(new Runnable() {
            @Override
            public void run() {
                ListView mlist = lvPTR.getRefreshableView();
                int preSum = mlist.getCount();
                MessageEntity messageEntity = adapter.getTopMsgEntity();
                if (messageEntity != null) {
                    List<MessageEntity> historyMsgInfo = imService.getMessageManager().loadHistoryMsg(messageEntity, historyTimes);
                    if (historyMsgInfo.size() > 0) {
                        historyTimes++;
                        adapter.loadHistoryList(historyMsgInfo);
                    }
                }

                int afterSum = mlist.getCount();
                mlist.setSelection(afterSum - preSum);
                /**展示位置为这次消息的最末尾*/
                //mlist.setSelection(size);
                // 展示顶部
//                if (!(mlist).isStackFromBottom()) {
//                    mlist.setStackFromBottom(true);
//                }
//                mlist.setStackFromBottom(false);
                refreshView.onRefreshComplete();
            }
        }, 200);
    }
 
Example 23
Source Project: sctalk   Source File: SoundPullEventListener.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public final void onPullEvent(PullToRefreshBase<V> refreshView, State event, Mode direction) {
	Integer soundResIdObj = mSoundMap.get(event);
	if (null != soundResIdObj) {
		playSound(soundResIdObj.intValue());
	}
}
 
Example 24
Source Project: Viewer   Source File: CameraListActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
	if(mUserInfo.isLogin){
		mCameraListHandler.doThing(CameraListHandler.SYNC_CID_REQUEST);
	}else{
		mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
    			mCameraListView.onRefreshComplete();
            }
        }, DELAY_TIME);
	}
}
 
Example 25
Source Project: ONE-Unofficial   Source File: SoundPullEventListener.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public final void onPullEvent(PullToRefreshBase<V> refreshView, State event, Mode direction) {
	Integer soundResIdObj = mSoundMap.get(event);
	if (null != soundResIdObj) {
		playSound(soundResIdObj.intValue());
	}
}
 
Example 26
Source Project: SmileEssence   Source File: UserListFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) {
    final MainActivity activity = getMainActivity();
    final Account account = activity.getAccount();
    final Consumer consumer = activity.getConsumer();
    Twitter twitter = TwitterApi.getTwitter(consumer, account);
    final UserListListAdapter adapter = getListAdapter(activity);
    String listFullName = adapter.getListFullName();
    if (TextUtils.isEmpty(listFullName)) {
        new UIHandler() {
            @Override
            public void run() {
                notifyTextEmpty(activity);
                refreshView.onRefreshComplete();
            }
        }.post();
        return;
    }
    Paging paging = TwitterUtils.getPaging(TwitterUtils.getPagingCount(activity));
    if (adapter.getCount() > 0) {
        paging.setSinceId(adapter.getTopID());
    }
    new UserListStatusesTask(twitter, listFullName, activity, paging) {
        @Override
        protected void onPostExecute(twitter4j.Status[] statuses) {
            super.onPostExecute(statuses);
            for (int i = statuses.length - 1; i >= 0; i--) {
                twitter4j.Status status = statuses[i];
                StatusViewModel statusViewModel = new StatusViewModel(status, account);
                adapter.addToTop(statusViewModel);
                StatusFilter.filter(activity, statusViewModel);
            }
            updateListViewWithNotice(refreshView.getRefreshableView(), adapter, true);
            refreshView.onRefreshComplete();
        }
    }.execute();
}
 
Example 27
Source Project: BigApp_Discuz_Android   Source File: ChatListView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
	IRefreshAndEditableAdapter adapter =  getAdapter();
	if (adapter != null) {
		adapter.loadMore(new OnLoadListener() {
			@Override
			public void onSuccess(boolean hasMore) {

				ZogUtils.printError(ChatListView.class, "onPullDownToRefresh onSuccess");

				clearChoices();
				onRefreshComplete();
				setMode(hasMore ? Mode.BOTH : Mode.PULL_FROM_END);
				if (mEmptyView != null) {
					mEmptyView.showEmpty();
				}
			}
			
			@Override
			public void onFailed() {

				ZogUtils.printError(ChatListView.class, "onPullDownToRefresh onFailed");

				onRefreshComplete();
				if (mEmptyView != null) {
					mEmptyView.showError();
				}
			}
		});
	}
}
 
Example 28
Source Project: BigApp_Discuz_Android   Source File: ChatListView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
	IRefreshAndEditableAdapter adapter =  getAdapter();
	if (adapter != null) {

		adapter.refresh(new OnLoadListener() {
			@Override
			public void onSuccess(boolean hasMore) {
				onRefreshComplete();
				clearChoices();
				setMode(hasMore ? Mode.BOTH : Mode.PULL_FROM_END);

				if (mEmptyView != null) {
					mEmptyView.showEmpty();
				}
			}
			
			@Override
			public void onFailed() {
				onRefreshComplete();
				if (mEmptyView != null) {
					mEmptyView.showError();
				}
			}
		});
	}
}
 
Example 29
Source Project: iZhihu   Source File: BaseListFragment.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    // 默认关闭下拉
    mPull2RefreshView.setMode(PullToRefreshBase.Mode.DISABLED);
}
 
Example 30
Source Project: BigApp_Discuz_Android   Source File: ArticleListFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    list = (RefreshListView) inflater.inflate(R.layout.fragment_list, null);
    adapter = new ArticleListAdapter(getActivity(), null, null);
    adapter.setCatId(catId);
    list.setDefaultMode(PullToRefreshBase.Mode.BOTH);
    list.setAdapter(adapter);
    return list;
}