package com.twolf.stressball11; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import java.util.Random; import pl.droidsonroids.gif.GifTextView; /******************************************************************* * This Class is designed for the user to practice breathing techniques * This class is started once the button is clicked from main and will generate one of 2 giffs * based on a random number. This is one of the last classes I made I would like the user to have * the option to chose simple breathing or the more advanced breathing technique. * * Giffs are stored in the drawable file. * Lines simply is just a 5 second breathing technique where * the user simply breaths in and out. * * Balls is more advanced where the user breaths in as the expand hold their breath as it rotates * then breath out as the balls collapse back in. * * in the future a small tutorial and a countdown should be added. * * -Thomas Wolf * * Help from: http://stackoverflow.com/questions/6533942/adding-gif-image-in-an-imageview-in-android * for giff info */ public class Breath extends AppCompatActivity { GifTextView gtLines; GifTextView gtBalls; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_breath); Random r = new Random(); int i= r.nextInt(4);//generate random number gtLines = (GifTextView) findViewById(R.id.lines);//set the giffs to object gtBalls = (GifTextView) findViewById(R.id.balls); if (i % 2 == 0) { gtLines.setVisibility(View.INVISIBLE);//Depending on number make one visible gtBalls.setVisibility(View.VISIBLE); } else { gtLines.setVisibility(View.VISIBLE); gtBalls.setVisibility(View.INVISIBLE); } } }