ActivityResults {
private final List<ActivityListener> activityListeners = new CopyOnWriteArrayList<>();
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!activityListeners.isEmpty()) {
for (ActivityListener activityListener : activityListeners) {
activityListener.onActivityResult(requestCode, resultCode, data);
}
} }
public void addListener(ActivityListener activityListener) {
activityListeners.add(activityListener);
}
public void removeListener(ActivityListener activityListener) {
activityListeners.remove(activityListener);
}
}
public interface ActivityListener {
void onActivityResult(int requestCode, int resultCode, Intent data);
}