mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 21:03:12 +00:00
move to single activity with fragments
This commit is contained in:
parent
a565a7906b
commit
b3ca73002b
12 changed files with 305 additions and 147 deletions
|
@ -13,7 +13,7 @@
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:name=".ChaosflixApplication"
|
android:name=".ChaosflixApplication"
|
||||||
android:theme="@style/Base.Theme.AppCompat.Light">
|
android:theme="@style/Base.Theme.AppCompat.Light">
|
||||||
<activity android:name=".touch.activities.ConferencesActivity"
|
<activity android:name=".touch.activities.BrowseActivity"
|
||||||
android:icon="@drawable/icon_notext"
|
android:icon="@drawable/icon_notext"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".touch.activities.EventsActivity"/>
|
|
||||||
|
|
||||||
<service android:name=".common.network.MediaApiService"/>
|
<service android:name=".common.network.MediaApiService"/>
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||||
import de.nicidienase.chaosflix.R;
|
import de.nicidienase.chaosflix.R;
|
||||||
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
||||||
import de.nicidienase.chaosflix.common.entities.recording.ConferencesWrapper;
|
import de.nicidienase.chaosflix.common.entities.recording.ConferencesWrapper;
|
||||||
import de.nicidienase.chaosflix.touch.fragments.ConferencesFragment;
|
import de.nicidienase.chaosflix.touch.fragments.ConferenceGroupFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by felix on 18.09.17.
|
* Created by felix on 18.09.17.
|
||||||
|
@ -32,7 +32,7 @@ public class ConferenceGroupsFragmentPager extends FragmentPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
// ConferencesFragment conferenceFragment = ConferencesFragment.newInstance(getNumColumns());
|
// ConferencesFragment conferenceFragment = ConferencesFragment.newInstance(getNumColumns());
|
||||||
ConferencesFragment conferenceFragment = ConferencesFragment.newInstance(1);
|
ConferenceGroupFragment conferenceFragment = ConferenceGroupFragment.newInstance(1);
|
||||||
List<Conference> conferences = mConferenceMap.get(orderedConferencesList.get(position));
|
List<Conference> conferences = mConferenceMap.get(orderedConferencesList.get(position));
|
||||||
conferenceFragment.setContent(conferences);
|
conferenceFragment.setContent(conferences);
|
||||||
return conferenceFragment;
|
return conferenceFragment;
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package de.nicidienase.chaosflix.touch.activities;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.TabLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.transition.TransitionInflater;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.nicidienase.chaosflix.R;
|
||||||
|
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
||||||
|
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||||
|
import de.nicidienase.chaosflix.touch.adapters.ItemRecyclerViewAdapter;
|
||||||
|
import de.nicidienase.chaosflix.touch.ConferenceGroupsFragmentPager;
|
||||||
|
import de.nicidienase.chaosflix.touch.fragments.ConferencesBrowseFragment;
|
||||||
|
import de.nicidienase.chaosflix.touch.fragments.EventsFragment;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by felix on 17.09.17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class BrowseActivity extends TouchBaseActivity implements ItemRecyclerViewAdapter.OnListFragmentInteractionListener{
|
||||||
|
|
||||||
|
private static final String TAG = BrowseActivity.class.getSimpleName();
|
||||||
|
CompositeDisposable mDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.fragment_container_layout);
|
||||||
|
Disposable disposable = getApiServiceObservable()
|
||||||
|
.subscribe(mediaApiService -> {
|
||||||
|
mediaApiService.getConferences()
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(conferencesWrapper -> {
|
||||||
|
ConferencesBrowseFragment browseFragment
|
||||||
|
= ConferencesBrowseFragment.newInstance(getNumColumns());
|
||||||
|
browseFragment.setContent(conferencesWrapper);
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.replace(R.id.fragment_container,browseFragment);
|
||||||
|
ft.commit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
mDisposables.add(disposable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mDisposables.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListFragmentInteraction(Object item) {
|
||||||
|
if(item instanceof Conference){
|
||||||
|
Conference con = (Conference) item;
|
||||||
|
Disposable disposable = getApiServiceObservable()
|
||||||
|
.subscribe(mediaApiService -> {
|
||||||
|
mediaApiService.getConference(con.getApiID())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(conference -> {
|
||||||
|
EventsFragment eventsFragment = EventsFragment.newInstance(getNumColumns());
|
||||||
|
eventsFragment.setContent(conference);
|
||||||
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
|
Fragment oldFragment = fm.findFragmentById(R.id.fragment_container);
|
||||||
|
|
||||||
|
TransitionInflater transitionInflater = TransitionInflater.from(this);
|
||||||
|
oldFragment.setExitTransition(
|
||||||
|
transitionInflater.inflateTransition(android.R.transition.fade));
|
||||||
|
eventsFragment.setEnterTransition(
|
||||||
|
transitionInflater.inflateTransition(android.R.transition.slide_right));
|
||||||
|
eventsFragment.setExitTransition(
|
||||||
|
transitionInflater.inflateTransition(android.R.transition.slide_right));
|
||||||
|
|
||||||
|
FragmentTransaction ft = fm.beginTransaction();
|
||||||
|
ft.replace(R.id.fragment_container,eventsFragment);
|
||||||
|
ft.addToBackStack(null);
|
||||||
|
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
|
||||||
|
ft.commit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
mDisposables.add(disposable);
|
||||||
|
} else if (item instanceof Event){
|
||||||
|
Event event = (Event) item;
|
||||||
|
// TODO show event details
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getNumColumns() {
|
||||||
|
return getResources().getInteger(R.integer.num_columns);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
package de.nicidienase.chaosflix.touch.activities;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.design.widget.TabLayout;
|
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import de.nicidienase.chaosflix.R;
|
|
||||||
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
|
||||||
import de.nicidienase.chaosflix.touch.adapters.ItemRecyclerViewAdapter;
|
|
||||||
import de.nicidienase.chaosflix.touch.ConferenceGroupsFragmentPager;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by felix on 17.09.17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ConferencesActivity extends TouchBaseActivity implements ItemRecyclerViewAdapter.OnListFragmentInteractionListener<Conference>{
|
|
||||||
|
|
||||||
private static final String TAG = ConferencesActivity.class.getSimpleName();
|
|
||||||
CompositeDisposable mDisposables = new CompositeDisposable();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
// setContentView(R.layout.touch_browse);
|
|
||||||
setContentView(R.layout.tab_layout);
|
|
||||||
Disposable disposable = getApiServiceObservable()
|
|
||||||
.subscribe(mediaApiService -> {
|
|
||||||
mediaApiService.getConferences()
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(conferencesWrapper -> {
|
|
||||||
ConferenceGroupsFragmentPager fragmentPager
|
|
||||||
= new ConferenceGroupsFragmentPager(ConferencesActivity.this,getSupportFragmentManager());
|
|
||||||
fragmentPager.setContent(conferencesWrapper.getConferencesBySeries());
|
|
||||||
|
|
||||||
ViewPager pager = (ViewPager) findViewById(R.id.viewpager);
|
|
||||||
pager.setAdapter(fragmentPager);
|
|
||||||
|
|
||||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
|
|
||||||
tabLayout.setupWithViewPager(pager);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
mDisposables.add(disposable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
mDisposables.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onListFragmentInteraction(Conference item) {
|
|
||||||
Log.d(TAG,"Clicked " + item.getAcronym());
|
|
||||||
Intent intent = new Intent(this, EventsActivity.class);
|
|
||||||
intent.putExtra(EventsActivity.CONFERENCE_KEY,item);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package de.nicidienase.chaosflix.touch.activities;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.nicidienase.chaosflix.R;
|
|
||||||
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
|
||||||
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by felix on 18.09.17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventsActivity extends TouchBaseActivity implements EventsRecyclerViewAdapter.OnListFragmentInteractionListener {
|
|
||||||
public static String CONFERENCE_KEY = "conference";
|
|
||||||
private CompositeDisposable mDisposable = new CompositeDisposable();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.recycler_view_layout);
|
|
||||||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
|
|
||||||
if(getNumColumns() <= 1){
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
||||||
} else {
|
|
||||||
recyclerView.setLayoutManager(new GridLayoutManager(this,getNumColumns()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Conference intentConference = (Conference) getIntent().getParcelableExtra(CONFERENCE_KEY);
|
|
||||||
Disposable disposable = getApiServiceObservable().subscribe(mediaApiService -> {
|
|
||||||
mediaApiService.getConference(intentConference.getApiID())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(conference -> {
|
|
||||||
getSupportActionBar().setTitle(conference.getTitle());
|
|
||||||
List<Event> events = conference.getEvents();
|
|
||||||
// TODO build Adapters, etc.
|
|
||||||
recyclerView.setAdapter(new EventsRecyclerViewAdapter(events,this));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
mDisposable.add(disposable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
mDisposable.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onListItemSelected(Event event) {
|
|
||||||
// TODO start detailview for Events
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getNumColumns() {
|
|
||||||
return getResources().getInteger(R.integer.num_columns);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
||||||
|
|
||||||
public class ConferenceRecyclerViewAdapter extends ItemRecyclerViewAdapter<Conference> {
|
public class ConferenceRecyclerViewAdapter extends ItemRecyclerViewAdapter<Conference> {
|
||||||
|
|
||||||
public ConferenceRecyclerViewAdapter(List<Conference> items, OnListFragmentInteractionListener<Conference> listener) {
|
public ConferenceRecyclerViewAdapter(List<Conference> items, OnListFragmentInteractionListener listener) {
|
||||||
super(items, listener);
|
super(items, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||||
|
|
||||||
public class EventRecyclerViewAdapter extends ItemRecyclerViewAdapter<Event> {
|
public class EventRecyclerViewAdapter extends ItemRecyclerViewAdapter<Event> {
|
||||||
|
|
||||||
public EventRecyclerViewAdapter(List<Event> items, OnListFragmentInteractionListener<Event> listener) {
|
public EventRecyclerViewAdapter(List<Event> items, OnListFragmentInteractionListener listener) {
|
||||||
super(items, listener);
|
super(items, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ public abstract class ItemRecyclerViewAdapter<T> extends RecyclerView.Adapter<It
|
||||||
protected final List<T> mItems;
|
protected final List<T> mItems;
|
||||||
protected final OnListFragmentInteractionListener mListener;
|
protected final OnListFragmentInteractionListener mListener;
|
||||||
|
|
||||||
public ItemRecyclerViewAdapter(List<T> items, OnListFragmentInteractionListener<T> listener) {
|
public ItemRecyclerViewAdapter(List<T> items, OnListFragmentInteractionListener listener) {
|
||||||
mItems = items;
|
mItems = items;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public abstract class ItemRecyclerViewAdapter<T> extends RecyclerView.Adapter<It
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnListFragmentInteractionListener <T> {
|
public interface OnListFragmentInteractionListener {
|
||||||
void onListFragmentInteraction(T item);
|
void onListFragmentInteraction(Object item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,23 +18,23 @@ import de.nicidienase.chaosflix.touch.adapters.ItemRecyclerViewAdapter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ConferencesFragment extends Fragment {
|
public class ConferenceGroupFragment extends Fragment {
|
||||||
|
|
||||||
|
|
||||||
private static final String ARG_COLUMN_COUNT = "column-count";
|
private static final String ARG_COLUMN_COUNT = "column-count";
|
||||||
private int mColumnCount = 1;
|
private int mColumnCount = 1;
|
||||||
private ItemRecyclerViewAdapter.OnListFragmentInteractionListener<Conference> mListener;
|
private ItemRecyclerViewAdapter.OnListFragmentInteractionListener mListener;
|
||||||
private List<Conference> mItmes = new ArrayList<>();
|
private List<Conference> mItmes = new ArrayList<>();
|
||||||
|
|
||||||
public ConferencesFragment() {
|
public ConferenceGroupFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContent(List<Conference> itmes){
|
public void setContent(List<Conference> itmes){
|
||||||
mItmes = itmes;
|
mItmes = itmes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConferencesFragment newInstance(int columnCount) {
|
public static ConferenceGroupFragment newInstance(int columnCount) {
|
||||||
ConferencesFragment fragment = new ConferencesFragment();
|
ConferenceGroupFragment fragment = new ConferenceGroupFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ARG_COLUMN_COUNT, columnCount);
|
args.putInt(ARG_COLUMN_COUNT, columnCount);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
@ -75,7 +75,7 @@ public class ConferencesFragment extends Fragment {
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
if (context instanceof ItemRecyclerViewAdapter.OnListFragmentInteractionListener) {
|
if (context instanceof ItemRecyclerViewAdapter.OnListFragmentInteractionListener) {
|
||||||
mListener = (ItemRecyclerViewAdapter.OnListFragmentInteractionListener<Conference>) context;
|
mListener = (ItemRecyclerViewAdapter.OnListFragmentInteractionListener) context;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(context.toString()
|
throw new RuntimeException(context.toString()
|
||||||
+ " must implement OnListFragmentInteractionListener");
|
+ " must implement OnListFragmentInteractionListener");
|
|
@ -0,0 +1,85 @@
|
||||||
|
package de.nicidienase.chaosflix.touch.fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.TabLayout;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import de.nicidienase.chaosflix.R;
|
||||||
|
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
||||||
|
import de.nicidienase.chaosflix.common.entities.recording.ConferencesWrapper;
|
||||||
|
import de.nicidienase.chaosflix.touch.ConferenceGroupsFragmentPager;
|
||||||
|
import de.nicidienase.chaosflix.touch.adapters.ItemRecyclerViewAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by felix on 19.09.17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ConferencesBrowseFragment extends Fragment {
|
||||||
|
|
||||||
|
private static final String ARG_COLUMN_COUNT = "column-count";
|
||||||
|
private int mColumnCount = 1;
|
||||||
|
private ItemRecyclerViewAdapter.OnListFragmentInteractionListener mListener;
|
||||||
|
private ConferencesWrapper conferencesWrapper;
|
||||||
|
|
||||||
|
public ConferencesBrowseFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(ConferencesWrapper conferencesWrapper){
|
||||||
|
this.conferencesWrapper = conferencesWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConferencesBrowseFragment newInstance(int columnCount) {
|
||||||
|
ConferencesBrowseFragment fragment = new ConferencesBrowseFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(ARG_COLUMN_COUNT, columnCount);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if (getArguments() != null) {
|
||||||
|
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.tab_layout, container, false);
|
||||||
|
ConferenceGroupsFragmentPager fragmentPager
|
||||||
|
= new ConferenceGroupsFragmentPager(this.getContext(),getChildFragmentManager());
|
||||||
|
fragmentPager.setContent(conferencesWrapper.getConferencesBySeries());
|
||||||
|
|
||||||
|
ViewPager pager = (ViewPager) view.findViewById(R.id.viewpager);
|
||||||
|
pager.setAdapter(fragmentPager);
|
||||||
|
|
||||||
|
TabLayout tabLayout = (TabLayout) view.findViewById(R.id.sliding_tabs);
|
||||||
|
tabLayout.setupWithViewPager(pager);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
if (context instanceof ItemRecyclerViewAdapter.OnListFragmentInteractionListener) {
|
||||||
|
mListener = (ItemRecyclerViewAdapter.OnListFragmentInteractionListener) context;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(context.toString()
|
||||||
|
+ " must implement OnListFragmentInteractionListener");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
super.onDetach();
|
||||||
|
mListener = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
package de.nicidienase.chaosflix.touch.fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.nicidienase.chaosflix.R;
|
||||||
|
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
||||||
|
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||||
|
import de.nicidienase.chaosflix.touch.adapters.EventRecyclerViewAdapter;
|
||||||
|
import de.nicidienase.chaosflix.touch.adapters.ItemRecyclerViewAdapter;
|
||||||
|
|
||||||
|
public class EventsFragment extends Fragment {
|
||||||
|
|
||||||
|
|
||||||
|
private static final String ARG_COLUMN_COUNT = "column-count";
|
||||||
|
private int mColumnCount = 1;
|
||||||
|
private ItemRecyclerViewAdapter.OnListFragmentInteractionListener mListener;
|
||||||
|
private Conference mConference;
|
||||||
|
private List<Event> mItmes = new ArrayList<>();
|
||||||
|
private CharSequence mPreviousTitle;
|
||||||
|
private ActionBar mActionBar;
|
||||||
|
|
||||||
|
public EventsFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(Conference conference){
|
||||||
|
mConference = conference;
|
||||||
|
mItmes = conference.getEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EventsFragment newInstance(int columnCount) {
|
||||||
|
EventsFragment fragment = new EventsFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(ARG_COLUMN_COUNT, columnCount);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if (getArguments() != null) {
|
||||||
|
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.recycler_view_layout, container, false);
|
||||||
|
|
||||||
|
// Set the adapter
|
||||||
|
if (view instanceof RecyclerView) {
|
||||||
|
Context context = view.getContext();
|
||||||
|
RecyclerView recyclerView = (RecyclerView) view;
|
||||||
|
if (mColumnCount <= 1) {
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||||
|
} else {
|
||||||
|
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
recyclerView.setAdapter(new EventRecyclerViewAdapter(mItmes, mListener) {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
mActionBar = ((AppCompatActivity) context).getSupportActionBar();
|
||||||
|
mPreviousTitle = mActionBar.getTitle();
|
||||||
|
mActionBar.setTitle(mConference.getTitle());
|
||||||
|
if (context instanceof ItemRecyclerViewAdapter.OnListFragmentInteractionListener) {
|
||||||
|
mListener = (ItemRecyclerViewAdapter.OnListFragmentInteractionListener) context;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(context.toString()
|
||||||
|
+ " must implement OnListFragmentInteractionListener");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
super.onDetach();
|
||||||
|
mListener = null;
|
||||||
|
mActionBar.setTitle(mPreviousTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
5
touch/src/main/res/layout/fragment_container_layout.xml
Normal file
5
touch/src/main/res/layout/fragment_container_layout.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/fragment_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
Loading…
Reference in a new issue