|
|
@ -23,9 +23,9 @@ import android.app.Dialog; |
|
|
|
import android.app.Service; |
|
|
|
import android.app.Service; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Context; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Build; |
|
|
|
import android.support.v4.app.DialogFragment; |
|
|
|
|
|
|
|
import android.support.v4.app.Fragment; |
|
|
|
|
|
|
|
import android.widget.PopupWindow; |
|
|
|
import android.widget.PopupWindow; |
|
|
|
|
|
|
|
import androidx.fragment.app.DialogFragment; |
|
|
|
|
|
|
|
import androidx.fragment.app.Fragment; |
|
|
|
import com.arialyy.aria.core.download.DownloadReceiver; |
|
|
|
import com.arialyy.aria.core.download.DownloadReceiver; |
|
|
|
import com.arialyy.aria.core.upload.UploadReceiver; |
|
|
|
import com.arialyy.aria.core.upload.UploadReceiver; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
|
import com.arialyy.aria.util.ALog; |
|
|
@ -86,7 +86,7 @@ import com.arialyy.aria.util.ALog; |
|
|
|
* @param obj 观察者对象,为本类对象,使用{@code this} |
|
|
|
* @param obj 观察者对象,为本类对象,使用{@code this} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static DownloadReceiver download(Object obj) { |
|
|
|
public static DownloadReceiver download(Object obj) { |
|
|
|
if (AriaManager.getInstance() != null){ |
|
|
|
if (AriaManager.getInstance() != null) { |
|
|
|
return AriaManager.getInstance().download(obj); |
|
|
|
return AriaManager.getInstance().download(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
return get(convertContext(obj)).download(obj); |
|
|
|
return get(convertContext(obj)).download(obj); |
|
|
@ -100,7 +100,7 @@ import com.arialyy.aria.util.ALog; |
|
|
|
* @param obj 观察者对象,为本类对象,使用{@code this} |
|
|
|
* @param obj 观察者对象,为本类对象,使用{@code this} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static UploadReceiver upload(Object obj) { |
|
|
|
public static UploadReceiver upload(Object obj) { |
|
|
|
if (AriaManager.getInstance() != null){ |
|
|
|
if (AriaManager.getInstance() != null) { |
|
|
|
return AriaManager.getInstance().upload(obj); |
|
|
|
return AriaManager.getInstance().upload(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
return get(convertContext(obj)).upload(obj); |
|
|
|
return get(convertContext(obj)).upload(obj); |
|
|
@ -111,7 +111,8 @@ import com.arialyy.aria.util.ALog; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static AriaManager get(Context context) { |
|
|
|
public static AriaManager get(Context context) { |
|
|
|
if (context == null) { |
|
|
|
if (context == null) { |
|
|
|
throw new NullPointerException("context 无效,在非【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】," |
|
|
|
throw new NullPointerException( |
|
|
|
|
|
|
|
"context 无效,在非【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】," |
|
|
|
+ "请参考【https://aria.laoyuyu.me/aria_doc/start/any_java.html】,参数请使用 download(this) 或 upload(this);" |
|
|
|
+ "请参考【https://aria.laoyuyu.me/aria_doc/start/any_java.html】,参数请使用 download(this) 或 upload(this);" |
|
|
|
+ "不要使用 download(getContext()) 或 upload(getContext())"); |
|
|
|
+ "不要使用 download(getContext()) 或 upload(getContext())"); |
|
|
|
} |
|
|
|
} |
|
|
@ -139,7 +140,7 @@ import com.arialyy.aria.util.ALog; |
|
|
|
return ((DialogFragment) obj).getContext(); |
|
|
|
return ((DialogFragment) obj).getContext(); |
|
|
|
} else if (obj instanceof android.app.DialogFragment) { |
|
|
|
} else if (obj instanceof android.app.DialogFragment) { |
|
|
|
return ((android.app.DialogFragment) obj).getActivity(); |
|
|
|
return ((android.app.DialogFragment) obj).getActivity(); |
|
|
|
} else if (obj instanceof android.support.v4.app.Fragment) { |
|
|
|
} else if (obj instanceof Fragment) { |
|
|
|
return ((Fragment) obj).getContext(); |
|
|
|
return ((Fragment) obj).getContext(); |
|
|
|
} else if (obj instanceof android.app.Fragment) { |
|
|
|
} else if (obj instanceof android.app.Fragment) { |
|
|
|
return ((android.app.Fragment) obj).getActivity(); |
|
|
|
return ((android.app.Fragment) obj).getActivity(); |
|
|
|