uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout Java Examples

The following examples show how to use uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout. 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: ListViewWithEmptyActivity.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview_empty);

    /**
     * Get ListView and give it an adapter to display the sample items
     */
    ListView listView = (ListView) findViewById(R.id.ptr_listview);
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            new ArrayList<String>());
    listView.setEmptyView(findViewById(android.R.id.empty));
    listView.setAdapter(mAdapter);

    /**
     * Here we create a PullToRefreshAttacher manually without an Options instance.
     * PullToRefreshAttacher will manually create one using default values.
     */
    mPullToRefreshAttacher = PullToRefreshAttacher.get(this);

    // Set the Refreshable View to be the ListView and the refresh listener to be this.
    PullToRefreshLayout ptrLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout);
    ptrLayout.setPullToRefreshAttacher(mPullToRefreshAttacher, this);
}
 
Example #2
Source File: ScrollViewActivity.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrollview);

    // Create new PullToRefreshAttacher
    mPullToRefreshAttacher = PullToRefreshAttacher.get(this);

    // Retrieve the PullToRefreshLayout from the content view
    PullToRefreshLayout ptrLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout);

    // Give the PullToRefreshAttacher to the PullToRefreshLayout, along with the refresh
    // listener (this).
    ptrLayout.setPullToRefreshAttacher(mPullToRefreshAttacher, this);
}
 
Example #3
Source File: WebViewActivity.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);

    /**
     * Get ListView and give it an adapter to display the sample items
     */
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.setWebViewClient(new SampleWebViewClient());

    /**
     * Here we create a PullToRefreshAttacher without an Options instance.
     * PullToRefreshAttacher will manually create one using default values.
     */
    mPullToRefreshAttacher = PullToRefreshAttacher.get(this);

    // Retrieve the PullToRefreshLayout from the content view
    PullToRefreshLayout ptrLayout = (PullToRefreshLayout) findViewById(R.id.ptr_webview);

    // Give the PullToRefreshAttacher to the PullToRefreshLayout, along with the refresh
    // listener (this).
    ptrLayout.setPullToRefreshAttacher(mPullToRefreshAttacher, this);

    // Finally make the WebView load something...
    mWebView.loadUrl("http://www.google.com");
}
 
Example #4
Source File: NewestNodeFragment.java    From v2ex-daily-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mPullToRefreshLayout = (PullToRefreshLayout) inflater.inflate(R.layout.fragment_node, container, false);
    mListView = (ListView) mPullToRefreshLayout.findViewById(R.id.list_fragment_node);
    mListView.setEmptyView(mPullToRefreshLayout.findViewById(R.id.progress_fragment_node));
    mListView.setOnItemClickListener(this);
    mAllNodesDataHelper = new AllNodesDataHelper(getActivity());
    mNewestNodeDataHelper = new NewestNodeDataHelper(getActivity());
    mNewestNodeAdapter = new NewestNodeAdapter(getActivity(), this);
    mListView.setAdapter(mNewestNodeAdapter);
    getLoaderManager().initLoader(0, null, this);
    return mPullToRefreshLayout;
}
 
Example #5
Source File: UserFragment.java    From v2ex-daily-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mPullToRefreshLayout = (PullToRefreshLayout) inflater.inflate(R.layout.fragment_user, container, false);
    mListView = (ListView) mPullToRefreshLayout.findViewById(R.id.list_fragment_user);
    mHeader = mPullToRefreshLayout.findViewById(R.id.header_fragment_user);
    mHeaderLogo = (ImageView) mPullToRefreshLayout.findViewById(R.id.header_logo_fragment_user);
    mName = (TextView) mPullToRefreshLayout.findViewById(R.id.txt_fragment_user_name);
    mDescription = (TextView) mPullToRefreshLayout.findViewById(R.id.txt_fragment_user_description);
    mPlaceHolderView = getActivity().getLayoutInflater().inflate(R.layout.view_header_placeholder, mListView, false);
    mListView.addHeaderView(mPlaceHolderView, null, false);
    mListView.setOnItemClickListener(this);
    return mPullToRefreshLayout;
}
 
Example #6
Source File: TopicFragment.java    From v2ex-daily-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mPullToRefreshLayout = (PullToRefreshLayout) inflater.inflate(R.layout.fragment_topic, container, false);
    mListView = (ListView) mPullToRefreshLayout.findViewById(R.id.list_fragment_topic);
    mListView.setEmptyView(mPullToRefreshLayout.findViewById(R.id.progress_fragment_topic));
    return mPullToRefreshLayout;
}
 
Example #7
Source File: NotificationFragment.java    From v2ex-daily-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mPullToRefreshLayout = (PullToRefreshLayout) inflater.inflate(R.layout.fragment_notification, container, false);
    mListView = (ListView) mPullToRefreshLayout.findViewById(R.id.list_fragment_notification);
    mListView.setEmptyView(mPullToRefreshLayout.findViewById(R.id.txt_fragment_notification_empty));
    mListView.setOnItemClickListener(this);
    return mPullToRefreshLayout;
}
 
Example #8
Source File: NodeFragment.java    From v2ex-daily-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mPullToRefreshLayout = (PullToRefreshLayout) inflater.inflate(R.layout.fragment_node, container, false);
    mListView = (ListView) mPullToRefreshLayout.findViewById(R.id.list_fragment_node);
    mListView.setEmptyView(mPullToRefreshLayout.findViewById(R.id.progress_fragment_node));
    mListView.setOnItemClickListener(this);
    return mPullToRefreshLayout;
}
 
