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
c416bafc
Commit
c416bafc
authored
Jun 25, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add preliminary body fragment
parent
d9103bc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
161 additions
and
7 deletions
+161
-7
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
...va/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
+41
-2
app/src/main/res/layout/fragment_body.xml
app/src/main/res/layout/fragment_body.xml
+120
-5
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/BodyFragment.java
View file @
c416bafc
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.google.gson.Gson
;
import
com.squareup.picasso.Picasso
;
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.ShareURLMaker
;
import
in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface
;
import
in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator
;
import
in.ac.iitb.gymkhana.iitbapp.data.AppDatabase
;
...
...
@@ -20,6 +29,7 @@ import in.ac.iitb.gymkhana.iitbapp.data.Body;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
import
ru.noties.markwon.Markwon
;
/**
* A simple {@link Fragment} subclass.
...
...
@@ -102,12 +112,41 @@ public class BodyFragment extends Fragment {
});
}
private
void
displayBody
(
Body
body
)
{
private
void
displayBody
(
final
Body
body
)
{
TextView
bodyName
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_name
);
TextView
bodyDescription
=
(
TextView
)
getView
().
findViewById
(
R
.
id
.
body_description
);
ImageView
eventPicture
=
(
ImageView
)
getActivity
().
findViewById
(
R
.
id
.
body_picture
);
ImageButton
webBodyButton
=
getActivity
().
findViewById
(
R
.
id
.
web_body_button
);
ImageButton
shareBodyButton
=
getActivity
().
findViewById
(
R
.
id
.
share_body_button
);
bodyName
.
setText
(
body
.
getBodyName
());
bodyDescription
.
setText
(
body
.
getBodyDescription
());
Markwon
.
setMarkdown
(
bodyDescription
,
body
.
getBodyDescription
());
Picasso
.
with
(
getContext
()).
load
(
body
.
getBodyImageURL
()).
into
(
eventPicture
);
if
(
body
.
getBodyWebsiteURL
()
!=
null
&&
!
body
.
getBodyWebsiteURL
().
isEmpty
())
{
webBodyButton
.
setVisibility
(
View
.
VISIBLE
);
webBodyButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
String
bodywebURL
=
body
.
getBodyWebsiteURL
();
@Override
public
void
onClick
(
View
view
)
{
Intent
browserIntent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
bodywebURL
));
startActivity
(
browserIntent
);
}
});
}
shareBodyButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
String
shareUrl
=
ShareURLMaker
.
getBodyURL
(
body
);
@Override
public
void
onClick
(
View
view
)
{
Intent
i
=
new
Intent
(
Intent
.
ACTION_SEND
);
i
.
setType
(
"text/plain"
);
i
.
putExtra
(
Intent
.
EXTRA_SUBJECT
,
"Sharing URL"
);
i
.
putExtra
(
Intent
.
EXTRA_TEXT
,
shareUrl
);
startActivity
(
Intent
.
createChooser
(
i
,
"Share URL"
));
}
});
}
@Override
...
...
app/src/main/res/layout/fragment_body.xml
View file @
c416bafc
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".fragment.BodyFragment"
>
<ScrollView
...
...
@@ -11,18 +13,131 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"0dp"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/body_name"
<ImageView
android:id=
"@+id/body_picture"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
android:adjustViewBounds=
"true"
android:scaleType=
"fitCenter"
/>
<android.support.v7.widget.CardView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:cardBackgroundColor=
"@color/colorPrimary"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginBottom=
"12dp"
android:layout_marginEnd=
"16dp"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"12dp"
android:layout_weight=
"3"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/body_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"10"
android:text=
"Org Title"
android:textColor=
"#fff"
android:textSize=
"21sp"
android:textStyle=
"bold"
/>
<ImageButton
android:id=
"@+id/web_body_button"
android:layout_width=
"10dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:contentDescription=
"Org Website"
android:src=
"@drawable/ic_language_black_24dp"
android:tint=
"@color/colorWhite"
android:visibility=
"invisible"
/>
<ImageButton
android:id=
"@+id/share_body_button"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:background=
"?attr/selectableItemBackgroundBorderless"
android:contentDescription=
"Share Body"
android:src=
"@drawable/ic_menu_share"
android:tint=
"@color/colorWhite"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout
style=
"?android:attr/buttonBarStyle"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/follow_button"
style=
"?android:attr/buttonBarButtonStyle"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_margin=
"0dp"
android:layout_weight=
"1"
android:text=
"Follow"
android:textColor=
"@color/colorGray"
/>
</LinearLayout>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:background=
"#aaa"
>
</View>
<TextView
android:id=
"@+id/body_description"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"10dp"
android:layout_marginStart=
"10dp"
android:layout_marginTop=
"12dp"
android:layout_marginBottom=
"16dp"
android:textColor=
"#777"
android:textSize=
"16sp"
/>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/body_card_recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
/>
</LinearLayout>
</ScrollView>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
</LinearLayout>
</ScrollView>
...
...
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