Android Open Source - infinitep Main Activity






From Project

Back to project page infinitep.

License

The source code is released under:

Apache License

If you think the Android project infinitep listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package es.daconstenla.infinip.activity;
//w  w w .ja  v  a2  s .  c  om
import java.util.Random;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import es.daconstenla.infinip.R;
import es.daconstenla.infinip.R.id;
import es.daconstenla.infinip.R.layout;
import es.daconstenla.infinip.R.menu;
import es.daconstenla.infinip.customcomponents.HorizontalGraph;
import es.daconstenla.infinip.customcomponents.pieces.data.ColorMyCustom;

public class MainActivity extends Activity {

  private static String POS = "position";
  //private SelectorColor ctlColor;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR); // Add this line
        setContentView(R.layout.activity_main);
        if( getActionBar() != null){
          ActionBar actionBar = getActionBar();
          actionBar.show();
        }else
          Log.d("oh","ss null :o");
        //Resources res = getResources();
        
        float tempF = 0;
        if(savedInstanceState != null && savedInstanceState.containsKey(POS))
          tempF = (Float) savedInstanceState.get(POS);
        else
          tempF = 0;

        final HorizontalGraph graph = (HorizontalGraph) this.findViewById(R.id.HorizontalBar);

        int tempMax = 5000;
        float tempVal = 0;
        int tempVal2 = 0;
        int tempVal2_a = 0;
        Random r = new Random();
        //Log.v("init"," add data");
    while( tempMax > 0 ){
      
          tempVal = r.nextInt(500);
          tempMax -= tempVal;
          tempVal2_a = tempVal2;
          while( tempVal2 == tempVal2_a ) tempVal2 = r.nextInt(6);
          
          switch(tempVal2){
            case 1: graph.addItem(String.valueOf(tempVal+tempMax),tempVal,ColorMyCustom.COLOR_SLEEP_DEEP); break;
            case 2: graph.addItem(String.valueOf(tempVal+tempMax),tempVal,ColorMyCustom.COLOR_SLEEP_LIGHT); break;
            case 3: graph.addItem(String.valueOf(tempVal+tempMax),tempVal,ColorMyCustom.COLOR_EXERCISE_HEAVY); break;
            case 4: graph.addItem(String.valueOf(tempVal+tempMax),tempVal,ColorMyCustom.COLOR_EXERCISE_LIGHT); break;
            case 5: graph.addItem(String.valueOf(tempVal+tempMax),tempVal,ColorMyCustom.COLOR_NOT_MOVING_COMPUTER); break;
            case 6: graph.addItem(String.valueOf(tempVal+tempMax),tempVal,ColorMyCustom.COLOR_NOT_MOVING); break;
          }
          //Log.v("init"," add data "+tempMax);
        }
        
    //Log.v("init"," add hours");
    for(int i = 0 ; i < 25 ; i++){
          if(i<10) graph.addHour("0"+String.valueOf(i));
          else graph.addHour(String.valueOf(i));
        }
    
    graph.setGraphPosition(tempF);
          
    }

    private void launchCalendarActivity(){
      Intent calendarIntent = new Intent().setClass(MainActivity.this, CalendarActivity.class);
    startActivity(calendarIntent);
    }
    
    private void launchRangeDateActivity(){
      Intent rangeDateIntent = new Intent().setClass(MainActivity.this, RangeActivity.class);
      startActivity(rangeDateIntent);
    }
    
    private void launchSyncActivity(){
      Intent syncDateIntent = new Intent().setClass(MainActivity.this, SyncActivity.class);
      startActivity(syncDateIntent);
    }
        
    private void launchSettingsActivity(){
      Intent settingsIntent = new Intent().setClass(MainActivity.this, SettingsActivity.class);
      startActivity(settingsIntent);
    }
    
    

    @Override
    protected void onSaveInstanceState(Bundle outState) {
      outState.putFloat(POS, ((HorizontalGraph) this.findViewById(R.id.HorizontalBar)).getGraphPosition());
      super.onSaveInstanceState(outState);
      //Log.v("onSaveInstanceState" , " saved state? :O");
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
          case R.id.settings_settings:
            launchSettingsActivity();
            return true;
          case R.id.settings_calendar:
            launchCalendarActivity();
            return true;
          case R.id.settings_range:
            launchRangeDateActivity();
            return true;
          case R.id.settings_sync:
            launchSyncActivity();
            return true;
        
        default:
            return super.onOptionsItemSelected(item);
        }
    }
    
}




Java Source Code List

com.example.databasetest.FullscreenActivity.java
com.example.databasetest.util.SystemUiHiderBase.java
com.example.databasetest.util.SystemUiHiderHoneycomb.java
com.example.databasetest.util.SystemUiHider.java
com.example.datatest.MainActivity.java
com.example.datatest.database.InfinitepHelper.java
com.example.datatest.database.MovementRaw.java
com.example.datatest.database.MovementSummary.java
com.example.datatest.database.TableMovementRaw.java
com.example.datatest.database.TableMovementSummary.java
com.example.datatest.databaseTest.DatabaseTester.java
com.example.datatest.util.Utils.java
es.daconstenla.infinip.activity.CalendarActivity.java
es.daconstenla.infinip.activity.DayActivity.java
es.daconstenla.infinip.activity.MainActivity.java
es.daconstenla.infinip.activity.RangeActivity.java
es.daconstenla.infinip.activity.SettingsActivity.java
es.daconstenla.infinip.activity.SplashActivity.java
es.daconstenla.infinip.activity.SyncActivity.java
es.daconstenla.infinip.customcomponents.HorizontalGraph.java
es.daconstenla.infinip.customcomponents.InformationBox.java
es.daconstenla.infinip.customcomponents.MonthFragmentTest.java
es.daconstenla.infinip.customcomponents.MonthFragment.java
es.daconstenla.infinip.customcomponents.MonthView.java
es.daconstenla.infinip.customcomponents.MyFragmentMonthAdapter.java
es.daconstenla.infinip.customcomponents.events.OnSwipeTouchListener.java
es.daconstenla.infinip.customcomponents.pieces.ElementBackground.java
es.daconstenla.infinip.customcomponents.pieces.HorGraphBar.java
es.daconstenla.infinip.customcomponents.pieces.ItemCalendarDay.java
es.daconstenla.infinip.customcomponents.pieces.data.BarElementData.java
es.daconstenla.infinip.customcomponents.pieces.data.ColorMyCustom.java
es.daconstenla.infinip.customcomponents.pieces.data.CustomScrollView.java
es.daconstenla.infinip.customcomponents.pieces.data.ItemHorizontalBar.java
es.daconstenla.infinip.database.InfinitepHelper.java
es.daconstenla.infinip.database.MovementRaw.java
es.daconstenla.infinip.database.MovementSummary.java
es.daconstenla.infinip.database.TableMovementRaw.java
es.daconstenla.infinip.database.TableMovementSummary.java
es.daconstenla.infinip.database.utils.Utils.java
es.daconstenla.infinip.unused.AutoResizeTextView.java