Skip to content

Commit

Permalink
Fixed webcams not loading, increased min sdk version from 16 to 21
Browse files Browse the repository at this point in the history
  • Loading branch information
hej2010 committed May 30, 2024
1 parent 9dd0c5d commit 2dd3b83
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 233 deletions.
15 changes: 11 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ android {
compileSdk 34
defaultConfig {
applicationId "se.swecookie.valthorens"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 34
versionCode 35
versionName "3.4.1"
versionCode 36
versionName "3.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
viewBinding true
}
buildTypes {
debug {
minifyEnabled false
Expand All @@ -30,10 +33,14 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'org.jsoup:jsoup:1.14.3'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
}

configurations.implementation {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}
6 changes: 3 additions & 3 deletions app/src/main/java/se/swecookie/valthorens/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ protected void onCreate(Bundle savedInstanceState) {

ImageView imgHelpMessages = findViewById(R.id.imgHelpMessages);
imgHelpMessages.setOnClickListener(view -> {
AlertDialog.Builder b = new AlertDialog.Builder(AboutActivity.this, R.style.Theme_AppCompat_Light_Dialog_Alert);
AlertDialog.Builder b = new AlertDialog.Builder(AboutActivity.this, androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert);
b.setTitle(getString(R.string.about_help_messages_title))
.setMessage(getString(R.string.about_help_messages_message))
.setPositiveButton(R.string.ok, null)
.show();
});
ImageView imgHelpPreviews = findViewById(R.id.imgHelpPreviews);
imgHelpPreviews.setOnClickListener(view -> {
AlertDialog.Builder b = new AlertDialog.Builder(AboutActivity.this, R.style.Theme_AppCompat_Light_Dialog_Alert);
AlertDialog.Builder b = new AlertDialog.Builder(AboutActivity.this, androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert);
b.setTitle(getString(R.string.about_help_previews_title))
.setMessage(getString(R.string.about_help_previews_message))
.setPositiveButton(R.string.ok, null)
.show();
});
ImageView imgHelpDownloads = findViewById(R.id.imgHelpDownloads);
imgHelpDownloads.setOnClickListener(view -> {
AlertDialog.Builder b = new AlertDialog.Builder(AboutActivity.this, R.style.Theme_AppCompat_Light_Dialog_Alert);
AlertDialog.Builder b = new AlertDialog.Builder(AboutActivity.this, androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert);
b.setTitle(getString(R.string.about_help_downloads_title))
.setMessage(getString(R.string.about_help_downloads_message))
.setPositiveButton(R.string.ok, null)
Expand Down
26 changes: 9 additions & 17 deletions app/src/main/java/se/swecookie/valthorens/ImageDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ImageDownloader {

void startDownload(Webcam webcam, AppCompatActivity context, IOnImageDownloaded iOnImageDownloaded) {
currentURL = webcam.url;
downloadTask = new DownloadPhoto(ImageDownloader.this, iOnImageDownloaded).execute();
downloadTask = new DownloadPhoto(ImageDownloader.this, iOnImageDownloaded)
.execute();
this.context = context;
this.webcam = webcam;
}
Expand All @@ -57,7 +58,11 @@ protected Void doInBackground(Void... voids) {
doc = Jsoup.connect(imageDownloader.currentURL).ignoreContentType(true).get();
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "doInBackground: got error " + e.getMessage());
errorMessage = e.getMessage();
if (imageDownloader.webcam.isStatic && imageDownloader.webcam.staticImageUrl != null) {
imageDownloader.currentURL = imageDownloader.webcam.staticImageUrl;
}
return null;
}

Expand Down Expand Up @@ -117,22 +122,9 @@ protected Void doInBackground(Void... voids) {
}

} else {
switch (imageDownloader.webcam) {
case LA_TYROLIENNE:
imageDownloader.currentURL = "http://www.trinum.com/ibox/ftpcam/mega_val_thorens_tyrolienne.jpg";
break;
case PLAN_BOUCHET:
imageDownloader.currentURL = "http://www.trinum.com/ibox/ftpcam/original_orelle_sommet-tc-orelle.jpg";
break;
case LIVECAM_360:
imageDownloader.currentURL = "http://backend.roundshot.com/cams/232/default";
break;
case PLEIN_SUD:
imageDownloader.currentURL = "http://www.trinum.com/ibox/ftpcam/mega_val_thorens_funitel-bouquetin.jpg";
break;
case CIME_CARON:
imageDownloader.currentURL = "http://www.trinum.com/ibox/ftpcam/mega_val_thorens_cime-caron.jpg";
break;
imageDownloader.currentURL = imageDownloader.webcam.staticImageUrl;
if (imageDownloader.currentURL == null) {
imageDownloader.currentURL = imageDownloader.webcam.url;
}

boolean found = false;
Expand Down
16 changes: 3 additions & 13 deletions app/src/main/java/se/swecookie/valthorens/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,10 @@ private void checkLoadPreviewsSettings() {

private static void showConnectionError(final Context context) {
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(context, R.style.Theme_AppCompat_Light_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(context);
}
builder = new AlertDialog.Builder(context, androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert);
if (context instanceof AppCompatActivity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (((AppCompatActivity) context).isFinishing() || ((AppCompatActivity) context).isDestroyed()) {
return;
}
} else {
if (((AppCompatActivity) context).isFinishing()) {
return;
}
if (((AppCompatActivity) context).isFinishing() || ((AppCompatActivity) context).isDestroyed()) {
return;
}
}
builder.setTitle(context.getString(R.string.connection_title))
Expand Down
25 changes: 2 additions & 23 deletions app/src/main/java/se/swecookie/valthorens/MainAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,11 @@ public MainAdapter.MyViewHolder onCreateViewHolder(@NonNull final ViewGroup pare
return new MyViewHolder(relativeLayout);
}

/*
* FUNITEL_3_VALLEES(1), <meta property="og:image" content="http://storage.gra3.cloud.ovh.net/v1/AUTH_0e308f8996f940d38153db4d0e7d7e81/static/ValThorensBouquetin/2019/04/27/large/05-04.jpg"> // thumb
DE_LA_MAISON(2), <meta property="og:image" content="http://data.skaping.com/ValThorensLaMaison/2019/09/17/large/11-02.jpg"> // thumb
LES_2_LACS(3), <meta property="og:image" content="http://storage.gra3.cloud.ovh.net/v1/AUTH_0e308f8996f940d38153db4d0e7d7e81/static/vt2lacs-360/2019/07/31/large/09-22.jpg"> // thumb
FUNITEL_DE_THORENS(4), <meta property="og:image" content="http://storage.gra3.cloud.ovh.net/v1/AUTH_0e308f8996f940d38153db4d0e7d7e81/static/funitelthorens-360/2019/09/04/large/13-22.jpg"> // thumb
STADE(5), <meta property="og:image" content="http://storage.gra3.cloud.ovh.net/v1/AUTH_0e308f8996f940d38153db4d0e7d7e81/static/setam/stade-val-thorens/2019/06/10/large/16-22.jpg"> // thumb
BOISMINT(6), <meta property="og:image" content="http://storage.gra3.cloud.ovh.net/v1/AUTH_0e308f8996f940d38153db4d0e7d7e81/static/val-thorens/boismint/2019/08/29/large/00-04.jpg"> // thumb
LA_TYROLIENNE(7), http://www.trinum.com/ibox/ftpcam/small_val_thorens_tyrolienne.jpg
PLAN_BOUCHET(8), http://www.trinum.com/ibox/ftpcam/small_orelle_sommet-tc-orelle.jpg
LIVECAM_360(9),
PLEIN_SUD(10), http://www.trinum.com/ibox/ftpcam/small_val_thorens_funitel-bouquetin.jpg
CIME_CARON(11) http://www.trinum.com/ibox/ftpcam/small_val_thorens_cime-caron.jpg
*
*/

@Override
public void onBindViewHolder(@NonNull final MyViewHolder holder, int position) {
final MainActivity context = weakReference.get();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (context.isFinishing() || context.isDestroyed()) {
return;
}
} else {
if (context.isFinishing()) {
return;
}
if (context.isFinishing() || context.isDestroyed()) {
return;
}
holder.cardView.setOnClickListener(view -> {
final int id = holder.getBindingAdapterPosition();
Expand Down
Loading

0 comments on commit 2dd3b83

Please sign in to comment.