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
18d998ba
Commit
18d998ba
authored
Jul 31, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add edit body button (WebView)
parent
5bccc51a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
239 additions
and
165 deletions
+239
-165
app/src/main/java/app/insti/fragment/AddEventFragment.java
app/src/main/java/app/insti/fragment/AddEventFragment.java
+30
-0
app/src/main/java/app/insti/fragment/BodyFragment.java
app/src/main/java/app/insti/fragment/BodyFragment.java
+25
-0
app/src/main/res/layout/fragment_body.xml
app/src/main/res/layout/fragment_body.xml
+184
-165
No files found.
app/src/main/java/app/insti/fragment/AddEventFragment.java
View file @
18d998ba
...
...
@@ -29,6 +29,7 @@ import app.insti.MainActivity;
import
app.insti.R
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.Body
;
import
app.insti.data.Event
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
...
...
@@ -90,6 +91,9 @@ public class AddEventFragment extends BaseFragment {
String
url
=
"https://"
+
host
+
"/add-event?sandbox=true"
;
if
(
getArguments
().
containsKey
(
"id"
))
{
url
=
"https://"
+
host
+
"/edit-event/"
+
getArguments
().
getString
(
"id"
)
+
"?sandbox=true"
;
}
else
if
(
getArguments
().
containsKey
(
"bodyId"
))
{
url
=
"https://"
+
host
+
"/edit-body/"
+
getArguments
().
getString
(
"bodyId"
)
+
"?sandbox=true"
;
toolbar
.
setTitle
(
"Update Organization"
);
}
webView
.
loadUrl
(
url
);
...
...
@@ -145,6 +149,23 @@ public class AddEventFragment extends BaseFragment {
public
void
onFailure
(
Call
<
Event
>
call
,
Throwable
t
)
{
}
});
return
true
;
}
else
if
(
url
.
contains
(
"/org/"
))
{
url
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
retrofitInterface
.
getBody
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Body
>()
{
@Override
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
if
(
response
.
isSuccessful
())
{
openBody
(
response
.
body
());
}
}
@Override
public
void
onFailure
(
Call
<
Body
>
call
,
Throwable
t
)
{
}
});
return
true
;
}
// return true; //Indicates WebView to NOT load the url;
...
...
@@ -202,6 +223,15 @@ public class AddEventFragment extends BaseFragment {
transaction
.
addToBackStack
(
eventFragment
.
getTag
()).
commit
();
}
void
openBody
(
Body
body
)
{
BodyFragment
bodyFragment
=
BodyFragment
.
newInstance
(
body
);
FragmentManager
manager
=
getActivity
().
getSupportFragmentManager
();
FragmentTransaction
transaction
=
manager
.
beginTransaction
();
transaction
.
setCustomAnimations
(
R
.
anim
.
slide_in_left
,
R
.
anim
.
slide_out_left
,
R
.
anim
.
slide_in_right
,
R
.
anim
.
slide_out_right
);
transaction
.
replace
(
R
.
id
.
framelayout_for_fragment
,
bodyFragment
,
bodyFragment
.
getTag
());
transaction
.
addToBackStack
(
bodyFragment
.
getTag
()).
commit
();
}
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
){
if
(
requestCode
==
101
)
{
if
(
uploadMessage
==
null
)
return
;
...
...
app/src/main/java/app/insti/fragment/BodyFragment.java
View file @
18d998ba
...
...
@@ -12,8 +12,10 @@ import android.graphics.Rect;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.widget.NestedScrollView
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
...
...
@@ -345,6 +347,29 @@ public class BodyFragment extends BackHandledFragment {
childrenRecyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
()));
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
/* Show update button if role */
final
FloatingActionButton
fab
=
(
FloatingActionButton
)
getView
().
findViewById
(
R
.
id
.
edit_fab
);
fab
.
setVisibility
(
View
.
VISIBLE
);
NestedScrollView
nsv
=
(
NestedScrollView
)
getView
().
findViewById
(
R
.
id
.
body_scrollview
);
nsv
.
setOnScrollChangeListener
(
new
NestedScrollView
.
OnScrollChangeListener
()
{
@Override
public
void
onScrollChange
(
NestedScrollView
v
,
int
scrollX
,
int
scrollY
,
int
oldScrollX
,
int
oldScrollY
)
{
if
(
scrollY
>
oldScrollY
)
fab
.
hide
();
else
fab
.
show
();
}
});
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
AddEventFragment
addEventFragment
=
new
AddEventFragment
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
"bodyId"
,
body
.
getBodyID
());
addEventFragment
.
setArguments
(
bundle
);
((
MainActivity
)
getActivity
()).
updateFragment
(
addEventFragment
);
}
});
}
/**
...
...
app/src/main/res/layout/fragment_body.xml
View file @
18d998ba
...
...
@@ -8,12 +8,17 @@
android:orientation=
"vertical"
tools:context=
".fragment.BodyFragment"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<android.support.v4.widget.SwipeRefreshLayout
android:id=
"@+id/body_swipe_refresh_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<android.support.v4.widget.NestedScrollView
android:id=
"@+id/body_scrollview"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
...
...
@@ -202,8 +207,22 @@
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id=
"@+id/edit_fab"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_alignParentRight=
"true"
android:layout_margin=
"16dp"
android:src=
"@drawable/ic_edit_black_24dp"
android:tint=
"@android:color/black"
android:visibility=
"gone"
/>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/loadingPanel"
android:layout_width=
"match_parent"
...
...
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