Android Open Source - opentraining I Data Provider






From Project

Back to project page opentraining.

License

The source code is released under:

GNU General Public License

If you think the Android project opentraining listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * /*  w w  w.  j  a  va  2s  .  co m*/
 * This is OpenTraining, an Android application for planning your your fitness training.
 * Copyright (C) 2012-2014 Christian Skubich
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package de.skubware.opentraining.db;

import java.util.List;

import de.skubware.opentraining.basic.ExerciseTag;
import de.skubware.opentraining.basic.ExerciseType;
import de.skubware.opentraining.basic.License.LicenseType;
import de.skubware.opentraining.basic.Muscle;
import de.skubware.opentraining.basic.SportsEquipment;
import de.skubware.opentraining.basic.Workout;

/**
 * Interface for classes that handle I/O.
 * 
 * @author Christian Skubich
 * 
 */
public interface IDataProvider {
  /** The name of the folder that contains exercises .xml files and images */
  static public final String EXERCISE_FOLDER = "opentraining-exercises";
  
  /** The name of the folder that contains user-created exercises .xml files */
  static public final String CUSTOM_EXERCISE_FOLDER = "user_exercises";
  
  /** The name of the folder that contains synced exercise .xml files */
  static public final String SYNCED_EXERCISE_FOLDER = "synced_exercises";

  /** The name of the folder that contains user-created images */
  static public final String CUSTOM_IMAGES_FOLDER = "user_images";

  /** The name of the folder that contains synced (downloaded) images */
  static public final String SYNCED_IMAGES_FOLDER = "synced_images";
  
  /** The name of the folder that contains exercises the example {@link Workout}s */
  static public final String EXAMPLE_WORKOUT_FOLDER = "example_workouts";
  
  /** The name of the folder that contains the workout .xml files */
  static public final String WORKOUT_FOLDER = "";

  /** The JSON file that contains the {@link Muscle}s */
  static public final String MUSCLE_FILE = "muscles.json";

  /** The JSON file that contains the {@link SportsEquipment} */
  static public final String EQUIPMENT_FILE = "equipment.json";
  
  /** The JSON file that contains the {@link ExerciseTag}s */
  static public final String EXERCISE_TAG_FILE = "exercisetags.json";

  /**
   * Lists all {@link ExerciseType}s
   * 
   * @return All {@link ExerciseType}s
   */
  public List<ExerciseType> getExercises();

  /**
   * Saves the (user-generated) exercise to {@link CUSTOM_EXERCISE_FOLDER}.
   * 
   * @param ex
   *            The {@link ExerciseType} to save.
   * 
   * @return true if successful
   */
  public boolean saveCustomExercise(ExerciseType ex);

  /**
   * Deletes the (user-generated) exercise if available.
   * Will also delete related images if not referenced anywhere else.
   * 
   * @param ex
   *            The {@link ExerciseType} to delete.
   * 
   * @return true if successful
   */
  public boolean deleteCustomExercise(ExerciseType ex);
  
  
  /**
   * Deletes the (user-generated) image if available.
   * 
   * @param ex
   *            The name of the image to delete.
   * 
   * @param checkForReferences
   *            If this flag is set, images will not be deleted
   *            when they are referenced by any exercise.            
   * 
   * @return true if successful
   */
  public boolean deleteCustomImage(String imageName, boolean checkForReferences);
  
  
  /**
   * Saves the (synced) exercises to {@link SYNCED_EXERCISE_FOLDER}.
   * 
   * @param ex
   *            The {@link ExerciseType}s to save.
   * 
   * @return all exercises that could not be saved
   */
  public List<ExerciseType> saveSyncedExercises(List<ExerciseType> exerciseList);  
  
  /**
   * Tries to find and return the exercise with the name.
   * 
   * @param name
   *            The name of the exercise to look for
   * 
   * @return An exercise with the name or null.
   */
  public ExerciseType getExerciseByName(String name);

  /**
   * Checks if the exercise does exist.
   * 
   * @param name
   *            The name of the exercise to look for
   * 
   * @return true if the exercise exists, false otherwise
   */
  public boolean exerciseExists(String name);

  /**
   * Lists all {@link Muscle}s
   * 
   * @return All {@link Muscle}s
   */
  public List<Muscle> getMuscles();

  /**
   * Tries to find and return the {@link Muscle} with the name.
   * 
   * @param name
   *            The name of the {@link Muscle} to look for
   * 
   * @return An {@link Muscle} with the name or null.
   */
  public Muscle getMuscleByName(String name);

