Android Open Source - welcome-android Home Fragment






From Project

Back to project page welcome-android.

License

The source code is released under:

Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software")...

If you think the Android project welcome-android 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.feedhenry.android.fragments;
/*from  w w w . j a  va  2s  .  c  om*/
import android.app.Activity;
import android.app.Fragment;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.feedhenry.android.R;

public class HomeFragment extends Fragment implements OnClickListener {

  // TODO Set state selector for buttons
  
  OnOptionSelectedListener mCallback;
  private View rootView;

  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_home, container, false);
    initUI();
    return rootView;
  }

  
  private void initUI() {
    
    // TODO Possible Memory Issues Here creating new instances of font
    Typeface font = Typeface.createFromAsset(getActivity()
        .getApplicationContext().getAssets(),
        "fonts/fontawesome-webfont.ttf");
    
    Button cloudButton = (Button) rootView.findViewById(R.id.cloud_btn);
    cloudButton.setTypeface(font);
    cloudButton.setOnClickListener(this);
    Button exampleButton = (Button) rootView.findViewById(R.id.example_btn);
    exampleButton.setTypeface(font);
    exampleButton.setOnClickListener(this);
    Button dataBrowserButton = (Button) rootView.findViewById(R.id.data_browser_btn);
    dataBrowserButton.setTypeface(font);
    dataBrowserButton.setOnClickListener(this);
    Button pushButton = (Button) rootView.findViewById(R.id.push_btn);
    pushButton.setTypeface(font);
    pushButton.setOnClickListener(this);
  }

  
  @Override
  public void onClick(View view) {
    int selected = 0;
    switch(view.getId()) {
    case R.id.cloud_btn:  
      selected = 0;
            break;
    case R.id.push_btn:  
      selected = 1;
            break;
    case R.id.example_btn:  
      selected = 2;
      break;
    case R.id.data_browser_btn:  
      selected = 3;
      break;
    }
    mCallback.onOptionSelected(selected);
  }
  
  
  @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            mCallback = (OnOptionSelectedListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement OnOptionSelectedListener");
        }
    }
  
  
  public interface OnOptionSelectedListener {
        public void onOptionSelected(int selection);
    }
}




Java Source Code List

com.feedhenry.android.MainActivity.java
com.feedhenry.android.MyApplication.java
com.feedhenry.android.drawer.adapter.NavDrawerListAdapter.java
com.feedhenry.android.drawer.model.NavDrawerItem.java
com.feedhenry.android.fragments.CallCloudFragment.java
com.feedhenry.android.fragments.CloudIntegrationsFragment.java
com.feedhenry.android.fragments.DataBrowserFragment.java
com.feedhenry.android.fragments.HomeFragment.java
com.feedhenry.android.fragments.LocationFragment.java
com.feedhenry.android.fragments.NativeAppInfoFragment.java
com.feedhenry.android.fragments.PushNotificationsFragment.java
com.feedhenry.android.fragments.StatsFragment.java
com.feedhenry.android.server.FHAgent.java
com.feedhenry.android.utilities.KeyboardToggle.java
com.feedhenry.android.utilities.MyLocation.java
com.feedhenry.android.utilities.MyToast.java