project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/ConnectionDependendDialogFragment.java
changeset 7582 714310efad8f
parent 7444 2e31f114f57e
child 7584 7831c84cc644
equal deleted inserted replaced
7580:c92596feac0d 7582:714310efad8f
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU General Public License
       
     7  * as published by the Free Software Foundation; either version 2
       
     8  * of the License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program; if not, write to the Free Software
       
    17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
       
    18  */
       
    19 
     1 package org.hedgewars.hedgeroid;
    20 package org.hedgewars.hedgeroid;
     2 
    21 
     3 import org.hedgewars.hedgeroid.netplay.Netplay;
    22 import org.hedgewars.hedgeroid.netplay.Netplay;
     4 import org.hedgewars.hedgeroid.netplay.Netplay.State;
    23 import org.hedgewars.hedgeroid.netplay.Netplay.State;
     5 
    24 
     9 import android.content.Intent;
    28 import android.content.Intent;
    10 import android.content.IntentFilter;
    29 import android.content.IntentFilter;
    11 import android.support.v4.app.DialogFragment;
    30 import android.support.v4.app.DialogFragment;
    12 import android.support.v4.content.LocalBroadcastManager;
    31 import android.support.v4.content.LocalBroadcastManager;
    13 
    32 
       
    33 /**
       
    34  * Helper class for DialogFragments that are supposed to be dismissed when the
       
    35  * network connection is lost. This is used for some dialog fragments that
       
    36  * appear during connecting (e.g. username input)
       
    37  */
    14 public class ConnectionDependendDialogFragment extends DialogFragment {
    38 public class ConnectionDependendDialogFragment extends DialogFragment {
    15 	@Override
    39 	@Override
    16 	public void onStart() {
    40 	public void onStart() {
    17 		super.onStart();
    41 		super.onStart();
    18 		LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(dismissReceiver, new IntentFilter(Netplay.ACTION_DISCONNECTED));
    42 		LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(dismissReceiver, new IntentFilter(Netplay.ACTION_DISCONNECTED));