Android Open Source - Curio_android_SDK Curio Util






From Project

Back to project page Curio_android_SDK.

License

The source code is released under:

Apache License

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

/*
 * Copyright (C) 2014 Turkcell/*from  w  ww .j  a v a  2  s  . c  o m*/
 * 
 * Created by Can Ciloglu on 10 Haz 2014
 *
 */
package com.turkcell.curio.utils;

import java.util.UUID;


/**
 * Utility class which holds static methods.
 * 
 * @author Can Ciloglu
 *
 */
public class CurioUtil {
  
  /**
   * !!Legacy method from 8digits. May be removed!!
   * @param urlPrefix
   * @return
   */
  public static String formatUrlPrefix(String urlPrefix) {
    if (!urlPrefix.startsWith(Constants.HTTP) && !urlPrefix.startsWith(Constants.HTTPS))
      urlPrefix = Constants.HTTPS + urlPrefix;

    if (urlPrefix.endsWith(Constants.BACKSLASH))
      urlPrefix = urlPrefix.substring(0, urlPrefix.length() - 1);

    if (urlPrefix.endsWith(Constants.API))
      urlPrefix = urlPrefix.substring(0, urlPrefix.length() - (Constants.API.length() + 1));

    return urlPrefix;
  }
  
  /**
   * Generates a version 1 Universally Unique Identifier.
   * 
   * @return id String.
   */
  public static String generateTimeBasedUUID(long timeStamp){
    return UUIDGenerator.generateTimeBasedUUID(timeStamp).toString();
  }
  
  /**
   * Generates a version 4 Universally Unique Identifier.
   * 
   * @return
   */
  public static String generateRandomUUID(){
    return UUID.randomUUID().toString();
  }
  
  /**
   * Gets request type according to the request url.
   * 
   * @param url
   * @return
   */
  public static int getRequestType(String url){
    int type = -1;
    if(url.endsWith(Constants.SERVER_URL_SUFFIX_SESSION_START)){
      type = 0;
    }else if(url.endsWith(Constants.SERVER_URL_SUFFIX_SESSION_END)){
      type = 1;
    }else if(url.endsWith(Constants.SERVER_URL_SUFFIX_SCREEN_START)){
      type = 2;
    }else if(url.endsWith(Constants.SERVER_URL_SUFFIX_SCREEN_END)){
      type = 3;
    }else if(url.endsWith(Constants.SERVER_URL_SUFFIX_SEND_EVENT)){
      type = 4;
    }
    
    return type;
  }
}




Java Source Code List

com.turkcell.curio.CurioClient.java
com.turkcell.curio.CurioRequestProcessor.java
com.turkcell.curio.DBRequestProcessor.java
com.turkcell.curio.ICurioResultListener.java
com.turkcell.curio.INetworkConnectivityChangeListener.java
com.turkcell.curio.model.OfflineRequest.java
com.turkcell.curio.model.OnlineRequest.java
com.turkcell.curio.model.Screen.java
com.turkcell.curio.utils.Constants.java
com.turkcell.curio.utils.CurioClientSettings.java
com.turkcell.curio.utils.CurioDBContract.java
com.turkcell.curio.utils.CurioDBHelper.java
com.turkcell.curio.utils.CurioLogger.java
com.turkcell.curio.utils.CurioUtil.java
com.turkcell.curio.utils.NetworkUtil.java
com.turkcell.curio.utils.ParameterLoader.java
com.turkcell.curio.utils.PushUtil.java
com.turkcell.curio.utils.UUIDGenerator.java
com.turkcell.curio.utils.VisitorCodeManager.java
com.turkcell.curiosample.BlankActivity.java
com.turkcell.curiosample.MainActivity.java
com.turkcell.curiosample.PushNotificationBroadcastReceiver.java
com.turkcell.curiosample.PushNotificationIntentService.java