Java Code Examples for com.handmark.pulltorefresh.library.PullToRefreshListView#setOnRefreshListener()

The following examples show how to use com.handmark.pulltorefresh.library.PullToRefreshListView#setOnRefreshListener() . 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 File: PullToRefreshListActivity.java    From effective_android_sample with Apache License 2.0 6 votes vote down vote up
/**
 *  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 File: AllChatRankFragment.java    From Social with 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(R.layout.all_chat_rank_fragment_lalyout, container, false);

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case OkhttpUtil.MESSAGE_CHAT_RANK:
                    handleCharRank(msg);
                    break;
            }
        }
    };

    listView = (PullToRefreshListView)view.findViewById(R.id.id_all_chat_rank_fg_listview);

    listView.setMode(PullToRefreshBase.Mode.BOTH);
    listView.getLoadingLayoutProxy(false, true).setPullLabel(
            getString(R.string.pull_to_load));
    listView.getLoadingLayoutProxy(false, true).setRefreshingLabel(
            getString(R.string.loading));
    listView.getLoadingLayoutProxy(false, true).setReleaseLabel(
            getString(R.string.release_to_load));
    listView.setOnRefreshListener(this);
    listView.setOnItemClickListener(this);

    list_chat_rank_item = new ArrayList<>();

    listView.setVisibility(View.GONE);

    return view;
}
 
Example 3
Source File: UserListFragment.java    From SmileEssence with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View page = inflater.inflate(R.layout.fragment_userlist, container, false);
    PullToRefreshListView listView = getListView(page);
    UserListListAdapter adapter = getListAdapter((MainActivity) getActivity());
    listView.setAdapter(adapter);
    listView.setOnScrollListener(this);
    listView.setOnRefreshListener(this);
    listView.setMode(getRefreshMode());
    ImageButton buttonUserLists = getUserListsButton(page);
    buttonUserLists.setOnClickListener(this);
    textListName = getTextListName(page);
    textListName.setText(adapter.getListFullName());
    return page;
}
 
Example 4
Source File: CustomListFragment.java    From SmileEssence with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View page = inflater.inflate(R.layout.fragment_list, container, false);
    Bundle args = getArguments();
    int fragmentIndex = args.getInt(ADAPTER_INDEX);
    PullToRefreshListView listView = getListView(page);
    ListAdapter adapter = getListAdapter(fragmentIndex);
    listView.setAdapter(adapter);
    listView.setOnScrollListener(this);
    listView.setOnRefreshListener(this);
    listView.setMode(getRefreshMode());
    return page;
}
 
Example 5
Source File: AndroidPullToRefreshSampleActivity.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@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 File: PostListFragment.java    From Broadsheet.ie-Android with 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
Source File: MyNewsfeedFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
/**
 * A method which initializes all of our members pointing to layout {@link android.view.View View}s.
 * @param viewGroup  The {@link android.view.ViewGroup ViewGroup} representing this {@link android.support.v4.app.Fragment Fragment}'s screen.
 */
private void initUIConfig(ViewGroup viewGroup) {
   mUsername = (TextView)viewGroup.findViewById(R.id.myNewsFeedFragment_userName);
   mUserProfilePicture = (ProfilePictureView) viewGroup.findViewById(R.id.com_dhsoftware_android_myNewsfeedFragment_userProfilePicture);
   mUserLoginButton = (LoginButton) viewGroup.findViewById(R.id.com_dhsoftware_android_myNewsFeedFragment_userLoginButton);
   // we need this permission to access the user's Newsfeed
   mUserLoginButton.setReadPermissions(Arrays.asList("read_stream"));
   mUserNewsfeed = (PullToRefreshListView) viewGroup.findViewById(R.id.myNewsfeedFragment_userNewsfeed);
   mUserNewsfeed.setAdapter(mAdapter);
   mUserNewsfeed.setOnRefreshListener(mRefreshListener);
}
 
Example 8
Source File: ShareRankFragment.java    From Social with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.share_rank_fragment_lalyout, container, false);

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case OkhttpUtil.MESSAGE_SHARE_RANK:
                    handleShareRank(msg);
                    break;
                case OkhttpUtil.MESSAGE_ADD_SHARE_RECORD:
                    handleAddShareRecord(msg);
                    break;
                case OkhttpUtil.MESSAGE_GET_SHARE_INFO:
                    handleGetShareInfo(msg);
                    break;
            }
        }
    };

    listView = (PullToRefreshListView)view.findViewById(R.id.id_share_rank_fg_listview);

    listView.setMode(PullToRefreshBase.Mode.BOTH);
    listView.getLoadingLayoutProxy(false, true).setPullLabel(
            getString(R.string.pull_to_load));
    listView.getLoadingLayoutProxy(false, true).setRefreshingLabel(
            getString(R.string.loading));
    listView.getLoadingLayoutProxy(false, true).setReleaseLabel(
            getString(R.string.release_to_load));
    listView.setOnRefreshListener(this);
    listView.setOnItemClickListener(this);

    list_share_rank_item = new ArrayList<>();

    rv_invite_user = (RippleView)view.findViewById(R.id.id_share_rank_fg_rv_invite_member);
    rv_invite_user.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
        @Override
        public void onComplete(RippleView rippleView) {
            //showShare();
            getShareInfo();
        }
    });

    getShareRank();//不显示数据

    return view;
}
 
