Android Open Source - Sortr Session Page






From Project

Back to project page Sortr.

License

The source code is released under:

Apache License

If you think the Android project Sortr 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.brownapps.sortr.pages;
//from  w w w .j ava  2s  .c o m
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import com.brownapps.sortr.R;
import com.brownapps.sortr.data.DataLayer;
import com.brownapps.sortr.data.GeneratedTeams;
import com.brownapps.sortr.utility.Consts;
import com.brownapps.sortr.utility.Logging;
import com.brownapps.sortr.utility.SortedGroupAdapter;

public class SessionPage extends Activity {
  
  private long sessionId = -1;
  private GeneratedTeams session;
  private DataLayer layer;
  private Button emailListButton;
  
  private ListView sortedList;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.session_page);
    
    sortedList = (ListView) findViewById(R.id.team_list);
    emailListButton = (Button) findViewById(R.id.email_list);
    
    layer = new DataLayer(this);
    
    try{
      sessionId = getIntent().getExtras().getLong(Consts.SESSION_ID);    
    }catch(Exception e){
      Logging.LogDebugError("SessionPage", e);
    }
    
    if(sessionId != -1){
      session = layer.getGeneratedTeam(sessionId);
      
      sortedList.setAdapter(new SortedGroupAdapter(this, R.layout.clickable_item, session.getGroupableObject()));
    }
    
    emailListButton.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("text/html");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sorted Teams");
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(session.getAsHtml()));
        startActivity(Intent.createChooser(emailIntent, "Email to..."));
      }
    });
  }

  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle item selection
      switch (item.getItemId()) {
      case R.id.menu_purchase_app:
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=com.brownapps.sortr.payed"));
        startActivity(intent);
        return true;
      }
      return false;
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
  }
  
}




Java Source Code List

com.brownapps.sortr.data.ClickableItem.java
com.brownapps.sortr.data.DataLayer.java
com.brownapps.sortr.data.GeneratedTeams.java
com.brownapps.sortr.data.PlayerList.java
com.brownapps.sortr.data.TeamNames.java
com.brownapps.sortr.data.Team.java
com.brownapps.sortr.pages.MainActivity.java
com.brownapps.sortr.pages.PersonsListPage.java
com.brownapps.sortr.pages.SessionPage.java
com.brownapps.sortr.pages.SortrPage.java
com.brownapps.sortr.pages.TeamsPage.java
com.brownapps.sortr.utility.ClickableItemAdapter.java
com.brownapps.sortr.utility.Consts.java
com.brownapps.sortr.utility.IGroupableObject.java
com.brownapps.sortr.utility.Logging.java
com.brownapps.sortr.utility.SimpleStringAdapter.java
com.brownapps.sortr.utility.SortedGroupAdapter.java