-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b19e29
commit 9dd4912
Showing
60 changed files
with
2,503 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.wangyz.commonmvvm" | ||
minSdkVersion 21 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
dataBinding{ | ||
enabled true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' | ||
|
||
implementation 'com.android.support:recyclerview-v7:28.0.0' | ||
|
||
implementation 'com.github.bumptech.glide:glide:4.8.0' | ||
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0' | ||
|
||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' | ||
implementation 'io.reactivex.rxjava2:rxjava:2.2.8' | ||
|
||
implementation 'com.squareup.retrofit2:retrofit:2.4.0' | ||
implementation 'com.squareup.retrofit2:converter-gson:2.4.0' | ||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' | ||
|
||
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-14' | ||
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-14' | ||
|
||
implementation 'com.just.agentweb:agentweb:4.0.2' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] |
26 changes: 26 additions & 0 deletions
26
CommonMVVM/app/src/androidTest/java/com/wangyz/commonmvvm/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.wangyz.commonmvvm; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.wangyz.commonmvvm", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.wangyz.commonmvvm"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".view.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".view.ListActivity" /> | ||
<activity android:name=".view.RecyclerActivity" /> | ||
<activity android:name=".view.ArticleActivity" /> | ||
</application> | ||
|
||
</manifest> |
35 changes: 35 additions & 0 deletions
35
CommonMVVM/app/src/main/java/com/wangyz/commonmvvm/adapter/BindingVH.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.wangyz.commonmvvm.adapter; | ||
|
||
import android.databinding.ViewDataBinding; | ||
import android.support.v7.widget.RecyclerView; | ||
|
||
/** | ||
* Created by mj | ||
* on 2017/5/22. | ||
* binding view holder | ||
*/ | ||
|
||
public class BindingVH<B extends ViewDataBinding> extends RecyclerView.ViewHolder { | ||
/** | ||
* viewDataBinding | ||
*/ | ||
private B mBinding; | ||
|
||
/** | ||
* constructor | ||
* | ||
* @param binding viewDataBinding | ||
*/ | ||
public BindingVH(B binding) { | ||
super(binding.getRoot()); | ||
mBinding = binding; | ||
} | ||
|
||
/** | ||
* @return viewDataBinding | ||
*/ | ||
public B getBinding() { | ||
return mBinding; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
CommonMVVM/app/src/main/java/com/wangyz/commonmvvm/adapter/ListViewAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.wangyz.commonmvvm.adapter; | ||
|
||
import android.content.Context; | ||
|
||
import com.wangyz.commonmvvm.base.BaseListViewAdapter; | ||
import com.wangyz.commonmvvm.bean.entity.Project; | ||
|
||
/** | ||
* @author wangyz | ||
* @time 2019/7/4 10:46 | ||
* @description ListViewAdapter | ||
*/ | ||
public class ListViewAdapter extends BaseListViewAdapter<Project> { | ||
|
||
public ListViewAdapter(Context context, int layoutId, int variableId) { | ||
super(context, layoutId, variableId); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
CommonMVVM/app/src/main/java/com/wangyz/commonmvvm/adapter/RecyclerViewAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.wangyz.commonmvvm.adapter; | ||
|
||
import android.databinding.DataBindingUtil; | ||
import android.databinding.ViewDataBinding; | ||
import android.view.ViewGroup; | ||
|
||
import com.wangyz.commonmvvm.BR; | ||
import com.wangyz.commonmvvm.R; | ||
import com.wangyz.commonmvvm.base.BaseRecyclerViewAdapter; | ||
import com.wangyz.commonmvvm.bean.entity.Project; | ||
|
||
/** | ||
* @author wangyz | ||
* @time 2019/7/4 13:55 | ||
* @description RecyclerViewAdapter | ||
*/ | ||
public class RecyclerViewAdapter extends BaseRecyclerViewAdapter<Project, BindingVH> { | ||
@Override | ||
public BindingVH createVH(ViewGroup parent, int viewType) { | ||
ViewDataBinding viewDataBinding = DataBindingUtil.inflate(inflater, R.layout.item_recycler, | ||
parent, false); | ||
return new BindingVH<>(viewDataBinding); | ||
} | ||
|
||
@Override | ||
public void bindVH(BindingVH bindingVH, int position) { | ||
bindingVH.getBinding().setVariable(BR.project, data.get(position)); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
CommonMVVM/app/src/main/java/com/wangyz/commonmvvm/api/Api.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.wangyz.commonmvvm.api; | ||
|
||
import com.wangyz.commonmvvm.bean.model.Project; | ||
|
||
import io.reactivex.Observable; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Path; | ||
import retrofit2.http.Query; | ||
|
||
/** | ||
* @author wangyz | ||
* @time 2019/7/3 17:25 | ||
* @description Api | ||
*/ | ||
public interface Api { | ||
|
||
/** | ||
* 加载数据 | ||
* | ||
* @param page | ||
* @param cid | ||
* @return | ||
*/ | ||
@GET("/project/list/{page}/json") | ||
Observable<Project> load(@Path("page") int page, @Query("cid") int cid); | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
CommonMVVM/app/src/main/java/com/wangyz/commonmvvm/base/BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.wangyz.commonmvvm.base; | ||
|
||
import android.content.Context; | ||
import android.content.pm.ActivityInfo; | ||
import android.databinding.DataBindingUtil; | ||
import android.databinding.ViewDataBinding; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
/** | ||
* @param <VDB> | ||
* @author wangyz | ||
*/ | ||
public abstract class BaseActivity<VDB extends ViewDataBinding> extends AppCompatActivity { | ||
/** | ||
* view data binding | ||
*/ | ||
public VDB viewDataBinding; | ||
/** | ||
* context | ||
*/ | ||
public Context context; | ||
|
||
/** | ||
* 获取 layout 资源id | ||
* | ||
* @return 资源id | ||
*/ | ||
public abstract int getLayoutId(); | ||
|
||
/** | ||
* 初始化操作 | ||
* | ||
* @param savedInstanceState savedInstanceState | ||
*/ | ||
public abstract void init(Bundle savedInstanceState); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
//禁止横屏 | ||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||
context = this; | ||
viewDataBinding = DataBindingUtil.setContentView(this, getLayoutId()); | ||
init(savedInstanceState); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
CommonMVVM/app/src/main/java/com/wangyz/commonmvvm/base/BaseBindingVH.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.wangyz.commonmvvm.base; | ||
|
||
import android.databinding.ViewDataBinding; | ||
import android.support.v7.widget.RecyclerView; | ||
|
||
/** | ||
* @param <B> | ||
* @author wangyz | ||
*/ | ||
public class BaseBindingVH<B extends ViewDataBinding> extends RecyclerView.ViewHolder { | ||
/** | ||
* viewDataBinding | ||
*/ | ||
private B mBinding; | ||
|
||
/** | ||
* constructor | ||
* | ||
* @param binding viewDataBinding | ||
*/ | ||
public BaseBindingVH(B binding) { | ||
super(binding.getRoot()); | ||
mBinding = binding; | ||
} | ||
|
||
/** | ||
* @return viewDataBinding | ||
*/ | ||
public B getBinding() { | ||
return mBinding; | ||
} | ||
|
||
} |
Oops, something went wrong.