Mtmini Project54
Mtmini Project54
Mtmini Project54
2115035
AIM:
The aim of this project is to develop a fitness tracking application using java programming
language in android.
PROCEDURE:
MainActivity.java:
package com.easyfitness.intro;
import android.content.Intent;
import android.os.Bundle;
import com.easyfitness.DAO.DAOProfile;
import com.easyfitness.R;
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
import com.heinrichreimersoftware.materialintro.slide.FragmentSlide;
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
import com.heinrichreimersoftware.materialintro.slide.Slide;
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
setFullscreen(false);
super.onCreate(savedInstanceState);
19IT66C – MOBILE TECHNOLOGIES LABORATORY 2
NATIONAL ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY
2115035
setButtonBackFunction(skipEnabled ? BUTTON_BACK_FUNCTION_SKIP :
BUTTON_BACK_FUNCTION_BACK);
setButtonNextFunction(finishEnabled ? BUTTON_NEXT_FUNCTION_NEXT_FINISH :
BUTTON_NEXT_FUNCTION_NEXT);
setButtonBackVisible(showBack);
setButtonNextVisible(showNext);
setButtonCtaVisible(getStartedEnabled);
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT);
addSlide(new SimpleSlide.Builder()
.title(R.string.introSlide1Title)
.description(R.string.introSlide1Text)
.image(R.drawable.web_hi_res_512)
.background(R.color.launcher_background)
.backgroundDark(R.color.launcher_background)
.scrollable(true)
.build());
addSlide(new SimpleSlide.Builder()
.title(R.string.introSlide2Title)
.description(R.string.introSlide2Text)
.image(R.drawable.bench_hi_res_512)
.background(R.color.launcher_background)
.backgroundDark(R.color.launcher_background)
.scrollable(true)
.build());
addSlide(new SimpleSlide.Builder()
.title(R.string.titleSlideEssential)
.description(R.string.textSlideEssential)
.image(R.drawable.idea_hi_res_485)
.background(R.color.launcher_background)
.backgroundDark(R.color.launcher_background)
.scrollable(true)
.build());
addSlide(new SimpleSlide.Builder()
.title(R.string.titleSlideOpenSource)
.description(R.string.textSlideOpenSource)
.image(R.drawable.group_hi_res_512)
.background(R.color.launcher_background)
.backgroundDark(R.color.launcher_background)
.scrollable(true)
.build());
if (mDbProfils.getCount() == 0) {
MeasureFit.java
package com.easyfitness.bodymeasures;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import com.easyfitness.BtnClickListener;
import com.easyfitness.DAO.bodymeasures.DAOBodyMeasure;
import com.easyfitness.R;
import com.easyfitness.enums.Unit;
import com.easyfitness.utils.DateConverter;
import java.util.Date;
super(context, c, flags);
mContext = context;
mClickListener = mD;
mInflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
19IT66C – MOBILE TECHNOLOGIES LABORATORY 4
NATIONAL ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY
2115035
TextView t0 = view.findViewById(R.id.LIST_BODYMEASURE_ID);
t0.setText(cursor.getString(0));
TextView t1 = view.findViewById(R.id.LIST_BODYMEASURE_DATE);
Date date =
DateConverter.DBDateStrToDate(cursor.getString(cursor.getColumnIndex(DAOBodyMeasure.DATE))
);
String dateStr = DateConverter.dateToLocalDateStr(date, mContext);
t1.setText(dateStr);
TextView t2 = view.findViewById(R.id.LIST_BODYMEASURE_WEIGHT);
t2.setText(t2Str);
int mFirstColorOdd = 0;
if (cursor.getPosition() % 2 == mFirstColorOdd) {
cdView.setCardBackgroundColor(context.getResources().getColor(R.color.record_background_even));
}
else {
cdView.setCardBackgroundColor(context.getResources().getColor(R.color.record_background_
odd));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return mInflater.inflate(R.layout.bodymeasure_row, parent, false);
}
19IT66C – MOBILE TECHNOLOGIES LABORATORY 5
NATIONAL ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY
2115035
ExerciseDetailsPagerFragment.java :
package com.easyfitness.machines;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import com.easyfitness.DAO.DAOMachine;
import com.easyfitness.DAO.DAOProfile;
import com.easyfitness.DAO.Machine;
import com.easyfitness.DAO.Profile;
import com.easyfitness.DAO.record.DAORecord;
import com.easyfitness.DAO.record.Record;
import com.easyfitness.MainActivity;
import com.easyfitness.R;
import com.easyfitness.fonte.FonteHistoryFragment;
import com.github.ivbaranov.mfb.MaterialFavoriteButton;
import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems;
import java.util.List;
/**
* Create a new instance of DetailsFragment, initialized to
* show the text at 'index'.
*/
public static ExerciseDetailsPager newInstance(long machineId, long machineProfile) {
ExerciseDetailsPager f = new ExerciseDetailsPager();
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (mViewPager.getAdapter() == null) {
getChildFragmentManager(), FragmentPagerItems.with(this.getContext())
mViewPager.setAdapter(pagerAdapter);
viewPagerTab = view.findViewById(R.id.exercise_pagertab);
viewPagerTab.setViewPager(mViewPager);
viewPagerTab.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
Fragment frag1 = pagerAdapter.getPage(position);
if (frag1 != null)
frag1.onHiddenChanged(false); // Refresh data
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
((MainActivity) getActivity()).getActivityToolbar().setVisibility(View.GONE);
top_toolbar = view.findViewById(R.id.actionToolbarMachine);
top_toolbar.setNavigationIcon(R.drawable.ic_back);
top_toolbar.setNavigationOnClickListener(onClickToolbarItem);
deleteButton = view.findViewById(R.id.deleteButton);
deleteButton.setOnClickListener(onClickToolbarItem);
favoriteButton = view.findViewById(R.id.favButton);
favoriteButton.setOnClickListener(v -> {
MaterialFavoriteButton mFav = (MaterialFavoriteButton) v;
boolean t = mFav.isFavorite();
mFav.setFavoriteAnimated(!t);
isFavorite = !t;
saveMachine();
});
favoriteButton.setFavorite(machine.getFavorite());
return view;
}
getExerciseFragment().requestForSave();
}
deleteDialogBuilder.setTitle(getActivity().getResources().getText(R.string.global_confirm));
deleteDialogBuilder.setMessage(getActivity().getResources().getText(R.string.deleteMachine_confirm_
text));
deleteDialogBuilder.setNegativeButton(this.getResources().getString(R.string.global_no), (dialog,
which) -> {
// Do nothing
dialog.dismiss();
});
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
19IT66C – MOBILE TECHNOLOGIES LABORATORY 9
NATIONAL ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY
2115035
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
// invoked when the activity may be temporarily destroyed, save the instance state here
@Override
public void onSaveInstanceState(Bundle outState) {
// call superclass to save any view hierarchy
super.onSaveInstanceState(outState);
}
@Override
public void onHiddenChanged(boolean hidden) {
if (!hidden) {
if (getViewPagerAdapter() != null) {
Fragment frag1;
OUTPUT:
RESULT:
Thus the mobile application for creating the fitness tracking application was
developed and executed successfully.