/* 
 * Copyright (C) 2013-2014 www.Andbrain.com 
 * Faster and more easily to create android apps
 * 
 * */
package com.mady.wifi.api;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.widget.Toast;

import java.util.List;


public class ScanTimerSimple extends ScanTimer {
    List<ScanResult> mResults;
    WifiManager mWifiManager;

    public ScanTimerSimple(Context c) {
        super(c);
        mWifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);

    }

    public ScanTimerSimple(long interval, long duration, Context c) {
        super(interval, duration, c);
        mWifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);

    }

    /**
     * This method is called periodically with the interval set as the delay between subsequent calls.
     */

    @Override
    protected void onTick() {
        scanNetworks();
        if (mResults != null) {
            List<ScanResult> results2 = mResults;

            for (ScanResult result : results2) {
                Toast.makeText(mContext, result.SSID + " " + result.level,
                        Toast.LENGTH_SHORT).show();
            }
        }

    }

    @Override
    protected void onFinish() {

    }

    public void scanNetworks() {
        boolean scan = mWifiManager.startScan();

        if (scan) {
            mResults = mWifiManager.getScanResults();


        } else
            switch (mWifiManager.getWifiState()) {
                case WifiManager.WIFI_STATE_DISABLING:
                    Toast.makeText(mContext, "wifi disabling", Toast.LENGTH_LONG).show();
                    break;
                case WifiManager.WIFI_STATE_DISABLED:
                    Toast.makeText(mContext, "wifi disabled", Toast.LENGTH_LONG).show();
                    break;
                case WifiManager.WIFI_STATE_ENABLING:
                    Toast.makeText(mContext, "wifi enabling", Toast.LENGTH_LONG).show();
                    break;
                case WifiManager.WIFI_STATE_ENABLED:
                    Toast.makeText(mContext, "wifi enabled", Toast.LENGTH_LONG).show();
                    break;
                case WifiManager.WIFI_STATE_UNKNOWN:
                    Toast.makeText(mContext, "wifi unknown state", Toast.LENGTH_LONG).show();
                    break;
            }

    }
}

@@ -237,37 +237,8 @@
 ger;
-%0Aimport android.widget.Toast;
 %0A%0Aim
@@ -907,1432 +907,222 @@
     
-    if (mResults != null) %7B%0A            List%3CScanResult%3E results2 = mResults;%0A%0A            for (ScanResult result : results2) %7B%0A                Toast.makeText(mContext, result.SSID + %22 %22 + result.level,%0A                        Toast.LENGTH_SHORT).show();%0A            %7D%0A        %7D%0A%0A    %7D%0A%0A    @Override%0A    protected void onFinish() %7B%0A%0A    %7D%0A%0A    public void scanNetworks() %7B%0A        boolean scan = mWifiManager.startScan();%0A%0A        if (scan) %7B%0A            mResults = mWifiManager.getScanResults();%0A%0A%0A        %7D else%0A            switch (mWifiManager.getWifiState()) %7B%0A                case WifiManager.WIFI_STATE_DISABLING:%0A                    Toast.makeText(mContext, %22wifi disabling%22, Toast.LENGTH_LONG).show();%0A                    break;%0A                case WifiManager.WIFI_STATE_DISABLED:%0A                    Toast.makeText(mContext, %22wifi disabled%22, Toast.LENGTH_LONG).show();%0A                    break;%0A                case WifiManager.WIFI_STATE_ENABLING:%0A                    Toast.makeText(mContext, %22wifi enabling%22, Toast.LENGTH_LONG).show();%0A                    break;%0A                case WifiManager.WIFI_STATE_ENABLED:%0A                    Toast.makeText(mContext, %22wifi enabled%22, Toast.LENGTH_LONG).show();%0A                    break;%0A                case WifiManager.WIFI_STATE_UNKNOWN:%0A                    Toast.makeText(mContext, %22wifi unknown state%22, Toast.LENGTH_LONG).show();%0A                    break;%0A    
+%7D%0A%0A    @Override%0A    protected void onFinish() %7B%0A%0A    %7D%0A%0A    public void scanNetworks() %7B%0A        boolean scan = mWifiManager.startScan();%0A%0A        if (scan) %7B%0A            mResults = mWifiManager.getScanResults();%0A
     

Remove Toast messages