Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
cb6037d4
Unverified
Commit
cb6037d4
authored
8 years ago
by
Ernir Erlingsson
Browse files
Options
Downloads
Patches
Plain Diff
fixed memory leak
parent
3ce0131b
Branches
851-recyclerview-refresher
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/main/java/org/briarproject/briar/android/view/BriarRecyclerView.java
+25
-9
25 additions, 9 deletions
...rg/briarproject/briar/android/view/BriarRecyclerView.java
with
25 additions
and
9 deletions
briar-android/src/main/java/org/briarproject/briar/android/view/BriarRecyclerView.java
+
25
−
9
View file @
cb6037d4
...
...
@@ -29,7 +29,7 @@ public class BriarRecyclerView extends FrameLayout {
private
TextView
emptyView
;
private
ProgressBar
progressBar
;
private
RecyclerView
.
AdapterDataObserver
emptyObserver
;
private
R
unnable
refresher
=
null
;
private
R
efresher
refresher
;
private
boolean
isScrollingToEnd
=
false
;
public
BriarRecyclerView
(
Context
context
)
{
...
...
@@ -188,14 +188,8 @@ public class BriarRecyclerView extends FrameLayout {
if
(
recyclerView
==
null
||
recyclerView
.
getAdapter
()
==
null
)
{
throw
new
IllegalStateException
(
"Need to call setAdapter() first!"
);
}
refresher
=
new
Runnable
()
{
@Override
public
void
run
()
{
LOG
.
info
(
"Updating Content..."
);
recyclerView
.
getAdapter
().
notifyDataSetChanged
();
postDelayed
(
refresher
,
DEFAULT_REFRESH_INTERVAL
);
}
};
refresher
=
new
Refresher
(
this
);
LOG
.
info
(
"Adding Handler Callback"
);
postDelayed
(
refresher
,
DEFAULT_REFRESH_INTERVAL
);
}
...
...
@@ -203,8 +197,30 @@ public class BriarRecyclerView extends FrameLayout {
public
void
stopPeriodicUpdate
()
{
if
(
refresher
!=
null
)
{
LOG
.
info
(
"Removing Handler Callback"
);
refresher
.
setRecyclerView
(
null
);
removeCallbacks
(
refresher
);
}
}
private
static
class
Refresher
implements
Runnable
{
private
BriarRecyclerView
rv
;
Refresher
(
BriarRecyclerView
rv
)
{
setRecyclerView
(
rv
);
}
void
setRecyclerView
(
BriarRecyclerView
rv
)
{
this
.
rv
=
rv
;
}
@Override
public
void
run
()
{
if
(
rv
!=
null
)
{
rv
.
getRecyclerView
().
getAdapter
().
notifyDataSetChanged
();
rv
.
postDelayed
(
this
,
DEFAULT_REFRESH_INTERVAL
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment