Add original project.
This commit is contained in:
1 parent
b3c2fb7e6a
commit
e02d5ef761
66 files changed
+3195
No files matched your search
+100
@@ -0,0 +1,100 @@
|
||||
package com.hyperling.carbupbeta;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
public class Home extends AppCompatActivity {
|
||||
|
||||
Resources recs;
|
||||
|
||||
Button btnCarbCalc, btnCalcHelp, btnWhyHCLF, btnWhyVegan;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up variables
|
||||
recs = getResources();
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up views
|
||||
btnCarbCalc = (Button) findViewById(R.id.btnCarbCalc);
|
||||
btnCalcHelp = (Button) findViewById(R.id.btnCalcHelp);
|
||||
btnWhyHCLF = (Button) findViewById(R.id.btnWhyHCLF);
|
||||
btnWhyVegan = (Button) findViewById(R.id.btnWhyVegan);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Set up button click listeners
|
||||
btnCarbCalc.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Home.this, Main.class));
|
||||
}
|
||||
});
|
||||
|
||||
btnCalcHelp = (Button) findViewById(R.id.btnCalcHelp);
|
||||
|
||||
btnWhyHCLF = (Button) findViewById(R.id.btnWhyHCLF);
|
||||
|
||||
btnWhyVegan = (Button) findViewById(R.id.btnWhyVegan);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Finally, load ads >:)
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
// Load an ad into the AdMob banner view.
|
||||
AdView adView = (AdView) findViewById(R.id.adViewHome);
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("C6A494DC6E7C9AC29102694D48487084") // nexus 7
|
||||
.addTestDevice("B8B7561B850A9AB24E0D5B560FC50628") // Moto G
|
||||
.addTestDevice("") // Cappy, even though it doesn't support ads
|
||||
.setRequestAgent("android_studio:ad_template")
|
||||
.build();
|
||||
adView.loadAd(adRequest);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@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_home, 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();
|
||||
|
||||
if (id == R.id.action_exit) {
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user