android.support.v4.widget.SwipeRefreshLayout Java Examples

The following examples show how to use android.support.v4.widget.SwipeRefreshLayout. 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: NewsView.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
public void doAdapter(boolean force18) {
    mSwipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            mSwipeRefreshLayout.setRefreshing(true);
        }
    });

    posts = new SubredditPostsRealm(id, getContext(), force18);
    adapter = new SubmissionNewsAdapter(getActivity(), posts, rv, id, this);
    adapter.setHasStableIds(true);
    rv.setAdapter(adapter);
    posts.loadMore(getActivity(), this, true);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refresh();
        }
    });
}
 
Example #2
Source File: MultiTypeActivity.java    From basic-adapter with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multi_type);

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
    mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);

    BasicParams p = new BasicController.Builder()
            .layoutRes(R.layout.item)
            .layoutRes(R.layout.item2,1)
            .layoutRes(R.layout.item3,2)
            .build();


    List<Man> dataList = new ArrayList<>();
    dataList.addAll(DataGenerator.generate(0,10));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setAdapter(new MyAdapter(p,dataList));
}
 
Example #3
Source File: LabelsFragment.java    From YuanNewsForAndroid with Apache License 2.0 6 votes vote down vote up
private void initSwipeRefreshLayout() {
    binding.swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary
            ,R.color.colorPrimaryDark
            ,R.color.colorAccent);
    binding.swipeRefreshLayout.setSize(SwipeRefreshLayout.LARGE);
    binding.swipeRefreshLayout.setProgressViewEndTarget(true,500);//进度条位置
    binding.swipeRefreshLayout.setOnRefreshListener(swipeOnRefresh=new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            onloadInitData();
        }
    });

    binding.swipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            binding.swipeRefreshLayout.setRefreshing(true);
        }
    });
    swipeOnRefresh.onRefresh();
}
 
Example #4
Source File: TableView.java    From SortableTableView with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the {@link SwipeToRefreshListener} for this table view. If there is already a {@link SwipeToRefreshListener}
 * set it will be replaced.
 *
 * @param listener The {@link SwipeToRefreshListener} that is called when the user triggers the refresh action.
 */
public void setSwipeToRefreshListener(final SwipeToRefreshListener listener) {
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            listener.onRefresh(new SwipeToRefreshListener.RefreshIndicator() {
                @Override
                public void hide() {
                    swipeRefreshLayout.setRefreshing(false);
                }

                @Override
                public void show() {
                    swipeRefreshLayout.setRefreshing(true);
                }

                @Override
                public boolean isVisible() {
                    return swipeRefreshLayout.isRefreshing();
                }
            });
        }
    });
}
 
Example #5
Source File: SwipeRefreshFragment.java    From DoubanTop with Apache License 2.0 6 votes vote down vote up
private void setupRecyclerView() {
    mRecyclerView.setHasFixedSize(true);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(layoutManager);
    if (mMoviesList != null && mMoviesList.size() > 0) {
        mArrayAdapter = new ContentItemAdapter(getActionsListener(), mMoviesList);
        mRecyclerView.setAdapter(mArrayAdapter);
    }

    mSwipeRefreshLayout.setColorSchemeResources(R.color.orange, R.color.green, R.color.blue);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            doUpdateWork(mApiType);
        }
    });
    if (DoubanApiUtils.API_TYPE_SEARCH == mApiType) {
        setRefreshEnable(false);
    }
}
 
Example #6
Source File: TestFragment.java    From CoordinatorLayoutExample with Apache License 2.0 6 votes vote down vote up
private void initView(ViewGroup root) {
    mRecyclerView = (RecyclerView) root.findViewById(R.id.test_recycler);
    mSwipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
    mSwipeRefreshLayout.setEnabled(getArguments().getBoolean(REFRESH_SUPPORT));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(false);
                    Toast.makeText(mContext, "刷新完成", Toast.LENGTH_SHORT).show();
                }
            }, 2000);
        }
    });
}
 
Example #7
Source File: CollectionFragment.java    From foodie-app with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    updateDishes();
    sr.setColorSchemeResources(
            R.color.colorPrimary,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    sr.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updateDishes();
            sr.setRefreshing(false);
        }
    });
}
 
