Java Code Examples for android.support.v4.widget.SwipeRefreshLayout

The following examples show how to use android.support.v4.widget.SwipeRefreshLayout. 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
Source Project: DoubanTop   Source File: SwipeRefreshFragment.java    License: 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 2
Source Project: basic-adapter   Source File: MultiTypeActivity.java    License: 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 Project: SortableTableView   Source File: TableView.java    License: 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 4
Source Project: YuanNewsForAndroid   Source File: LabelsFragment.java    License: 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 5
Source Project: CoordinatorLayoutExample   Source File: TestFragment.java    License: 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 6
Source Project: foodie-app   Source File: CollectionFragment.java    License: 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 7
Source Project: PracticeDemo   Source File: ListFragment.java    License: 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 8
Source Project: YCAudioPlayer   Source File: InnovationFragment.java    License: 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 9
Source Project: Moment   Source File: MainActivity.java    License: 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 10
Source Project: FakeWeather   Source File: AllLineActivity.java    License: 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 11
Source Project: Conquer   Source File: OtherTaskFragment.java    License: 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 12
Source Project: twitt4droid   Source File: TimelineFragment.java    License: 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 13
Source Project: 1Rramp-Android   Source File: MyCompetitionsFragment.java    License: 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 14
Source Project: 1Rramp-Android   Source File: CompetitionDetailsActivity.java    License: 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 15
Source Project: orz   Source File: RefreshProxy.java    License: 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 16
Source Project: MobileInfo   Source File: BaseNetFragment.java    License: 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 17
Source Project: SimpleNews   Source File: NewsListFragment.java    License: 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 18
Source Project: Slide   Source File: NewsView.java    License: 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 19
Source Project: foodie-app   Source File: DishListFragment.java    License: 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.fragment_home, container, false);
    dishListView = (StaggeredGridView) view.findViewById(R.id.channel_dish_list);
    sr = (SwipeRefreshLayout) view.findViewById(R.id.sr);
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    return view;
}
 
Example 20
Source Project: go-bees   Source File: AndroidUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Displays or hide loading indicator.
 *
 * @param view   current view.
 * @param active true or false.
 */
public static void setLoadingIndicator(View view, final boolean active) {
    if (view == null) {
        return;
    }
    final SwipeRefreshLayout srl =
            (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
    // Make sure setRefreshing() is called after the layout is done with everything else
    srl.post(new Runnable() {
        @Override
        public void run() {
            srl.setRefreshing(active);
        }
    });
}
 
Example 21
Source Project: GoogleFitExample   Source File: PageFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_page, container, false);

    ButterKnife.bind(this, view);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this.getActivity(), 2));

    List<Workout> items = new ArrayList<>();

    adapter = new RecyclerViewAdapter(items, Utilities.getTimeFrameText(Utilities.TimeFrame.values()[mPage - 1]));
    adapter.setOnItemClickListener(this);
    filter();
    mRecyclerView.setItemAnimator(new ItemAnimator());
    mRecyclerView.setAdapter(adapter);

    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.contentView);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            //CacheManager.getReport(Utilities.TimeFrame.values()[mPage - 1], mReciever, getActivity());
            if (mPage < 4) {
                //UserPreferences.setLastSync(getActivity(), Utilities.getTimeFrameStart(Utilities.TimeFrame.values()[mPage - 1]));
            }
            mCallback.quickDataRead();
        }
    });
    mSwipeRefreshLayout.setEnabled(false);

    return view;
}
 
Example 22
Source Project: chaining-rxjava   Source File: FlickrListFragment.java    License: 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 23
Source Project: Weather-Lite   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void initView() {
    weatherGrid = (RecyclerView) findViewById(R.id.weather_grid);
    weatherGrid.setHasFixedSize(true);
    weatherAdaper = new WeatherAdaper();
    weatherGrid.setAdapter(weatherAdaper);
    GridLayoutManager gm = new GridLayoutManager(this, 2);

    weatherGrid.setLayoutManager(gm);
    weatherGrid.setItemAnimator(new DefaultItemAnimator());

    ItemTouchHelper touchHelper = new ItemTouchHelper(touchCallback);
    touchHelper.attachToRecyclerView(weatherGrid);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_content);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (!isNetWorkAccess()) {
                toast("无网络,请尝试联网并下拉刷新");
                swipeRefreshLayout.setRefreshing(false);
                return;
            }
            initWeather();
        }
    });

}
 
