Android Open Source - Gents Running Server Fragment






From Project

Back to project page Gents.

License

The source code is released under:

MIT License

If you think the Android project Gents 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 org.gsfraley.gents.app.fragments;
//from w w  w. j ava  2 s  .  com
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.TextView;

import org.gsfraley.gents.R;
import org.gsfraley.gents.app.adapters.RunningServerAdapter;
import org.gsfraley.gents.service.ServerGhost;

/**
 * A fragment representing a list of Items.
 * <p />
 * Large screen devices (such as tablets) are supported by replacing the
 * ListView with a GridView.
 * <p />
 * Activities containing this fragment MUST implement the {@link Callbacks}
 * interface.
 */
public class RunningServerFragment extends Fragment implements
    AbsListView.OnItemClickListener {

  private AbsListView mListView;
  private RunningServerAdapter mAdapter;
  
  public RunningServerFragment() {
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    mAdapter = new RunningServerAdapter(getActivity());
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_runningserver,
        container, false);

    // Set the adapter
    mListView = (AbsListView) view.findViewById(android.R.id.list);
    ((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter);

    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(this);

    return view;
  }

  @Override
  public void onStart() {
    super.onStart();
    
    // Throw out preferences in case invalidated
    // Perhaps in future, implement per-server listeners?
    mAdapter.notifyDataSetInvalidated();
  }
  
  // Each item has buttons, no need to do anything onclick
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position,
      long id) {
    ServerGhost server = mAdapter.getItem(position);
    startActivity(server.configIntent());
  }

  /**
   * The default content for this Fragment has a TextView that is shown when
   * the list is empty. If you would like to change the text, call this method
   * to supply the text it should use.
   */
  public void setEmptyText(CharSequence emptyText) {
    View emptyView = mListView.getEmptyView();

    if (emptyText instanceof TextView) {
      ((TextView) emptyView).setText(emptyText);
    }
  }
}




Java Source Code List

fi.iki.elonen.NanoHTTPD.java
org.gsfraley.gents.app.adapters.RunningServerAdapter.java
org.gsfraley.gents.app.adapters.ServerTypeAdapter.java
org.gsfraley.gents.app.fragments.RunningServerFragment.java
org.gsfraley.gents.app.fragments.ServerTypeFragment.java
org.gsfraley.gents.app.main.MainActivityListener.java
org.gsfraley.gents.app.main.MainActivity.java
org.gsfraley.gents.service.ManagerListener.java
org.gsfraley.gents.service.ServerBoss.java
org.gsfraley.gents.service.ServerGhost.java
org.gsfraley.gents.service.ServerManager.java
org.gsfraley.gents.service.servers.echoserver.EchoServerPreferenceActivity.java
org.gsfraley.gents.service.servers.echoserver.EchoServer.java
org.gsfraley.gents.service.servers.helloserver.HelloServerPreferenceActivity.java
org.gsfraley.gents.service.servers.helloserver.HelloServer.java
org.gsfraley.gents.service.servers.nullserver.NullServer.java
org.gsfraley.gents.service.servers.yesserver.YesServerPreferenceActivity.java
org.gsfraley.gents.service.servers.yesserver.YesServer.java