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
73133568
Commit
73133568
authored
Mar 24, 2018
by
Sajal Narang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ProfileFragment, fix #61
parent
09ef8cff
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
0 deletions
+134
-0
app/build.gradle
app/build.gradle
+1
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
+1
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
...c/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
+11
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
...va/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
+4
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/ProfileFragment.java
...in/ac/iitb/gymkhana/iitbapp/fragment/ProfileFragment.java
+77
-0
app/src/main/res/layout/fragment_profile.xml
app/src/main/res/layout/fragment_profile.xml
+40
-0
No files found.
app/build.gradle
View file @
73133568
...
...
@@ -34,6 +34,7 @@ ext {
}
dependencies
{
implementation
'com.android.support:support-v4:26.1.0'
compile
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
androidTestCompile
(
'com.android.support.test.espresso:espresso-core:2.2.2'
,
{
exclude
group:
'com.android.support'
,
module:
'support-annotations'
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
View file @
73133568
...
...
@@ -3,4 +3,5 @@ package in.ac.iitb.gymkhana.iitbapp;
public
class
Constants
{
public
static
final
String
NOTIFICATIONS_RESPONSE_JSON
=
"notifications_json"
;
public
static
final
String
EVENT_JSON
=
"event_json"
;
public
static
final
java
.
lang
.
String
USER_ID
=
"user_id"
;
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
View file @
73133568
...
...
@@ -42,6 +42,7 @@ import in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment;
import
in.ac.iitb.gymkhana.iitbapp.fragment.NotificationsFragment
;
import
in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment
;
import
in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment
;
import
in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment
;
import
in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
...
...
@@ -91,6 +92,16 @@ public class MainActivity extends AppCompatActivity
NavigationView
navigationView
=
(
NavigationView
)
findViewById
(
R
.
id
.
nav_view
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
View
header
=
navigationView
.
getHeaderView
(
0
);
header
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
USER_ID
,
currentUser
.
getUserID
());
ProfileFragment
profileFragment
=
new
ProfileFragment
();
profileFragment
.
setArguments
(
bundle
);
updateFragment
(
profileFragment
);
}
});
TextView
nameTextView
=
header
.
findViewById
(
R
.
id
.
user_name_nav_header
);
TextView
rollNoTextView
=
header
.
findViewById
(
R
.
id
.
user_rollno_nav_header
);
ImageView
profilePictureImageView
=
header
.
findViewById
(
R
.
id
.
user_profile_picture_nav_header
);
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
View file @
73133568
...
...
@@ -8,6 +8,7 @@ import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse;
import
in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse
;
import
in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsRequest
;
import
in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse
;
import
in.ac.iitb.gymkhana.iitbapp.data.User
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.GET
;
...
...
@@ -25,6 +26,9 @@ public interface RetrofitInterface {
@GET
(
"users/{uuid}/followed_bodies_events"
)
Call
<
NewsFeedResponse
>
getNewsFeed
(
@Path
(
"uuid"
)
String
uuid
);
@GET
(
"users/{uuid}"
)
Call
<
User
>
getUser
(
@Path
(
"uuid"
)
String
uuid
);
@POST
(
"getNotifications/"
)
Call
<
NotificationsResponse
>
getNotifications
(
@Body
NotificationsRequest
notificationsRequest
);
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/ProfileFragment.java
0 → 100644
View file @
73133568
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.squareup.picasso.Picasso
;
import
in.ac.iitb.gymkhana.iitbapp.Constants
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
import
in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface
;
import
in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator
;
import
in.ac.iitb.gymkhana.iitbapp.data.User
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
/**
* A simple {@link Fragment} subclass.
*/
public
class
ProfileFragment
extends
Fragment
{
User
user
;
public
ProfileFragment
()
{
// Required empty public constructor
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
return
inflater
.
inflate
(
R
.
layout
.
fragment_profile
,
container
,
false
);
}
@Override
public
void
onStart
()
{
super
.
onStart
();
Bundle
bundle
=
getArguments
();
String
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
retrofitInterface
.
getUser
(
userID
).
enqueue
(
new
Callback
<
User
>()
{
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
if
(
response
.
isSuccessful
())
{
user
=
response
.
body
();
populateViews
();
}
}
@Override
public
void
onFailure
(
Call
<
User
>
call
,
Throwable
t
)
{
}
});
}
private
void
populateViews
()
{
ImageView
userProfilePictureImageView
=
getActivity
().
findViewById
(
R
.
id
.
user_profile_picture_profile
);
TextView
userNameTextView
=
getActivity
().
findViewById
(
R
.
id
.
user_name_profile
);
TextView
userRollNumberTextView
=
getActivity
().
findViewById
(
R
.
id
.
user_rollno_profile
);
TextView
userEmailIDTextView
=
getActivity
().
findViewById
(
R
.
id
.
user_email_profile
);
TextView
userContactNumberTextView
=
getActivity
().
findViewById
(
R
.
id
.
user_contact_no_profile
);
Picasso
.
with
(
getContext
()).
load
(
user
.
getUserProfilePictureUrl
()).
into
(
userProfilePictureImageView
);
userNameTextView
.
setText
(
user
.
getUserName
());
userRollNumberTextView
.
setText
(
user
.
getUserRollNumber
());
userEmailIDTextView
.
setText
(
user
.
getUserEmail
());
userContactNumberTextView
.
setText
(
user
.
getUserContactNumber
());
}
}
app/src/main/res/layout/fragment_profile.xml
0 → 100644
View file @
73133568
<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=
"horizontal"
tools:context=
"in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment"
>
<ImageView
android:id=
"@+id/user_profile_picture_profile"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<TextView
android:id=
"@+id/user_name_profile"
android:textStyle=
"bold"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/user_rollno_profile"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/user_email_profile"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/user_contact_no_profile"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</LinearLayout>
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