0

I was just going through the source code of Ion and found that Ion uses static HashMap static HashMap<String, Ion> instances = new HashMap<String, Ion>(); for storing Ion objects and calling Ion.with(context) should return the same instance as evident from the code (correct me if I am wrong)

 public static Ion getDefault(Context context) {
        return getInstance(context, "ion");
    }

public static Ion getInstance(Context context, String name) {
    if (context == null)
        throw new NullPointerException("Can not pass null context in to retrieve ion instance");
    Ion instance = instances.get(name);
    if (instance == null)
        instances.put(name, instance = new Ion(context, name));
    return instance;
}

but when I compare objects it returns false. Can anyone tell me what am I missing ?

Log.d(TAG, String.valueOf( Ion.with(getApplicationContext()).equals(Ion.with(getApplicationContext())) ));
mallaudin
  • 4,744
  • 3
  • 36
  • 68

1 Answers1

0

sorry, I was missing this line

  public static LoadBuilder<Builders.Any.B> with(Context context) {
        return getDefault(context).build(context);
    }

 public LoadBuilder<Builders.Any.B> build(Context context) {
        return new IonRequestBuilder(ContextReference.fromContext(context), this);
    }

It uses same Ion object but returns new builder every time.

mallaudin
  • 4,744
  • 3
  • 36
  • 68