当前位置: 首页>>代码示例>>Java>>正文


Java SwipeRefreshLayout.setOnRefreshListener方法代码示例

本文整理汇总了Java中android.support.v4.widget.SwipeRefreshLayout.setOnRefreshListener方法的典型用法代码示例。如果您正苦于以下问题:Java SwipeRefreshLayout.setOnRefreshListener方法的具体用法?Java SwipeRefreshLayout.setOnRefreshListener怎么用?Java SwipeRefreshLayout.setOnRefreshListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.SwipeRefreshLayout的用法示例。


在下文中一共展示了SwipeRefreshLayout.setOnRefreshListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fagment_bookmarks, container, false);

    refreshLayout =
            (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh_bookmarks);
    RecyclerView recyclerView =
            (RecyclerView) rootView.findViewById(R.id.bookmark_recycler_view);
    mAdapter = new BookmarksRecyclerViewAdapter(getActivity());
    recyclerView.setAdapter(mAdapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if(onRequestReloadListener != null) {
                onRequestReloadListener.requestReload();
            }
        }
    });

    return rootView;
}
 
开发者ID:theScrabi,项目名称:OCBookmarks,代码行数:25,代码来源:BookmarkFragment.java

示例2: onCreateView

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
                         @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_dialogs, container, false);
    mLayoutManager = new LinearLayoutManager(getActivity());
    recyclerView = (RecyclerView) view.findViewById(R.id.dialogs_recycler);
    recyclerView.setLayoutManager(mLayoutManager);
    ((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.dialogs_swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);

    setHasOptionsMenu(true);

    return view;
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:18,代码来源:PublicDialogsFragment.java

示例3: onCreateView

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    rootLayout = (LinearLayout) rootView.findViewById(R.id.root_layout);
    replaceLayout = (ViewStubCompat) rootView.findViewById(R.id.replace_layout);
    multiStateView = (MultiStateView) rootView.findViewById(R.id.multiStateView);
    if (inflateExtraView() != -1) {
        replaceLayout.setLayoutResource(inflateExtraView());
        replaceLayout.inflate();
    }
    swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
    swipeRefresh.setOnRefreshListener(onRefreshListener());

    multiStateView.setStateListener(onStateListener());
    return view;
}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:19,代码来源:BaseMainWithDataFragment.java

示例4: initView

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
private void initView(Context context) {
    mContext = context;
    View view = LayoutInflater.from(context).inflate(com.wuxiaolong.pullloadmorerecyclerview.R.layout.pull_loadmore_layout, null);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));

    mRecyclerView = (RecyclerView) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.recycler_view);
    mRecyclerView.setVerticalScrollBarEnabled(true);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addOnScrollListener(new RecyclerViewOnScroll(this));

    mRecyclerView.setOnTouchListener(new onTouchRecyclerView());

    mFooterView = view.findViewById(R.id.footerView);

    loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
    loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);

    mFooterView.setVisibility(View.GONE);

    this.addView(view);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PullLoadMoreRecyclerView.java

示例5: onCreateView

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
    listView = (RecyclerView) view.findViewById(R.id.list);
    listView.setHasFixedSize(true);
    listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
    List<ItemList> lists = new ArrayList<ItemList>();
    videoadapter = new VideoAdapter(lists);
    listView.setAdapter(videoadapter);

    mPresent = new VideoPresenter((VideoData.View) this);

    srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
    srfLayout.setOnRefreshListener(this);
    srfLayout.post(() -> onRefresh());
    return view;
}
 
开发者ID:popo1379,项目名称:popomusic,代码行数:19,代码来源:GameFragment.java

示例6: UpdatesViewBinder

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
public UpdatesViewBinder(final AppCompatActivity activity, FrameLayout parent) {
    View view = activity.getLayoutInflater().inflate(R.layout.main_tab_updates, parent, true);

    adapter = new UpdatesAdapter(activity);
    adapter.registerAdapterDataObserver(adapterChangeListener);

    list = (RecyclerView) view.findViewById(R.id.list);
    list.setHasFixedSize(true);
    list.setLayoutManager(new LinearLayoutManager(activity));
    list.setAdapter(adapter);

    ItemTouchHelper touchHelper = new ItemTouchHelper(new UpdatesItemTouchCallback(activity, adapter));
    touchHelper.attachToRecyclerView(list);

    emptyState = (TextView) view.findViewById(R.id.empty_state);
    emptyImage = (ImageView) view.findViewById(R.id.image);

    final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_to_refresh);
    swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeToRefresh.setRefreshing(false);
            UpdateService.updateNow(activity);
        }
    });

}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:28,代码来源:UpdatesViewBinder.java

