Android Open Source - gokit-android Base Activity






From Project

Back to project page gokit-android.

License

The source code is released under:

Copyright (c) 2014~2015 Xtreme Programming Group, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...

If you think the Android project gokit-android 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

/**
 * Project Name:Gokit/*from  www  .j  av a 2  s . c  om*/
 * File Name:BaseActivity.java
 * Package Name:com.xpg.gokit.activity
 * Date:2014-11-18 10:04:05
 * Copyright (c) 2014~2015 Xtreme Programming Group, Inc.
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.xpg.gokit.activity;

import java.util.ArrayList;
import java.util.List;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import com.xpg.gokit.sdk.MessageCenter;
import com.xpg.gokit.setting.SettingManager;
import com.xtremeprog.xpgconnect.XPGWifiDevice;
import com.xtremeprog.xpgconnect.XPGWifiDeviceListener;
import com.xtremeprog.xpgconnect.XPGWifiSDKListener;

/**
 * ??activity??????????XPGWifiDeviceListener?XPGWifiSDKListener?????????????????????
 * .
 * 
 * @author Lien Li
 */
public class BaseActivity extends Activity {

  /** The action bar. */
  protected ActionBar actionBar;

  /** xpg???? */
  protected static List<XPGWifiDevice> xpgwifidevicelist;

  /** ???? */
  protected static List<XPGWifiDevice> deviceslist = new ArrayList<XPGWifiDevice>();

  /** The is init. */
  static boolean isInit = false;

  /** ??????? */
  protected MessageCenter mCenter;

  /** SharePreference????? */
  protected SettingManager setmanager;

  /**
   * XPGWifiDeviceListener
   * <P>
   * ?????????? ???????????????????????????????????????????????.
   */
  protected XPGWifiDeviceListener deviceListener = new XPGWifiDeviceListener() {

    @Override
    public void didLogin(XPGWifiDevice device, int result) {
      BaseActivity.this.didLogin(device, result);
    };
    
    @Override
    public void didDeviceOnline(XPGWifiDevice device, boolean isOnline) {
      BaseActivity.this.didDeviceOnline(device, isOnline);
    };
    
    @Override
    public void didDisconnected(XPGWifiDevice device) {
      BaseActivity.this.didDisconnected(device);
    };
    
    @Override
    public void didReceiveData(XPGWifiDevice device, java.util.concurrent.ConcurrentHashMap<String,Object> dataMap, int result) {
      BaseActivity.this.didReceiveData(device, dataMap, result);
    };
    
    @Override
    public void didQueryHardwareInfo(XPGWifiDevice device, int result, java.util.concurrent.ConcurrentHashMap<String,String> hardwareInfo) {
      BaseActivity.this.didQueryHardwareInfo(device, result, hardwareInfo);
    };
  };