  /**
   * Tries to find and return the {@link SportsEquipment} with the name.
   * 
   * @param name
   *            The name of the {@link SportsEquipment} to look for
   * 
   * @return An {@link SportsEquipment} with the name or null.
   */
  public SportsEquipment getEquipmentByName(String name);

  /**
   * Lists all {@link SportsEquipment}s
   * 
   * @return All {@link SportsEquipment}s
   */
  public List<SportsEquipment> getEquipment();
  
  /**
   * Tries to find and return the {@link ExerciseTag} with the name.
   * 
   * @param name
   *            The name of the {@link ExerciseTag} to look for
   * 
   * @return An {@link ExerciseTag} with the name or null.
   */
  public ExerciseTag getExerciseTagByName(String name);

  /**
   * Lists all available {@link LicenseType}s
   * 
   * @return All {@link LicenseType}s
   */
  public List<LicenseType> getLicenseTypes();
  
  /**
   * Tries to find and return the {@link LicenseType} with the name.
   * If the License cannot be found LicenseType.UNKNOWN will be returned.
   * 
   * @param name
   *            The (short) name of the {@link LicenseType}
   * 
   * @return An {@link LicenseType} with the name or LicenseType.UNKNOWN.
   */
  public LicenseType getLicenseTypeByName(String name);
  
  /**
   * Lists all {@link ExerciseTag}s
   * 
   * @return All {@link ExerciseTag}s
   */
  public List<ExerciseTag> getExerciseTags();

  /**
   * Lists all {@link Workout}s
   * 
   * @return All {@link Workout}s
   */
  public List<Workout> getWorkouts();

  /**
   * Saves the {@link Workout}.
   * 
   * @param w
   *            The {@link Workout} to save.
   * 
   * @return true if successful
   */
  public boolean saveWorkout(Workout w);

  /**
   * Deletes the {@link Workout}
   * 
   * @param w
   *            The {@link Workout} to delete
   * 
   * @return True if successful, false otherwise
   */
  public boolean deleteWorkout(Workout w);

}




Java Source Code List

