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
5cdfecd7
Commit
5cdfecd7
authored
May 30, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get a minimal Body Fragment working
parent
f5dd48aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
18 deletions
+27
-18
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyCardFragment.java
...n/ac/iitb/gymkhana/iitbapp/fragment/BodyCardFragment.java
+4
-4
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
...va/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
+19
-11
app/src/main/res/layout/fragment_body.xml
app/src/main/res/layout/fragment_body.xml
+1
-0
app/src/main/res/layout/fragment_body_card.xml
app/src/main/res/layout/fragment_body_card.xml
+3
-3
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyCardFragment.java
View file @
5cdfecd7
...
...
@@ -68,9 +68,9 @@ public class BodyCardFragment extends Fragment {
public
void
onStart
()
{
super
.
onStart
();
LinearLayout
linearLayout
=
(
LinearLayout
)
getView
().
findViewById
(
R
.
id
.
body_card_layout
);
ImageView
bodyAvatar
=
(
ImageView
)
getView
().
findViewById
(
R
.
id
.
body_avatar
);
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
TextView
bodyDescription
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_description
);
ImageView
bodyAvatar
=
(
ImageView
)
getView
().
findViewById
(
R
.
id
.
body_
card_
avatar
);
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_
card_
name
);
TextView
bodyDescription
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_
card_
description
);
bodyName
.
setText
(
body
.
getBodyName
());
bodyDescription
.
setText
(
body
.
getBodyShortDescription
());
...
...
@@ -80,7 +80,7 @@ public class BodyCardFragment extends Fragment {
@Override
public
void
onClick
(
View
view
)
{
/* Show the next fragment and destroy the page */
BodyFragment
bodyFragment
=
BodyFragment
.
newInstance
(
"Dummy"
,
"Dummy"
);
BodyFragment
bodyFragment
=
BodyFragment
.
newInstance
(
body
);
bodyFragment
.
setArguments
(
getArguments
());
FragmentTransaction
ft
=
getActivity
().
getSupportFragmentManager
().
beginTransaction
();
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
bodyFragment
,
bodyFragment
.
getTag
());
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
View file @
5cdfecd7
...
...
@@ -6,8 +6,12 @@ import android.support.v4.app.Fragment;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
import
com.google.gson.Gson
;
import
in.ac.iitb.gymkhana.iitbapp.R
;
import
in.ac.iitb.gymkhana.iitbapp.data.Body
;
/**
* A simple {@link Fragment} subclass.
...
...
@@ -17,14 +21,12 @@ import in.ac.iitb.gymkhana.iitbapp.R;
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_PARAM1
=
"param1"
;
private
static
final
String
ARG_PARAM2
=
"param2"
;
private
static
final
String
ARG_BODY
=
"body"
;
String
TAG
=
"BodyFragment"
;
// TODO: Rename and change types of parameters
private
String
mParam1
;
private
String
mParam2
;
private
Body
body
;
public
BodyFragment
()
{
...
...
@@ -35,16 +37,14 @@ public class BodyFragment extends Fragment {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @param arg_body Body for details
* @return A new instance of fragment BodyFragment.
*/
// TODO: Rename and change types and number of parameters
public
static
BodyFragment
newInstance
(
String
param1
,
String
param2
)
{
public
static
BodyFragment
newInstance
(
Body
arg_body
)
{
BodyFragment
fragment
=
new
BodyFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_PARAM1
,
param1
);
args
.
putString
(
ARG_PARAM2
,
param2
);
args
.
putString
(
ARG_BODY
,
new
Gson
().
toJson
(
arg_body
));
fragment
.
setArguments
(
args
);
return
fragment
;
}
...
...
@@ -53,11 +53,19 @@ public class BodyFragment extends Fragment {
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
mParam1
=
getArguments
().
getString
(
ARG_PARAM1
);
mParam2
=
getArguments
().
getString
(
ARG_PARAM2
);
body
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
ARG_BODY
),
Body
.
class
);
}
}
@Override
public
void
onStart
()
{
super
.
onStart
();
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
bodyName
.
setText
(
body
.
getBodyName
());
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
...
...
app/src/main/res/layout/fragment_body.xml
View file @
5cdfecd7
...
...
@@ -7,6 +7,7 @@
<!-- TODO: Update blank fragment layout -->
<TextView
android:id=
"@+id/body_name"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:text=
"@string/hello_blank_fragment"
/>
...
...
app/src/main/res/layout/fragment_body_card.xml
View file @
5cdfecd7
...
...
@@ -17,7 +17,7 @@
android:orientation=
"horizontal"
>
<ImageView
android:id=
"@+id/body_avatar"
android:id=
"@+id/body_
card_
avatar"
android:layout_width=
"80dp"
android:layout_height=
"80dp"
android:layout_gravity=
"center"
...
...
@@ -33,7 +33,7 @@
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/body_name"
android:id=
"@+id/body_
card_
name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Organization"
...
...
@@ -41,7 +41,7 @@
android:textSize=
"18sp"
/>
<TextView
android:id=
"@+id/body_description"
android:id=
"@+id/body_
card_
description"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Description"
/>
...
...
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