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

The following examples show how to use com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener. 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
/**
 *  Activity生成時にシステムから呼ばれる
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_list);

    // レイアウトからカスタムリストビューを取得
    mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);

    // リストを引っ張ったときの処理を記述
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            new GetDataTask().execute();
        }
    });

    // リストビューにアイテム追加
    mItemList = new LinkedList<String>();
    mItemList.addAll(Arrays.asList(INITIAL_LIST));
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mItemList);
    ListView actualListView = mPullRefreshListView.getRefreshableView();
    actualListView.setAdapter(mAdapter);
}
 
Example 2
Source Project: yiim_v2   Source File: FriendManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void onCreateView() {
	mListView = (PullToRefreshExpandableListView) mRootView
			.findViewById(R.id.tab_contacts_list);

	mPinnedHeaderView = mRootView
			.findViewById(R.id.friend_list_group_header);

	mPinnedImageView = (ImageView) mRootView
			.findViewById(R.id.friend_list_group_img);
	mPinnedTextView = (TextView) mRootView
			.findViewById(R.id.friend_list_group_text);
	mPinnedRightTextView = (TextView) mRootView
			.findViewById(R.id.friend_list_group_right_text);

	mPinnedImageView.setBackgroundResource(R.drawable.group_unfold_arrow);

	mListView
			.setOnRefreshListener(new OnRefreshListener<ExpandableListView>() {

				@Override
				public void onRefresh(
						PullToRefreshBase<ExpandableListView> refreshView) {
					// TODO Auto-generated method stub
					mGroups.clear();
					mEntries.clear();
					mAdapter.notifyDataSetChanged();
					XmppLoadRosterRunnable runnable = new XmppLoadRosterRunnable(
							mYiFragment.getActivity(), null);
					getXmppBinder().execute(runnable);
				}
			});
}
 
Example 3
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 4
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 5
@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 6
Source Project: Broadsheet.ie-Android   Source File: PostListFragment.java    License: MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = super.onCreateView(inflater, container, savedInstanceState);

    // Get original ListView and Frame
    ListView originalLv = (ListView) layout.findViewById(android.R.id.list);
    ViewGroup frame = (ViewGroup) originalLv.getParent();

    // Remove old ListView
    frame.removeView(originalLv);

    // Create new PullToRefreshListView and add to Frame
    mPullRefreshListView = new PullToRefreshListView(getActivity());
    frame.addView(mPullRefreshListView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            fetchPosts(null);
        }
    });

    boolean pauseOnScroll = false;
    boolean pauseOnFling = true;
    PauseOnScrollListener listener = new PauseOnScrollListener(ImageLoader.getInstance(), pauseOnScroll,
            pauseOnFling);
    mPullRefreshListView.setOnScrollListener(listener);

    return layout;
}
 
Example 7
public ListView getListView() {
	if (mpPullToRefreshPinnedSectionListView == null) {
		mpPullToRefreshPinnedSectionListView = (PullToRefreshPinnedSectionListView) findViewById(R.id.list);
		mpPullToRefreshPinnedSectionListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
			@Override
			public void onRefresh(final PullToRefreshBase<ListView> refreshView) {
				String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(),
						DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);

				// Update the LastUpdatedLabel
				refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);

				//TODO Do work to refresh the list here.
				new Thread(new Runnable() {
					
					@Override
					public void run() {
						try {
							Thread.sleep(1500);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						
						SampleActivity.this.runOnUiThread(new Runnable() {
							
							@Override
							public void run() {
								// Stop refreshing
								refreshView.onRefreshComplete();									
							}
						});
						
					}
				}).start();
			}
		});
		mpPullToRefreshPinnedSectionListView
				.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> arg0, View arg1,
							int arg2, long arg3) {
						Item item = (Item) getListView().getAdapter()
								.getItem(arg2);
						if (item != null) {
							Toast.makeText(SampleActivity.this,
									"Item " + arg2 + ": " + item.text,
									Toast.LENGTH_SHORT).show();
						} else {
							Toast.makeText(SampleActivity.this,
									"Item " + arg2, Toast.LENGTH_SHORT)
									.show();
						}

					}
				});
	}
	return mpPullToRefreshPinnedSectionListView.getRefreshableView();
}
 
Example 8
Source Project: codeexamples-android   Source File: MainActivity.java    License: Eclipse Public License 1.0 4 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_ptr_list);

	mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);

	// Set a listener to be invoked when the list should be refreshed.
	mPullRefreshListView
			.setOnRefreshListener(new OnRefreshListener<ListView>() {
				@Override
				public void onRefresh(
						PullToRefreshBase<ListView> refreshView) {
					String label = DateUtils.formatDateTime(
							getApplicationContext(),
							System.currentTimeMillis(),
							DateUtils.FORMAT_SHOW_TIME
									| DateUtils.FORMAT_SHOW_DATE
									| DateUtils.FORMAT_ABBREV_ALL);

					// Update the LastUpdatedLabel
					refreshView.getLoadingLayoutProxy()
							.setLastUpdatedLabel(label);

					// Do work to refresh the list here.
					new GetDataTask().execute();
				}
			});

	// Add an end-of-list listener
	mPullRefreshListView
			.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {

				@Override
				public void onLastItemVisible() {
					Toast.makeText(MainActivity.this, "End of List!",
							Toast.LENGTH_SHORT).show();
				}
			});

	ListView actualListView = mPullRefreshListView.getRefreshableView();

	// Need to use the Actual ListView when registering for Context Menu
	registerForContextMenu(actualListView);

	mListItems = new LinkedList<String>();
	mListItems.addAll(Arrays.asList(mStrings));

	mAdapter = new ArrayAdapter<String>(this,
			android.R.layout.simple_list_item_1, mListItems);
	// You can also just use setListAdapter(mAdapter) or
	// mPullRefreshListView.setAdapter(mAdapter)
	actualListView.setAdapter(mAdapter);
}
 
Example 9
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_list);

    mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);

    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        // ひっぱりきって指をはなしたとき?
        @Override
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            String label = DateUtils.formatDateTime(getApplicationContext(),
                    System.currentTimeMillis(),
                    DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE
                            | DateUtils.FORMAT_ABBREV_ALL);

            // Update the LastUpdatedLabel
            refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);

            // Do work to refresh the list here.
            new GetDataTask().execute();
        }
    });

    /**
     * customize
     */
    mPullRefreshListView.setMode(Mode.BOTH);

    // LoadingLayoutに関してカスタマイズ(主に文言)
    ILoadingLayout iLoadingLayout = mPullRefreshListView.getLoadingLayoutProxy(true, true);
    iLoadingLayout.setLastUpdatedLabel("");
    iLoadingLayout.setReleaseLabel("離してください、更新します");
    iLoadingLayout.setPullLabel("さらに下に引いて下さい");
    iLoadingLayout.setRefreshingLabel("更新中です");

    // Add an end-of-list listener
    mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {

        @Override
        public void onLastItemVisible() {
            Toast.makeText(PullToRefreshCustomActivity.this, "End of List!", Toast.LENGTH_SHORT)
                    .show();
        }
    });

    /**
     *  リスト表示
     */
    mIemsList = new LinkedList<String>();
    mIemsList.addAll(Arrays.asList(INITIAL_LIST));
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mIemsList);

    ListView actualListView = mPullRefreshListView.getRefreshableView();
    actualListView.setAdapter(mAdapter);
}
 
Example 10
Source Project: Social   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 11
Source Project: sctalk   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 12
Source Project: BigApp_Discuz_Android   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 13
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 14
Source Project: LbaizxfPulltoRefresh   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 15
Source Project: GifAssistant   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 16
Source Project: PullToRefreshLibrary   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 17
Source Project: SweetMusicPlayer   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 18
Source Project: ONE-Unofficial   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 19
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 20
Source Project: iSCAU-Android   Source File: IPullToRefresh.java    License: GNU General Public License v3.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 21
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 22
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 23
Source Project: zen4android   Source File: IPullToRefresh.java    License: MIT License 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 24
Source Project: effective_android_sample   Source File: IPullToRefresh.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);
 
Example 25
/**
 * Set OnRefreshListener for the Widget
 * 
 * @param listener - Listener to be used when the Widget is set to Refresh
 */
public void setOnRefreshListener(OnRefreshListener<T> listener);