Search in sources :

Example 1 with OneStopAdapter

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

the class StopLineFragment 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);
    recyclerView.setBackgroundColor(getResources().getColor(R.color.windowBackgroundCard));
    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter = new OneStopAdapter(stopZone.getStops(line));
    recyclerView.setAdapter(adapter);
    adapter.SetOnItemClickListener(new OneStopAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View v, int position) {
        // Unneeded ?
        }
    });
    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);
    return view;
}
Also used : OneStopAdapter(flying.grub.tamtime.adapter.OneStopAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 2 with OneStopAdapter

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

the class StopLineFragment method onEvent.

public void onEvent(MessageUpdate event) {
    if (event.type == MessageUpdate.Type.TIMES_UPDATE) {
        refreshLayout.setRefreshing(false);
        stopZone = Data.getData().getMap().getStopZoneById(getArguments().getInt("stop_zone_id"));
        line = stopZone.getLines().get(getArguments().getInt("linePosition"));
        adapter = new OneStopAdapter(stopZone.getStops(line));
        recyclerView.swapAdapter(adapter, true);
    }
}
Also used : OneStopAdapter(flying.grub.tamtime.adapter.OneStopAdapter)

Aggregations

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