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
cdd4b1e0
Commit
cdd4b1e0
authored
May 30, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make an HTTP request for full body in BodyFragment
parent
f59eed5e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
6 deletions
+61
-6
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
...c/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
+4
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/SessionManager.java
...main/java/in/ac/iitb/gymkhana/iitbapp/SessionManager.java
+4
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
...va/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
+3
-0
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
...va/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
+31
-1
app/src/main/res/layout/fragment_body.xml
app/src/main/res/layout/fragment_body.xml
+19
-5
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
View file @
cdd4b1e0
...
@@ -293,6 +293,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -293,6 +293,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
}
}
public
String
getSessionIDHeader
()
{
return
"sessionid="
+
session
.
getSessionID
();
}
@Override
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/SessionManager.java
View file @
cdd4b1e0
...
@@ -41,6 +41,10 @@ public class SessionManager {
...
@@ -41,6 +41,10 @@ public class SessionManager {
editor
.
commit
();
editor
.
commit
();
}
}
public
String
getSessionID
()
{
return
pref
.
getString
(
Constants
.
SESSION_ID
,
""
);
}
public
boolean
isLoggedIn
()
{
public
boolean
isLoggedIn
()
{
return
pref
.
getBoolean
(
Constants
.
IS_LOGGED_IN
,
false
);
return
pref
.
getBoolean
(
Constants
.
IS_LOGGED_IN
,
false
);
}
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/api/RetrofitInterface.java
View file @
cdd4b1e0
...
@@ -28,6 +28,9 @@ public interface RetrofitInterface {
...
@@ -28,6 +28,9 @@ public interface RetrofitInterface {
@GET
(
"users/{uuid}"
)
@GET
(
"users/{uuid}"
)
Call
<
User
>
getUser
(
@Header
(
"Cookie"
)
String
sessionId
,
@Path
(
"uuid"
)
String
uuid
);
Call
<
User
>
getUser
(
@Header
(
"Cookie"
)
String
sessionId
,
@Path
(
"uuid"
)
String
uuid
);
@GET
(
"bodies/{uuid}"
)
Call
<
in
.
ac
.
iitb
.
gymkhana
.
iitbapp
.
data
.
Body
>
getBody
(
@Header
(
"Cookie"
)
String
sessionId
,
@Path
(
"uuid"
)
String
uuid
);
@POST
(
"upload"
)
@POST
(
"upload"
)
Call
<
ImageUploadResponse
>
uploadImage
(
@Header
(
"Cookie"
)
String
sessionID
,
@Body
ImageUploadRequest
imageUploadRequest
);
Call
<
ImageUploadResponse
>
uploadImage
(
@Header
(
"Cookie"
)
String
sessionID
,
@Body
ImageUploadRequest
imageUploadRequest
);
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
View file @
cdd4b1e0
...
@@ -10,8 +10,15 @@ import android.widget.TextView;
...
@@ -10,8 +10,15 @@ import android.widget.TextView;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
in.ac.iitb.gymkhana.iitbapp.Constants
;
import
in.ac.iitb.gymkhana.iitbapp.MainActivity
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
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.Body
;
import
in.ac.iitb.gymkhana.iitbapp.data.Body
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
/**
/**
* A simple {@link Fragment} subclass.
* A simple {@link Fragment} subclass.
...
@@ -60,10 +67,33 @@ public class BodyFragment extends Fragment {
...
@@ -60,10 +67,33 @@ public class BodyFragment extends Fragment {
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
updateBody
();
}
private
void
updateBody
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
retrofitInterface
.
getBody
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
min_body
.
getBodyID
()).
enqueue
(
new
Callback
<
Body
>()
{
@Override
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
if
(
response
.
isSuccessful
())
{
Body
body
=
response
.
body
();
displayBody
(
body
);
}
}
@Override
public
void
onFailure
(
Call
<
Body
>
call
,
Throwable
t
)
{
// Network Error
}
});
}
private
void
displayBody
(
Body
body
)
{
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
bodyName
.
setText
(
min_body
.
getBodyName
()
);
TextView
bodyDescription
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_description
);
bodyName
.
setText
(
body
.
getBodyName
());
bodyDescription
.
setText
(
body
.
getBodyDescription
());
}
}
@Override
@Override
...
...
app/src/main/res/layout/fragment_body.xml
View file @
cdd4b1e0
...
@@ -5,11 +5,25 @@
...
@@ -5,11 +5,25 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".fragment.BodyFragment"
>
tools:context=
".fragment.BodyFragment"
>
<!-- TODO: Update blank fragment layout -->
<ScrollView
<TextView
android:id=
"@+id/body_name"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"wrap_content"
>
android:text=
"@string/hello_blank_fragment"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/body_name"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<TextView
android:id=
"@+id/body_description"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</LinearLayout>
</ScrollView>
</FrameLayout>
</FrameLayout>
\ 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