Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
ac2917bb
Commit
ac2917bb
authored
Jun 28, 2018
by
Yash Khemchandani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added BodyRecyclerViewFragment and EventRecyclerViewFragment
parent
b5c1aa9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
208 additions
and
0 deletions
+208
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyRecyclerViewFragment.java
...b/gymkhana/iitbapp/fragment/BodyRecyclerViewFragment.java
+92
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventRecyclerViewFragment.java
.../gymkhana/iitbapp/fragment/EventRecyclerViewFragment.java
+91
-0
app/src/main/res/layout/fragment_body_recycler_view.xml
app/src/main/res/layout/fragment_body_recycler_view.xml
+15
-0
app/src/main/res/layout/fragment_event_recycler_view.xml
app/src/main/res/layout/fragment_event_recycler_view.xml
+10
-0
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyRecyclerViewFragment.java
0 → 100644
View file @
ac2917bb
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentTransaction
;
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
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.List
;
import
in.ac.iitb.gymkhana.iitbapp.Constants
;
import
in.ac.iitb.gymkhana.iitbapp.ItemClickListener
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
import
in.ac.iitb.gymkhana.iitbapp.adapter.BodyAdapter
;
import
in.ac.iitb.gymkhana.iitbapp.data.Body
;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* to handle interaction events.
* Use the {@link BodyRecyclerViewFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public
class
BodyRecyclerViewFragment
extends
Fragment
{
private
static
final
String
ARG_BODY
=
"bodies"
;
private
RecyclerView
recyclerView
;
private
BodyAdapter
bodyAdapter
;
private
List
<
Body
>
bodyList
;
public
BodyRecyclerViewFragment
()
{
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public
static
BodyRecyclerViewFragment
newInstance
(
List
<
Body
>
arg_bodyList
)
{
BodyRecyclerViewFragment
fragment
=
new
BodyRecyclerViewFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_BODY
,
new
Gson
().
toJson
(
arg_bodyList
));
fragment
.
setArguments
(
args
);
return
fragment
;
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
bodyList
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
ARG_BODY
),
new
TypeToken
<
List
<
Body
>>(){}.
getType
());
}
}
@Override
public
void
onStart
()
{
super
.
onStart
();
recyclerView
=
(
RecyclerView
)
getActivity
().
findViewById
(
R
.
id
.
body_recycler_view
);
bodyAdapter
=
new
BodyAdapter
(
bodyList
,
new
ItemClickListener
()
{
@Override
public
void
onItemClick
(
View
v
,
int
position
)
{
Body
body
=
bodyList
.
get
(
position
);
BodyFragment
bodyFragment
=
new
BodyFragment
();
Bundle
arguments
=
getArguments
();
arguments
.
putString
(
Constants
.
BODY_JSON
,
new
Gson
().
toJson
(
body
));
bodyFragment
.
setArguments
(
getArguments
());
FragmentTransaction
ft
=
getActivity
().
getSupportFragmentManager
().
beginTransaction
();
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
bodyFragment
,
bodyFragment
.
getTag
());
ft
.
addToBackStack
(
bodyFragment
.
getTag
());
ft
.
commit
();
}
});
recyclerView
.
setAdapter
(
bodyAdapter
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
()));
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_body_recycler_view
,
container
,
false
);
}
}
\ No newline at end of file
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventRecyclerViewFragment.java
0 → 100644
View file @
ac2917bb
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentTransaction
;
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
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.List
;
import
in.ac.iitb.gymkhana.iitbapp.Constants
;
import
in.ac.iitb.gymkhana.iitbapp.ItemClickListener
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
import
in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter
;
import
in.ac.iitb.gymkhana.iitbapp.data.Event
;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* to handle interaction events.
* Use the {@link EventRecyclerViewFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public
class
EventRecyclerViewFragment
extends
Fragment
{
private
static
final
String
ARG_EVENT
=
"events"
;
private
RecyclerView
recyclerView
;
private
FeedAdapter
feedAdapter
;
private
List
<
Event
>
eventList
;
public
EventRecyclerViewFragment
()
{
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public
static
EventRecyclerViewFragment
newInstance
(
List
<
Event
>
arg_eventList
)
{
EventRecyclerViewFragment
fragment
=
new
EventRecyclerViewFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_EVENT
,
new
Gson
().
toJson
(
arg_eventList
));
fragment
.
setArguments
(
args
);
return
fragment
;
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
eventList
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
ARG_EVENT
),
new
TypeToken
<
List
<
Event
>>(){}.
getType
());
}
}
@Override
public
void
onStart
()
{
super
.
onStart
();
recyclerView
=
(
RecyclerView
)
getActivity
().
findViewById
(
R
.
id
.
event_recycler_view
);
feedAdapter
=
new
FeedAdapter
(
eventList
,
new
ItemClickListener
()
{
@Override
public
void
onItemClick
(
View
v
,
int
position
)
{
Event
event
=
eventList
.
get
(
position
);
EventFragment
eventFragment
=
new
EventFragment
();
Bundle
arguments
=
getArguments
();
arguments
.
putString
(
Constants
.
EVENT_JSON
,
new
Gson
().
toJson
(
event
));
eventFragment
.
setArguments
(
getArguments
());
FragmentTransaction
ft
=
getActivity
().
getSupportFragmentManager
().
beginTransaction
();
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
eventFragment
,
eventFragment
.
getTag
());
ft
.
addToBackStack
(
eventFragment
.
getTag
());
ft
.
commit
();
}
});
recyclerView
.
setAdapter
(
feedAdapter
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
()));
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_event_recycler_view
,
container
,
false
);
}
}
\ No newline at end of file
app/src/main/res/layout/fragment_body_recycler_view.xml
0 → 100644
View file @
ac2917bb
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".fragment.BodyRecyclerViewFragment"
>
<!-- TODO: Update blank fragment layout -->
<android.support.v7.widget.RecyclerView
android:id=
"@+id/body_recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_event_recycler_view.xml
0 → 100644
View file @
ac2917bb
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/event_recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment