Android Open Source - foxail_reader Client Factory






From Project

Back to project page foxail_reader.

License

The source code is released under:

GNU General Public License

If you think the Android project foxail_reader 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 org.foxail.android.reader.client;
//ww w. j a va2s.  c  o  m
import java.util.HashMap;
import java.util.Map;

public class ClientFactory {
  
  private Map<String, String> clientMap = new HashMap<String, String>();
  
  private static ClientFactory instance;
  
  private Map<String, Client> clients = new HashMap<String, Client>();
  
  public Map<String, String> getClientMap() {
    return clientMap;
  }
  
  public static ClientFactory getInstance()  {
    if (instance == null) {
      instance = new ClientFactory();
      instance.clientMap.put("cnbeta", "org.foxail.android.reader.client.CnBetaClient");
    }
    return instance;
  }
  
  public Client getClient(String clientName) {
    if (!clientMap.containsKey(clientName)) {
      return null;
    }
    
    Client client = clients.get(clientName);
    if (client == null) {
      String className = clientMap.get(clientName);
      try{
        client = (Client) Class.forName(className).newInstance();
      }catch(Exception e){
        
      }
      clients.put(clientName, client);
    }
    return client;
  }

}




Java Source Code List

org.foxail.android.common.CommonUtil.java
org.foxail.android.common.http.ConnectionManager.java
org.foxail.android.common.http.HttpConnection.java
org.foxail.android.common.volley.HtmlRequest.java
org.foxail.android.reader.activity.BaseActivity.java
org.foxail.android.reader.activity.FavoritesActivity.java
org.foxail.android.reader.activity.MainActivity.java
org.foxail.android.reader.activity.NewsActivity.java
org.foxail.android.reader.client.ClientFactory.java
org.foxail.android.reader.client.Client.java
org.foxail.android.reader.client.CnBetaClient.java
org.foxail.android.reader.model.News.java