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
3671ede4
Commit
3671ede4
authored
Dec 13, 2018
by
Sajal Narang
Committed by
GitHub
Dec 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #260 from wncc/patch2
Fix a few broken things
parents
c5541cfd
d9deb324
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
38 deletions
+37
-38
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+4
-3
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+27
-35
app/src/main/java/app/insti/fragment/BodyFragment.java
app/src/main/java/app/insti/fragment/BodyFragment.java
+5
-0
app/src/main/res/layout/feed_card.xml
app/src/main/res/layout/feed_card.xml
+1
-0
No files found.
app/src/main/java/app/insti/Utils.java
View file @
3671ede4
...
...
@@ -139,23 +139,24 @@ public final class Utils {
.
commit
();
}
public
static
BodyFragment
getBodyFragment
(
Body
body
)
{
public
static
BodyFragment
getBodyFragment
(
Body
body
,
boolean
sharedElements
)
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
BODY_JSON
,
new
Gson
().
toJson
(
body
));
bundle
.
putBoolean
(
Constants
.
NO_SHARED_ELEM
,
!
sharedElements
);
BodyFragment
bodyFragment
=
new
BodyFragment
();
bodyFragment
.
setArguments
(
bundle
);
return
bodyFragment
;
}
public
static
void
openBodyFragment
(
Body
body
,
FragmentActivity
fragmentActivity
)
{
updateFragment
(
getBodyFragment
(
body
),
fragmentActivity
);
updateFragment
(
getBodyFragment
(
body
,
false
),
fragmentActivity
);
}
public
static
void
openBodyFragment
(
Body
body
,
Fragment
currentFragment
,
View
sharedAvatar
)
{
Map
<
View
,
String
>
sharedElements
=
new
HashMap
<>();
sharedElements
.
put
(
sharedAvatar
,
"sharedAvatar"
);
updateSharedElementFragment
(
getBodyFragment
(
body
),
currentFragment
,
sharedElements
getBodyFragment
(
body
,
true
),
currentFragment
,
sharedElements
);
}
...
...
app/src/main/java/app/insti/activity/MainActivity.java
View file @
3671ede4
...
...
@@ -42,6 +42,8 @@ import com.google.gson.JsonElement;
import
com.google.gson.JsonObject
;
import
com.squareup.picasso.Picasso
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.List
;
import
app.insti.Constants
;
...
...
@@ -328,10 +330,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
switch
(
type
)
{
case
DATA_TYPE_BODY:
openBodyFragment
(
id
);
Utils
.
openBodyFragment
(
new
Body
(
id
),
this
);
return
;
case
DATA_TYPE_USER:
openUserFragment
(
id
);
Utils
.
openUserFragment
(
id
,
this
);
return
;
case
DATA_TYPE_EVENT:
openEventFragment
(
id
);
...
...
@@ -363,21 +365,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
/**
* Open user fragment from given id
*/
private
void
openUserFragment
(
String
id
)
{
UserFragment
userFragment
=
UserFragment
.
newInstance
(
id
);
updateFragment
(
userFragment
);
}
/**
* Open the body fragment from given id
*/
private
void
openBodyFragment
(
String
id
)
{
Utils
.
openBodyFragment
(
new
Body
(
id
),
this
);
}
/**
* Open the event fragment from the provided id
*/
...
...
@@ -393,27 +380,32 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
private
String
getID
(
String
appLinkData
)
{
if
(
appLinkData
.
charAt
(
appLinkData
.
length
()
-
1
)
==
'/'
)
appLinkData
=
appLinkData
.
substring
(
0
,
appLinkData
.
length
()
-
1
);
switch
(
getType
(
appLinkData
))
{
case
DATA_TYPE_BODY:
return
appLinkData
.
substring
(
appLinkData
.
indexOf
(
"org"
)
+
4
);
case
DATA_TYPE_USER:
return
appLinkData
.
substring
(
appLinkData
.
indexOf
(
"user"
)
+
5
);
case
DATA_TYPE_EVENT:
return
appLinkData
.
substring
(
appLinkData
.
indexOf
(
"event"
)
+
6
);
}
try
{
/* Parse URL and get second part */
String
[]
parts
=
new
URL
(
appLinkData
).
getPath
().
split
(
"/"
);
if
(
parts
.
length
>=
3
)
{
return
parts
[
2
];
}
}
catch
(
MalformedURLException
ignored
)
{}
return
null
;
}
private
String
getType
(
String
appLinkData
)
{
if
(
appLinkData
.
contains
(
"://insti.app/org/"
))
{
return
DATA_TYPE_BODY
;
}
else
if
(
appLinkData
.
contains
(
"://insti.app/user/"
))
{
return
DATA_TYPE_USER
;
}
else
if
(
appLinkData
.
contains
(
"://insti.app/event/"
))
{
return
DATA_TYPE_EVENT
;
}
try
{
/* Parse URL and check length */
String
[]
parts
=
new
URL
(
appLinkData
).
getPath
().
split
(
"/"
);
if
(
parts
.
length
<
2
)
return
null
;
/* Map to proper data type */
switch
(
parts
[
1
].
toLowerCase
())
{
case
"org"
:
return
DATA_TYPE_BODY
;
case
"event"
:
return
DATA_TYPE_EVENT
;
case
"user"
:
return
DATA_TYPE_USER
;
}
}
catch
(
MalformedURLException
ignored
)
{}
return
null
;
}
...
...
@@ -466,7 +458,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
header
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
openUserFragment
(
currentUser
.
getUserID
()
);
Utils
.
openUserFragment
(
currentUser
.
getUserID
(),
MainActivity
.
this
);
DrawerLayout
drawer
=
findViewById
(
R
.
id
.
drawer_layout
);
drawer
.
closeDrawer
(
GravityCompat
.
START
);
}
...
...
app/src/main/java/app/insti/fragment/BodyFragment.java
View file @
3671ede4
...
...
@@ -153,6 +153,11 @@ public class BodyFragment extends BackHandledFragment implements TransitionTarge
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
min_body
.
getBodyName
());
Bundle
bundle
=
getArguments
();
if
(
bundle
!=
null
&&
bundle
.
getBoolean
(
Constants
.
NO_SHARED_ELEM
,
true
))
{
this
.
transitionEnd
();
}
}
private
void
updateBody
()
{
...
...
app/src/main/res/layout/feed_card.xml
View file @
3671ede4
...
...
@@ -25,6 +25,7 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"80dp"
android:orientation=
"horizontal"
>
<de.hdodenhof.circleimageview.CircleImageView
...
...
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