Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
3 votes
1 answer
124 views

Login system using callbacks in android

I wrote a login system for an app I am developing, but I'm not really happy with the code I have at the moment. I feel like there is a better way at tackling a problem like this. In particular I'm not ...
RuuddR's user avatar
  • 131
4 votes
3 answers
7k views

Simple Publisher Subscriber in Java

I am new to Java and had some difficulty creating this simple Publisher Subscriber class. It finally seems to be working and I wanted to check if I have been following best practices and see if there ...
KNejad's user avatar
  • 171
2 votes
2 answers
401 views

Read lines from file, calling a consumer function for each line

I wrote a function for iterating over a large file with performance in mind. It takes in an InputStream and reads until it reaches the end of the file. Whenever it ...
LapisSea's user avatar
2 votes
1 answer
678 views

Event Handler Registration in Java [closed]

I have a stateful object on which I'd like client code to be able to register many event handlers. These handlers have different signatures—they usually accept the originating object and some piece of ...
John Dorian's user avatar
10 votes
1 answer
709 views

ActivityLifecycleHelper implementation

Description The ActivityLifecycleHelper uses wrap(Context)to create the class and save a global ...
Jon Merritt's user avatar
5 votes
2 answers
3k views

Synchronization in an event manager

I'm working on an event manager, and I am wanting it to be a tool developers use. It is lightweight and it uses annotations to register events. I've tried to set up ...
CoderMusgrove's user avatar
1 vote
1 answer
88 views

Is this a proper callback implementation in Java?

I have a code which I believe is callback implementation. Can you please provide your more experienced opinions on whether this is a good way to ...
Alex's user avatar
  • 111
7 votes
2 answers
22k views

Callback on AlertDialog

I am using an AlertDialog in Android, asking the user for some input. I would like do run some code when the user has finished entering her input. Since an ...
JonasVautherin's user avatar
4 votes
2 answers
14k views

Generic callback object, but I need the type parameter inside methods

Inside my android app, I currently have methods that look like below code. Since they all need a callback object that basically does the same thing and I would like to try to eliminate the duplicated ...
nPn's user avatar
  • 165
7 votes
4 answers
470 views

Identify Java Callback

I have this common design in my application: ...
Pierre-Jean's user avatar
6 votes
2 answers
78 views

Alternate way for comparison call back function?

I'm doing a programming practice problem and was wondering if someone can suggest a better to create/setup the call back for the comparison function. I have the following classes: ...
user3379755's user avatar
2 votes
2 answers
165 views

Allowing messages to be passed to listeners [closed]

I have written an implementation of the observer pattern that allows messages to be passed to listeners in what would normally be the notify() method. For example a ...
JeremyFromEarth's user avatar
5 votes
1 answer
911 views

"Piping" from a callback to an Iterator

My project has a central concept of a Callback<T> which is defined very simply: ...
Steven Schlansker's user avatar
3 votes
1 answer
5k views

Efficient implemetation of AlertDialog callback in Android

One day I realised that my Android project utilizes AlertDialogs here and there in very ineffective way. The heavily duplicated portion of code looked like this (actually, copied and pasted from some ...
Stan's user avatar
  • 211
36 votes
2 answers
6k views

Asynchronous network callback code

I did not get the job after submitting this piece of work in an interview, but I have no feedback to know what "BAD" things are inside this block of code. The requirements are: Connect to the ...
Kit Ho's user avatar
  • 491