Telegram android版 源碼分析(二) ——設置代理

老毛子代碼寫的還真是精緻,在昨天把中文XML資源擼出來後,發現裏面的代碼寫的還是挺有意思的,可讀性很強。

今天繼續研究設置代理的業務邏輯。

通過猜測,我們可知道ProxyListActivity.java就是設置代理的界面了,那麼裏面肯定有設置代理的代碼,

public boolean onFragmentCreate() {
        super.onFragmentCreate();

        SharedConfig.loadProxyList();  // 這句是重點!!!!!
        currentConnectionState = ConnectionsManager.getInstance(currentAccount).getConnectionState();

        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxyCheckDone);
        NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.didUpdateConnectionState);

        final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        useProxySettings = preferences.getBoolean("proxy_enabled", false) && !SharedConfig.proxyList.isEmpty();
        useProxyForCalls = preferences.getBoolean("proxy_enabled_calls
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章