at.technikum.mti.fancycoverflow.FancyCoverFlowAdapter.java
at.technikum.mti.fancycoverflow.FancyCoverFlowItemWrapper.java
at.technikum.mti.fancycoverflow.FancyCoverFlow.java
de.skubware.opentraining.activity.ChangeLogDialog.java
de.skubware.opentraining.activity.DisclaimerDialog.java
de.skubware.opentraining.activity.MainActivity.java
de.skubware.opentraining.activity.NavigationGalleryAdapter.java
de.skubware.opentraining.activity.SelectWorkoutDialogFragment.java
de.skubware.opentraining.activity.WhatsNewDialog.java
de.skubware.opentraining.activity.acra.ACRACrashReportMailer.java
de.skubware.opentraining.activity.acra.ACRAFeedbackMailer.java
de.skubware.opentraining.activity.acra.OpenTrainingApplication.java
de.skubware.opentraining.activity.acra.RequestExerciseUpdate.java
de.skubware.opentraining.activity.create_exercise.CreateExerciseActivity.java
de.skubware.opentraining.activity.create_exercise.CustomSpinner.java
de.skubware.opentraining.activity.create_exercise.DescriptionFragment.java
de.skubware.opentraining.activity.create_exercise.EditImageMetadataDialog.java
de.skubware.opentraining.activity.create_exercise.EquipmentDataFragment.java
de.skubware.opentraining.activity.create_exercise.ExerciseImageListAdapter.java
de.skubware.opentraining.activity.create_exercise.ImageFragment.java
de.skubware.opentraining.activity.create_exercise.MuscleDataFragment.java
de.skubware.opentraining.activity.create_exercise.NameFragment.java
de.skubware.opentraining.activity.create_exercise.SimpleDataFragment.java
de.skubware.opentraining.activity.create_exercise.SpinnerDataFragment.java
de.skubware.opentraining.activity.create_workout.DialogFilterMusclesAndEquipment.java
de.skubware.opentraining.activity.create_workout.DialogWorkoutOverviewFragment.java
de.skubware.opentraining.activity.create_workout.ExerciseDetailOnGestureListener.java
de.skubware.opentraining.activity.create_workout.ExerciseTypeDetailActivity.java
de.skubware.opentraining.activity.create_workout.ExerciseTypeDetailFragment.java
de.skubware.opentraining.activity.create_workout.ExerciseTypeListActivity.java
de.skubware.opentraining.activity.create_workout.ExerciseTypeListAdapter.java
de.skubware.opentraining.activity.create_workout.ExerciseTypeListFragment.java
de.skubware.opentraining.activity.create_workout.SelectMuscleDialog.java
de.skubware.opentraining.activity.create_workout.SendExerciseFeedbackDialogFragment.java
de.skubware.opentraining.activity.create_workout.upload_exercise.ExerciseImage.java
de.skubware.opentraining.activity.create_workout.upload_exercise.UploadExerciseAsyncTask.java
de.skubware.opentraining.activity.create_workout.upload_exercise.UploadExerciseImagesAsyncTask.java
de.skubware.opentraining.activity.create_workout.upload_exercise.WgerRestService.java
de.skubware.opentraining.activity.manage_workouts.RenameWorkoutDialogFragment.java
de.skubware.opentraining.activity.manage_workouts.WorkoutDetailActivity.java
de.skubware.opentraining.activity.manage_workouts.WorkoutDetailFragment.java
de.skubware.opentraining.activity.manage_workouts.WorkoutListActivity.java
de.skubware.opentraining.activity.manage_workouts.WorkoutListFragment.java
de.skubware.opentraining.activity.settings.LicenseDialog.java
de.skubware.opentraining.activity.settings.SettingsActivity.java
de.skubware.opentraining.activity.settings.sync.OpenTrainingSyncResultReceiver.java
de.skubware.opentraining.activity.settings.sync.OpenTrainingSyncService.java
de.skubware.opentraining.activity.settings.sync.RestClient.java
de.skubware.opentraining.activity.settings.sync.SyncFinishedDialog.java
de.skubware.opentraining.activity.settings.sync.WgerImageDownloader.java
de.skubware.opentraining.activity.settings.sync.WgerJSONParser.java
de.skubware.opentraining.activity.start_training.DialogFragmentAddEntry.java
de.skubware.opentraining.activity.start_training.DialogFragmentTrainingEntryTable.java
de.skubware.opentraining.activity.start_training.FExDetailActivity.java
de.skubware.opentraining.activity.start_training.FExDetailFragment.java
de.skubware.opentraining.activity.start_training.FExListActivity.java
de.skubware.opentraining.activity.start_training.FExListAdapter.java
de.skubware.opentraining.activity.start_training.FExListFragment.java
de.skubware.opentraining.activity.start_training.RecoveryTimerManager.java
de.skubware.opentraining.activity.start_training.SwipeDismissListViewTouchListener.java
de.skubware.opentraining.activity.start_training.SwipeDismissTouchListener.java
de.skubware.opentraining.activity.start_training.TrainingEntryListAdapter.java
de.skubware.opentraining.basic.ActivationLevel.java
de.skubware.opentraining.basic.ExerciseTag.java
de.skubware.opentraining.basic.ExerciseType.java
de.skubware.opentraining.basic.FSet.java
de.skubware.opentraining.basic.FitnessExercise.java
de.skubware.opentraining.basic.IExercise.java
de.skubware.opentraining.basic.License.java
de.skubware.opentraining.basic.Muscle.java
de.skubware.opentraining.basic.SportsEquipment.java
de.skubware.opentraining.basic.TrainingEntry.java
de.skubware.opentraining.basic.Translatable.java
de.skubware.opentraining.basic.Workout.java
de.skubware.opentraining.db.Cache.java
de.skubware.opentraining.db.DataHelper.java
de.skubware.opentraining.db.DataProvider.java
de.skubware.opentraining.db.IDataProvider.java
de.skubware.opentraining.db.parser.AbstractJSONParser.java
de.skubware.opentraining.db.parser.ExerciseTagJSONParser.java
de.skubware.opentraining.db.parser.ExerciseTypeXMLParser.java
de.skubware.opentraining.db.parser.IParser.java
de.skubware.opentraining.db.parser.MuscleJSONParser.java
de.skubware.opentraining.db.parser.SportsEquipmentJSONParser.java
de.skubware.opentraining.db.parser.WorkoutXMLParser.java
de.skubware.opentraining.db.parser.XMLSaver.java
de.skubware.opentraining.db.rest.ExerciseImageGSONSerializer.java
de.skubware.opentraining.db.rest.ExerciseTypeGSONSerializer.java
de.skubware.opentraining.db.rest.LanguageGSONDeserializer.java
de.skubware.opentraining.db.rest.MuscleGSONDeserializer.java
de.skubware.opentraining.db.rest.ServerModel.java
de.skubware.opentraining.db.rest.SportsEquipmentGSONDeserializer.java
de.skubware.opentraining.exporter.HTMLExporter.java
de.skubware.opentraining.exporter.LaTeXExporter.java
de.skubware.opentraining.exporter.WorkoutExporter.java