Example 24
Source Project: freeiot-android   Source File: MyDevicesListFragment.java    License: MIT License 5 votes vote down vote up
public void initView(View rootView) {
        mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
        mSwipeRefreshLayout.setColorScheme(R.color.main_red_color);
        mSwipeRefreshLayout.setOnRefreshListener(this);
        mSwipeRefreshLayout.setProgressViewOffset(true, 0, UIUtils.dip2px(getActivity(), 48));
        mListView = (ListView) rootView.findViewById(R.id.listview);

        LocalBroadcastManager.getInstance(getActivity())
                .registerReceiver(refreshDevicesReceiver,
                        new IntentFilter(ActionConstants.ACTON_REFRESH_DEVICES));
        refreshDevices(true);
//		UpdateConfig.setDebug(true);
        UmengUpdateAgent.forceUpdate(getActivity());
    }
 
Example 25
Source Project: SprintNBA   Source File: MatchDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initViewsAndEvents() {
    EventBus.getDefault().register(this);
    mid = getIntent().getStringExtra(INTENT_MID);
    year = getIntent().getStringExtra(INTENT_YEAR);
    LogUtils.i(year);

    //rlMatchToolbar.getBackground().setAlpha(0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        rlMatchToolbar.getLayoutParams().height += StatusBarCompat.getStatusBarHeight(this);
        rlMatchToolbar.setPadding(0, StatusBarCompat.getStatusBarHeight(this), 0, 0);
    }

    indicator.setScrollBar(new GameDetailScrollBar(getApplicationContext(), ContextCompat.getColor(this, R.color.colorPrimary), DimenUtils.dpToPxInt(3)));
    indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
    stickyNavLayout.setOnStickStateChangeListener(this);

    tvBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    swipeRefreshLayout.setColorSchemeResources(R.color.material_red, R.color.material_green);
    swipeRefreshLayout.setSize(SwipeRefreshLayout.DEFAULT);
    swipeRefreshLayout.setEnabled(true);
    swipeRefreshLayout.setOnRefreshListener(mOnRefreshListener);

    presenter = new MatchDetailPresenter(this, this);
    presenter.getMatchBaseInfo(mid);
}
 
Example 26
Source Project: v9porn   Source File: AuthorActivity.java    License: 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 Project: UltimateAndroid   Source File: UltimateListviewActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ultimate_list_view_temp_activity);
    ultimateListview = (UltimateListview) findViewById(R.id.ultimateListview);
    adapter = new ArrayAdapter<String>(this, R.layout.ultimate_list_view_activity_item,
            getResources().getStringArray(R.array.items_name));


    ultimateListview.setAdapter(adapter);
    ultimateListview.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            ultimateListview.getSwipeRefreshLayout().setEnabled(true);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    ultimateListview.getSwipeRefreshLayout().setRefreshing(false);
                }
            }, 1000);
        }
    });
    ultimateListview.getListView().setOnLoadMoreListener(new BasicUltimateListView.OnLoadMoreListener() {
        @Override
        public void loadMore() {
            Logs.d("loadMore");
        }
    });
}
 
Example 28
Source Project: YCAudioPlayer   Source File: LocalMusicFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    adapter = new LocalMusicAdapter(activity);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if(NetworkUtils.isConnected()){
                onLazyLoad();
            }else {
                com.pedaily.yc.ycdialoglib.toast.ToastUtils.showRoundRectToast("没有网络");
            }
        }
    });
}
 
Example 29
Source Project: XFrame   Source File: XMultiTypeAdapterActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public void initView() {
        SwipeRefreshLayout mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
        mSwipeLayout.setEnabled(false);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        recyclerView.addItemDecoration(new DividerDecoration(Color.parseColor("#f2f2f2"),15));

        //解决NestedScrollView嵌套RecycleView的滑动冲突问题
//        recyclerView.setNestedScrollingEnabled(false);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        final MultiTypeAdapter adapter = new MultiTypeAdapter(recyclerView, NewDataSource.getNewsList());
        recyclerView.setAdapter(adapter);

        // StickyHeader
        StickyHeaderDecoration decoration = new StickyHeaderDecoration(new StickyHeaderAdapter(this));
        decoration.setIncludeHeader(false);
        recyclerView.addItemDecoration(decoration);

        adapter.setOnItemClickListener(new XRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                //修改局部item的数据,点击那个修改哪个
                int random = new Random().nextInt(9);
                News news=NewDataSource.getNewsList().get(random);
                adapter.replace(position,news);
            }
        });
    }
 
Example 30
Source Project: MaterialMasterDetail   Source File: PeopleFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void setupSwipeRefresh() {
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            presenter.loadMorePeople();
        }
    });
}