Skip to content

Commit 0f2bd14

Browse files
author
Daniel Novak
authored
Merge pull request #38 from inloop/update_dependencies
Update dependencies, deprecate
2 parents bfa5bd0 + f84504a commit 0f2bd14

File tree

16 files changed

+70
-52
lines changed

16 files changed

+70
-52
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 1.3.3(2017-11-02)
1+
## 1.3.5(2018-03-07)
2+
3+
- Updated dependencies (Support library, build tools, Gradle).
4+
5+
## 1.3.4(2017-11-02)
26

37
- Update Gradle plugin. Fix Nullable annotation in getBinding().
48

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
AndroidViewModel
22
================
33

4+
<b>Important notice: Deprecated</b>
5+
--------
6+
<b>This library served it's purpose for over 3 years. We believe that Google's Android [Architecture Components](https://developer.android.com/topic/libraries/architecture/index.html) are the preferred setup now for new projects. </b>
7+
<b>[INLOOPX](http://www.inloopx.com) is dedicated to continue maintaining this library (no deadline on support end). So rest assured that your existing projects don't need be migrated from AndroidViewModel because of this deprecation. We are only stopping new feature development and don't recommend using it for new projects.</b>
8+
9+
410
Separating data and state handling from Fragments or Activities without lots of boilerplate-code. Reducing them to simple <i>dumb views</i>.
511

612
<b>Basic idea behind this library</b>.
@@ -87,7 +93,7 @@ Data binding is supported - extend [ViewModelBaseBindingFragment.java](library/s
8793
``` java
8894
@Override
8995
public ViewModelBindingConfig getViewModelBindingConfig() {
90-
return new ViewModelBindingConfig(R.layout.fragment_sample_binding, getActivity());
96+
return new ViewModelBindingConfig(R.layout.fragment_sample_binding, requireActivity());
9197
}
9298
```
9399

@@ -112,7 +118,7 @@ Download
112118
--------
113119

114120
```groovy
115-
compile 'eu.inloop:androidviewmodel:1.3.4'
121+
compile 'eu.inloop:androidviewmodel:1.3.5'
116122
```
117123

118124
## Android Studio Template

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
google()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:3.0.0'
7+
classpath 'com.android.tools.build:gradle:3.0.1'
88
}
99
}
1010

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
1919

20-
VERSION_NAME=1.3.4
20+
VERSION_NAME=1.3.5

library/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ apply plugin: 'com.android.library'
22
apply plugin: 'maven'
33

44
android {
5-
compileSdkVersion 26
6-
buildToolsVersion '26.0.2'
5+
compileSdkVersion 27
6+
buildToolsVersion '27.0.3'
77

88
defaultConfig {
99
minSdkVersion 15
10-
targetSdkVersion 26
10+
targetSdkVersion 27
1111
versionCode 1
1212
versionName VERSION_NAME
1313
consumerProguardFiles 'proguard-rules.pro'
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}
1616
compileOptions {
17-
sourceCompatibility JavaVersion.VERSION_1_7
18-
targetCompatibility JavaVersion.VERSION_1_7
17+
sourceCompatibility JavaVersion.VERSION_1_8
18+
targetCompatibility JavaVersion.VERSION_1_8
1919
}
2020
buildTypes {
2121
}
@@ -26,8 +26,9 @@ android {
2626
}
2727

2828
dependencies {
29-
implementation 'com.android.support:support-fragment:26.1.0'
30-
implementation 'com.android.support:appcompat-v7:26.1.0'
29+
implementation 'com.android.support:support-fragment:27.1.0'
30+
implementation 'com.android.support:appcompat-v7:27.1.0'
31+
implementation 'com.android.support:support-v4:27.1.0'
3132

3233
androidTestImplementation 'junit:junit:4.12'
3334
androidTestImplementation 'com.android.support.test:runner:1.0.1'

library/src/androidTest/java/eu/inloop/viewmodel/fixture/fragment/VMTestFragment.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package eu.inloop.viewmodel.fixture.fragment;
22

33
import android.os.Bundle;
4+
import android.support.annotation.NonNull;
45
import android.support.annotation.Nullable;
56
import android.view.LayoutInflater;
67
import android.view.View;
@@ -15,19 +16,19 @@ public class VMTestFragment extends ViewModelBaseFragment<IVMTestFragmentView, V
1516

1617
@Nullable
1718
@Override
18-
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
19+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
1920
return new LinearLayout(getContext());
2021
}
2122

2223
@Override
23-
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
24+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
2425
super.onViewCreated(view, savedInstanceState);
2526
setModelView(this);
2627
}
2728

2829
@Override
2930
public void onLoadData(boolean loaded) {
30-
getActivity().setResult(VMTestActivity.RESULT_CODE_OK);
31-
getActivity().finish();
31+
requireActivity().setResult(VMTestActivity.RESULT_CODE_OK);
32+
requireActivity().finish();
3233
}
3334
}

library/src/main/java/eu/inloop/viewmodel/ProxyViewHelper.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ public static Class<?> getGenericType(@NonNull Class<?> in, @NonNull Class<?> wh
4848
return null;
4949
}
5050

51-
private static final InvocationHandler sInvocationHandler = new InvocationHandler() {
52-
@Override
53-
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
54-
return null;
55-
}
56-
};
51+
private static final InvocationHandler sInvocationHandler = (proxy, method, args) -> null;
5752

5853
}

library/src/main/java/eu/inloop/viewmodel/ViewModelHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ public void onDestroy(@NonNull final Fragment fragment) {
162162
//no viewmodel for this fragment
163163
return;
164164
}
165-
if (fragment.getActivity().isFinishing()) {
166-
removeViewModel(fragment.getActivity());
165+
if (fragment.requireActivity().isFinishing()) {
166+
removeViewModel(fragment.requireActivity());
167167
} else if (fragment.isRemoving() && !mOnSaveInstanceCalled) {
168168
// The fragment can be still in backstack even if isRemoving() is true.
169169
// We check mOnSaveInstanceCalled - if this was not called then the fragment is totally removed.
170170
if (BuildConfig.DEBUG) {
171171
Log.d("mode", "Removing viewmodel - fragment replaced"); //NON-NLS
172172
}
173-
removeViewModel(fragment.getActivity());
173+
removeViewModel(fragment.requireActivity());
174174
}
175175
mBinding = null;
176176
}

library/src/main/java/eu/inloop/viewmodel/base/ViewModelBaseFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
2929
//noinspection unchecked
3030
viewModelClass = (Class<? extends AbstractViewModel<T>>) ProxyViewHelper.getGenericType(getClass(), AbstractViewModel.class);
3131
}
32-
getViewModelHelper().onCreate(getActivity(), savedInstanceState, viewModelClass, getArguments());
32+
getViewModelHelper().onCreate(requireActivity(), savedInstanceState, viewModelClass, getArguments());
3333
}
3434

3535
@CallSuper
@@ -94,7 +94,7 @@ public ViewModelHelper<T, R> getViewModelHelper() {
9494

9595
@Override
9696
public void removeViewModel() {
97-
mViewModelHelper.removeViewModel(getActivity());
97+
mViewModelHelper.removeViewModel(requireActivity());
9898
}
9999

100100
/**

library/src/main/java/eu/inloop/viewmodel/binding/ViewModelBaseBindingFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
2525

2626
@Nullable
2727
@Override
28-
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
28+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
2929
getViewModelHelper().performBinding(this);
3030
final ViewDataBinding binding = getViewModelHelper().getBinding();
3131
if (binding != null) {

0 commit comments

Comments
 (0)