package org.wikipedia.json;

import android.net.Uri;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;

public class UriTypeAdapter extends TypeAdapter<Uri> {
    @Override
    public void write(JsonWriter out, Uri value) throws IOException {
        out.value(value == null ? null : value.toString());
    }

    @Override
    public Uri read(JsonReader in) throws IOException {
        String url = in.nextString();

        if (url == null) {
            return null;
        }

        // TODO: previously, only host parts were preserved for WikiSite.domain. Remove in September
        //       2016 once Gson has had a chance to deserialize.
        if (!url.startsWith("http")) {
            url = "https://" + url;
        }

        return Uri.parse(url);
    }
}
@@ -579,260 +579,8 @@
  %7D%0A%0A
-        // TODO: previously, only host parts were preserved for WikiSite.domain. Remove in September%0A        //       2016 once Gson has had a chance to deserialize.%0A        if (!url.startsWith(%22http%22)) %7B%0A            url = %22https://%22 + url;%0A        %7D%0A%0A
     
@@ -613,8 +613,9 @@
 %0A    %7D%0A%7D
+%0A

remove legacy code for Site domain