Android Open Source - Android-Project-Manager Main Activity






From Project

Back to project page Android-Project-Manager.

License

The source code is released under:

GNU General Public License

If you think the Android project Android-Project-Manager 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 com.vaquerosisd.projectmanager;
/*  ww  w  . ja va 2 s  . c  o m*/
import java.util.Timer;
import java.util.TimerTask;

import com.vaquerosisd.object.JsonWrapper;
import com.vaquerosisd.object.User;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.widget.TextView;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;

public class MainActivity extends Activity implements WebserviceCallback {

  private long splashDelayOnline = 600;
  private long splashDelayOffline = 600;
  
  static private final int LOGIN = 0;
  static private final int CREATE = 1;
  
  private User currentUser;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    //Set font to the project manager title
    TextView title = (TextView) findViewById(R.id.title);
    Typeface typefaceTitle = Typeface.createFromAsset(getAssets(), "fonts/RODUScut100.otf");
    title.setTypeface(typefaceTitle);
    
    currentUser = User.getUser(MainActivity.this);
    
    TimerTask task = new TimerTask() {
        @Override
        public void run() {
          if(currentUser != null)
          {
            Intent intent = new Intent(MainActivity.this, ProjectList.class);
                startActivity(intent);
                finish();
          }
          else
          {
            Intent intent = new Intent(MainActivity.this, Login.class);
                startActivityForResult(intent, LOGIN);
          }
        }
      };
    
    //Check is Internet connection is available in order to pull sync data
    if(isNetworkAvailable() == true) {
      
      Timer timer = new Timer();
        timer.schedule(task, splashDelayOnline); //Dispatch task at 6 seconds
    } else {
      Timer timer = new Timer();
        timer.schedule(task, splashDelayOffline); //Dispatch task at 6 seconds
    }
  }
  
  @Override
  public void callback(JsonWrapper jw) {
    currentUser = User.getUser(MainActivity.this);
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == LOGIN || requestCode == CREATE)
    {
      if(resultCode == RESULT_OK)
      {
        currentUser = User.getUser(MainActivity.this);
        
        if(currentUser != null)
        {
          Intent intent = new Intent(MainActivity.this, ProjectList.class);
                startActivity(intent);
                finish();
        }
      }
      else if(resultCode == RESULT_CANCELED)
      {
        if(data.getBooleanExtra("LogIn", false))
        {
          Intent intent = new Intent(MainActivity.this, Login.class);
                startActivityForResult(intent, LOGIN);
        }
        else if(data.getBooleanExtra("Create", false))
        {
          Intent intent = new Intent(MainActivity.this, NewAccount.class);
                startActivityForResult(intent, CREATE);
        }
      }
    }
  }
  
  //Check if device is connected to Internet
  private boolean isNetworkAvailable() {
      ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
      return activeNetworkInfo != null && activeNetworkInfo.isConnected();
  }
}




Java Source Code List

com.vaquerosisd.adapters.ProjectListViewAdapter.java
com.vaquerosisd.adapters.TaskListViewAdapter.java
com.vaquerosisd.adapters.VideoNoteGridViewAdapter.java
com.vaquerosisd.adapters.VoiceNoteGridViewAdapter.java
com.vaquerosisd.database.DatabaseHelper.java
com.vaquerosisd.database.ProjectOperations.java
com.vaquerosisd.dialog.CustomStatus.java
com.vaquerosisd.dialog.DatePickerFragment.java
com.vaquerosisd.dialog.DeleteDialog.java
com.vaquerosisd.dialog.DeletePhotoDialog.java
com.vaquerosisd.dialog.DeleteTaskDialog.java
com.vaquerosisd.dialog.EditProject.java
com.vaquerosisd.fragments.TaskDescriptionFragment.java
com.vaquerosisd.fragments.VideoNotesFragment.java
com.vaquerosisd.fragments.VoiceNotesFragment.java
com.vaquerosisd.object.JsonWrapper.java
com.vaquerosisd.object.PhotoRef.java
com.vaquerosisd.object.Project.java
com.vaquerosisd.object.Task.java
com.vaquerosisd.object.User.java
com.vaquerosisd.object.WebServiceManager.java
com.vaquerosisd.projectmanager.About.java
com.vaquerosisd.projectmanager.ContentTask.java
com.vaquerosisd.projectmanager.Login.java
com.vaquerosisd.projectmanager.MainActivity.java
com.vaquerosisd.projectmanager.NewAccount.java
com.vaquerosisd.projectmanager.NewProject.java
com.vaquerosisd.projectmanager.NewTask.java
com.vaquerosisd.projectmanager.OnSwipeListener.java
com.vaquerosisd.projectmanager.PhotoManager.java
com.vaquerosisd.projectmanager.ProjectList.java
com.vaquerosisd.projectmanager.TaskList.java
com.vaquerosisd.projectmanager.WebserviceCallback.java
com.vaquerosisd.utils.FileOperations.java
com.vaquerosisd.utils.OnSwipeListener.java
com.vaquerosisd.utils.SpinnerUtil.java
com.vaquerosisd.utils.TabListener.java