Example #8
Source File: ListFragment.java    From PracticeDemo with Apache License 2.0 6 votes vote down vote up
protected void init(Bundle savedInstanceState) {

        mData = new ArrayList<>();
        mAdapter = new ListAdapter(getActivity(),mData);

        for (int i = 0; i < 20; i++) {
            mData.add("~~"+i);
        }

        mRvList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
        mRvList.setAdapter(mAdapter);
        mSwipeRefresh.setColorSchemeResources(R.color.primary, R.color.accent, R.color.primary_dark);
        mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (null != mSwipeRefresh) {
                            mSwipeRefresh.setRefreshing(false);
                        }
                    }
                }, 3000);
            }
        });
    }
 
Example #9
Source File: InnovationFragment.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initYCRefreshView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    final RecycleViewItemLine line = new RecycleViewItemLine(activity, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new InnovationAdapter(activity);
    recyclerView.setAdapter(adapter);
    addHeader();
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            SwipeRefreshLayout swipeToRefresh = recyclerView.getSwipeToRefresh();
            if(swipeToRefresh.isRefreshing()){
                recyclerView.setRefreshing(false);
            }
        }
    });

    //设置回收复用池大小,(如果一屏内相同类型的 View 个数比较多,需要设置一个合适的大小,防止来回滚动时重新创建 View)
    RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
    recyclerView.getRecyclerView().setRecycledViewPool(viewPool);
    viewPool.setMaxRecycledViews(0, 20);
}
 
Example #10
Source File: MainActivity.java    From Moment with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    errorContainer = (LinearLayout) findViewById(R.id.error_container);
    ImageButton errorIcon = (ImageButton) findViewById(R.id.error_icon);
    errorIcon.setOnClickListener(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    applyFontsToTitle(toolbar);

    list = (RecyclerView) findViewById(R.id.list);
    refresh = (SwipeRefreshLayout) findViewById(R.id.refreshLayout);

    toolbar.setOnClickListener(v -> list.scrollToPosition(0));

    url = getString(R.string.pic_category_url, 21, page);
    setupRecyclerView();

    toolbar.setOnClickListener(v -> list.scrollToPosition(0));

    loadData(true);
}
 
Example #11
Source File: AllLineActivity.java    From FakeWeather with Apache License 2.0 6 votes vote down vote up
@Override
protected void initViews(Bundle savedInstanceState) {
    setDisplayHomeAsUpEnabled(true);
    refreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    refreshLayout.setColorSchemeResources(ThemeUtil.getCurrentColorPrimary(this));
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            loadData();
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.rv_bus_all);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    adapter = new AllLineAdapter(R.layout.item_bus_all, null);
    recyclerView.setAdapter(adapter);
}
 
Example #12
Source File: OtherTaskFragment.java    From Conquer with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.refreshLayout);
    mRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.theme_0), getResources().getColor(R.color.theme_1), getResources().getColor(R.color.theme_2), getResources().getColor(R.color.theme_3));
    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            getOtherTask();
        }
    });


    mRecylerView = (RecyclerView) getView().findViewById(R.id.recylerView);
    mLayoutManager = new LinearLayoutManager(context);
    mRecylerView.setLayoutManager(mLayoutManager);
    adapter = new OtherTaskAdapter(context, list);
    mRecylerView.setAdapter(adapter);

    mRecylerView.addItemDecoration(new SimpleListDividerDecorator(createRectShape(8, PixelUtil.dp2px(8), Color.TRANSPARENT), false));
    getOtherTask();
}
 
Example #13
Source File: TimelineFragment.java    From twitt4droid with Apache License 2.0 6 votes vote down vote up
/**
 * Sets up the layout with the given view.
 * 
 * @param layout the root view.
 */
protected void setUpLayout(View layout) {
    swipeLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipe_container);
    tweetListView = (ListView) layout.findViewById(R.id.tweets_list);
    progressBar = (ProgressBar) layout.findViewById(R.id.tweets_progress_bar);
    listAdapter = new TweetAdapter(getActivity());
    listAdapter.setUseDarkTheme(isDarkThemeEnabled());
    tweetListView.setAdapter(listAdapter);
    swipeLayout.setColorSchemeResources(R.color.twitt4droid_primary_color, 
            R.color.twitt4droid_secundary_color_1,
            R.color.twitt4droid_secundary_color_2,
            R.color.twitt4droid_secundary_color_3);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        
        @Override
        public void onRefresh() {
            reloadTweetsIfPossible();
        }
    });
}
 