Example #9
Source File: FragmentFeeds.java    From rss with GNU General Public License v3.0 5 votes vote down vote up
@Override
public
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    super.onCreateView(inflater, container, savedInstanceState);

    FeedsActivity activity = (FeedsActivity) getActivity();
    PullToRefreshLayout layout = (PullToRefreshLayout) inflater.inflate(R.layout.viewpager, container, false);

    // Find and configure the ViewPager.
    s_viewPager = (ViewPager) layout.findViewById(R.id.viewpager);
    s_viewPager.setOffscreenPageLimit(128);
    s_viewPager.setOnPageChangeListener(new OnPageChangeListener());

    // Create the Options object for the ActionBarPullToRefresh SetupWizard.
    Options.Builder optionsBuilder = Options.create();
    optionsBuilder.scrollDistance(PULL_DISTANCE);
    Options options = optionsBuilder.build();

    // Create the ActionBarPullToRefresh object using its SetupWizard.
    ActionBarPullToRefresh.SetupWizard setup = ActionBarPullToRefresh.from(activity);
    setup.allChildrenArePullable();
    setup.options(options);
    setup.useViewDelegate(ViewPager.class, new ViewPagerDelegate());
    setup.listener(new RefreshListener(activity));
    setup.setup(layout);

    return layout;
}
 
Example #10
Source File: ThreadViewFragment.java    From something.apk with MIT License 4 votes vote down vote up
@Override
protected void setupPullToRefresh(PullToRefreshLayout ptr) {
    ActionBarPullToRefresh.from(getActivity()).allChildrenArePullable().options(generatePullToRefreshOptions()).bottomListener(this).setup(ptr);
}
 
Example #11
Source File: MainFragment.java    From Bitocle with Apache License 2.0 4 votes vote down vote up
public PullToRefreshLayout getPull() {
    return pull;
}
 
Example #12
Source File: MainFragment.java    From Bitocle with Apache License 2.0 4 votes vote down vote up
public PullToRefreshLayout getPullToRefreshLayout() {
    return pullToRefreshLayout;
}
 
Example #13
Source File: MainFragment.java    From Bitocle with Apache License 2.0 4 votes vote down vote up
public PullToRefreshLayout getPull() {
    return pull;
}
 
Example #14
Source File: Constants.java    From rss with GNU General Public License v3.0 4 votes vote down vote up
static
void saveViews()
{
    s_viewPager = (ViewPager) findView(R.id.viewpager);
    s_pullToRefreshLayout = (PullToRefreshLayout) s_viewPager.getParent();
}
 
Example #15
Source File: AbstractMessagesActivity.java    From Faceless with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(getLayoutResourceID());

	// set up access to the preferences
	mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
	Global.Setup.load(mPrefs);

	// check if introduction has already been completed
	if (mPrefs.getInt(Global.Preferences.INTRO_STEP, 0) < Integer.MAX_VALUE) {
		// if introduction has not yet been completed
		// switch to introduction screen
		startActivity(new Intent(this, ActivityIntro.class));
		// prevent any window animation because the user is to be redirected immediately
		overridePendingTransition(0, 0);
		finish();
		return;
	}

	// check if setup has been completed
	if (!Global.Setup.isComplete()) {
		// try to run automatic setup
		if (!Global.Setup.runAuto(this, mPrefs)) {
			// if automatic setup did not succeed
			// switch to manual setup
			startActivity(new Intent(this, ActivitySetup.class));
			// prevent any window animation because the user is to be redirected immediately
			overridePendingTransition(0, 0);
			finish();
			return;
		}
	}

	// set up the layout inflater
	mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

	// set up other resources
	mResources = getResources();
	mMessagePropertyDrawables = new Global.MessagePropertyDrawables(this);
	mBackgroundPatterns = BackgroundPatterns.getInstance(this);

	// set up the two mode tabs
	setupButtonBar();

	// set up the ListView with its ArrayAdapter and the ProgressBar
	mListView = (ListView) findViewById(R.id.listViewMessages);
	mProgressBarLoading = (ProgressBar) findViewById(R.id.progressBarLoading);
	mAdapter = new MessagesAdapter(this, R.layout.row_messages_list, new ArrayList<Message>());
	mListView.setAdapter(mAdapter);
	mListView.setOnItemClickListener(mMessageClickListener);

	// set up pull-to-refresh (at the top)
	mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.viewListViewContainer);
	ActionBarPullToRefresh.from(this).allChildrenArePullable().listener(this).setup(mPullToRefreshLayout);

	// set up infinite scrolling (at the bottom)
	mListView.setOnScrollListener(mInfiniteScrollListener);

	// set up the action bar
	getActionBar().setDisplayHomeAsUpEnabled(isActionBarUpEnabled());

	// create the location provider
	mSimpleLocation = new SimpleLocation(this);

	// load first data into the ListView
	reloadMessages(getMessagesMode(), 0, true, false, false);

	// prompt the user to rate the app if this is appropriate
	AppRater appRater = new AppRater(this);
	appRater.setPhrases(R.string.app_rater_title, R.string.app_rater_explanation, R.string.app_rater_now, R.string.app_rater_later, R.string.app_rater_never);
	appRater.show();
}