Android Open Source - miner Dialog Provider






From Project

Back to project page miner.

License

The source code is released under:

Apache License

If you think the Android project miner 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.kolomiyets.miner.dialog;
//from   ww w .  j  ava2 s.  co m
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.kolomiyets.miner.R;

public class DialogProvider extends DialogFragment {
  
    public static void showDialog(FragmentActivity activity, EDialogType type, 
        String title, String message, IDialogResult callBack) {
      DialogProvider dialog = new DialogProvider();
      
      dialog.type = type;
      dialog.title = title;
      dialog.message = message;
      dialog.callBack = callBack;
      
      FragmentManager fm = activity.getSupportFragmentManager();
      if(fm.findFragmentByTag(DialogProvider.class.getName()+dialog.message)==null){
        FragmentTransaction ft = fm.beginTransaction();
          ft.add(dialog, DialogProvider.class.getName()+dialog.message);
          ft.commit();
      }
    }
    
    private EDialogType type;
    private String title;
    private String message;
    private IDialogResult callBack;
    private View rootView;
    
    public DialogProvider() {
      super();
      this.type = EDialogType.INFO;
  }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setStyle(DialogFragment.STYLE_NO_TITLE, 
          R.style.DialogBaseTheme);
      setCancelable(false);
    }
    
    @SuppressWarnings("unused")
  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
      rootView = inflater.inflate(R.layout.dialog_sceleton, null);
      TextView titleView = (TextView)rootView.findViewById(R.id.dlg_title);
      TextView messageView = (TextView)rootView.findViewById(R.id.dlg_message);
      FrameLayout controlPanel = (FrameLayout)rootView.findViewById(R.id.dlg_control_panel);
      Button okButton = null;
      Button cancelButton = null;
      
      titleView.setText(title);
      messageView.setText(message);
      
      switch (type) {
    case INFO:
      View infoCtlPanel = inflater.inflate(
          R.layout.dialog_control_panel_info, null);
      controlPanel.addView(infoCtlPanel);
      okButton = (Button)controlPanel.findViewById(R.id.dlg_control_ok);
      break;
    case CONFIRM:
      
      break;
    default:
      break;
    }
      
      if(okButton!=null){
        okButton.setOnClickListener(new View.OnClickListener() {
        
        @Override
        public void onClick(View v) {
          if(callBack!=null){
            callBack.onResult(DialogProvider.this, IDialogResult.OK);
          } else {
            dismiss();
          }
        }
      });
      }
      
      if(cancelButton!=null){
        cancelButton.setOnClickListener(new View.OnClickListener() {
        
        @Override
        public void onClick(View v) {
          if(callBack!=null){
            callBack.onResult(DialogProvider.this, IDialogResult.CANCEL);
          } else {
            dismiss();
          }
        }
      });
      }
      
      return rootView;
    }
}




Java Source Code List

com.kolomiyets.miner.MinerActivity.java
com.kolomiyets.miner.Miner.java
com.kolomiyets.miner.bt.BtStateMonitor.java
com.kolomiyets.miner.bt.ConnectionBase.java
com.kolomiyets.miner.bt.ConnectionManager.java
com.kolomiyets.miner.bt.ConnectionMaster.java
com.kolomiyets.miner.bt.ConnectionProcessor.java
com.kolomiyets.miner.bt.ConnectionSlave.java
com.kolomiyets.miner.bt.EConnectMethod.java
com.kolomiyets.miner.bt.IBtEnableCallback.java
com.kolomiyets.miner.bt.IRequestBtResult.java
com.kolomiyets.miner.bt.notification.BtListener.java
com.kolomiyets.miner.bt.notification.BtNotificationCmd.java
com.kolomiyets.miner.bt.notification.BtNotificationConnect.java
com.kolomiyets.miner.bt.notification.BtNotificationDiscoveryDevice.java
com.kolomiyets.miner.bt.notification.BtNotificationDiscoveryState.java
com.kolomiyets.miner.bt.notification.BtNotificationDiscovery.java
com.kolomiyets.miner.bt.notification.BtNotificationHandshake.java
com.kolomiyets.miner.bt.notification.BtNotificationPower.java
com.kolomiyets.miner.bt.notification.BtNotificationState.java
com.kolomiyets.miner.bt.notification.BtNotification.java
com.kolomiyets.miner.bt.notification.EConnectionSate.java
com.kolomiyets.miner.bt.notification.NotificationManager.java
com.kolomiyets.miner.bt.protocol.CmdBase.java
com.kolomiyets.miner.bt.protocol.CmdFactory.java
com.kolomiyets.miner.bt.protocol.CmdFieldState.java
com.kolomiyets.miner.bt.protocol.CmdGameState.java
com.kolomiyets.miner.bt.protocol.CmdGameTeam.java
com.kolomiyets.miner.bt.protocol.CmdHandshake.java
com.kolomiyets.miner.bt.protocol.CmdPing.java
com.kolomiyets.miner.bt.protocol.CmdResponse.java
com.kolomiyets.miner.bt.protocol.ECmdName.java
com.kolomiyets.miner.bt.protocol.EGameState.java
com.kolomiyets.miner.dialog.DialogProvider.java
com.kolomiyets.miner.dialog.EDialogType.java
com.kolomiyets.miner.dialog.IDialogResult.java
com.kolomiyets.miner.screen.PlayGroundBase.java
com.kolomiyets.miner.screen.PlayGroundMiner.java
com.kolomiyets.miner.screen.PlayGroundSapper.java
com.kolomiyets.miner.screen.ScreenBase.java
com.kolomiyets.miner.screen.ScreenConnectingGame.java
com.kolomiyets.miner.screen.ScreenCreateGame.java
com.kolomiyets.miner.screen.ScreenDevices.java
com.kolomiyets.miner.screen.ScreenManager.java
com.kolomiyets.miner.screen.ScreenSelectPlayer.java
com.kolomiyets.miner.view.GridCell.java