Skip to content

Commit

Permalink
Merge pull request #7 from mazurio/develop
Browse files Browse the repository at this point in the history
Development Branch for 1.0.1
  • Loading branch information
mazurio committed Jul 14, 2015
2 parents 38f5ce1 + e2a4604 commit 0e32888
Show file tree
Hide file tree
Showing 79 changed files with 2,379 additions and 274 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ An android application created for /r/bodyweightfitness subreddit.
Simple interface for accessing multiple exercise videos and up-to-date beginner routine with a handy timer helpful to finish the exercise.

<p align="center">
<img src="/screenshots/Nexus%205%20Overview.png?raw=true" alt="Nexus 5 Screenshot" width="325"/>
<img src="/screenshots/Nexus%206%20GitHub.png?raw=true" alt="Nexus 6 Screenshot" width="325"/>
</p>

### LICENSE
Expand Down
13 changes: 8 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ android {
productFlavors {
pro {
applicationId 'io.mazur.fit.pro'
versionCode 100
versionName "1.0.0"
versionCode 101
versionName "1.0.1"
}

free {
applicationId 'io.mazur.fit.free'
versionCode 100
versionName "1.0.0"
versionCode 101
versionName "1.0.1"
}
}

Expand All @@ -52,6 +52,9 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:support-v4:22.2.0'
Expand All @@ -60,7 +63,7 @@ dependencies {
compile 'com.android.support:design:22.2.0'

compile 'com.google.code.gson:gson:2.3.1'

compile 'com.github.mazurio:glacier:0.0.3'
compile 'net.danlew:android.joda:2.7.1'

compile 'commons-io:commons-io:2.4'
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/io/mazur/fit/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.content.Context;

import com.crashlytics.android.Crashlytics;

import net.danlew.android.joda.JodaTimeAndroid;

import io.mazur.glacier.Glacier;
import io.fabric.sdk.android.Fabric;

public class App extends Application {
Expand All @@ -16,7 +16,9 @@ public class App extends Application {
public void onCreate() {
super.onCreate();

JodaTimeAndroid.init(this);
Glacier.init(getApplicationContext());
JodaTimeAndroid.init(getApplicationContext());

if(!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/mazur/fit/Constants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.mazur.fit;

public class Constants {
public static final String PREFERENCE_PLAY_SOUND_WHEN_TIMER_STOPS = "PREFERENCE_PLAY_SOUND_WHEN_TIMER_STOPS";
public static final String PREFERENCE_KEEP_SCREEN_ON = "PREFERENCE_KEEP_SCREEN_ON";
public static final String PREFERENCE_TIMER_KEY = "PREFERENCE_TIMER_KEY";
}
54 changes: 35 additions & 19 deletions app/src/main/java/io/mazur/fit/adapter/RoutineAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@

import butterknife.ButterKnife;
import butterknife.InjectView;

import io.mazur.fit.R;
import io.mazur.fit.model.Category;
import io.mazur.fit.model.Routine;
import io.mazur.fit.model.Exercise;
import io.mazur.fit.model.LinkedRoutine;
import io.mazur.fit.model.RoutineType;
import io.mazur.fit.model.Section;
import io.mazur.fit.stream.RoutineStream;

public class RoutineAdapter extends RecyclerView.Adapter<RoutineAdapter.RoutinePresenter> {
Expand All @@ -35,7 +40,7 @@ public RoutinePresenter onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(RoutinePresenter holder, int position) {
holder.onBindView(mRoutine.getPartRoutines().get(position));
holder.onBindView(mRoutine.getLinkedRoutine().get(position));
}

@Override
Expand All @@ -44,12 +49,12 @@ public int getItemCount() {
return 0;
}

return mRoutine.getSize();
return mRoutine.getLinkedRoutine().size();
}

@Override
public int getItemViewType(int position) {
return mRoutine.getPartRoutines().get(position).getType().ordinal();
return mRoutine.getLinkedRoutine().get(position).getType().ordinal();
}

public void setRoutine(Routine routine) {
Expand All @@ -58,66 +63,77 @@ public void setRoutine(Routine routine) {
notifyDataSetChanged();
}

public abstract class RoutinePresenter extends RecyclerView.ViewHolder {
public abstract class RoutinePresenter<T extends LinkedRoutine> extends RecyclerView.ViewHolder {
public RoutinePresenter(View itemView) {
super(itemView);

ButterKnife.inject(this, itemView);
}

public abstract void onBindView(Routine.PartRoutine partRoutine);
public abstract void onBindView(T linkedRoutine);
}

public class RoutineCategoryPresenter extends RoutinePresenter {
public class RoutineCategoryPresenter extends RoutinePresenter<Category> {
@InjectView(R.id.routine_category_text_view) TextView mRoutineCategoryTextView;

public RoutineCategoryPresenter(View itemView) {
super(itemView);
}

@Override
public void onBindView(Routine.PartRoutine partRoutine) {
mRoutineCategoryTextView.setText(partRoutine.getTitle());
public void onBindView(Category category) {
mRoutineCategoryTextView.setText(category.getTitle());
}
}

public class RoutineSectionPresenter extends RoutinePresenter {
public class RoutineSectionPresenter extends RoutinePresenter<Section> {
@InjectView(R.id.routine_section_text_view) TextView mRoutineSectionTextView;
@InjectView(R.id.routine_section_description_text_view) TextView mRoutineSectionDescriptionTextView;

public RoutineSectionPresenter(View itemView) {
super(itemView);
}

@Override
public void onBindView(Routine.PartRoutine partRoutine) {
mRoutineSectionTextView.setText(partRoutine.getTitle());
public void onBindView(Section section) {
mRoutineSectionTextView.setText(section.getTitle());
mRoutineSectionDescriptionTextView.setText(section.getDescription());
}
}

public class RoutineExercisePresenter extends RoutinePresenter {
public class RoutineExercisePresenter extends RoutinePresenter<Exercise> {
@InjectView(R.id.routine_exercise_level_text_view) TextView mRoutineExerciseLevelTextView;
@InjectView(R.id.routine_exercise_text_view) TextView mRoutineExerciseTextView;

public RoutineExercisePresenter(View itemView) {
super(itemView);
}

@Override
public void onBindView(Routine.PartRoutine partRoutine) {
mRoutineExerciseTextView.setText(partRoutine.getTitle());
public void onBindView(Exercise exercise) {
if(exercise.getLevel() == null) {
mRoutineExerciseLevelTextView.setVisibility(View.GONE);
} else {
mRoutineExerciseLevelTextView.setVisibility(View.VISIBLE);
mRoutineExerciseLevelTextView.setText(exercise.getLevel());
}

mRoutineExerciseTextView.setText(exercise.getTitle());

itemView.setOnClickListener(new OnItemClickListener(partRoutine));
itemView.setOnClickListener(new OnItemClickListener(exercise));
}
}

public class OnItemClickListener implements View.OnClickListener {
private Routine.PartRoutine mPartRoutine;
private LinkedRoutine mLinkedRoutine;

public OnItemClickListener(Routine.PartRoutine partRoutine) {
mPartRoutine = partRoutine;
public OnItemClickListener(LinkedRoutine linkedRoutine) {
mLinkedRoutine = linkedRoutine;
}

@Override
public void onClick(View v) {
RoutineStream.getInstance().setExercise(mPartRoutine);
RoutineStream.getInstance().setExercise((Exercise) mLinkedRoutine);
}
}
}
7 changes: 7 additions & 0 deletions app/src/main/java/io/mazur/fit/model/ActivityState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.mazur.fit.model;

public enum ActivityState {
OnCreate,
OnPause,
OnStop
}
32 changes: 32 additions & 0 deletions app/src/main/java/io/mazur/fit/model/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.mazur.fit.model;

import java.io.Serializable;
import java.util.ArrayList;

public class Category extends LinkedRoutine implements Serializable {
private String mTitle;

private ArrayList<Section> mSections = new ArrayList<>();

public Category(String title) {
mTitle = title;
}

public String getTitle() {
return mTitle;
}

public RoutineType getType() {
return RoutineType.CATEGORY;
}

public void insertSection(Section section) {
section.setCategory(this);

mSections.add(section);
}

public ArrayList<Section> getSections() {
return mSections;
}
}
83 changes: 83 additions & 0 deletions app/src/main/java/io/mazur/fit/model/Exercise.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package io.mazur.fit.model;

import java.io.Serializable;

public class Exercise extends LinkedRoutine implements Serializable {
private String mId;
private String mLevel;
private String mTitle;
private String mDescription;

private Category mCategory;
private Section mSection;

private Exercise mPrevious;
private Exercise mNext;

public Exercise(String id, String level, String title, String description) {
mId = id;
mLevel = level;
mTitle = title;
mDescription = description;
}

public String getId() {
return mId;
}

public String getLevel() {
return mLevel;
}

public String getTitle() {
return mTitle;
}

public RoutineType getType() {
return RoutineType.EXERCISE;
}

public String getDescription() {
return mDescription;
}

public void setCategory(Category category) {
mCategory = category;
}

public Category getCategory() {
return mCategory;
}

public void setSection(Section section) {
mSection = section;
}

public Section getSection() {
return mSection;
}

public boolean isPrevious() {
return mPrevious != null;
}

public void setPrevious(Exercise previous) {
mPrevious = previous;
}

public Exercise getPrevious() {
return mPrevious;
}

public boolean isNext() {
return mNext != null;
}

public void setNext(Exercise next) {
mNext = next;
}

public Exercise getNext() {
return mNext;
}
}
Loading

0 comments on commit 0e32888

Please sign in to comment.