Android Open Source - YourWiFi Essid






From Project

Back to project page YourWiFi.

License

The source code is released under:

MIT License

If you think the Android project YourWiFi 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.akisute.yourwifi.app.model;
/*from  ww  w. j av a2s  .c  om*/
import android.text.TextUtils;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;

import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Essid {

    private final Set<Network> mNetworkSet = new HashSet<Network>();

    public static Essid newInstance(Network... networks) {
        return newInstance(Arrays.asList(networks));
    }

    public static Essid newInstance(Collection<Network> networkList) {
        Essid essid = new Essid();
        essid.update(networkList);
        return essid;
    }

    private Essid() {
    }

    @Override
    public int hashCode() {
        return getSsid().hashCode();
    }

    public String getSsid() {
        Network network = mNetworkSet.iterator().next();
        return network.getSsid();
    }

    public Set<Network> getNetworkSet() {
        return Sets.newHashSet(mNetworkSet);
    }

    public int getCount() {
        return mNetworkSet.size();
    }

    public int getLevel() {
        return Ordering.from(NetworkComparators.LEVEL_DESC).min(mNetworkSet).getLevel();
    }

    public int getCryptoType() {
        return Ordering.from(NetworkComparators.CRYPTOTYPE_WEAKEST_TO_STRONGEST).min(mNetworkSet).getCryptoType();
    }

    public Date getUpdatedAt() {
        return Ordering.from(NetworkComparators.UPDATED_AT_ASC).min(mNetworkSet).getUpdatedAt();
    }

    public void update(Collection<Network> networkList) {
        mNetworkSet.retainAll(networkList);
        mNetworkSet.addAll(networkList);
        validate();
    }

    private void validate() {
        // Make sure networkList contains at least 1 Network instance
        // Make sure all Network instances in the list shares the same SSID (since it is ESSID)
        Iterator<Network> iterator = mNetworkSet.iterator();
        if (iterator.hasNext()) {
            final Network firstNetwork = iterator.next();
            if (!Iterators.all(iterator, new Predicate<Network>() {
                @Override
                public boolean apply(Network input) {
                    return TextUtils.equals(firstNetwork.getSsid(), input.getSsid());
                }
            })) {
                throw new IllegalStateException("All SSIDs in Essid object must be same");
            }
        } else {
            throw new IllegalStateException("Essid object must contain at least 1 Network object");
        }
    }
}




Java Source Code List

com.akisute.yourwifi.app.Application.java
com.akisute.yourwifi.app.CloudLoginDialogFragment.java
com.akisute.yourwifi.app.EssidDetailActivity.java
com.akisute.yourwifi.app.EssidDetailFragment.java
com.akisute.yourwifi.app.EssidListFragment.java
com.akisute.yourwifi.app.MainActivity.java
com.akisute.yourwifi.app.NetworkMapFragment.java
com.akisute.yourwifi.app.NetworkRecordingService.java
com.akisute.yourwifi.app.RawNetworkListFragment.java
com.akisute.yourwifi.app.SettingsActivity.java
com.akisute.yourwifi.app.SettingsFragment.java
com.akisute.yourwifi.app.cloud.CloudManager.java
com.akisute.yourwifi.app.dagger.AndroidSystemModule.java
com.akisute.yourwifi.app.dagger.ApplicationModule.java
com.akisute.yourwifi.app.intent.Intents.java
com.akisute.yourwifi.app.model.BssidListAdapter.java
com.akisute.yourwifi.app.model.EssidComparators.java
com.akisute.yourwifi.app.model.EssidListAdapter.java
com.akisute.yourwifi.app.model.Essid.java
com.akisute.yourwifi.app.model.LocationScanManager.java
com.akisute.yourwifi.app.model.NetworkCache.java
com.akisute.yourwifi.app.model.NetworkComparators.java
com.akisute.yourwifi.app.model.NetworkScanManager.java
com.akisute.yourwifi.app.model.Network.java
com.akisute.yourwifi.app.model.RawNetworkListAdapter.java
com.akisute.yourwifi.app.util.GlobalEventBus.java
com.akisute.yourwifi.app.util.GlobalResources.java
com.akisute.yourwifi.app.util.GlobalSharedPreferences.java