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
55ae8355
Commit
55ae8355
authored
Feb 01, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scroll to news/blog article on push notification open (fix #265)
parent
c2e0bd37
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
5 deletions
+56
-5
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+13
-3
app/src/main/java/app/insti/api/model/NewsArticle.java
app/src/main/java/app/insti/api/model/NewsArticle.java
+2
-0
app/src/main/java/app/insti/api/model/PlacementBlogPost.java
app/src/main/java/app/insti/api/model/PlacementBlogPost.java
+2
-0
app/src/main/java/app/insti/api/model/TrainingBlogPost.java
app/src/main/java/app/insti/api/model/TrainingBlogPost.java
+2
-0
app/src/main/java/app/insti/fragment/RecyclerViewFragment.java
...rc/main/java/app/insti/fragment/RecyclerViewFragment.java
+35
-2
app/src/main/java/app/insti/interfaces/Clickable.java
app/src/main/java/app/insti/interfaces/Clickable.java
+2
-0
No files found.
app/src/main/java/app/insti/activity/MainActivity.java
View file @
55ae8355
...
@@ -339,7 +339,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -339,7 +339,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
openEventFragment
(
id
);
openEventFragment
(
id
);
return
;
return
;
case
DATA_TYPE_NEWS:
case
DATA_TYPE_NEWS:
updateFragment
(
new
NewsFragment
(
));
updateFragment
(
(
new
NewsFragment
()).
withId
(
id
));
return
;
return
;
}
}
Log
.
e
(
"NOTIFICATIONS"
,
"Server sent invalid notification?"
);
Log
.
e
(
"NOTIFICATIONS"
,
"Server sent invalid notification?"
);
...
@@ -355,9 +355,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -355,9 +355,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
switch
(
type
)
{
switch
(
type
)
{
case
DATA_TYPE_PT:
case
DATA_TYPE_PT:
if
(
extra
.
contains
(
"/trainingblog"
))
{
if
(
extra
.
contains
(
"/trainingblog"
))
{
openTrainingBlog
();
openTrainingBlog
(
id
);
}
else
{
}
else
{
openPlacementBlog
();
openPlacementBlog
(
id
);
}
}
return
;
return
;
}
}
...
@@ -586,8 +586,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -586,8 +586,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
* Open placement blog fragment
* Open placement blog fragment
*/
*/
private
void
openPlacementBlog
()
{
private
void
openPlacementBlog
()
{
openPlacementBlog
(
null
);
}
private
void
openPlacementBlog
(
String
id
)
{
if
(
session
.
isLoggedIn
())
{
if
(
session
.
isLoggedIn
())
{
PlacementBlogFragment
placementBlogFragment
=
new
PlacementBlogFragment
();
PlacementBlogFragment
placementBlogFragment
=
new
PlacementBlogFragment
();
if
(
id
!=
null
)
placementBlogFragment
.
withId
(
id
);
updateFragment
(
placementBlogFragment
);
updateFragment
(
placementBlogFragment
);
}
else
{
}
else
{
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
...
@@ -595,8 +600,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -595,8 +600,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
private
void
openTrainingBlog
()
{
private
void
openTrainingBlog
()
{
openTrainingBlog
(
null
);
}
private
void
openTrainingBlog
(
String
id
)
{
if
(
session
.
isLoggedIn
())
{
if
(
session
.
isLoggedIn
())
{
TrainingBlogFragment
trainingBlogFragment
=
new
TrainingBlogFragment
();
TrainingBlogFragment
trainingBlogFragment
=
new
TrainingBlogFragment
();
if
(
id
!=
null
)
trainingBlogFragment
.
withId
(
id
);
updateFragment
(
trainingBlogFragment
);
updateFragment
(
trainingBlogFragment
);
}
else
{
}
else
{
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
Constants
.
LOGIN_MESSAGE
,
Toast
.
LENGTH_LONG
).
show
();
...
...
app/src/main/java/app/insti/api/model/NewsArticle.java
View file @
55ae8355
...
@@ -41,6 +41,8 @@ public class NewsArticle implements Clickable {
...
@@ -41,6 +41,8 @@ public class NewsArticle implements Clickable {
this
.
body
=
body
;
this
.
body
=
body
;
}
}
public
String
getId
()
{
return
articleID
;
}
public
String
getArticleID
()
{
public
String
getArticleID
()
{
return
articleID
;
return
articleID
;
}
}
...
...
app/src/main/java/app/insti/api/model/PlacementBlogPost.java
View file @
55ae8355
...
@@ -37,6 +37,8 @@ public class PlacementBlogPost implements Clickable {
...
@@ -37,6 +37,8 @@ public class PlacementBlogPost implements Clickable {
this
.
published
=
published
;
this
.
published
=
published
;
}
}
public
String
getId
()
{
return
postID
;
}
public
String
getPostID
()
{
public
String
getPostID
()
{
return
postID
;
return
postID
;
}
}
...
...
app/src/main/java/app/insti/api/model/TrainingBlogPost.java
View file @
55ae8355
...
@@ -37,6 +37,8 @@ public class TrainingBlogPost implements Clickable {
...
@@ -37,6 +37,8 @@ public class TrainingBlogPost implements Clickable {
this
.
published
=
published
;
this
.
published
=
published
;
}
}
public
String
getId
()
{
return
postID
;
}
public
String
getPostID
()
{
public
String
getPostID
()
{
return
postID
;
return
postID
;
}
}
...
...
app/src/main/java/app/insti/fragment/RecyclerViewFragment.java
View file @
55ae8355
package
app.insti.fragment
;
package
app.insti.fragment
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.LinearSmoothScroller
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.SearchView
;
import
android.support.v7.widget.SearchView
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -42,6 +41,12 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
...
@@ -42,6 +41,12 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
private
S
adapter
=
null
;
private
S
adapter
=
null
;
boolean
loading
=
false
;
boolean
loading
=
false
;
private
boolean
allLoaded
=
false
;
private
boolean
allLoaded
=
false
;
private
String
initId
=
null
;
public
RecyclerViewFragment
<
T
,
S
>
withId
(
String
id
)
{
initId
=
id
;
return
this
;
}
/** Update the data clearing existing */
/** Update the data clearing existing */
protected
void
updateData
()
{
protected
void
updateData
()
{
...
@@ -89,6 +94,11 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
...
@@ -89,6 +94,11 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
if
(
adapter
==
null
||
recyclerView
.
getAdapter
()
!=
adapter
)
{
if
(
adapter
==
null
||
recyclerView
.
getAdapter
()
!=
adapter
)
{
initAdapter
(
result
);
initAdapter
(
result
);
/* Scroll to current post */
if
(
initId
!=
null
)
{
scrollToPosition
(
getPosition
(
result
,
initId
));
}
}
else
{
}
else
{
adapter
.
setPosts
(
result
);
adapter
.
setPosts
(
result
);
adapter
.
notifyDataSetChanged
();
adapter
.
notifyDataSetChanged
();
...
@@ -97,6 +107,29 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
...
@@ -97,6 +107,29 @@ public abstract class RecyclerViewFragment<T extends Clickable, S extends Recycl
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
GONE
);
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
GONE
);
}
}
/** Set position of id in list of clickables */
int
getPosition
(
List
<
T
>
result
,
String
id
)
{
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
if
(
result
.
get
(
i
).
getId
().
equals
(
id
))
{
return
i
;
}
}
return
-
1
;
}
/** Scroll the recyclerview to position */
void
scrollToPosition
(
int
i
)
{
if
(
i
<
0
)
return
;
RecyclerView
.
SmoothScroller
smoothScroller
=
new
LinearSmoothScroller
(
getContext
())
{
@Override
protected
int
getVerticalSnapPreference
()
{
return
LinearSmoothScroller
.
SNAP_TO_START
;
}
};
smoothScroller
.
setTargetPosition
(
i
);
recyclerView
.
getLayoutManager
().
startSmoothScroll
(
smoothScroller
);
}
/** Initialize the adapter */
/** Initialize the adapter */
private
void
initAdapter
(
final
List
<
T
>
result
)
{
private
void
initAdapter
(
final
List
<
T
>
result
)
{
try
{
try
{
...
...
app/src/main/java/app/insti/interfaces/Clickable.java
View file @
55ae8355
...
@@ -4,5 +4,7 @@ import android.content.Context;
...
@@ -4,5 +4,7 @@ import android.content.Context;
import
android.view.View.OnClickListener
;
import
android.view.View.OnClickListener
;
public
interface
Clickable
{
public
interface
Clickable
{
String
getId
();
OnClickListener
getOnClickListener
(
Context
context
);
OnClickListener
getOnClickListener
(
Context
context
);
}
}
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