Android Open Source - TAQueue Network Test Fragment






From Project

Back to project page TAQueue.

License

The source code is released under:

MIT License

If you think the Android project TAQueue 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.familybiz.greg.taqueue;
//from w w  w  .  j av  a2 s  .c  o  m
import android.app.Fragment;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

/**
 * Created by Greg Anderson
 */
public class NetworkTestFragment extends Fragment {

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout rootLayout = new RelativeLayout(getActivity());

    Button retry = new Button(getActivity());
    retry.setText(getString(R.string.retry_connection_button));
    retry.setBackgroundResource(R.drawable.custom_button);

    RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        ViewGroup.LayoutParams.WRAP_CONTENT);

    buttonParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    retry.setLayoutParams(buttonParams);

    rootLayout.addView(retry);

    retry.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        ConnectivityManager manager = (ConnectivityManager)getActivity()
            .getSystemService(Context.CONNECTIVITY_SERVICE);

        NetworkInfo activeNetworkInfo = manager.getActiveNetworkInfo();
        if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
          if (mOnNetworkReconnectedListener != null)
            mOnNetworkReconnectedListener.onNetworkReconnected();
        }
        else
          Toast.makeText(getActivity(), getString(R.string.network_timeout_toast), Toast.LENGTH_SHORT).show();
      }
    });

    return rootLayout;
  }


  /***************************** LISTENERS *****************************/


  public interface OnNetworkReconnectedListener {
    public void onNetworkReconnected();
  }

  private OnNetworkReconnectedListener mOnNetworkReconnectedListener;

  public void setOnNetworkReconnectedListener(OnNetworkReconnectedListener onNetworkReconnectedListener) {
    mOnNetworkReconnectedListener = onNetworkReconnectedListener;
  }
}




Java Source Code List

com.familybiz.greg.taqueue.ApplicationTest.java
com.familybiz.greg.taqueue.MainActivity.java
com.familybiz.greg.taqueue.MoreInformationActivity.java
com.familybiz.greg.taqueue.NetworkTestFragment.java
com.familybiz.greg.taqueue.SettingsActivity.java
com.familybiz.greg.taqueue.model.Instructor.java
com.familybiz.greg.taqueue.model.School.java
com.familybiz.greg.taqueue.model.StudentQueue.java
com.familybiz.greg.taqueue.model.Student.java
com.familybiz.greg.taqueue.model.TA.java
com.familybiz.greg.taqueue.model.User.java
com.familybiz.greg.taqueue.model.queue.QueueData.java
com.familybiz.greg.taqueue.model.queue.QueueStudent.java
com.familybiz.greg.taqueue.model.queue.QueueTA.java
com.familybiz.greg.taqueue.network.CustomStringRequest.java
com.familybiz.greg.taqueue.network.NetworkRequest.java
com.familybiz.greg.taqueue.network.QueueRequest.java
com.familybiz.greg.taqueue.network.SchoolRequest.java
com.familybiz.greg.taqueue.network.StudentRequest.java
com.familybiz.greg.taqueue.network.TARequest.java
com.familybiz.greg.taqueue.view.lists.InstructorListFragment.java
com.familybiz.greg.taqueue.view.lists.ListFragment.java
com.familybiz.greg.taqueue.view.lists.QueueListFragment.java
com.familybiz.greg.taqueue.view.lists.SchoolListFragment.java
com.familybiz.greg.taqueue.view.login.LoginFragment.java
com.familybiz.greg.taqueue.view.login.StudentLoginFragment.java
com.familybiz.greg.taqueue.view.login.TALoginFragment.java
com.familybiz.greg.taqueue.view.queue.ColorableStudentArrayAdapter.java
com.familybiz.greg.taqueue.view.queue.ColorableTAArrayAdapter.java
com.familybiz.greg.taqueue.view.queue.QueueFragment.java
com.familybiz.greg.taqueue.view.queue.StudentQueueFragment.java
com.familybiz.greg.taqueue.view.queue.TAQueueFragment.java