Skip to content

Commit

Permalink
fix for video support.
Browse files Browse the repository at this point in the history
  • Loading branch information
senpl committed Jan 16, 2025
1 parent 7ca9d2d commit a17c86f
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 154 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
minSdkVersion 26
compileSdk 35
targetSdkVersion 35
versionCode 66
versionName "0.25.03"
versionCode 68
versionName "0.25.05"
vectorDrawables.useSupportLibrary = true
}

Expand Down
23 changes: 19 additions & 4 deletions app/src/main/java/com/easyfitness/DAO/DAOExerciseInProgram.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.easyfitness.DAO
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.database.Cursor.FIELD_TYPE_INTEGER
import android.database.Cursor.FIELD_TYPE_STRING
import android.widget.Toast
import timber.log.Timber
import java.util.*
Expand Down Expand Up @@ -156,6 +158,19 @@ class DAOExerciseInProgram(var mContext: Context) : DAOBase(mContext) {
val distanceUnit = cursor!!.getColumnIndex(DISTANCE_UNIT)
val youtubeUrlStart = cursor!!.getColumnIndex(YOUTUBE_URL_START)
val videoSeconds = cursor!!.getColumnIndex(VIDEO_SECONDS)
var youtubeUrl=""
var youtubeEnd=0
try{ //probably not needed, but to not crash for old user
if (cursor!!.getType(youtubeUrlStart) == FIELD_TYPE_STRING) {
youtubeUrl = cursor!!.getString(youtubeUrlStart)
}
if (cursor!!.getType(videoSeconds) == FIELD_TYPE_INTEGER) {
youtubeEnd = cursor!!.getInt(videoSeconds)
}
}catch(e:Exception){
youtubeUrl=""
youtubeEnd=0
}
val value = ExerciseInProgram( //int secRest, String pMachine, int pSerie, int pRepetition, float pPoids,
// Profile pProfile, int pUnit, String pNote, long pMachineKey, String pTime,
// int type, int distance, String duration, int seconds, int distanceUnit,
Expand All @@ -175,8 +190,8 @@ class DAOExerciseInProgram(var mContext: Context) : DAOBase(mContext) {
cursor!!.getLong(cursor!!.getColumnIndex(DURATION)),
cursor!!.getInt(cursor!!.getColumnIndex(SECONDS)),
cursor!!.getInt(distanceUnit),
cursor!!.getString(youtubeUrlStart),
cursor!!.getInt(videoSeconds),
youtubeUrl,//cursor!!.getString(youtubeUrlStart),
youtubeEnd,//cursor!!.getInt(videoSeconds),
cursor!!.getLong(cursor!!.getColumnIndex(ORDER_EXECUTION))
)
value.setId(cursor!!.getLong(cursor!!.getColumnIndex(KEY)))
Expand Down Expand Up @@ -213,8 +228,8 @@ class DAOExerciseInProgram(var mContext: Context) : DAOBase(mContext) {
cursor!!.getInt(cursor!!.getColumnIndex(MACHINE_KEY)).toLong(),
cursor!!.getString(cursor!!.getColumnIndex(TIME)),
cursor!!.getInt(cursor!!.getColumnIndex(TYPE)),
cursor!!.getString(cursor!!.getColumnIndex(YOUTUBE_URL_START)),
cursor!!.getInt(cursor!!.getColumnIndex(VIDEO_SECONDS)),
"",//cursor!!.getString(cursor!!.getColumnIndex(YOUTUBE_URL_START)),
0,//cursor!!.getInt(cursor!!.getColumnIndex(VIDEO_SECONDS)),
mContext
)
value.setId(cursor!!.getLong(cursor!!.getColumnIndex(KEY)))
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/easyfitness/DAO/DatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class DatabaseHelper extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 22;
public static final int DATABASE_VERSION = 23;
private static final String OLD09_DATABASE_NAME = "easyfitness";
private static final String DATABASE_NAME = "easyfitness.db";
private static DatabaseHelper sInstance;
Expand Down Expand Up @@ -151,9 +151,13 @@ public void onUpgrade(
db.execSQL(DAOExerciseInProgram.TABLE_CREATE);
String defaultProgramName="training program default";
DAOProgram.Companion.addInitialProgram(db, defaultProgramName);
break;
case 22:
db.execSQL("ALTER TABLE " + DAOExerciseInProgram.TABLE_NAME + " ADD COLUMN " + DAOExerciseInProgram.YOUTUBE_URL_START + " TEXT");
db.execSQL("ALTER TABLE " + DAOExerciseInProgram.TABLE_NAME + " ADD COLUMN " + DAOExerciseInProgram.VIDEO_SECONDS + " INTEGER DEFAULT 0");
break;
// case24:
// db.
}
upgradeTo++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ class ExercisesInProgramFragment : Fragment(R.layout.tab_program_with_exercises)
binding.bodybuildingSelector.setBackgroundColor(ContextCompat.getColor(requireActivity().baseContext, R.color.background))
binding.staticExerciseSelector.setBackgroundColor(ContextCompat.getColor(requireActivity().baseContext, R.color.record_background_odd))
binding.serieCardView.visibility = View.VISIBLE
binding.seriesEdit.setText("1")
binding.repetitionCardView.visibility = GONE
binding.secondsCardView.visibility = View.VISIBLE
binding.weightCardView.visibility = View.VISIBLE
Expand All @@ -603,6 +604,7 @@ class ExercisesInProgramFragment : Fragment(R.layout.tab_program_with_exercises)
binding.bodybuildingSelector.setBackgroundColor(ContextCompat.getColor(requireActivity().baseContext, R.color.record_background_odd))
binding.staticExerciseSelector.setBackgroundColor(ContextCompat.getColor(requireActivity().baseContext, R.color.background))
binding.serieCardView.visibility = View.VISIBLE
binding.seriesEdit.setText("1")
binding.repetitionCardView.visibility = View.VISIBLE
binding.secondsCardView.visibility = GONE
binding.weightCardView.visibility = View.VISIBLE
Expand Down
Loading

0 comments on commit a17c86f

Please sign in to comment.