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
8630f6f2
Unverified
Commit
8630f6f2
authored
9 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Don't allow 'this' to escape the constructor.
parent
141d6497
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/org/briarproject/android/util/BriarRecyclerView.java
+33
-38
33 additions, 38 deletions
.../src/org/briarproject/android/util/BriarRecyclerView.java
with
33 additions
and
38 deletions
briar-android/src/org/briarproject/android/util/BriarRecyclerView.java
+
33
−
38
View file @
8630f6f2
...
@@ -21,27 +21,18 @@ public class BriarRecyclerView extends FrameLayout {
...
@@ -21,27 +21,18 @@ public class BriarRecyclerView extends FrameLayout {
public
BriarRecyclerView
(
Context
context
)
{
public
BriarRecyclerView
(
Context
context
)
{
super
(
context
);
super
(
context
);
initViews
();
}
}
public
BriarRecyclerView
(
Context
context
,
AttributeSet
attrs
)
{
public
BriarRecyclerView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
super
(
context
,
attrs
);
initViews
();
}
}
public
BriarRecyclerView
(
Context
context
,
AttributeSet
attrs
,
public
BriarRecyclerView
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
super
(
context
,
attrs
,
defStyle
);
initViews
();
}
}
private
void
initViews
()
{
private
void
initViews
()
{
if
(
isInEditMode
())
{
return
;
}
View
v
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
View
v
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
briar_recycler_view
,
this
,
true
);
R
.
layout
.
briar_recycler_view
,
this
,
true
);
...
@@ -54,22 +45,24 @@ public class BriarRecyclerView extends FrameLayout {
...
@@ -54,22 +45,24 @@ public class BriarRecyclerView extends FrameLayout {
// scroll down when opening keyboard
// scroll down when opening keyboard
if
(
Build
.
VERSION
.
SDK_INT
>=
11
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
11
)
{
recyclerView
.
addOnLayoutChangeListener
(
new
View
.
OnLayoutChangeListener
()
{
recyclerView
.
addOnLayoutChangeListener
(
@Override
new
View
.
OnLayoutChangeListener
()
{
public
void
onLayoutChange
(
View
v
,
@Override
int
left
,
int
top
,
int
right
,
int
bottom
,
public
void
onLayoutChange
(
View
v
,
int
left
,
int
top
,
int
oldLeft
,
int
oldTop
,
int
oldRight
,
int
oldBottom
)
{
int
right
,
int
bottom
,
int
oldLeft
,
int
oldTop
,
if
(
bottom
<
oldBottom
)
{
int
oldRight
,
int
oldBottom
)
{
recyclerView
.
postDelayed
(
new
Runnable
()
{
if
(
bottom
<
oldBottom
)
{
@Override
recyclerView
.
postDelayed
(
new
Runnable
()
{
public
void
run
()
{
@Override
scrollToPosition
(
public
void
run
()
{
recyclerView
.
getAdapter
().
getItemCount
()
-
1
);
scrollToPosition
(
recyclerView
.
getAdapter
()
.
getItemCount
()
-
1
);
}
},
100
);
}
}
},
100
);
}
}
});
}
});
}
}
emptyObserver
=
new
RecyclerView
.
AdapterDataObserver
()
{
emptyObserver
=
new
RecyclerView
.
AdapterDataObserver
()
{
...
@@ -82,10 +75,13 @@ public class BriarRecyclerView extends FrameLayout {
...
@@ -82,10 +75,13 @@ public class BriarRecyclerView extends FrameLayout {
}
}
public
void
setLayoutManager
(
RecyclerView
.
LayoutManager
layout
)
{
public
void
setLayoutManager
(
RecyclerView
.
LayoutManager
layout
)
{
if
(
recyclerView
==
null
)
initViews
();
recyclerView
.
setLayoutManager
(
layout
);
recyclerView
.
setLayoutManager
(
layout
);
}
}
public
void
setAdapter
(
RecyclerView
.
Adapter
adapter
)
{
public
void
setAdapter
(
RecyclerView
.
Adapter
adapter
)
{
if
(
recyclerView
==
null
)
initViews
();
RecyclerView
.
Adapter
oldAdapter
=
recyclerView
.
getAdapter
();
RecyclerView
.
Adapter
oldAdapter
=
recyclerView
.
getAdapter
();
if
(
oldAdapter
!=
null
)
{
if
(
oldAdapter
!=
null
)
{
oldAdapter
.
unregisterAdapterDataObserver
(
emptyObserver
);
oldAdapter
.
unregisterAdapterDataObserver
(
emptyObserver
);
...
@@ -105,35 +101,34 @@ public class BriarRecyclerView extends FrameLayout {
...
@@ -105,35 +101,34 @@ public class BriarRecyclerView extends FrameLayout {
}
}
public
void
setEmptyText
(
String
text
)
{
public
void
setEmptyText
(
String
text
)
{
if
(
recyclerView
==
null
)
initViews
();
emptyView
.
setText
(
text
);
emptyView
.
setText
(
text
);
}
}
public
void
showProgressBar
()
{
public
void
showProgressBar
()
{
recyclerView
.
setVisibility
(
View
.
INVISIBLE
);
if
(
recyclerView
==
null
)
initViews
();
emptyView
.
setVisibility
(
View
.
INVISIBLE
);
recyclerView
.
setVisibility
(
INVISIBLE
);
progressBar
.
setVisibility
(
View
.
VISIBLE
);
emptyView
.
setVisibility
(
INVISIBLE
);
progressBar
.
setVisibility
(
VISIBLE
);
}
}
public
void
showData
()
{
public
void
showData
()
{
RecyclerView
.
Adapter
<?>
adapter
=
recyclerView
.
getAdapter
();
if
(
recyclerView
==
null
)
initViews
();
RecyclerView
.
Adapter
adapter
=
recyclerView
.
getAdapter
();
if
(
adapter
!=
null
)
{
if
(
adapter
!=
null
)
{
if
(
adapter
.
getItemCount
()
==
0
)
{
if
(
adapter
.
getItemCount
()
==
0
)
{
emptyView
.
setVisibility
(
View
.
VISIBLE
);
emptyView
.
setVisibility
(
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
INVISIBLE
);
recyclerView
.
setVisibility
(
INVISIBLE
);
}
else
{
}
else
{
emptyView
.
setVisibility
(
View
.
INVISIBLE
);
emptyView
.
setVisibility
(
INVISIBLE
);
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
VISIBLE
);
}
}
progressBar
.
setVisibility
(
View
.
INVISIBLE
);
progressBar
.
setVisibility
(
INVISIBLE
);
}
}
}
}
public
void
scrollToPosition
(
int
position
)
{
public
void
scrollToPosition
(
int
position
)
{
if
(
recyclerView
==
null
)
initViews
();
recyclerView
.
scrollToPosition
(
position
);
recyclerView
.
scrollToPosition
(
position
);
}
}
public
RecyclerView
getRecyclerView
()
{
return
recyclerView
;
}
}
}
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