Example #14
Source File: MyCompetitionsFragment.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
private void initializeList() {
  dataStore = new DataStore();
  Drawable drawable = ContextCompat.getDrawable(mContext, R.drawable.post_item_divider_view);
  ViewItemDecoration viewItemDecoration = new ViewItemDecoration(drawable);
  viewItemDecoration.setWantTopOffset(false, 0);
  competitionsListRecyclerAdapter = new CompetitionsListRecyclerAdapter(mContext);
  competitionsListRecyclerAdapter.setDeleteListener(this);
  competitionsListRecyclerAdapter.setLoadMoreCallback(this);
  competitionList.setLayoutManager(new LinearLayoutManager(mContext));
  competitionList.addItemDecoration(viewItemDecoration);
  competitionList.setAdapter(competitionsListRecyclerAdapter);
  swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
      refreshCompetitions();
    }
  });
}
 
Example #15
Source File: CompetitionDetailsActivity.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
private void initializeList() {
  countDownTimerUtils = new CountDownTimerUtils();
  dataStore = new DataStore();
  if (headerData != null) {
    showMessagePanel(false, "");
    setPrizeAmount(PrizeMoneyFilter.getTotalPrize(headerData.getPrizes()));
    invalidateActionButton();
    setAdapter();
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
      @Override
      public void onRefresh() {
        setAdapter();
        fetchEntries();
      }
    });
  } else {
    showMessagePanel(true, "Invalid competition data!");
  }
}
 
Example #16
Source File: RefreshProxy.java    From orz with Apache License 2.0 6 votes vote down vote up
public RefreshProxy bindingRefresh(@NonNull View layout, IRefreshProxyListener listener) {
    mSwipeRefreashLayout = (SwipeRefreshLayout) layout.findViewById(R.id.common_refreash_swipe_layout);
    mProxyListener = listener;
    if (mSwipeRefreashLayout == null) {
        throw new NullPointerException("SwipeRefreshLayout null");
    }
    mRefreshListener = new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (mProxyListener != null) {
                mProxyListener.onRefresh();
            }
        }
    };
    mSwipeRefreashLayout.setOnRefreshListener(mRefreshListener);
    mSwipeRefreashLayout.setColorSchemeResources(R.color.refreash_circle_1, R.color.refreash_circle_2, R.color.refreash_circle_3);
    return this;
}
 
Example #17
Source File: BaseNetFragment.java    From MobileInfo with Apache License 2.0 6 votes vote down vote up
private void onSwipeRefreshLayout() {
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            getParam();
        }
    });
    mSwipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            mSwipeRefreshLayout.setRefreshing(true);
            getParam();

        }
    });
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light,
            android.R.color.holo_red_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_green_light);
}
 
Example #18
Source File: NewsListFragment.java    From SimpleNews with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_newslist, null);

    mSwipeRefreshWidget = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_widget);
    mSwipeRefreshWidget.setColorSchemeResources(R.color.primary,
            R.color.primary_dark, R.color.primary_light,
            R.color.accent);
    mSwipeRefreshWidget.setOnRefreshListener(this);

    mRecyclerView = (RecyclerView)view.findViewById(R.id.recycle_view);
    mRecyclerView.setHasFixedSize(true);

    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new NewsAdapter(getActivity().getApplicationContext());
    mAdapter.setOnItemClickListener(mOnItemClickListener);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.addOnScrollListener(mOnScrollListener);
    onRefresh();
    return view;
}
 
Example #19
Source File: CouponListActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void initViews() {
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    listView = (ListView) findViewById(R.id.list_view);
    listAdapter = new CouponListAdapter(this);
    listView.setAdapter(listAdapter);
}
 
