Java Android Singleton to dagger can I use it?
up vote
-2
down vote
favorite
I created a singleton class , but I read that Dagger is better , In may application I changed a objects in my singleton :
public class Singleton {
private static Singleton instance;
public ROOT root;
public ConcurrentHashMap<String, List<LoadingRow>> expandableListDetail = new ConcurrentHashMap<>();
public ArrayList<RowEntity> rowEntities = new ArrayList<>();
public volatile ArrayList<RowEntity> rowEntityArrayList = new ArrayList<>();
private Singleton() {
// Constructor hidden because this is a singleton
}
public static void initInstance() {
if (instance == null) {
// Create the instance
instance = new Singleton();
}
}
public static Singleton getInstance() {
return instance;
}
}
And Now I don not know if I can use a dagger to do this , in singleton I have a list which I use into an Adapter and a class ROOT
which I have another objects. And I have a question how I can use dagger in my case , I changed a value in root into rowEntities
java android
|
show 2 more comments
up vote
-2
down vote
favorite
I created a singleton class , but I read that Dagger is better , In may application I changed a objects in my singleton :
public class Singleton {
private static Singleton instance;
public ROOT root;
public ConcurrentHashMap<String, List<LoadingRow>> expandableListDetail = new ConcurrentHashMap<>();
public ArrayList<RowEntity> rowEntities = new ArrayList<>();
public volatile ArrayList<RowEntity> rowEntityArrayList = new ArrayList<>();
private Singleton() {
// Constructor hidden because this is a singleton
}
public static void initInstance() {
if (instance == null) {
// Create the instance
instance = new Singleton();
}
}
public static Singleton getInstance() {
return instance;
}
}
And Now I don not know if I can use a dagger to do this , in singleton I have a list which I use into an Adapter and a class ROOT
which I have another objects. And I have a question how I can use dagger in my case , I changed a value in root into rowEntities
java android
Why do you use a Singleton to store a list of objects?
– ZUNJAE
Nov 22 at 9:45
@ZUNJAE I need to , I ue a singleton but I read that dagger is satefy, but I don ot know igf I can change value add , remove object fro list
– jpok2
Nov 22 at 9:47
Off-topic: who tells you you need to use a Singleton? It seems like your application is an architectural mess and adding Dagger won't solve your issue. Dagger won't make your application safer.
– ZUNJAE
Nov 22 at 9:47
@ZUNJAE in my service I update this list , in 5 activities I work at this objects , I use a singleton to get this objects and update
– jpok2
Nov 22 at 9:52
Why not save those data to disk and only retrieve it when needed?
– ZUNJAE
Nov 22 at 10:34
|
show 2 more comments
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I created a singleton class , but I read that Dagger is better , In may application I changed a objects in my singleton :
public class Singleton {
private static Singleton instance;
public ROOT root;
public ConcurrentHashMap<String, List<LoadingRow>> expandableListDetail = new ConcurrentHashMap<>();
public ArrayList<RowEntity> rowEntities = new ArrayList<>();
public volatile ArrayList<RowEntity> rowEntityArrayList = new ArrayList<>();
private Singleton() {
// Constructor hidden because this is a singleton
}
public static void initInstance() {
if (instance == null) {
// Create the instance
instance = new Singleton();
}
}
public static Singleton getInstance() {
return instance;
}
}
And Now I don not know if I can use a dagger to do this , in singleton I have a list which I use into an Adapter and a class ROOT
which I have another objects. And I have a question how I can use dagger in my case , I changed a value in root into rowEntities
java android
I created a singleton class , but I read that Dagger is better , In may application I changed a objects in my singleton :
public class Singleton {
private static Singleton instance;
public ROOT root;
public ConcurrentHashMap<String, List<LoadingRow>> expandableListDetail = new ConcurrentHashMap<>();
public ArrayList<RowEntity> rowEntities = new ArrayList<>();
public volatile ArrayList<RowEntity> rowEntityArrayList = new ArrayList<>();
private Singleton() {
// Constructor hidden because this is a singleton
}
public static void initInstance() {
if (instance == null) {
// Create the instance
instance = new Singleton();
}
}
public static Singleton getInstance() {
return instance;
}
}
And Now I don not know if I can use a dagger to do this , in singleton I have a list which I use into an Adapter and a class ROOT
which I have another objects. And I have a question how I can use dagger in my case , I changed a value in root into rowEntities
java android
java android
edited Nov 22 at 11:34
Rahul Chandrabhan
1,63741122
1,63741122
asked Nov 22 at 9:27
jpok2
168
168
Why do you use a Singleton to store a list of objects?
– ZUNJAE
Nov 22 at 9:45
@ZUNJAE I need to , I ue a singleton but I read that dagger is satefy, but I don ot know igf I can change value add , remove object fro list
– jpok2
Nov 22 at 9:47
Off-topic: who tells you you need to use a Singleton? It seems like your application is an architectural mess and adding Dagger won't solve your issue. Dagger won't make your application safer.
– ZUNJAE
Nov 22 at 9:47
@ZUNJAE in my service I update this list , in 5 activities I work at this objects , I use a singleton to get this objects and update
– jpok2
Nov 22 at 9:52
Why not save those data to disk and only retrieve it when needed?
– ZUNJAE
Nov 22 at 10:34
|
show 2 more comments
Why do you use a Singleton to store a list of objects?
– ZUNJAE
Nov 22 at 9:45
@ZUNJAE I need to , I ue a singleton but I read that dagger is satefy, but I don ot know igf I can change value add , remove object fro list
– jpok2
Nov 22 at 9:47
Off-topic: who tells you you need to use a Singleton? It seems like your application is an architectural mess and adding Dagger won't solve your issue. Dagger won't make your application safer.
– ZUNJAE
Nov 22 at 9:47
@ZUNJAE in my service I update this list , in 5 activities I work at this objects , I use a singleton to get this objects and update
– jpok2
Nov 22 at 9:52
Why not save those data to disk and only retrieve it when needed?
– ZUNJAE
Nov 22 at 10:34
Why do you use a Singleton to store a list of objects?
– ZUNJAE
Nov 22 at 9:45
Why do you use a Singleton to store a list of objects?
– ZUNJAE
Nov 22 at 9:45
@ZUNJAE I need to , I ue a singleton but I read that dagger is satefy, but I don ot know igf I can change value add , remove object fro list
– jpok2
Nov 22 at 9:47
@ZUNJAE I need to , I ue a singleton but I read that dagger is satefy, but I don ot know igf I can change value add , remove object fro list
– jpok2
Nov 22 at 9:47
Off-topic: who tells you you need to use a Singleton? It seems like your application is an architectural mess and adding Dagger won't solve your issue. Dagger won't make your application safer.
– ZUNJAE
Nov 22 at 9:47
Off-topic: who tells you you need to use a Singleton? It seems like your application is an architectural mess and adding Dagger won't solve your issue. Dagger won't make your application safer.
– ZUNJAE
Nov 22 at 9:47
@ZUNJAE in my service I update this list , in 5 activities I work at this objects , I use a singleton to get this objects and update
– jpok2
Nov 22 at 9:52
@ZUNJAE in my service I update this list , in 5 activities I work at this objects , I use a singleton to get this objects and update
– jpok2
Nov 22 at 9:52
Why not save those data to disk and only retrieve it when needed?
– ZUNJAE
Nov 22 at 10:34
Why not save those data to disk and only retrieve it when needed?
– ZUNJAE
Nov 22 at 10:34
|
show 2 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427657%2fjava-android-singleton-to-dagger-can-i-use-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427657%2fjava-android-singleton-to-dagger-can-i-use-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why do you use a Singleton to store a list of objects?
– ZUNJAE
Nov 22 at 9:45
@ZUNJAE I need to , I ue a singleton but I read that dagger is satefy, but I don ot know igf I can change value add , remove object fro list
– jpok2
Nov 22 at 9:47
Off-topic: who tells you you need to use a Singleton? It seems like your application is an architectural mess and adding Dagger won't solve your issue. Dagger won't make your application safer.
– ZUNJAE
Nov 22 at 9:47
@ZUNJAE in my service I update this list , in 5 activities I work at this objects , I use a singleton to get this objects and update
– jpok2
Nov 22 at 9:52
Why not save those data to disk and only retrieve it when needed?
– ZUNJAE
Nov 22 at 10:34