Back to project page ScoponeDaPolso.
The source code is released under:
GNU General Public License
If you think the Android project ScoponeDaPolso listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.gdg.bari.scopone.fragment; //www . j a v a2s .c om import android.app.Activity; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import com.google.android.gms.common.api.GoogleApiClient; import org.gdg.bari.scopone.activity.MobileMainActivity; import org.gdg.bari.scopone.R; import org.gdg.bari.scopone.util.GoogleApiClientManager; import org.gdg.bari.scopone.util.LogUtil; public class MenuFragment extends Fragment implements View.OnClickListener { private static final String TAG = MenuFragment.class.getSimpleName(); private Button signOutButton, startMatchButton, checkGamesButton, quickMatchButton; private MobileMainActivity mActivity; private OnMenuFragmentInteractionListener mListener; // Client used to interact with Google APIs private GoogleApiClient mGoogleApiClient; @Override public void onAttach(Activity activity) { super.onAttach(activity); mActivity = (MobileMainActivity) activity; try { mListener = (OnMenuFragmentInteractionListener) mActivity; } catch (ClassCastException ex) { LogUtil.w(TAG, TAG + " ClassCastException"); LogUtil.e(TAG, Log.getStackTraceString(ex)); throw new ClassCastException(activity.toString() + " must implement OnFragmentInteractionListener"); } // Get the Google API Client instance mGoogleApiClient = GoogleApiClientManager.getInstance(mActivity); } @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Log.d(TAG, TAG + " onCreateView() method"); View v = inflater.inflate(R.layout.fragment_menu, container, false); signOutButton = (Button) v.findViewById(R.id.sign_out_button); startMatchButton = (Button) v.findViewById(R.id.start_match_button); checkGamesButton = (Button) v.findViewById(R.id.check_games_button); quickMatchButton = (Button) v.findViewById(R.id.quick_match_button); signOutButton.setOnClickListener(this); startMatchButton.setOnClickListener(this); checkGamesButton.setOnClickListener(this); quickMatchButton.setOnClickListener(this); return v; } @Override public void onClick(View v) { switch (v.getId()) { case(R.id.start_match_button): { mListener.onStartMatchClicked(); } break; case(R.id.sign_out_button): { mListener.onSignOutClicked(); } break; case(R.id.check_games_button): { mListener.onCheckGamesClicked(); } break; } } /** * This interface must be implemented by activities that contain this * fragment to allow an interaction in this fragment to be communicated * to the activity and potentially other fragments contained in that * activity. */ public interface OnMenuFragmentInteractionListener { public void onSignOutClicked(); public void onStartMatchClicked(); public void onCheckGamesClicked(); } }