Example 9
Source File: CameraListActivity.java    From Viewer with Apache License 2.0 4 votes vote down vote up
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.camera_list);
		mUserInfo = UserInfo.getUserInfo(this);
		mLayoutInflater = LayoutInflater.from(this);
		mUserLayout = (DrawerLayout) findViewById(R.id.user_layout);
		mCameraListView = (PullToRefreshListView) findViewById(R.id.cameraList);
		mCameraListView.setOnRefreshListener(this);
		
		findViewById(R.id.help).setOnClickListener(this);
		findViewById(R.id.feedback).setOnClickListener(this);
		findViewById(R.id.about).setOnClickListener(this);
		findViewById(R.id.disclaimer).setOnClickListener(this);
		findViewById(R.id.business).setOnClickListener(this);
		Button logout = (Button) findViewById(R.id.logout);
		logout.setOnClickListener(this);
		if(!mUserInfo.isLogin) logout.setVisibility(View.INVISIBLE);
		
		TextView userNameView = (TextView) findViewById(R.id.user_name);
		String name = getResources().getString(R.string.not_login);
		userNameView.setText(StringUtils.isEmpty(mUserInfo.name) ? name : mUserInfo.name);
//		mToolbar = (Toolbar) findViewById(R.id.toolbar);
//		mToolbar.setTitle(R.string.app_name);
//		setSupportActionBar(mToolbar);
//		mToolbar.setOnMenuItemClickListener(this);
//		mToolbar.setNavigationIcon(R.drawable.navigation_icon);
//		mToolbar.setNavigationOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				if(!mUserLayout.isDrawerOpen(Gravity.LEFT))
//					mUserLayout.openDrawer(Gravity.LEFT);
//			}
//		});
		
		mViewer = Viewer.getViewer();
		mMyViewerHelper = MyViewerHelper.getInstance(getApplicationContext());
		mMyViewerHelper.addCameraStateListener(this);
		mCameraDefaulThumb = BitmapFactory.decodeResource(getResources(), R.drawable.avs_type_android);
		
		mCameraInfoManager = new CameraInfoManager(this);
		mCameraInfos = mMyViewerHelper.getAllCameraInfos();
		for (CameraInfo info : mCameraInfos) {
			addStreamer(info.getCid(), info.getCameraUser(), info.getCameraPwd());
		}
		mCameraListAdapter = new CameraListAdapter(this, mCameraInfos);
		mCameraListView.setAdapter(mCameraListAdapter);
		mCameraListView.setOnItemClickListener(this);
//        mCameraListView.setOnScrollChangeListener(new OnScrollChangeListener() {
//            
//            @Override
//            public void onScrollChange(View v, int scrollX, int scrollY,
//                    int oldScrollX, int oldScrollY) {
//                mCameraListAdapter.closeAllItems();
//            }
//        });

		mShowChinese = "zh".equals(Locale.getDefault().getLanguage().toLowerCase());
		
		mCameraListHandler = new CameraListHandler(this, mHandler);
		mCameraListHandler.doThing(CameraListHandler.SYNC_CID_REQUEST);
		mAddCidHandler = new AddCidHandler(this, mHandler);
		mEditCidHandler = new EditCidHandler(this, mHandler);
		
		//update
		UmengUpdateAgent.setUpdateOnlyWifi(false);
		UmengUpdateAgent.update(this);
		findViewById(R.id.back_linlayout).setOnClickListener(this);
		findViewById(R.id.titlebar_back_image).setBackgroundResource(R.drawable.navigation_icon);
		titlebar_back_text = (TextView) findViewById(R.id.titlebar_back_text);
		titlebar_back_text.setText(R.string.app_name);
		titlebar_opt_image = (ImageView) findViewById(R.id.titlebar_opt_image);
		titlebar_opt_image.setBackgroundResource(R.drawable.add_icon);//(getResources().getDrawable(R.drawable.add_icon));
		findViewById(R.id.opt_linlayout).setOnClickListener(this);
		add_layout = (LinearLayout) findViewById(R.id.add_layout);
//		findViewById(R.id.add_cid).setOnClickListener(this);
//		findViewById(R.id.add_cid_by_qr).setOnClickListener(this);
	}
 
Example 10
Source File: MainActivity.java    From codeexamples-android with 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 11
Source File: PullToRefreshCustomActivity.java    From effective_android_sample with Apache License 2.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();
        }
    });

    /**
     * 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);
}