  /**
   * XPGWifiSDKListener
   * <P>
   * sdk?????? ????????????????????????????????????????.
   */
  private XPGWifiSDKListener sdkListener = new XPGWifiSDKListener() {
    
    @Override
    public void didBindDevice(int error, String errorMessage, String did) {
      BaseActivity.this.didBindDevice(error, errorMessage, did);
    };
    
    @Override
    public void didUnbindDevice(int error, String errorMessage, String did) {
      BaseActivity.this.didUnbindDevice(error, errorMessage, did);
    };

    @Override
    public void didChangeUserPassword(int error, String errorMessage) {
      BaseActivity.this.didChangeUserPassword(error, errorMessage);
    };

    @Override
    public void didRequestSendVerifyCode(int error, String errorMessage) {
      BaseActivity.this.didRequestSendVerifyCode(error, errorMessage);
    };

    @Override
    public void didDiscovered(int error, java.util.List<XPGWifiDevice> devicesList) {
      BaseActivity.this.didDiscovered(error, devicesList);
    };

    @Override
    public void didRegisterUser(int error, String errorMessage, String uid, String token) {
      BaseActivity.this.didRegisterUser(error, errorMessage, uid, token);
    };

    @Override
    public void didUserLogin(int error, String errorMessage, String uid, String token) {
      BaseActivity.this.didUserLogin(error, errorMessage, uid, token);
    };
    
    public void didUserLogout(int error, String errorMessage) {
      BaseActivity.this.didUserLogout(error, errorMessage);
    };

    @Override
    public void didSetDeviceWifi(int error, XPGWifiDevice device) {
      BaseActivity.this.didSetDeviceWifi(error, device);
    };

    @Override
    public void didGetSSIDList(int error, java.util.List<com.xtremeprog.xpgconnect.XPGWifiSSID> ssidInfoList) {
      BaseActivity.this.didGetSSIDList(error, ssidInfoList);
    };
  };

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setmanager = new SettingManager(this);
    actionBar = getActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    mCenter = MessageCenter.getInstance(this.getApplicationContext());
  }

  /**
   * ??did?mac????????device.
   * 
   * @param mac
   *            the mac
   * @param did
   *            the did
   * @return the XPG wifi device
   */
  public static XPGWifiDevice findDeviceByMac(String mac, String did) {
    XPGWifiDevice xpgdevice = null;
    Log.i("count", BaseActivity.deviceslist.size() + "");
    for (int i = 0; i < BaseActivity.deviceslist.size(); i++) {
      XPGWifiDevice device = deviceslist.get(i);
      if (device != null) {
        Log.i("deviceMac", device.getMacAddress());
        if (device != null && device.getMacAddress().equals(mac)
            && device.getDid().equals(did)) {
          xpgdevice = device;
          break;
        }
      }

    }

    return xpgdevice;
  }

  public void onResume() {
    super.onResume();
    mCenter.getXPGWifiSDK().setListener(sdkListener);
  }

  public void onPause() {
    super.onPause();

  }

  /**
   * ?????????????????????changeUserPassword??changeUserPasswordByCode?
   * @param error
   * 0?????????
   * @param errorMessag
   * ??????????????null?
   * @see ???????XPGWifiSDK changeUserPassword??changeUserPasswordByCode??changeUserPasswordByEmail
   */
  protected void didChangeUserPassword(int error, String errorMessage) {
  };

  /**
   * ???????????????????????????????
   * @param error
   * 0?????????
   * @param errorMessag
   * ??????????????null?
   * @see ???????XPGWifiSDK requestSendVerifyCode
   */
  protected void didRequestSendVerifyCode(int error, String errorMessage) {
  };

  /**
   * ??????????????????
   * @param error
   * 0?????????
   * @param deviceList
   * ????????? XPGWifiDevice ?????
   * @see ???????XPGWifiSDK getBoundDevices
   */
  protected void didDiscovered(int error, java.util.List<XPGWifiDevice> devicesList) {

  }

  /**
   * ????????????????
   * @param error
   * 0?????????
   * @param errorMessag
   * ??????????????null?
   * @param uid
   * ???????????uid?????????null?
   * @param token
   * ???????????token?????????nulll?
   * @see ???????XPGWifiSDK registerUser registerUserByPhoneAndCode registerUserByEmail
   */
  protected void didRegisterUser(int error, String errorMessage, String uid, String token) {
  };

  /**
   * ????????????????
   * @param error
   * 0?????????
   * @param errorMessag
   * ??????????????null?
   * @param uid
   * ???????????uid??????????null?
   * @param token
   * ???????????token??????????null?
   * @see ???????XPGWifiSDK userLoginAnonymous userLoginWithUserName userLoginWithThirdAccountType
   */
  protected void didUserLogin(int error, String errorMessage, String uid, String token) {
  };
  
  /**
   * ????????????????
   * @param error
   * 0?????????
   * @param errorMessag
   * ??????????????null?
   * @see ???????XPGWifiSDK userLogout
   */
  protected void didUserLogout(int error, String errorMessage) {
  };


  /**
   * ?????????????????
   * @param error
   * ????? ?????? ????????device?null
   * @param device
   * ??????????
   * @see ???????XPGWifiSDK setDeviceWifi
   */
  protected void didSetDeviceWifi(int error, XPGWifiDevice device) {
  }

  /**
   * ??????????? Soft AP ????? SSID ??
   * @param error
   * ?????? ?????? ?????????ssidList???null
   * @param ssidList
   * ?????????? XPGWifiSSID ???????
   * @see ???????XPGWifiSDK getSSIDList
   */
  protected void didGetSSIDList(int error, java.util.List<com.xtremeprog.xpgconnect.XPGWifiSSID> ssidInfoList) {
  };

  /**
   * ?????????????
   * @param did
   * ?? did
   * @param error
   * 0?????????
   * @param errorMessage
   * ??????????????null?
   * @see ???????XPGWifiSDK bindDevice
   */
  public void didBindDevice(int error, String errorMessage, String did) {
  };

  /**
   * ?????????????
   * @param error
   * 0?????????
   * @param did
   * ?? did
   * @param errorMessage
   * ??????????????null?
   * @see ???????XPGWifiSDK unBindDevice
   */
  public void didUnbindDevice(int error, String errorMessage, String did) {
  };

  /**
   * ???????????????
   * @param device
   * ????
   * @param result
   * 0????????0??
   * @see ???????XPGWifiDevice login
   */
  public void  didLogin(XPGWifiDevice device, int result) {
  };

  /**
   * ?????????????????????
   * @param device
   * ????
   * @param result
   * 0????????0??
   * @param hardwareInfo
   * XPGWifiHardwareInfo??????????????result???0????null?
   */
  public void didQueryHardwareInfo(XPGWifiDevice device, int result, java.util.concurrent.ConcurrentHashMap<String,String> hardwareInfo) {
  };

  /**
   * ??????????????????????????????
   * @param device
   * ????
   * @param isOnline
   * true=???false=????
   */
  public void didDeviceOnline(XPGWifiDevice device, boolean isOnline) {
  };

  /**
   * ???????????????????????????????
   * @see ???????XPGWifiDevice disconnect
   */
  public void didDisconnected(XPGWifiDevice device) {
  }

  /**
   * ???????????????????????????????????????????????????????????????
   * @param device
   * ????
   * @param dataMap
   * dataMap????data??binary??faults??alerts??key?data??faults??alerts??Value????String?JSON????????????? write ???binary??Value????byte[]
   * @param result
   * 0????????0??
   * @see ???????XPGWifiDevice write
   */
  public boolean didReceiveData(XPGWifiDevice device, java.util.concurrent.ConcurrentHashMap<String,Object> dataMap, int result) {
    return true;
  };
}




Java Source Code List

com.xpg.gokit.WApplication.java
com.xpg.gokit.activity.AirLinkActivity.java
com.xpg.gokit.activity.BaseActivity.java
com.xpg.gokit.activity.DeviceApActivity.java
com.xpg.gokit.activity.DeviceListActivity.java
com.xpg.gokit.activity.ForgetPasswordActivity.java
com.xpg.gokit.activity.GokitControlActivity.java
com.xpg.gokit.activity.LoginActivity.java
com.xpg.gokit.activity.MainActivity.java
com.xpg.gokit.activity.RegisterActivity.java
com.xpg.gokit.adapter.DeviceListAdapter.java
com.xpg.gokit.adapter.WifiListAdapter.java
com.xpg.gokit.adapter.WifiSpinnerAdapter.java
com.xpg.gokit.bean.ControlDevice.java
com.xpg.gokit.dialog.SetWifiDialog.java
com.xpg.gokit.dialog.listener.SetWifiListener.java
com.xpg.gokit.sdk.MessageCenter.java
com.xpg.gokit.setting.SettingManager.java
com.xpg.gokit.utils.AssertsUtils.java
com.xpg.gokit.utils.NetUtils.java