Android Open Source - mha-android Test Fragment






From Project

Back to project page mha-android.

License

The source code is released under:

Copyright (c) 2011-2012 Cameron Porter, Ryan Brown http://github.com/camporter/mha-android Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated...

If you think the Android project mha-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.teamacra.myhomeaudio.ui.fragment;
//w  w  w .  j  ava  2s .c om
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

public final class TestFragment extends Fragment {
  private static final String KEY_CONTENT = "TestFragment:Content";
  
  public static TestFragment newInstance(String content) {
    TestFragment fragment = new TestFragment();

    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < 20; i++) {
      builder.append(content).append(" ");
    }
    builder.deleteCharAt(builder.length() - 1);
    fragment.mContent = builder.toString();
    
    return fragment;
  }
  
  private String mContent = "???";
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
      mContent = savedInstanceState.getString(KEY_CONTENT);
    }
    
    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);
    
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(text);
    
    return layout;
  }

  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(KEY_CONTENT, mContent);
  }
}




Java Source Code List

com.teamacra.myhomeaudio.MHAApplication.java
com.teamacra.myhomeaudio.bluetooth.BluetoothService.java
com.teamacra.myhomeaudio.discovery.DiscoveryConstants.java
com.teamacra.myhomeaudio.discovery.DiscoveryDescription.java
com.teamacra.myhomeaudio.discovery.DiscoverySearchListener.java
com.teamacra.myhomeaudio.discovery.DiscoverySearch.java
com.teamacra.myhomeaudio.discovery.MDNSDiscovery.java
com.teamacra.myhomeaudio.http.HttpBase.java
com.teamacra.myhomeaudio.http.HttpClient.java
com.teamacra.myhomeaudio.http.HttpNode.java
com.teamacra.myhomeaudio.http.HttpSource.java
com.teamacra.myhomeaudio.http.HttpStream.java
com.teamacra.myhomeaudio.http.StatusCode.java
com.teamacra.myhomeaudio.locations.NodeSignalRange.java
com.teamacra.myhomeaudio.locations.NodeSignature.java
com.teamacra.myhomeaudio.manager.ConfigurationManager.java
com.teamacra.myhomeaudio.manager.LocationManager.java
com.teamacra.myhomeaudio.manager.NodeManager.java
com.teamacra.myhomeaudio.manager.StreamManager.java
com.teamacra.myhomeaudio.media.MediaDescriptor.java
com.teamacra.myhomeaudio.node.Node.java
com.teamacra.myhomeaudio.source.Source.java
com.teamacra.myhomeaudio.stream.StreamAction.java
com.teamacra.myhomeaudio.stream.Stream.java
com.teamacra.myhomeaudio.ui.InitialConfigActivity.java
com.teamacra.myhomeaudio.ui.LoginActivity.java
com.teamacra.myhomeaudio.ui.MyHomeAudioActivity.java
com.teamacra.myhomeaudio.ui.RegisterActivity.java
com.teamacra.myhomeaudio.ui.fragment.SongFragment.java
com.teamacra.myhomeaudio.ui.fragment.SourceFragment.java
com.teamacra.myhomeaudio.ui.fragment.TestFragment.java