示例7: prepareSwipeRefreshLayout

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
private void prepareSwipeRefreshLayout(SavedStoriesCardAdapter savedStoriesCardAdapter) {
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.saved_stories_swipe_refresh_layout);
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        loadSavedStories(savedStoriesCardAdapter, mService);
        mSwipeRefreshLayout.setRefreshing(false);
    });
}
 
开发者ID:dandanes7,项目名称:lurkerhn,代码行数:8,代码来源:SavedStoriesActivity.java

示例8: WhatsNewViewBinder

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
WhatsNewViewBinder(final AppCompatActivity activity, FrameLayout parent) {
    this.activity = activity;

    View whatsNewView = activity.getLayoutInflater().inflate(R.layout.main_tab_whats_new, parent, true);

    whatsNewAdapter = new WhatsNewAdapter(activity);

    GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
    layoutManager.setSpanSizeLookup(new WhatsNewAdapter.SpanSizeLookup());

    emptyState = (TextView) whatsNewView.findViewById(R.id.empty_state);

    appList = (RecyclerView) whatsNewView.findViewById(R.id.app_list);
    appList.setHasFixedSize(true);
    appList.setLayoutManager(layoutManager);
    appList.setAdapter(whatsNewAdapter);

    final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) whatsNewView
            .findViewById(R.id.swipe_to_refresh);
    swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeToRefresh.setRefreshing(false);
            UpdateService.updateNow(activity);
        }
    });

    FloatingActionButton searchFab = (FloatingActionButton) whatsNewView.findViewById(R.id.btn_search);
    searchFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.startActivity(new Intent(activity, AppListActivity.class));
        }
    });

    activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:38,代码来源:WhatsNewViewBinder.java

示例9: onCreate

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_log);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    final LogPersistence logPersistence = new LogPersistence(this);

    ListView logListView = (ListView) findViewById(R.id.log_list);
    List<LogResult> logs = logPersistence.getLogs();
    logListViewAdapter = new LogListViewAdapter(logs, this);
    logListView.setAdapter(logListViewAdapter);

    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.log_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            List<LogResult> refreshLogs = logPersistence.getLogs();
            logListViewAdapter.updateLogs(refreshLogs);
            swipeRefreshLayout.setRefreshing(false);
        }
    });

    boolean loggingOn = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(GENEARL_LOG_KEY, false);
    if (!loggingOn) {
        Toast.makeText(this, R.string.logging_turned_off_message, Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:bjaanes,项目名称:BeaconMqtt,代码行数:34,代码来源:LogActivity.java

示例10: initSwipeRefresh

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
private void initSwipeRefresh() {
    swipeRefreshLayout = (SwipeRefreshLayout) contentView.findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(ExtraUtil.fetchColor(getContext(), R.attr.colorAccent));
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            (new LoadAppsTask()).execute(true);
        }
    });
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:11,代码来源:ReqStatsFragment.java

示例11: onCreate

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    url = getIntent().getStringExtra(URL_KEY);
    detailContentParsable = new DetailContentParsable(url);

    setContentView(R.layout.activity_view_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    setTitle(getIntent().getStringExtra(TITLE_KEY));

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AppUtil.openWebPageAndShowSnackbarIfFail(ViewDetailActivity.this, url, view);
        }
    });

    toolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    AppUtil.setupSwipeRefreshLayoutColors(swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshAsync();
        }
    });
    detailWebView = (WebView) findViewById(R.id.detail_web_view);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    refreshAsync();
}
 
开发者ID:ShreckYe,项目名称:SCUYouth,代码行数:36,代码来源:ViewDetailActivity.java

示例12: onCreateView

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_tencent_shehui, container, false);

  refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
  listView = (ListView) view.findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(getActivity(), data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_tencent_news, position);
      Map<String, Object> map = data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.abstract_content, map.get("abstract").toString())
          .setText(R.id.time, FormatUtil.getRelativeTimeSpanString(
              new Date((long) (((double) map.get("timestamp")) * 1000))
          ));
      holder.setNetImage(R.id.thumbnails, ((List) map.get("thumbnails_qqnews")).get(0).toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(getActivity(), listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);
  refreshLayout.setRefreshing(true);

  return view;
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:31,代码来源:TencentSheHuiFragment.java

示例13: onCreate

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_zhihu_daily);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.zhihu_daily);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      ZhiHuDailyActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  listView = (ListView) findViewById(R.id.list_view);
  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  adapter = new MyBaseAdapter<Story>(this, data) {
    List<Integer> positions = new ArrayList<>();

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_zhihudaily, position);
      Story story = _data.get(position);
      holder.setText(R.id.title, story.getTitle());
      if (story.getImages().size() > 0) {
        positions.add(holder.getPosition());
      } else {
        positions.remove((Integer) holder.getPosition());
      }
      if (positions.contains(holder.getPosition())) {
        holder.setNetImage(R.id.image, story.getImages().get(0));
      }
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(this, listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  initData();

}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:47,代码来源:ZhiHuDailyActivity.java