Example #20
Source File: FlickrListFragment.java    From chaining-rxjava with Apache License 2.0 5 votes vote down vote up
private void setupView(View view) {
    swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.flickr_swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_orange_dark);
    swipeRefreshLayout.setOnRefreshListener(this);

    recyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    recyclerView.setHasFixedSize(true);
    // use a linear layout manager
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    // specify an adapter
    recyclerView.setAdapter(flickrListAdapter = new FlickrListAdapter(new Timestamped<>(getViewDataTimestampMillis(), Collections.<FlickrCardVM>emptyList())));
}
 
Example #21
Source File: AuthorActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void init() {
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            presenter.authorVideos(uid, true);
        }
    });
    swipeLayout.setEnabled(false);
    mV91PornAdapter = new V91PornAdapter(R.layout.item_v_9porn);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(mV91PornAdapter);

    mV91PornAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            V9PornItem v9PornItems = (V9PornItem) adapter.getData().get(position);
            Intent intent = new Intent();
            intent.putExtra(Keys.KEY_INTENT_V9PORN_ITEM, v9PornItems);
            //setResult(KeysActivityRequestResultCode.AUTHOR_ACTIVITY_RESULT_CODE, intent);
            onBackPressed();
        }
    });
    mV91PornAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
        @Override
        public void onLoadMoreRequested() {

            presenter.authorVideos(uid, false);
        }
    }, recyclerView);

    helper = new LoadViewHelper(recyclerView);
    helper.setListener(new OnLoadViewListener() {
        @Override
        public void onRetryClick() {
            swipeLayout.setEnabled(false);
            presenter.authorVideos(uid, true);
        }
    });
    presenter.authorVideos(uid, false);
}
 
Example #22
Source File: BaseListDelegate.java    From CoreModule with Apache License 2.0 5 votes vote down vote up
@Override
public void initWidget() {
    super.initWidget();
    SwipeRefreshLayout refreshLayout = get(R.id.swiperefreshlayout);
    refreshLayout.setColorSchemeResources(R.color.base_swiperefresh_color1,
            R.color.base_swiperefresh_color2,
            R.color.base_swiperefresh_color3,
            R.color.base_swiperefresh_color4);

    mRecyclerView = get(R.id.recyclerView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),
            LinearLayoutManager.VERTICAL, false));
}
 
Example #23
Source File: RecyclerViewFragment.java    From the-tech-frontier-app with MIT License 5 votes vote down vote up
protected void initRefreshView(View rootView) {
    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
    mSwipeRefreshLayout.setOnRefreshListener(this);

    mRecyclerView = (AutoLoadRecyclerView) rootView.findViewById(R.id.articles_recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()
            .getApplicationContext()));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setVisibility(View.VISIBLE);
    mRecyclerView.setOnLoadListener(this);
}
 
Example #24
Source File: BaseContentFragment.java    From FakeWeather with Apache License 2.0 5 votes vote down vote up
private void initRefreshLayout() {
    refreshLayout = findView(R.id.swipe_container);
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            lazyFetchData();
        }
    });
    refreshLayout.setColorSchemeResources(ThemeUtil.getCurrentColorPrimary(getActivity()));
}
 
Example #25
Source File: LeaveActivity.java    From KUAS-AP-Material with MIT License 5 votes vote down vote up
private void findViews() {
	mScrollView = (ObservableScrollView) findViewById(R.id.scrollView);
	mPickYmsTextView = (TextView) findViewById(R.id.textView_pickYms);
	mPickYmsView = findViewById(R.id.view_pickYms);
	mPickYmsImageView = (ImageView) findViewById(R.id.imageView_pickYms);
	mMaterialProgressBar = (MaterialProgressBar) findViewById(R.id.materialProgressBar);
	mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
	mNoLeaveLinearLayout = (LinearLayout) findViewById(R.id.linearLayout_no_leave);
	mNoLeaveTextView = (TextView) findViewById(R.id.textView_no_leave);
	mLeaveTableLayout = (TableLayout) findViewById(R.id.tableLayout_leave);
	mLeaveNightTextView = (TextView) findViewById(R.id.textView_night);
	mFab = (FloatingActionButton) findViewById(R.id.fab);
}
 
