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
b273f42b
Commit
b273f42b
authored
Jun 24, 2018
by
maitreya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solves #103 added refresh layout to body fragment
parent
a706c93b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
19 deletions
+38
-19
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/fragment/BodyFragment.java
...va/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
+14
-3
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
...a/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
+2
-0
app/src/main/res/layout/fragment_body.xml
app/src/main/res/layout/fragment_body.xml
+21
-16
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/Constants.java
View file @
b273f42b
...
...
@@ -19,4 +19,5 @@ public class Constants {
public
static
final
int
STATUS_GOING
=
2
;
public
static
final
int
STATUS_INTERESTED
=
1
;
public
static
final
int
STATUS_NOT_GOING
=
0
;
public
static
final
String
BODY_JSON
=
"body_json"
;
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
View file @
b273f42b
...
...
@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -29,13 +30,14 @@ import retrofit2.Response;
public
class
BodyFragment
extends
Fragment
{
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private
static
final
String
ARG_BODY
=
"body"
;
private
AppDatabase
appDatabase
;
String
TAG
=
"BodyFragment"
;
// TODO: Rename and change types of parameters
private
Body
min_body
;
private
SwipeRefreshLayout
bodySwipeRefreshLayout
;
public
BodyFragment
()
{
...
...
@@ -53,7 +55,7 @@ public class BodyFragment extends Fragment {
public
static
BodyFragment
newInstance
(
Body
arg_body
)
{
BodyFragment
fragment
=
new
BodyFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_BODY
,
new
Gson
().
toJson
(
arg_body
));
args
.
putString
(
Constants
.
BODY_JSON
,
new
Gson
().
toJson
(
arg_body
));
fragment
.
setArguments
(
args
);
return
fragment
;
}
...
...
@@ -62,7 +64,7 @@ public class BodyFragment extends Fragment {
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
min_body
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
ARG_BODY
),
Body
.
class
);
min_body
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
Constants
.
BODY_JSON
),
Body
.
class
);
}
}
...
...
@@ -79,6 +81,13 @@ public class BodyFragment extends Fragment {
}
else
{
updateBody
();
}
bodySwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
body_swipe_refresh_layout
);
bodySwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
@Override
public
void
onRefresh
()
{
updateBody
();
}
});
}
private
void
updateBody
()
{
...
...
@@ -92,11 +101,13 @@ public class BodyFragment extends Fragment {
appDatabase
.
dbDao
().
insertBody
(
body
);
displayBody
(
body
);
bodySwipeRefreshLayout
.
setRefreshing
(
false
);
}
}
@Override
public
void
onFailure
(
Call
<
Body
>
call
,
Throwable
t
)
{
bodySwipeRefreshLayout
.
setRefreshing
(
false
);
// Network Error
}
});
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/EventFragment.java
View file @
b273f42b
...
...
@@ -121,6 +121,8 @@ public class EventFragment extends BaseFragment implements View.OnClickListener
public
void
onItemClick
(
View
v
,
int
position
)
{
Body
body
=
bodyList
.
get
(
position
);
BodyFragment
bodyFragment
=
BodyFragment
.
newInstance
(
body
);
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
());
...
...
app/src/main/res/layout/fragment_body.xml
View file @
b273f42b
...
...
@@ -4,26 +4,31 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".fragment.BodyFragment"
>
<ScrollView
<android.support.v4.widget.SwipeRefreshLayout
android:id=
"@+id/body_swipe_refresh_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<
LinearLayout
android:layout_height=
"wrap_content"
>
<
ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
android:layout_height=
"wrap_content"
>
<TextView
android:id=
"@+id/body_name"
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/body_description"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<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>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</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