XMLRequest.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.mylove.okhttp;
  2. import android.annotation.SuppressLint;
  3. import android.content.Context;
  4. import com.mylove.okhttp.listener.OnOkHttpListener;
  5. import java.util.Map;
  6. /**
  7. * @author myLove
  8. */
  9. public class XMLRequest {
  10. @SuppressLint("StaticFieldLeak")
  11. private static XMLRequest instance;
  12. private static String url;
  13. @SuppressLint("StaticFieldLeak")
  14. private static Context mContext;
  15. private static RequestType requestType;
  16. private XMLRequest() {
  17. }
  18. public static XMLRequest getInstance(Context context, String str, RequestType type) {
  19. if (instance == null) {
  20. synchronized (XMLRequest.class) {
  21. if (instance == null) {
  22. instance = new XMLRequest();
  23. }
  24. }
  25. }
  26. mContext = context;
  27. url = str;
  28. requestType = type;
  29. return instance;
  30. }
  31. public void sync(Map<Object, Object> map, OnOkHttpListener OnOkHttpListener) {
  32. ObservableRequest.getInstance(mContext, requestType, CallType.SYNC).request(url, map, OnOkHttpListener);
  33. }
  34. public void async(Map<Object, Object> map, OnOkHttpListener OnOkHttpListener) {
  35. ObservableRequest.getInstance(mContext, requestType, CallType.ASYNC).request(url, map, OnOkHttpListener);
  36. }
  37. }