Example #26
Source File: AuthorActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void init() {
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            presenter.authorVideos(uid, true);
        }
    });
    swipeLayout.setEnabled(false);
    mV91PornAdapter = new V91PornAdapter(R.layout.item_v_9porn);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(mV91PornAdapter);

    mV91PornAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            V9PornItem v9PornItems = (V9PornItem) adapter.getData().get(position);
            Intent intent = new Intent();
            intent.putExtra(Keys.KEY_INTENT_V9PORN_ITEM, v9PornItems);
            //setResult(KeysActivityRequestResultCode.AUTHOR_ACTIVITY_RESULT_CODE, intent);
            onBackPressed();
        }
    });
    mV91PornAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
        @Override
        public void onLoadMoreRequested() {

            presenter.authorVideos(uid, false);
        }
    }, recyclerView);

    helper = new LoadViewHelper(recyclerView);
    helper.setListener(new OnLoadViewListener() {
        @Override
        public void onRetryClick() {
            swipeLayout.setEnabled(false);
            presenter.authorVideos(uid, true);
        }
    });
    presenter.authorVideos(uid, false);
}
 
Example #27
Source File: NotesFragment.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_notes, container, false);
    RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.notes_list);
    recyclerView.setAdapter(mListAdapter);

    int numColumns = getContext().getResources().getInteger(R.integer.num_notes_columns);

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new GridLayoutManager(getContext(), numColumns));

    // Set up floating action button
    FloatingActionButton fab =
            (FloatingActionButton) getActivity().findViewById(R.id.fab_add_notes);

    fab.setImageResource(R.drawable.ic_add);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mActionsListener.addNewNote();
        }
    });

    // Pull-to-refresh
    SwipeRefreshLayout swipeRefreshLayout =
            (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
    swipeRefreshLayout.setColorSchemeColors(
            ContextCompat.getColor(getActivity(), R.color.colorPrimary),
            ContextCompat.getColor(getActivity(), R.color.colorAccent),
            ContextCompat.getColor(getActivity(), R.color.colorPrimaryDark));
   swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mActionsListener.loadNotes(true);
        }
    });
    return root;
}
 
Example #28
Source File: MyRecruitActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_recruit_activity_layout);

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

    intentFilter = new IntentFilter();
    intentFilter.addAction("com.allever.social.updateMyRecruitList");
    updateMyRecruitListReceiver = new UpdateMyRecruitListReceiver();
    registerReceiver(updateMyRecruitListReceiver, intentFilter);

    ActionBar ab = this.getSupportActionBar();
    ab.setLogo(R.mipmap.ic_arrow_back_white_24dp);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle("我的招聘");

    listView = (ListView)this.findViewById(R.id.id_my_recruit_activity_listview);
    swipeRefreshLayout = (SwipeRefreshLayout)this.findViewById(R.id.id_my_recruit_activity_refresh);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimary,
            com.hyphenate.easeui.R.color.holo_orange_light, com.hyphenate.easeui.R.color.holo_red_light);

    btn_add_recruit = (AddFloatingActionButton)this.findViewById(R.id.id_my_recruit_activity_fab_add_recruit);
    btn_add_recruit.setOnClickListener(this);

    list_myRecruitItem = new ArrayList<>();

    getMyRecruit();


}
 
Example #29
Source File: CollectionFragment.java    From ZhiHu-TopAnswer with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {

            initData();
        }
    });
}
 
Example #30
Source File: SwipeToRefreshActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.day4_activity_swipe_to_refresh);

    mSwipeRefresh = (SwipeRefreshLayout)
            findViewById(R.id.swipe_refresh_layout);
    mListView = (ListView) findViewById(R.id.list_view);

    initSampleData();

    mSimpleAdapter = new ArrayAdapter(this,
            android.R.layout.simple_list_item_1, android.R.id.text1, mData);

    mListView.setAdapter(mSimpleAdapter);

    mSwipeRefresh.setColorSchemeColors(Color.parseColor("#4183D7"),
            Color.parseColor("#F62459"),
            Color.parseColor("#03C9A9"),
            Color.parseColor("#F4D03F"));

    mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {

            new Handler().postDelayed(new Runnable() {
                @Override public void run() {

                    mSimpleAdapter.clear();

                    initSampleData();

                    mSimpleAdapter.notifyDataSetChanged();

                    mSwipeRefresh.setRefreshing(false);
                }
            }, 5000);
        }
    });
}