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 {
...
@@ -68,9 +68,9 @@ public class BodyCardFragment extends Fragment {
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
LinearLayout
linearLayout
=
(
LinearLayout
)
getView
().
findViewById
(
R
.
id
.
body_card_layout
);
LinearLayout
linearLayout
=
(
LinearLayout
)
getView
().
findViewById
(
R
.
id
.
body_card_layout
);
ImageView
bodyAvatar
=
(
ImageView
)
getView
().
findViewById
(
R
.
id
.
body_avatar
);
ImageView
bodyAvatar
=
(
ImageView
)
getView
().
findViewById
(
R
.
id
.
body_
card_
avatar
);
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_
card_
name
);
TextView
bodyDescription
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_description
);
TextView
bodyDescription
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_
card_
description
);
bodyName
.
setText
(
body
.
getBodyName
());
bodyName
.
setText
(
body
.
getBodyName
());
bodyDescription
.
setText
(
body
.
getBodyShortDescription
());
bodyDescription
.
setText
(
body
.
getBodyShortDescription
());
...
@@ -80,7 +80,7 @@ public class BodyCardFragment extends Fragment {
...
@@ -80,7 +80,7 @@ public class BodyCardFragment extends Fragment {
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
/* Show the next fragment and destroy the page */
/* Show the next fragment and destroy the page */
BodyFragment
bodyFragment
=
BodyFragment
.
newInstance
(
"Dummy"
,
"Dummy"
);
BodyFragment
bodyFragment
=
BodyFragment
.
newInstance
(
body
);
bodyFragment
.
setArguments
(
getArguments
());
bodyFragment
.
setArguments
(
getArguments
());
FragmentTransaction
ft
=
getActivity
().
getSupportFragmentManager
().
beginTransaction
();
FragmentTransaction
ft
=
getActivity
().
getSupportFragmentManager
().
beginTransaction
();
ft
.
replace
(
R
.
id
.
framelayout_for_fragment
,
bodyFragment
,
bodyFragment
.
getTag
());
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;
...
@@ -6,8 +6,12 @@ import android.support.v4.app.Fragment;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
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.R
;
import
in.ac.iitb.gymkhana.iitbapp.data.Body
;
/**
/**
* A simple {@link Fragment} subclass.
* A simple {@link Fragment} subclass.
...
@@ -17,14 +21,12 @@ import in.ac.iitb.gymkhana.iitbapp.R;
...
@@ -17,14 +21,12 @@ import in.ac.iitb.gymkhana.iitbapp.R;
public
class
BodyFragment
extends
Fragment
{
public
class
BodyFragment
extends
Fragment
{
// TODO: Rename parameter arguments, choose names that match
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private
static
final
String
ARG_PARAM1
=
"param1"
;
private
static
final
String
ARG_BODY
=
"body"
;
private
static
final
String
ARG_PARAM2
=
"param2"
;
String
TAG
=
"BodyFragment"
;
String
TAG
=
"BodyFragment"
;
// TODO: Rename and change types of parameters
// TODO: Rename and change types of parameters
private
String
mParam1
;
private
Body
body
;
private
String
mParam2
;
public
BodyFragment
()
{
public
BodyFragment
()
{
...
@@ -35,16 +37,14 @@ public class BodyFragment extends Fragment {
...
@@ -35,16 +37,14 @@ public class BodyFragment extends Fragment {
* Use this factory method to create a new instance of
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
* this fragment using the provided parameters.
*
*
* @param param1 Parameter 1.
* @param arg_body Body for details
* @param param2 Parameter 2.
* @return A new instance of fragment BodyFragment.
* @return A new instance of fragment BodyFragment.
*/
*/
// TODO: Rename and change types and number of parameters
// 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
();
BodyFragment
fragment
=
new
BodyFragment
();
Bundle
args
=
new
Bundle
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
ARG_PARAM1
,
param1
);
args
.
putString
(
ARG_BODY
,
new
Gson
().
toJson
(
arg_body
));
args
.
putString
(
ARG_PARAM2
,
param2
);
fragment
.
setArguments
(
args
);
fragment
.
setArguments
(
args
);
return
fragment
;
return
fragment
;
}
}
...
@@ -53,11 +53,19 @@ public class BodyFragment extends Fragment {
...
@@ -53,11 +53,19 @@ public class BodyFragment extends Fragment {
public
void
onCreate
(
Bundle
savedInstanceState
)
{
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
if
(
getArguments
()
!=
null
)
{
if
(
getArguments
()
!=
null
)
{
mParam1
=
getArguments
().
getString
(
ARG_PARAM1
);
body
=
new
Gson
().
fromJson
(
getArguments
().
getString
(
ARG_BODY
),
Body
.
class
);
mParam2
=
getArguments
().
getString
(
ARG_PARAM2
);
}
}
}
}
@Override
public
void
onStart
()
{
super
.
onStart
();
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
bodyName
.
setText
(
body
.
getBodyName
());
}
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
Bundle
savedInstanceState
)
{
...
...
app/src/main/res/layout/fragment_body.xml
View file @
5cdfecd7
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
<!-- TODO: Update blank fragment layout -->
<!-- TODO: Update blank fragment layout -->
<TextView
<TextView
android:id=
"@+id/body_name"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:text=
"@string/hello_blank_fragment"
/>
android:text=
"@string/hello_blank_fragment"
/>
...
...
app/src/main/res/layout/fragment_body_card.xml
View file @
5cdfecd7
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
>
<ImageView
<ImageView
android:id=
"@+id/body_avatar"
android:id=
"@+id/body_
card_
avatar"
android:layout_width=
"80dp"
android:layout_width=
"80dp"
android:layout_height=
"80dp"
android:layout_height=
"80dp"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<TextView
<TextView
android:id=
"@+id/body_name"
android:id=
"@+id/body_
card_
name"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Organization"
android:text=
"Organization"
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
android:textSize=
"18sp"
/>
android:textSize=
"18sp"
/>
<TextView
<TextView
android:id=
"@+id/body_description"
android:id=
"@+id/body_
card_
description"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Description"
/>
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