diff --git a/homework/week-1/CheesyHoroscope2/.gitignore b/homework/week-1/CheesyHoroscope2/.gitignore new file mode 100644 index 00000000..ae3dd091 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.gitignore @@ -0,0 +1,9 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +*.dex +.log + diff --git a/homework/week-1/CheesyHoroscope2/.idea/.name b/homework/week-1/CheesyHoroscope2/.idea/.name new file mode 100644 index 00000000..ac51f394 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/.name @@ -0,0 +1 @@ +CheesyHoroscope2 \ No newline at end of file diff --git a/homework/week-1/CheesyHoroscope2/.idea/compiler.xml b/homework/week-1/CheesyHoroscope2/.idea/compiler.xml new file mode 100644 index 00000000..217af471 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/.idea/copyright/profiles_settings.xml b/homework/week-1/CheesyHoroscope2/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000..e7bedf33 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/homework/week-1/CheesyHoroscope2/.idea/encodings.xml b/homework/week-1/CheesyHoroscope2/.idea/encodings.xml new file mode 100644 index 00000000..e206d70d --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/homework/week-1/CheesyHoroscope2/.idea/gradle.xml b/homework/week-1/CheesyHoroscope2/.idea/gradle.xml new file mode 100644 index 00000000..736c7b5c --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/.idea/inspectionProfiles/Project_Default.xml b/homework/week-1/CheesyHoroscope2/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..fe9931d8 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/homework/week-1/CheesyHoroscope2/.idea/inspectionProfiles/profiles_settings.xml b/homework/week-1/CheesyHoroscope2/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..3b312839 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/homework/week-1/CheesyHoroscope2/.idea/misc.xml b/homework/week-1/CheesyHoroscope2/.idea/misc.xml new file mode 100644 index 00000000..91bdd025 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/misc.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + 1.7 + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/.idea/modules.xml b/homework/week-1/CheesyHoroscope2/.idea/modules.xml new file mode 100644 index 00000000..309b026a --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/.idea/scopes/scope_settings.xml b/homework/week-1/CheesyHoroscope2/.idea/scopes/scope_settings.xml new file mode 100644 index 00000000..922003b8 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/homework/week-1/CheesyHoroscope2/.idea/vcs.xml b/homework/week-1/CheesyHoroscope2/.idea/vcs.xml new file mode 100644 index 00000000..def6a6a1 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/CheesyHoroscope2.iml b/homework/week-1/CheesyHoroscope2/CheesyHoroscope2.iml new file mode 100644 index 00000000..0bb6048a --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/CheesyHoroscope2.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/.gitignore b/homework/week-1/CheesyHoroscope2/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/homework/week-1/CheesyHoroscope2/app/app.iml b/homework/week-1/CheesyHoroscope2/app/app.iml new file mode 100644 index 00000000..2f1065b0 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/app.iml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/build.gradle b/homework/week-1/CheesyHoroscope2/app/build.gradle new file mode 100644 index 00000000..60b33d67 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "abassawo.c4q.nyc.cheesyhoroscope2" + minSdkVersion 15 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.1.1' +} diff --git a/homework/week-1/CheesyHoroscope2/app/proguard-rules.pro b/homework/week-1/CheesyHoroscope2/app/proguard-rules.pro new file mode 100644 index 00000000..dcb04d2d --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/c4q-Abass/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/homework/week-1/CheesyHoroscope2/app/src/androidTest/java/abassawo/c4q/nyc/cheesyhoroscope2/ApplicationTest.java b/homework/week-1/CheesyHoroscope2/app/src/androidTest/java/abassawo/c4q/nyc/cheesyhoroscope2/ApplicationTest.java new file mode 100644 index 00000000..9e2918f7 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/androidTest/java/abassawo/c4q/nyc/cheesyhoroscope2/ApplicationTest.java @@ -0,0 +1,13 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/AndroidManifest.xml b/homework/week-1/CheesyHoroscope2/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..e36eb7e8 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/AstroDetail.java b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/AstroDetail.java new file mode 100644 index 00000000..3b9fdf63 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/AstroDetail.java @@ -0,0 +1,93 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.HashMap; + + +public class AstroDetail extends ActionBarActivity { + TextView title; + String zodiacSign; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_horoscope_detail); + + zodiacSign = getIntent().getStringExtra("zodiac_sign"); + + title = (TextView) findViewById(R.id.signTitle); + title.setText(zodiacSign); + + TextView tvDetail = (TextView) findViewById(R.id.zodiac_Detail); + ImageView zodiacImage =(ImageView) findViewById(R.id.zodiacImage); + + //Log.d("test log", "sign = " + zodiacSign); + + + String[] zodiacs = {"Aries", "Taurus", "Gemini", + "Cancer", "Leo", "Virgo", "Libra", "Scorpio", + "Sagittarius", "Capricorn", "Aquarius", "Pisces"}; + + + int[] zodiacDetails = {R.string.ariesDetail, + R.string.taurusDetail, + R.string.geminiDetail, + R.string.cancerDetail, + R.string.leoDetail, + R.string.virgoDetail, + R.string.libraDetail, + R.string.scorpioDetail, + R.string.sagittariusDetail, + R.string.capricornDetail, + R.string.aquariusDetail, + R.string.piscesDetail}; + + + HashMap signMap = new HashMap<>(); + + for (int i = 0; i < 12; i++) { + signMap.put(zodiacs[i],zodiacDetails[i]); + } + tvDetail.setText(signMap.get(zodiacSign)); //FIXME + + HashMap imageMap = new HashMap<>(); + Integer[] imagePaths = {R.drawable.ariestat, R.drawable.taurustat, R.drawable.geminitat, + R.drawable.cancertat, R.drawable.leotat, R.drawable.virgotat, R.drawable.libratat, + R.drawable.scorpiotat, R.drawable.sagittariustat, R.drawable.capricorntat, R.drawable.aquariustat, R.drawable.piscestat}; + + for (int i = 0; i < 12; i++) { + imageMap.put(zodiacs[i], imagePaths[i]); + } + + zodiacImage.setImageResource(imageMap.get(zodiacSign)); + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_horoscope_detail, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/AstroReading.java b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/AstroReading.java new file mode 100644 index 00000000..0b67c77a --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/AstroReading.java @@ -0,0 +1,88 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.HashMap; + + +public class AstroReading extends ActionBarActivity { + //private String astroSign; + TextView title; + TextView tvDetail; + ImageView zodiacImage; + String astroSign; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_astro_reading); + + astroSign = getIntent().getStringExtra("zodiac_obj"); + title = (TextView) findViewById(R.id.signTitle); + title.setText(astroSign); + + tvDetail = (TextView) findViewById(R.id.zodiac_Detail); + zodiacImage = (ImageView) findViewById(R.id.zodiacImage); + + + String[] zodiacs = {"Aries", "Taurus", "Gemini", + "Cancer", "Leo", "Virgo", "Libra", "Scorpio", + "Sagittarius", "Capricorn", "Aquarius", "Pisces"}; + + int[] zodiacDetails = + {R.string.ariesDetail, R.string.taurusDetail, R.string.geminiDetail, R.string.cancerDetail, + R.string.leoDetail, R.string.virgoDetail, R.string.libraDetail, R.string.scorpioDetail, + R.string.sagittariusDetail, R.string.capricornDetail, R.string.aquariusDetail, R.string.piscesDetail}; + + HashMap signMap = new HashMap<>(); + + for (int i = 0; i < 12; i++) { + signMap.put(zodiacs[i], zodiacDetails[i]); + } + tvDetail.setText(signMap.get(astroSign)); //FIXME + + HashMap imageMap = new HashMap<>(); + Integer[] imagePaths = {R.drawable.ariestat, R.drawable.taurustat, R.drawable.geminitat, + R.drawable.cancertat, R.drawable.leotat, R.drawable.virgotat, R.drawable.libratat, + R.drawable.scorpiotat, R.drawable.sagittariustat, R.drawable.capricorntat, R.drawable.aquariustat, R.drawable.piscestat}; + + for (int i = 0; i < 12; i++) { + imageMap.put(zodiacs[i], imagePaths[i]); + } + + zodiacImage.setImageResource(imageMap.get(astroSign)); + + + } + + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_astro_reading, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/HoroscopeGame.java b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/HoroscopeGame.java new file mode 100644 index 00000000..3ad697e0 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/HoroscopeGame.java @@ -0,0 +1,59 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.Toast; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.Random; +//todo: create date randomizer, method that stores date and evaluates the sign that corresponds with it, +//todo: use timer to add constraint to how long user has to guess the sign + +public class HoroscopeGame extends ActionBarActivity { + private Timer gameTimer; + private TimerTask guessTimerTask; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_horoscope_game); +// Random random = new Random(); + +// guessTimerTask = new TimerTask() { +// @Override +// public void run() { +// Toast wait = Toast.makeText(getApplicationContext(), "Guess a sign", Toast.LENGTH_LONG); +// +// } +// }; +//// gameTimer.scheduleAtFixedRate(); +// gameTimer.scheduleAtFixedRate(guessTimerTask , 15, 11); +// gameTimer = new Timer(); + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_horoscope_game, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/MainActivity.java b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/MainActivity.java new file mode 100644 index 00000000..3ccd233e --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/MainActivity.java @@ -0,0 +1,234 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + + +import android.content.Intent; +import android.content.res.Configuration; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.support.v7.app.ActionBarDrawerToggle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.DatePicker; +import android.widget.FrameLayout; +import android.widget.ListView; +import android.widget.Spinner; +import android.widget.Toast; + +import java.util.Calendar; + + +public class MainActivity extends ActionBarActivity + implements AdapterView.OnItemSelectedListener{ + + private ListView mDrawerList; + private ArrayAdapter mAdapter; + ActionBarDrawerToggle mDrawerToggle; + private DatePicker.OnDateChangedListener l; + private DrawerLayout mDrawerLayout; + private String mActivityTitle; + private Intent detailIntent = null; + private Intent astroIntent = null; + private Intent intent = null; + private String astroSign; + private Button astroButton; + //private Intent romance; + DatePicker picker; + private int month, day, year; + int zMonth, zDay, zYear; + private String[] mDrawerListItems; + private FrameLayout frameLayout; + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + setCurrentDateOnView(); + mActivityTitle = getTitle().toString(); + frameLayout = (FrameLayout)findViewById(R.id.content_frame); + mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); + mDrawerList = (ListView) findViewById(R.id.navList); + mDrawerListItems = getResources().getStringArray(R.array.navItems); + + mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, + R.string.drawer_open, R.string.drawer_close){ + /** Called when a drawer has settled in a completely open state. */ + + public void onDrawerOpened(View drawerView) { + super.onDrawerOpened(drawerView); + getSupportActionBar().setTitle("Return!"); + invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() + } + + /** Called when a drawer has settled in a completely closed state. */ + public void onDrawerClosed(View view) { + super.onDrawerClosed(view); + getSupportActionBar().setTitle(mActivityTitle); + invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() + } + + }; + mDrawerToggle.setDrawerIndicatorEnabled(true); + mDrawerLayout.setDrawerListener(mDrawerToggle); + +// addNavBar(); +// setupDrawer(); + Spinner spinner = (Spinner) findViewById(R.id.signs_spinner); + + + DatePicker picker = (DatePicker) findViewById(R.id.datePicker); + + astroIntent = new Intent(MainActivity.this, AstroReading.class); + Button button = (Button) findViewById(R.id.openButton); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + startActivity(detailIntent); + } + }); + addButtonListener(); + + + mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mDrawerListItems); + mDrawerList.setAdapter(mAdapter); + mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener(){ + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + switch(position){ + case 0: + mDrawerLayout.closeDrawer(mDrawerList); + break; + case 1: + intent = new Intent(MainActivity.this, ZodiacRomance.class); + Log.d("case 0", " " + getIntent()); + startActivity(intent); + //startActivity(intent); + mDrawerLayout.closeDrawer(mDrawerList); + break; + case 2: + intent = new Intent(MainActivity.this, HoroscopeGame.class); + Log.d("case 0", " " + getIntent()); + startActivity(intent); + // startActivity(intent); + mDrawerLayout.closeDrawer(mDrawerList); + + break; + } + //startActivity(intent); + + + } + }); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + + + } + public void setCurrentDateOnView(){ + picker = (DatePicker) findViewById(R.id.datePicker); + final Calendar c = Calendar.getInstance(); + year = c.get(Calendar.YEAR); + month = c.get(Calendar.MONTH); + day = c.get(Calendar.DAY_OF_MONTH); + picker.init(year, month, day, l); + } + + + + + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + // Sync the toggle state after onRestoreInstanceState has occurred. + mDrawerToggle.syncState(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + mDrawerToggle.onConfigurationChanged(newConfig); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + // Activate the navigation drawer toggle + if (mDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + + + + return super.onOptionsItemSelected(item); + } + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { //for searching by sign + String zodiacSign; + zodiacSign = parent.getItemAtPosition(position).toString(); //Get sign + Log.d("getItem", zodiacSign); + detailIntent = new Intent(MainActivity.this, AstroDetail.class); + detailIntent.putExtra("zodiac_sign", zodiacSign); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + + public void addButtonListener(){ //Button listener for Astrobutton (searching sign by bday) + astroButton = (Button) findViewById(R.id.astroButton); + astroButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + astroSign = Zodiac.getZodiacSign(month, day); + Log.d("month " , " " + zMonth); + Log.d("day ", " " + zDay); + astroIntent.putExtra("zodiac_obj", astroSign); + Log.d("astro sign", astroSign); + startActivity(astroIntent); + + } + }); +//For selecting zodiac sign by birthday + l = new DatePicker.OnDateChangedListener(){ + @Override + public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { + zYear = year; + month = monthOfYear; + day= dayOfMonth; + Log.d("day " , "day " + zDay); + picker.init(zYear, month, day, l); + } + }; + + } +} + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/Zodiac.java b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/Zodiac.java new file mode 100644 index 00000000..6fb9a657 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/Zodiac.java @@ -0,0 +1,104 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + + +import java.util.ArrayList; + + + +/** + * Created by c4q-Abass on 5/14/15. + */ +public class Zodiac { + public String getName() { + return name; + } + + private String name, horoscopeDetail; + + private ArrayListcompatibles; + + + public Zodiac(String name){ + this.name = name; + } + + public ArrayList getCompatibles() { + return this.compatibles; + } + + public void addRomanceMatch(Zodiac x) { + this.compatibles.add(x); + } + + public void unMatchSign(Zodiac x){ + this.compatibles.remove(x); + } + + + //private static String[] zodiacSigns = {"Capricorn", "Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius"}; +// gemini.getName(), cancer.getName(), leo.getName(), virgo.getName(), libra.getName(), scorpio.getName(), sagittarius.getName()}; + + + public Zodiac(String name, String horoscopeDetail){ + this.name = name; + this.horoscopeDetail = horoscopeDetail; + } + public String getHoroscopeDetail() { + return horoscopeDetail; + } + + public static Zodiac aries = new Zodiac("Aries", " " + " "); + public static Zodiac taurus = new Zodiac("Taurus", "" + " "); + public static Zodiac gemini = new Zodiac("Gemini", "" + " "); + public static Zodiac cancer = new Zodiac("Cancer", "" + " "); + public static Zodiac leo = new Zodiac("Leo", " "); + public static Zodiac virgo = new Zodiac("Virgo", "" + " "); + public static Zodiac libra = new Zodiac("Libra", "" + R.string.libraDetail); + public static Zodiac scorpio = new Zodiac("Scorpio", "" + R.string.scorpioDetail ); + public static Zodiac sagittarius = new Zodiac("Sagittarius", "" + R.string.sagittariusDetail); + public static Zodiac capricorn = new Zodiac("Capricorn", "" + ""); + public static Zodiac aquarius = new Zodiac("Aquarius", "" + " " ); + public static Zodiac pisces = new Zodiac("Pisces", "" + " "); + private static String[] zodiacSigns = {capricorn.getName(), aquarius.getName(), pisces.getName(), aries.getName(), taurus.getName(), + gemini.getName(), cancer.getName(), leo.getName(), virgo.getName(), libra.getName(), scorpio.getName(), sagittarius.getName()}; //in Chronological Order. + + + int month, day; + + public static boolean isCompatible(String zodiacsign1, String zodiacSign2){ + boolean isCompat = false; //fixme + return isCompat; + } + public static String getZodiacSign(int month, int day){ + if((month == 11 && day>= 22) || (month == 0 && day <= 19)) { + return zodiacSigns[0]; //Capricorn + }else if((month == 0 && day >= 20) || (month == 1 && day <= 18)) { + return zodiacSigns[1]; //Aquarius + } else if((month == 1 && day >= 19) || (month == 2 && day <= 20)) { + return zodiacSigns[2]; //Pisces + } else if((month == 2 && day >= 21) || (month == 3 && day <= 19)) { + return zodiacSigns[3]; //Aries + } else if((month == 3 && day >= 20) || (month == 4 && day <= 20)) { + return zodiacSigns[4]; //Taurus + } else if((month == 4 && day >= 21) || (month == 5 && day <= 20)) { + return zodiacSigns[5]; //Gemini + } else if((month == 5 && day >= 21) || (month == 6 && day <= 22)) { + return zodiacSigns[6]; //Cancer + } else if((month == 6 && day >= 23) || (month == 7 && day <= 22)) { + return zodiacSigns[7]; //Leo` + } else if((month == 7 && day >= 23) || (month == 8 && day <= 21)) { + return zodiacSigns[8]; //Virgo + } else if((month == 8 && day >= 22) || (month == 9 && day <= 21)) { + return zodiacSigns[9]; //Libra + } else if((month == 9 && day >= 24) || (month == 10 && day <= 22)) { + return zodiacSigns[10]; //Scorpio + } else if((month == 10 && day >= 23) || (month == 11 && day <= 21)) { + return zodiacSigns[11]; //Sagittarius + } + else { + return null; + } + } + + +} diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/ZodiacRomance.java b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/ZodiacRomance.java new file mode 100644 index 00000000..0084e76f --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/java/abassawo/c4q/nyc/cheesyhoroscope2/ZodiacRomance.java @@ -0,0 +1,123 @@ +package abassawo.c4q.nyc.cheesyhoroscope2; + +import android.content.Intent; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.Spinner; + +import java.util.ArrayList; + + +public class ZodiacRomance extends ActionBarActivity { + + private ArrayList compatibles; + private Spinner.OnClickListener l; + private Intent compatIntent; + private String zodiacSign1; + private String zodiacSign2; + + //hashmap w. key - zodiac sign, and v - array of other zodiac signs + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_zodiac_romance); + + Spinner spinner1 = (Spinner) findViewById(R.id.signs_spinner); + Spinner spinner2 = (Spinner) findViewById(R.id.signs_spinner2); + + spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + zodiacSign1 = parent.getItemAtPosition(position).toString(); + //compatIntent. + //STORE STRING CHOSEN AND MAKE NEW ZODIAC OBJECT + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + zodiacSign2 = parent.getItemAtPosition(position).toString(); + //STORE STRING CHOSEN AND MAKE NEW ZODIAC OBJECT + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + + + + l = new View.OnClickListener(){ //main search button + @Override + public void onClick(View v) { + //todo Check if both objects are compatible + } + }; + //aries.addRomanceMatch(cancer); + // parse sign from both dropdowns. +// if (compatible){ +// +// } + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_zodiac_romance, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + public boolean isCompatibile(Zodiac x, Zodiac y){ + boolean compatible = false; + return compatible; + } + + + + Zodiac aries = new Zodiac("Aries"); + Zodiac taurus = new Zodiac("Taurus"); + Zodiac gemini = new Zodiac("Gemini"); + Zodiac cancer = new Zodiac("Cancer"); + Zodiac leo = new Zodiac("Leo"); + Zodiac virgo = new Zodiac("Virgo"); + Zodiac libra = new Zodiac("Libra"); + Zodiac scorpio = new Zodiac("Scorpio"); + Zodiac sagittarius = new Zodiac("Sagittarius"); + Zodiac capricorn = new Zodiac("Capricorn"); + Zodiac aquarius = new Zodiac("Aquarius"); + Zodiac pisces = new Zodiac("Pisces"); + + + +} + + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/aquariustat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/aquariustat.jpg new file mode 100755 index 00000000..20d9f231 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/aquariustat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/ariestat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/ariestat.jpg new file mode 100755 index 00000000..9e1e615e Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/ariestat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/cancertat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/cancertat.jpg new file mode 100755 index 00000000..7a56fa09 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/cancertat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/capricorntat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/capricorntat.jpg new file mode 100755 index 00000000..ef346bfa Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/capricorntat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/geminitat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/geminitat.jpg new file mode 100755 index 00000000..f8495880 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/geminitat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/leotat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/leotat.jpg new file mode 100755 index 00000000..e7245622 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/leotat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/libratat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/libratat.jpg new file mode 100755 index 00000000..1a93dfca Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/libratat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/piscestat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/piscestat.jpg new file mode 100755 index 00000000..3b312ef7 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/piscestat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/sagittariustat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/sagittariustat.jpg new file mode 100755 index 00000000..85b32882 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/sagittariustat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/scorpiotat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/scorpiotat.jpg new file mode 100755 index 00000000..b85d48b4 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/scorpiotat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/taurustat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/taurustat.jpg new file mode 100755 index 00000000..a8de543a Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/taurustat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/virgotat.jpg b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/virgotat.jpg new file mode 100755 index 00000000..88e8417e Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/virgotat.jpg differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/zodiacsignstocrop.gif b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/zodiacsignstocrop.gif new file mode 100644 index 00000000..872a5045 Binary files /dev/null and b/homework/week-1/CheesyHoroscope2/app/src/main/res/drawable/zodiacsignstocrop.gif differ diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_astro_detail.xml b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_astro_detail.xml new file mode 100644 index 00000000..a4db0815 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_astro_detail.xml @@ -0,0 +1,59 @@ + + + + // Resources res = getResources(); + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_astro_reading.xml b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_astro_reading.xml new file mode 100644 index 00000000..0fb601d8 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_astro_reading.xml @@ -0,0 +1,67 @@ + + + + + tools:context="abassawo.c4q.nyc.cheesyhoroscope.AstroReading"> + + + + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_horoscope_detail.xml b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_horoscope_detail.xml new file mode 100644 index 00000000..aa892a29 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_horoscope_detail.xml @@ -0,0 +1,64 @@ + + + tools:context="abassawo.c4q.nyc.cheesyhoroscope.HoroscopeDetail"> + + + + // Resources res = getResources(); + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_horoscope_game.xml b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_horoscope_game.xml new file mode 100644 index 00000000..76196b59 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_horoscope_game.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_main.xml b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..af142f59 --- /dev/null +++ b/homework/week-1/CheesyHoroscope2/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + +