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
2e1d0313
Commit
2e1d0313
authored
Oct 02, 2018
by
Sajal Narang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Associations tab to UserFragment
parent
68222b46
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
34 deletions
+113
-34
app/src/main/java/app/insti/Constants.java
app/src/main/java/app/insti/Constants.java
+1
-0
app/src/main/java/app/insti/adapter/RoleAdapter.java
app/src/main/java/app/insti/adapter/RoleAdapter.java
+9
-5
app/src/main/java/app/insti/fragment/RoleRecyclerViewFragment.java
...ain/java/app/insti/fragment/RoleRecyclerViewFragment.java
+76
-0
app/src/main/java/app/insti/fragment/UserFragment.java
app/src/main/java/app/insti/fragment/UserFragment.java
+13
-24
app/src/main/res/layout/fragment_role_recycler_view.xml
app/src/main/res/layout/fragment_role_recycler_view.xml
+14
-0
app/src/main/res/layout/fragment_user.xml
app/src/main/res/layout/fragment_user.xml
+0
-5
No files found.
app/src/main/java/app/insti/Constants.java
View file @
2e1d0313
...
@@ -25,6 +25,7 @@ public class Constants {
...
@@ -25,6 +25,7 @@ public class Constants {
public
static
final
int
STATUS_NOT_GOING
=
0
;
public
static
final
int
STATUS_NOT_GOING
=
0
;
public
static
final
String
BODY_JSON
=
"body_json"
;
public
static
final
String
BODY_JSON
=
"body_json"
;
public
static
final
String
BODY_LIST_JSON
=
"body_list_json"
;
public
static
final
String
BODY_LIST_JSON
=
"body_list_json"
;
public
static
final
String
ROLE_LIST_JSON
=
"role_list_json"
;
public
static
final
String
LOGIN_MESSAGE
=
"Please login to continue!"
;
public
static
final
String
LOGIN_MESSAGE
=
"Please login to continue!"
;
...
...
app/src/main/java/app/insti/adapter/RoleAdapter.java
View file @
2e1d0313
...
@@ -2,6 +2,7 @@ package app.insti.adapter;
...
@@ -2,6 +2,7 @@ package app.insti.adapter;
import
android.content.Context
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
...
@@ -14,6 +15,7 @@ import com.squareup.picasso.Picasso;
...
@@ -14,6 +15,7 @@ import com.squareup.picasso.Picasso;
import
java.util.List
;
import
java.util.List
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.api.model.Body
;
import
app.insti.api.model.Body
;
import
app.insti.api.model.Role
;
import
app.insti.api.model.Role
;
import
app.insti.interfaces.ItemClickListener
;
import
app.insti.interfaces.ItemClickListener
;
...
@@ -22,12 +24,12 @@ import app.insti.interfaces.ItemClickListener;
...
@@ -22,12 +24,12 @@ import app.insti.interfaces.ItemClickListener;
public
class
RoleAdapter
extends
RecyclerView
.
Adapter
<
RoleAdapter
.
ViewHolder
>
{
public
class
RoleAdapter
extends
RecyclerView
.
Adapter
<
RoleAdapter
.
ViewHolder
>
{
private
List
<
Role
>
roleList
;
private
List
<
Role
>
roleList
;
private
ItemClickListener
itemClickListener
;
private
Context
context
;
private
Context
context
;
private
Fragment
fragment
;
public
RoleAdapter
(
List
<
Role
>
roleList
,
ItemClickListener
itemClickListener
)
{
public
RoleAdapter
(
List
<
Role
>
roleList
,
Fragment
mFragment
)
{
this
.
roleList
=
roleList
;
this
.
roleList
=
roleList
;
this
.
itemClickListener
=
itemClickListener
;
this
.
fragment
=
mFragment
;
}
}
@NonNull
@NonNull
...
@@ -41,7 +43,7 @@ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> {
...
@@ -41,7 +43,7 @@ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> {
v
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
v
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
itemClickListener
.
onItemClick
(
view
,
postViewHolder
.
getAdapterPosition
());
Utils
.
openBodyFragment
(
roleList
.
get
(
postViewHolder
.
getAdapterPosition
()).
getRoleBodyDetails
(),
fragment
.
getActivity
());
}
}
});
});
...
@@ -55,7 +57,9 @@ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> {
...
@@ -55,7 +57,9 @@ public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> {
Body
roleBody
=
role
.
getRoleBodyDetails
();
Body
roleBody
=
role
.
getRoleBodyDetails
();
holder
.
bodyName
.
setText
(
roleBody
.
getBodyName
());
holder
.
bodyName
.
setText
(
roleBody
.
getBodyName
());
holder
.
role
.
setText
(
role
.
getRoleName
());
holder
.
role
.
setText
(
role
.
getRoleName
());
Picasso
.
get
().
load
(
roleBody
.
getBodyImageURL
()).
into
(
holder
.
image
);
Picasso
.
get
().
load
(
Utils
.
resizeImageUrl
(
roleBody
.
getBodyImageURL
())
).
into
(
holder
.
image
);
}
}
...
...
app/src/main/java/app/insti/fragment/RoleRecyclerViewFragment.java
0 → 100644
View file @
2e1d0313
package
app.insti.fragment
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
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
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.adapter.RoleAdapter
;
import
app.insti.api.model.Role
;
/**
* A simple {@link Fragment} subclass..
* Use the {@link RoleRecyclerViewFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public
class
RoleRecyclerViewFragment
extends
Fragment
{
private
static
final
String
TAG
=
"RoleRecyclerViewFragment"
;
private
RecyclerView
recyclerView
;
private
RoleAdapter
roleAdapter
;
private
List
<
Role
>
roleList
;
public
RoleRecyclerViewFragment
()
{
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public
static
RoleRecyclerViewFragment
newInstance
(
List
<
Role
>
roleList
)
{
RoleRecyclerViewFragment
fragment
=
new
RoleRecyclerViewFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
Constants
.
ROLE_LIST_JSON
,
new
Gson
().
toJson
(
roleList
));
fragment
.
setArguments
(
args
);
return
fragment
;
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
roleList
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
Constants
.
ROLE_LIST_JSON
),
new
TypeToken
<
List
<
Role
>>()
{
}.
getType
());
}
}
@Override
public
void
onStart
()
{
super
.
onStart
();
recyclerView
=
(
RecyclerView
)
getActivity
().
findViewById
(
R
.
id
.
role_recycler_view
);
roleAdapter
=
new
RoleAdapter
(
roleList
,
this
);
recyclerView
.
setAdapter
(
roleAdapter
);
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_role_recycler_view
,
container
,
false
);
}
}
\ No newline at end of file
app/src/main/java/app/insti/fragment/UserFragment.java
View file @
2e1d0313
...
@@ -134,25 +134,6 @@ public class UserFragment extends BackHandledFragment {
...
@@ -134,25 +134,6 @@ public class UserFragment extends BackHandledFragment {
/* Show tabs */
/* Show tabs */
getActivity
().
findViewById
(
R
.
id
.
tab_layout
).
setVisibility
(
VISIBLE
);
getActivity
().
findViewById
(
R
.
id
.
tab_layout
).
setVisibility
(
VISIBLE
);
final
List
<
Role
>
roleList
=
user
.
getUserRoles
();
List
<
Role
>
formerRoleList
=
user
.
getUserFormerRoles
();
for
(
Role
role
:
formerRoleList
)
{
role
.
setRoleName
(
"Former "
+
role
.
getRoleName
());
}
roleList
.
addAll
(
formerRoleList
);
RecyclerView
userRoleRecyclerView
=
getActivity
().
findViewById
(
R
.
id
.
role_recycler_view
);
RoleAdapter
roleAdapter
=
new
RoleAdapter
(
roleList
,
new
ItemClickListener
()
{
@Override
public
void
onItemClick
(
View
v
,
int
position
)
{
Role
role
=
roleList
.
get
(
position
);
Body
roleBody
=
role
.
getRoleBodyDetails
();
Utils
.
openBodyFragment
(
roleBody
,
getActivity
());
}
});
userRoleRecyclerView
.
setAdapter
(
roleAdapter
);
userRoleRecyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
()));
Picasso
.
get
()
Picasso
.
get
()
.
load
(
user
.
getUserProfilePictureUrl
())
.
load
(
user
.
getUserProfilePictureUrl
())
.
resize
(
500
,
0
)
.
resize
(
500
,
0
)
...
@@ -167,16 +148,24 @@ public class UserFragment extends BackHandledFragment {
...
@@ -167,16 +148,24 @@ public class UserFragment extends BackHandledFragment {
});
});
mShortAnimationDuration
=
getResources
().
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
);
mShortAnimationDuration
=
getResources
().
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
);
final
List
<
Role
>
roleList
=
user
.
getUserRoles
();
final
List
<
Body
>
bodyList
=
user
.
getUserFollowedBodies
();
final
List
<
Body
>
bodyList
=
user
.
getUserFollowedBodies
();
final
List
<
Event
>
eventList
=
user
.
getUserGoingEvents
();
final
List
<
Event
>
eventList
=
user
.
getUserGoingEvents
();
final
List
<
Event
>
eventInterestedList
=
user
.
getUserInterestedEvents
();
List
<
Role
>
formerRoleList
=
user
.
getUserFormerRoles
();
for
(
Role
role
:
formerRoleList
)
{
role
.
setRoleName
(
"Former "
+
role
.
getRoleName
());
}
roleList
.
addAll
(
formerRoleList
);
List
<
Event
>
eventInterestedList
=
user
.
getUserInterestedEvents
();
eventList
.
removeAll
(
eventInterestedList
);
eventList
.
removeAll
(
eventInterestedList
);
eventList
.
addAll
(
eventInterestedList
);
eventList
.
addAll
(
eventInterestedList
);
BodyRecyclerViewFragment
frag1
=
BodyRecyclerViewFragment
.
newInstance
(
bodyList
);
RoleRecyclerViewFragment
frag1
=
RoleRecyclerViewFragment
.
newInstance
(
roleList
);
EventRecyclerViewFragment
frag2
=
EventRecyclerViewFragment
.
newInstance
(
eventList
);
BodyRecyclerViewFragment
frag2
=
BodyRecyclerViewFragment
.
newInstance
(
bodyList
);
EventRecyclerViewFragment
frag3
=
EventRecyclerViewFragment
.
newInstance
(
eventList
);
TabAdapter
tabAdapter
=
new
TabAdapter
(
getChildFragmentManager
());
TabAdapter
tabAdapter
=
new
TabAdapter
(
getChildFragmentManager
());
tabAdapter
.
addFragment
(
frag1
,
"Following"
);
tabAdapter
.
addFragment
(
frag1
,
"Associations"
);
tabAdapter
.
addFragment
(
frag2
,
"Events"
);
tabAdapter
.
addFragment
(
frag2
,
"Following"
);
tabAdapter
.
addFragment
(
frag3
,
"Events"
);
// Set up the ViewPager with the sections adapter.
// Set up the ViewPager with the sections adapter.
ViewPager
viewPager
=
(
ViewPager
)
getActivity
().
findViewById
(
R
.
id
.
viewPager
);
ViewPager
viewPager
=
(
ViewPager
)
getActivity
().
findViewById
(
R
.
id
.
viewPager
);
viewPager
.
setAdapter
(
tabAdapter
);
viewPager
.
setAdapter
(
tabAdapter
);
...
...
app/src/main/res/layout/fragment_role_recycler_view.xml
0 → 100644
View file @
2e1d0313
<?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.RoleRecyclerViewFragment"
>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/role_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_user.xml
View file @
2e1d0313
...
@@ -75,11 +75,6 @@
...
@@ -75,11 +75,6 @@
</RelativeLayout>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/role_recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<android.support.design.widget.TabLayout
<android.support.design.widget.TabLayout
android:id=
"@+id/tab_layout"
android:id=
"@+id/tab_layout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
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