package com.dhbw.lh.gymmemore;

import android.content.Intent;
import android.graphics.Point;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Display;
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.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;

import com.dhbw.lh.Controler.TrainingsplanActivity;

public class MainActivity extends AppCompatActivity {

    private Button trainBtn;
    private Button planBtn;
    private Button createBtn;
    private ImageButton cameraBtn;

    private Spinner dynamicSpinner;
    Typeface font;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        font = Typeface.createFromAsset(this.getAssets(), "fonts/minimal.otf");

        trainBtn= (Button)findViewById(R.id.train);
        planBtn=(Button)findViewById(R.id.manage);
        createBtn=(Button)findViewById(R.id.create);
        cameraBtn=(ImageButton)findViewById(R.id.camera);
        dynamicSpinner  = (Spinner) findViewById(R.id.dynamic_spinner);

        trainBtn.setTypeface(font);
        planBtn.setTypeface(font);
        createBtn.setTypeface(font);


        trainBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent= new Intent(MainActivity.this, Train.class);
                startActivity(intent);
            }
        });

        planBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, TrainingsplanActivity.class);
                startActivity(intent);
            }
        });

        createBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Intent intent = new Intent(MainActivity.this, Uebung.class);
                //startActivity(intent);
            }
        });


        cameraBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, Camera.class);
                startActivity(intent);
            }
        });


        createDropdownMenue();
    }

    @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;
        }

        return super.onOptionsItemSelected(item);
    }

    private void createDropdownMenue() {

        String[] items = new String[] { "Plan 1", "Push Pull", "3er Split" };

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_layout, items)
        {
            public View getView(int position, View convertView, android.view.ViewGroup parent) {
                TextView v = (TextView) super.getView(position, convertView, parent);
                v.setTypeface(font);
                return v;
            }


        };


        adapter.setDropDownViewResource(R.layout.spinner_item_layout);
        int offset = getDisplayHeight() / 25;
        dynamicSpinner.setDropDownVerticalOffset(offset);


        dynamicSpinner.setAdapter(adapter);

        dynamicSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                Log.v("item", (String) parent.getItemAtPosition(position));
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                // TODO Auto-generated method stub
            }
        });
    }

    private int getDisplayHeight(){
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);

        return size.y;
    }

}

@@ -3844,17 +3844,16 @@
     %7D;%0A%0A
-%0A
         
@@ -3919,113 +3919,8 @@
 t);%0A
-        int offset = getDisplayHeight() / 25;%0A        dynamicSpinner.setDropDownVerticalOffset(offset);%0A%0A
 %0A   
@@ -4440,205 +4440,6 @@
   %7D%0A
-%0A    private int getDisplayHeight()%7B%0A        Display display = getWindowManager().getDefaultDisplay();%0A        Point size = new Point();%0A        display.getSize(size);%0A%0A        return size.y;%0A    %7D%0A%0A
 %7D%0A

Test Whack