Skip to content

Commit

Permalink
Detect wether stations are online or not
Browse files Browse the repository at this point in the history
  • Loading branch information
eviallet committed Nov 29, 2019
1 parent 35af5ee commit 1d265b1
Showing 26 changed files with 779 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .idea/assetWizardSettings.xml

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

Binary file removed .idea/caches/build_file_checksums.ser
Binary file not shown.
137 changes: 112 additions & 25 deletions .idea/codeStyles/Project.xml

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

4 changes: 4 additions & 0 deletions .idea/encodings.xml

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

18 changes: 16 additions & 2 deletions .idea/misc.xml

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

16 changes: 13 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.gueg.velovwidget"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
}
buildTypes {
release {
@@ -22,13 +26,19 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.osmdroid:osmdroid-android:6.0.2'
implementation 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
implementation 'com.android.volley:volley:1.1.1'

def room_version = "1.1.1"

implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
implementation "android.arch.persistence.room:rxjava2:$room_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

}
repositories {
mavenCentral()
}
21 changes: 19 additions & 2 deletions app/src/main/java/com/gueg/velovwidget/MainListActivity.java
Original file line number Diff line number Diff line change
@@ -11,7 +11,9 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.gueg.velovwidget.database_stations.JsonParser;
import com.gueg.velovwidget.map.PinsActivity;
@@ -33,6 +35,9 @@ public class MainListActivity extends AppCompatActivity {
SwipeRefreshLayout _swipe;
ProgressBar _progress;

ImageView _serverIcon;
TextView _serverText;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -41,6 +46,9 @@ public void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_list);

_serverIcon = findViewById(R.id.widget_list_servers_icon);
_serverText = findViewById(R.id.widget_list_servers_text);

_swipe = findViewById(R.id.widget_list_refresh);
_list = findViewById(R.id.widget_list_stations);
_progress = findViewById(R.id.widget_list_progress);
@@ -49,6 +57,8 @@ public void onCreate(Bundle savedInstanceState) {
_adapter.setListener(new MainListAdapter.RefreshListener() {
@Override public void onRefreshStarted() {
_swipe.setRefreshing(true);
_serverIcon.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.ic_server_loading));
_serverText.setText(getApplicationContext().getResources().getString(R.string.servers_loading));
}
@Override public void onProgressChanged(int progress, int max) {
if(_progress.getVisibility()!= View.VISIBLE)
@@ -62,6 +72,15 @@ public void onCreate(Bundle savedInstanceState) {
if(_progress.getProgress()==0)
startActivityForResult(new Intent(MainListActivity.this, PinsActivity.class), ACTIVITY_PINS);
}
@Override public void onServerResult(boolean err) {
if(err) {
_serverIcon.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.ic_server_offline));
_serverText.setText(getApplicationContext().getResources().getString(R.string.servers_offline));
} else {
_serverIcon.setImageDrawable(getApplicationContext().getResources().getDrawable(R.drawable.ic_server_online));
_serverText.setText(getApplicationContext().getResources().getString(R.string.servers_online));
}
}
});
_list.setAdapter(_adapter);
_list.setLayoutManager(new LinearLayoutManager(this));
@@ -95,8 +114,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
return;
switch(requestCode) {
case ACTIVITY_PINS:
_adapter.refresh();
break;
case ACTIVITY_SORT:
_adapter.refresh();
break;
Loading

0 comments on commit 1d265b1

Please sign in to comment.