Android Open Source - binghamton_svc About Adapter






From Project

Back to project page binghamton_svc.

License

The source code is released under:

MIT License

If you think the Android project binghamton_svc 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.github.chrzhang;
/*from   w w w.ja  v a 2s  .  c om*/
import Parsers.GetMembershipInfo;
import Parsers.GetMissionStatement;
import Parsers.GetVolunteerHours;
import android.content.Context;
import android.graphics.Typeface;
import android.os.StrictMode;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

/**
 * An adapter to manage the drop-expandable sub-sections of the About tab.
 * @author Christopher Zhang
 */
public class AboutAdapter extends BaseExpandableListAdapter 
{
  private Context context;
  private String[] parentList;
  private String[][] childList;
  
  public void initialize() 
  {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build();  
    StrictMode.setThreadPolicy(policy);
    
    GetMissionStatement getMS = new GetMissionStatement();
    GetMembershipInfo getMI = new GetMembershipInfo();
    GetVolunteerHours getVH = new GetVolunteerHours();
    
    String missionStatement = "No Internet connection.";
    String membershipInfo = "No Internet connection.";
    String volunteerHours = "No Internet connection.";
    String eboard ="See Contact Tab";
    
    try 
    {
      missionStatement = getMS.getInternetData();    
      membershipInfo = getMI.getInternetData();
      volunteerHours = getVH.getInternetData();
    } 
    catch (Exception e) 
    {
      e.printStackTrace();
    }
    
    parentList = new String[]{"Mission Statement", "Membership", "Volunteer Hours", "Current Executive Board"};
    childList = new String[][]
    {
        {
          missionStatement
        },
        {
          membershipInfo
        },
        {
          volunteerHours
        },
        {
          eboard
        }
    };
  }

  public AboutAdapter(Context c) 
  {
    initialize();
    context = c;
  }

  @Override
  public Object getChild(int arg0, int arg1) 
  {
    return null;
  }

  @Override
  public long getChildId(int arg0, int arg1) 
  {
    return 0;
  }

  @Override
  public View getChildView(int groupPosition, int childPosition,
      boolean isLastChild, View convertView, ViewGroup parent) 
  {
    TextView tv = new TextView(context);
    tv.setText(Html.fromHtml(childList[groupPosition][childPosition]));
    tv.setPadding(80, 10, 10, 10);
    tv.setTextSize(17);
    return tv;
  }

  @Override
  public int getChildrenCount(int groupPosition) 
  {
    return childList[groupPosition].length;
  }

  @Override
  public Object getGroup(int groupPosition) 
  {
    return groupPosition;
  }

  @Override
  public int getGroupCount() 
  {
    return parentList.length;
  }

  @Override
  public long getGroupId(int groupPosition) 
  {
    return groupPosition;
  }

  @Override
  public View getGroupView(int groupPosition, boolean isExpanded,
      View convertView, ViewGroup parent) 
  {
    TextView tv = new TextView(context);
    tv.setText(parentList[groupPosition]);
    tv.setPadding(50, 10, 10, 10);
    tv.setTextSize(30);
    tv.setTypeface(null, Typeface.BOLD);
    return tv;
  }

  @Override
  public boolean hasStableIds() 
  {
    return false;
  }

  @Override
  public boolean isChildSelectable(int groupPosition, int childPosition) 
  {
    return true;
  }
}




Java Source Code List

Fragments.AboutSectionFragment.java
Fragments.ContactSectionFragment.java
Fragments.EventsSectionFragment.java
Fragments.IsOnlineDialogFragment.java
Fragments.LaunchpadSectionFragment.java
Fragments.SignupSectionFragment.java
Parsers.GetEBoard.java
Parsers.GetMembershipInfo.java
Parsers.GetMissionStatement.java
Parsers.GetVolunteerHours.java
com.github.chrzhang.AboutAdapter.java
com.github.chrzhang.MainActivity.java
com.github.chrzhang.SplashScreen.java