Search in sources :

Example 1 with OneRouteAdapter

use of flying.grub.tamtime.adapter.OneRouteAdapter in project TamTime by flyingrub.

the class LineRouteFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.view_swype_refresh, container, false);
    recyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
    circularIndeterminate = (ProgressBarCircularIndeterminate) view.findViewById(R.id.progressBarCircularIndeterminate);
    refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity());
    recyclerView.addItemDecoration(itemDecoration);
    direction = Data.getData().getMap().getLine(linePosition).getDirections().get(routePosition);
    adapter = new OneRouteAdapter(direction.getStops(), getContext(), isTheoritical);
    recyclerView.setAdapter(adapter);
    adapter.SetOnItemClickListener(new OneRouteAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View v, int position) {
            selectitem(position);
        }
    });
    if (isTheoritical) {
        getActivity().setTitle("Théorique : Ligne " + Data.getData().getMap().getLine(linePosition).getShortName());
    } else {
        getActivity().setTitle("Ligne " + Data.getData().getMap().getLine(linePosition).getShortName());
    }
    circularIndeterminate.setVisibility(View.GONE);
    refreshLayout.setVisibility(View.VISIBLE);
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            Data.getData().update();
        }
    });
    refreshLayout.setColorSchemeResources(R.color.primaryColor);
    setHasOptionsMenu(true);
    return view;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(flying.grub.tamtime.adapter.DividerItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) OneRouteAdapter(flying.grub.tamtime.adapter.OneRouteAdapter)

Example 2 with OneRouteAdapter

use of flying.grub.tamtime.adapter.OneRouteAdapter in project TamTime by flyingrub.

the class LineRouteFragment method onEvent.

public void onEvent(MessageUpdate event) {
    if (event.type == MessageUpdate.Type.TIMES_UPDATE) {
        direction = Data.getData().getMap().getLine(linePosition).getDirections().get(routePosition);
        adapter = new OneRouteAdapter(direction.getStops(), getContext(), isTheoritical);
        adapter.SetOnItemClickListener(new OneRouteAdapter.OnItemClickListener() {

            @Override
            public void onItemClick(View v, int position) {
                selectitem(position);
            }
        });
        refreshLayout.setRefreshing(false);
        recyclerView.swapAdapter(adapter, true);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) OneRouteAdapter(flying.grub.tamtime.adapter.OneRouteAdapter)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 OneRouteAdapter (flying.grub.tamtime.adapter.OneRouteAdapter)2 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 DividerItemDecoration (flying.grub.tamtime.adapter.DividerItemDecoration)1