Skip to content

Commit b801d03

Browse files
committed
check internet connection
1 parent 4722cd9 commit b801d03

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/imjaspreet/mvvmpattern/ui/main/modelView/MainViewModel.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Context;
44
import android.databinding.ObservableInt;
55
import android.view.View;
6+
import android.widget.Toast;
67

78
import com.imjaspreet.mvvmpattern.App;
89
import com.imjaspreet.mvvmpattern.data.Injector;
@@ -51,6 +52,12 @@ public void onClickGetNews(View view) {
5152
}
5253

5354
private void loadNews(){
55+
56+
if(!App.hasNetwork()){
57+
Toast.makeText(context, "Please check internet connection.", Toast.LENGTH_SHORT).show();
58+
return;
59+
}
60+
5461
progressVisibility.set(View.VISIBLE);
5562
getNewsButtonVisibility.set(View.INVISIBLE);
5663
recyclerViewVisibility.set(View.INVISIBLE);
@@ -71,6 +78,7 @@ public void onNext(RedditNewsResponse value) {
7178
@Override
7279
public void onError(Throwable e) {
7380
progressVisibility.set(View.INVISIBLE);
81+
getNewsButtonVisibility.set(View.VISIBLE);
7482

7583
}
7684

0 commit comments

Comments
 (0)