-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update database access modifiers #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0deadf8
329a5dc
81b7da9
fa82073
4b6550c
12760c1
ccea6ec
b818cf8
7033d77
14d1f8c
d81994b
3b90228
1ead7c3
8ff8c06
d6fae5a
f4f031b
9c5f92b
00f389e
d2cec9d
22baf3d
8aeaa7c
81acc87
e5ca921
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* This class implements an array-like collection on top of a Firebase location. | ||
*/ | ||
class FirebaseArray implements ChildEventListener { | ||
public interface OnChangedListener { | ||
interface OnChangedListener { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should definitely be changed, I don't know why it's not at least protected. |
||
enum EventType { Added, Changed, Removed, Moved } | ||
void onChanged(EventType type, int index, int oldIndex); | ||
void onCancelled(DatabaseError databaseError); | ||
|
@@ -35,21 +35,21 @@ enum EventType { Added, Changed, Removed, Moved } | |
private OnChangedListener mListener; | ||
private ArrayList<DataSnapshot> mSnapshots; | ||
|
||
public FirebaseArray(Query ref) { | ||
FirebaseArray(Query ref) { | ||
mQuery = ref; | ||
mSnapshots = new ArrayList<DataSnapshot>(); | ||
mQuery.addChildEventListener(this); | ||
} | ||
|
||
public void cleanup() { | ||
void cleanup() { | ||
mQuery.removeEventListener(this); | ||
} | ||
|
||
public int getCount() { | ||
int getCount() { | ||
return mSnapshots.size(); | ||
|
||
} | ||
public DataSnapshot getItem(int index) { | ||
DataSnapshot getItem(int index) { | ||
return mSnapshots.get(index); | ||
} | ||
|
||
|
@@ -100,21 +100,21 @@ public void onCancelled(DatabaseError databaseError) { | |
} | ||
// End of ChildEventListener methods | ||
|
||
public void setOnChangedListener(OnChangedListener listener) { | ||
void setOnChangedListener(OnChangedListener listener) { | ||
mListener = listener; | ||
} | ||
|
||
protected void notifyChangedListeners(OnChangedListener.EventType type, int index) { | ||
void notifyChangedListeners(OnChangedListener.EventType type, int index) { | ||
notifyChangedListeners(type, index, -1); | ||
} | ||
|
||
protected void notifyChangedListeners(OnChangedListener.EventType type, int index, int oldIndex) { | ||
void notifyChangedListeners(OnChangedListener.EventType type, int index, int oldIndex) { | ||
if (mListener != null) { | ||
mListener.onChanged(type, index, oldIndex); | ||
} | ||
} | ||
|
||
protected void notifyCancelledListeners(DatabaseError databaseError) { | ||
void notifyCancelledListeners(DatabaseError databaseError) { | ||
if (mListener != null) { | ||
mListener.onCancelled(databaseError); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,10 +51,10 @@ | |
*/ | ||
public abstract class FirebaseListAdapter<T> extends BaseAdapter { | ||
|
||
private Activity mActivity; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had some cases in the past where I wanted to use the activity and layout in my concrete implementation. I'm not sure if these still apply, but would prefer to keep these protected for now. |
||
private final Class<T> mModelClass; | ||
protected int mLayout; | ||
protected Activity mActivity; | ||
FirebaseArray mSnapshots; | ||
private int mLayout; | ||
private FirebaseArray mSnapshots; | ||
|
||
|
||
/** | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed everything below to be no modifier since the class itself shouldn't be accessed from anywhere outside of the package, I don't see why the methods inside shouldn't follow along.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of SOLID programming, shouldn't at least the class itself be at least public for it to be open to extension? Building another adapter as an add-on to FirebaseUI using FirebaseArray wouldn't be possible with this configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think about that. Thanks! I'll update this PR when I get home.