Skip to content

Commit

Permalink
提供获取网络返回数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Reginer committed Mar 25, 2022
1 parent bb699d3 commit 3e38dd5
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 13 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ maven { url 'https://jitpack.io' }
```

```
implementation 'com.github.Reginer:MVVMHub:2.1.2'
implementation 'com.github.Reginer:MVVMHub:2.1.3'
```

登录:
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ dependencies {
androidTestImplementation(MvvmExt.espresso)
implementation project(path: ':base')
implementation(MvvmExt.viewBinding)
// releaseImplementation 'com.github.Reginer:MVVMHub:2.1.2'
// releaseImplementation 'com.github.Reginer:MVVMHub:2.1.3'
}
33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/*
* Copyright (c) 2019, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.base

import android.app.Dialog
Expand All @@ -11,7 +42,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat

/**
* @author :Reginer in 19-6-18 下午6:02.
* @author :Reginer 19-6-18 下午6:02.
* 联系方式:QQ:282921012
* 功能描述:Activity基类,普通Activity继承
*/
Expand Down
33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/base/BaseFragment.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/*
* Copyright (c) 2019, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.base

import android.os.Bundle
Expand All @@ -8,7 +39,7 @@ import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment

/**
* @author :Reginer in 2019/11/23 10:00.
* @author :Reginer 2019/11/23 10:00.
* 联系方式:QQ:282921012
* 功能描述:Fragment基类,普通Fragment继承
*/
Expand Down
33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/base/BaseViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
/*
* Copyright (c) 2019, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.base

import androidx.lifecycle.ViewModel

/**
* @author :Reginer in 19-6-18 下午6:03.
* @author :Reginer 19-6-18 下午6:03.
* 联系方式:QQ:282921012
* 功能描述:
*/
Expand Down
33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/base/BaseVmActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
/*
* Copyright (c) 2019, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.base

import android.os.Bundle

/**
* @author :Reginer in 19-6-18 下午6:05.
* @author :Reginer 19-6-18 下午6:05.
* 联系方式:QQ:282921012
* 功能描述:ViewModelActivity基类,ViewModelActivity继承
*/
Expand Down
33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/base/BaseVmFragment.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
/*
* Copyright (c) 2019, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.base

import android.os.Bundle

/**
* @author :Reginer in 2019/11/23 10:11.
* @author :Reginer 2019/11/23 10:11.
* 联系方式:QQ:282921012
* 功能描述:ViewModelFragment基类,ViewModelFragment继承
*/
Expand Down
2 changes: 1 addition & 1 deletion base/src/main/java/win/regin/base/ext/MvvmExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fun BaseViewModel.launchBlock(block: () -> Unit) {
* @param result 请求结果
*/
fun <T> VmLiveData<T>.paresVmResult(result: BaseEntity<T>) {
value = if (result.dataRight()) VmState.Success(result.data) else
value = if (result.dataRight()) VmState.Success(result.getResData()) else
VmState.Error(AppException(result.getMsg(), result.getResCode()))
}

Expand Down
7 changes: 7 additions & 0 deletions base/src/main/java/win/regin/common/BaseEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ open class BaseEntity<T>(
open fun getResCode(): Int {
return code
}

/**
* 获取返回数据
*/
open fun getResData(): T {
return data
}
}


33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/common/CommonExt.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/*
* Copyright (c) 2019, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.common

import com.google.gson.Gson
Expand All @@ -11,7 +42,7 @@ import java.lang.reflect.Type


/**
* @author :Reginer in 2019/7/27 11:20.
* @author :Reginer 2019/7/27 11:20.
* 联系方式:QQ:282921012
* 功能描述:日志扩展类
*/
Expand Down
33 changes: 32 additions & 1 deletion base/src/main/java/win/regin/common/MvvmHubProvider.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/*
* Copyright (c) 2021, Reginer
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
package win.regin.common;

import android.content.ContentProvider;
Expand All @@ -6,7 +37,7 @@
import android.net.Uri;

/**
* @author :Reginer in 2021/3/29 17:16.
* @author :Reginer 2021/3/29 17:16.
* 联系方式:QQ:282921012
* 功能描述:
*/
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/MvvmExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ object Version {
const val okhttp3LogVersion = "4.9.1"
const val materialVersion = "1.4.0"
const val loggerVersion = "2.2.0"
const val libVersionCode = 31
const val libVersionName = "2.1.2"
const val libVersionCode = 32
const val libVersionName = "2.1.3"
}

object MvvmExt {
Expand Down

0 comments on commit 3e38dd5

Please sign in to comment.