示例14: onCreate

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_cnode);

  toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.cnode);
  toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      CNodeActivity.this.finish();
    }
  });
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));

  recylerView = (RecyclerView) findViewById(R.id.recylerView);
  recylerView.setLayoutManager(new LinearLayoutManager(this));
  recylerView.addItemDecoration(new MyRecylerViewAdapter.DividerItemDecoration(this, MyRecylerViewAdapter.DividerItemDecoration.VERTICAL_LIST));
  refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
  adapter = new MyRecylerViewAdapter<Data>(this, data) {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      switch (viewType) {
        case -1:
          return new TypeViewHolder(inflater.inflate(R.layout.recylerview_footer_load_more, parent, false)) {
            @Override
            public void bindHolder(Data model) {

            }
          };
        case 0:
          return new TypeViewHolder(inflater.inflate(R.layout.list_view_item_cnode, parent, false)) {
            @Override
            public void bindHolder(Data model) {
              this.setText(R.id.title, model.getTitle())
                  .setText(R.id.time, FormatUtil.getRelativeTimeSpanString(model.getCreate_at()))
                  .setText(R.id.replyCount, String.valueOf(model.getReply_count()));
              this.setNetImage(R.id.avatar, model.getAuthor().getAvatar_url());
            }
          };
      }
      return null;
    }

    @Override
    public int getItemViewType(int position) {
      if (super.list.get(position) == null) return -1;
      return 0;
    }
  };
  adapter.setOnItemClickListener(this);
  recylerView.setAdapter(adapter);
  recylerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
      super.onScrolled(recyclerView, dx, dy);
      LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
      int totalItemCount = layoutManager.getItemCount();
      int lastVisibleItem = layoutManager.findLastVisibleItemPosition();
      if (!loading && totalItemCount < lastVisibleItem + 3) {
        page++;
        initData();
        loading = true;
      }
    }
  });
  refreshLayout.setOnRefreshListener(this);
  refreshLayout.setRefreshing(true);
  initData();

}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:72,代码来源:CNodeActivity.java

示例15: initViews

import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
protected void initViews(){
    messageBoxView = (ChatMessageBoxView) findViewById(R.id.chat_sdk_message_box);
    messageBoxView.setAlertToast(chatSDKUiHelper.getAlertToast());

    chatSDKChatHelper.setMessageBoxView(messageBoxView);

    progressBar = (ProgressBar) findViewById(R.id.chat_sdk_progressbar);

    chatSDKChatHelper.setProgressBar(progressBar);

    final SwipeRefreshLayout mSwipeRefresh = (SwipeRefreshLayout)findViewById(R.id.ptr_layout);
    
    mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (DEBUG) Timber.d("onRefreshStarted");

            BNetworkManager.sharedManager().getNetworkAdapter().loadMoreMessagesForThread(thread)
                    .done(new DoneCallback<List<BMessage>>() {
                        @Override
                        public void onDone(List<BMessage> bMessages) {
                            if (DEBUG)
                                Timber.d("New messages are loaded, Amount: %s", (bMessages == null ? "No messages" : bMessages.size()));

                            if (bMessages.size() < 2)
                                showToast(getString(R.string.chat_activity_no_more_messages_to_load_toast));
                            else {
                                // Saving the position in the list so we could back to it after the update.
                                chatSDKChatHelper.loadMessages(true, false, -1, messagesListAdapter.getCount() + bMessages.size());
                            }

                            mSwipeRefresh.setRefreshing(false);
                        }
                    })
                    .fail(new FailCallback<Void>() {
                        @Override
                        public void onFail(Void aVoid) {
                            mSwipeRefresh.setRefreshing(false);
                        }
                    });
        }
    });

    listMessages = (ListView) findViewById(R.id.list_chat);

    chatSDKChatHelper.setListMessages(listMessages);

    if (messagesListAdapter == null)
        messagesListAdapter = new ChatSDKMessagesListAdapter(ChatSDKAbstractChatActivity.this, BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel().getId());

    listMessages.setAdapter(messagesListAdapter);
    chatSDKChatHelper.setMessagesListAdapter(messagesListAdapter);
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:54,代码来源:ChatSDKAbstractChatActivity.java


注:本文中的android.support.v4.widget.SwipeRefreshLayout.setOnRefreshListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。