Search in sources :

Example 6 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project LeMondeRssReader by MBach.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    initCategories();
    // TODO
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mainActivityRecyclerView = (RecyclerView) findViewById(R.id.mainActivityRecyclerView);
    mainActivityRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            String category = selectedMenuItem == null ? Constants.CAT_NEWS : rssCats.get(selectedMenuItem.getItemId());
            getFeedFromCategory(category);
        }
    });
    initToolbar();
    setupDrawerLayout();
    mainActivityRecyclerView.setAdapter(adapter);
    getFeedFromCategory(Constants.CAT_NEWS);
}
Also used : StrictMode(android.os.StrictMode) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 7 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project twicalico by moko256.

the class ShowTweetActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_tweet);
    subscriptions = new CompositeSubscription();
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_back_white_24dp);
    }
    statusId = getIntent().getLongExtra("statusId", -1);
    if (statusId == -1) {
        ShowTweetActivity.this.finish();
        return;
    }
    Status status = GlobalApplication.statusCache.get(statusId);
    if (status == null) {
        subscriptions.add(updateStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
            if (result == null) {
                finish();
                return;
            }
            updateView(result);
        }, e -> {
            e.printStackTrace();
            finish();
        }));
    } else {
        updateView(status);
    }
    SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.tweet_show_swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.color_primary);
    swipeRefreshLayout.setOnRefreshListener(() -> subscriptions.add(updateStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        if (result == null) {
            finish();
            return;
        }
        updateView(result);
        swipeRefreshLayout.setRefreshing(false);
    }, e -> {
        e.printStackTrace();
        Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
        swipeRefreshLayout.setRefreshing(false);
    })));
}
Also used : Status(twitter4j.Status) Context(android.content.Context) Bundle(android.os.Bundle) PostTweetModel(com.github.moko256.twicalico.model.base.PostTweetModel) FrameLayout(android.widget.FrameLayout) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) LinkMovementMethod(android.text.method.LinkMovementMethod) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) UserMentionEntity(twitter4j.UserMentionEntity) MenuItem(android.view.MenuItem) AppCompatButton(android.support.v7.widget.AppCompatButton) Single(rx.Single) AppCustomTabsKt(com.github.moko256.twicalico.intent.AppCustomTabsKt) Toast(android.widget.Toast) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) TwitterException(twitter4j.TwitterException) VISIBLE(android.view.View.VISIBLE) ActionBar(android.support.v7.app.ActionBar) DateFormat(java.text.DateFormat) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) StatusCacheMap(com.github.moko256.twicalico.cacheMap.StatusCacheMap) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) CompositeSubscription(rx.subscriptions.CompositeSubscription) TextView(android.widget.TextView) GONE(android.view.View.GONE) Html(android.text.Html) Status(twitter4j.Status) PostTweetModelCreator(com.github.moko256.twicalico.model.impl.PostTweetModelCreator) AppCompatEditText(android.support.v7.widget.AppCompatEditText) CompositeSubscription(rx.subscriptions.CompositeSubscription) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ActionBar(android.support.v7.app.ActionBar)

Example 8 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project curb by irijwj.

the class InformationFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View info = inflater.inflate(R.layout.fragment_information, container, false);
    ButterKnife.bind(this, info);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    infoRecycler.setLayoutManager(layoutManager);
    infoRecycler.setAdapter(m_minfoAdapter);
    // 设置一些动画,但是没有显示出来
    infoRecycler.addItemDecoration(new DividerItemDecoration(checkNotNull(getActivity()), DividerItemDecoration.HORIZONTAL));
    // 设置一些颜色,但是我并不知道在哪里用的
    refreshInfoLayout.setColorSchemeColors(ContextCompat.getColor(checkNotNull(getActivity()), R.color.colorPrimary), ContextCompat.getColor(checkNotNull(getActivity()), R.color.colorAccent), ContextCompat.getColor(checkNotNull(getActivity()), R.color.colorPrimaryDark));
    // Set the scrolling view in the custom SwipeRefreshLayout.
    refreshInfoLayout.setScrollUpChild(infoRecycler);
    refreshInfoLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            presenter.loadInformation(true);
        }
    });
    setHasOptionsMenu(true);
    unbinder = ButterKnife.bind(this, info);
    return info;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ScrollChildSwipeRefreshLayout(jxpl.scnu.curb.utils.ScrollChildSwipeRefreshLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 9 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project IITB-App by wncc.

the class FeedFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    appDatabase = AppDatabase.getAppDatabase(getContext());
    final List<Event> events = appDatabase.dbDao().getAllEvents();
    FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {

        @Override
        public void onItemClick(View v, int position) {
            String eventJson = new Gson().toJson(events.get(position));
            Bundle bundle = new Bundle();
            bundle.putString(Constants.EVENT_JSON, eventJson);
            EventFragment eventFragment = new EventFragment();
            eventFragment.setArguments(bundle);
            FragmentManager manager = getActivity().getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
            transaction.commit();
        }
    });
    feedRecyclerView = (RecyclerView) getActivity().findViewById(R.id.feed_recycler_view);
    feedRecyclerView.setAdapter(feedAdapter);
    feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    // }
    updateFeed();
    feedSwipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.feed_swipe_refresh_layout);
    feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            updateFeed();
        }
    });
}
Also used : ItemClickListener(in.ac.iitb.gymkhana.iitbapp.ItemClickListener) Bundle(android.os.Bundle) Gson(com.google.gson.Gson) FeedAdapter(in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) Event(in.ac.iitb.gymkhana.iitbapp.data.Event)

Example 10 with SwipeRefreshLayout

use of android.support.v4.widget.SwipeRefreshLayout in project todo-mvp-rxjava by albertizzy.

the class TasksFragment method setLoadingIndicator.

@Override
public void setLoadingIndicator(final boolean active) {
    if (getView() == null) {
        return;
    }
    final SwipeRefreshLayout srl = getView().findViewById(R.id.refresh_layout);
    // Make sure setRefreshing() is called after the layout is done with everything else.
    srl.post(() -> srl.setRefreshing(active));
// TODO lambda
// srl.post(new Runnable() {
// @Override
// public void run() {
// srl.setRefreshing(active);
// }
// });
}
Also used : SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)102 View (android.view.View)55 RecyclerView (android.support.v7.widget.RecyclerView)43 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)41 TextView (android.widget.TextView)29 Bundle (android.os.Bundle)21 Intent (android.content.Intent)17 Handler (android.os.Handler)17 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)16 AdapterView (android.widget.AdapterView)15 ListView (android.widget.ListView)15 ArrayList (java.util.ArrayList)13 ImageView (android.widget.ImageView)10 ViewGroup (android.view.ViewGroup)9 Context (android.content.Context)8 LayoutInflater (android.view.LayoutInflater)8 GridLayoutManager (android.support.v7.widget.GridLayoutManager)7 PandaRecyclerView (com.instructure.pandarecycler.PandaRecyclerView)7 SearchView (android.support.v7.widget.SearchView)6 Toolbar (android.support.v7.widget.Toolbar)6