Android Open Source - ExampleApp Cache Manager






From Project

Back to project page ExampleApp.

License

The source code is released under:

Copyright (c) 2014, Altinn All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redis...

If you think the Android project ExampleApp 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.altinn.apps.fisher;
/**/*  www.j a  va  2  s  .co  m*/
 * A Singleton class...
 * This class is used to get Respective ROBOTO font.
 * Here a hash-table is maintained for caching purpose if a font is already created 
 * then the same reference will returned. other wise it will be loaded from asset-folder and cached.
 */
import java.util.Hashtable;

import android.graphics.Typeface;

public class CacheManager {
  private static CacheManager mInstance;
  private Hashtable<Integer,Typeface> mFontTable;
    private CacheManager(){
      mFontTable = new Hashtable<Integer,Typeface>();
    }
    
    public static CacheManager getInstance(){
      if(mInstance == null){
        mInstance = new CacheManager();
      }
      return mInstance;
    }
    
    public Typeface getTypeFace(int key){
      Typeface typeFace = null;
      if(mFontTable.containsKey(key)){
        typeFace =  mFontTable.get(key);
      }else{
        typeFace = Typeface.createFromAsset(AppContext.getInstance().getAssets(), getTypefaceFile(key));
        mFontTable.put(key, typeFace);
      }
      return typeFace;
    }
    
    
    
    
    /** FONTS **/
   private final int ROBOTO_THIN = 0;
   private final int ROBOTO_THIN_ITALIC = 1;
   private final int ROBOTO_LIGHT = 2;
   private final int ROBOTO_LIGHT_ITALIC = 3;
   private final int ROBOTO_REGULAR = 4;
   private final int ROBOTO_ITALIC = 5;
   private final int ROBOTO_MEDIUM = 6;
   private final int ROBOTO_MEDIUM_ITALIC = 7;
   private final int ROBOTO_BOLD = 8;
   private final int ROBOTO_BOLD_ITALIC = 9;
   private final int ROBOTO_BLACK = 10;
   private final int ROBOTO_BLACK_ITALIC = 11;
   private final int ROBOTO_CONDENSED_REGULAR = 12;
   private final int ROBOTO_CONDENSED_ITALIC = 13;
   private final int ROBOTO_CONDENSED_BOLD = 14;
   private final int ROBOTO_CONDENSED_BOLD_ITALIC = 15;   
   private final int ROBOTO_CONDENSED_LIGHT = 16;
   private final int ROBOTO_CONDENSED_LIGHT_ITALIC = 17;
    
    private String getTypefaceFile( int typefaceValue) {
        String typefaceFile;
        switch (typefaceValue) {
            case ROBOTO_THIN:
                typefaceFile =  "fonts/roboto/Roboto-Thin.ttf";
                break;
            case ROBOTO_THIN_ITALIC:
                typefaceFile = "fonts/roboto/Roboto-ThinItalic.ttf";
                break;
            case ROBOTO_LIGHT:
                typefaceFile =  "fonts/roboto/Roboto-Light.ttf";
                break;
            case ROBOTO_LIGHT_ITALIC:
                typefaceFile = "fonts/roboto/Roboto-LightItalic.ttf";
                break;
            case ROBOTO_REGULAR:
                typefaceFile = "fonts/roboto/Roboto-Regular.ttf";
                break;
            case ROBOTO_ITALIC:
                typefaceFile =  "fonts/roboto/Roboto-Italic.ttf";
                break;
            case ROBOTO_MEDIUM:
                typefaceFile = "fonts/roboto/Roboto-Medium.ttf";
                break;
            case ROBOTO_MEDIUM_ITALIC:
                typefaceFile = "fonts/roboto/Roboto-MediumItalic.ttf";
                break;
            case ROBOTO_BOLD:
                typefaceFile = "fonts/roboto/Roboto-Bold.ttf";
                break;
            case ROBOTO_BOLD_ITALIC:
                typefaceFile = "fonts/roboto/Roboto-BoldItalic.ttf";
                break;
            case ROBOTO_BLACK:
                typefaceFile = "fonts/roboto/Roboto-Black.ttf";
                break;
            case ROBOTO_BLACK_ITALIC:
                typefaceFile = "fonts/roboto/Roboto-BlackItalic.ttf";
                break;
            case ROBOTO_CONDENSED_REGULAR:
                typefaceFile = "fonts/roboto/RobotoCondensed-Regular.ttf";
                break;
            case ROBOTO_CONDENSED_ITALIC:
                typefaceFile = "fonts/roboto/RobotoCondensed-Italic.ttf";
                break;
            case ROBOTO_CONDENSED_BOLD:
                typefaceFile = "fonts/roboto/RobotoCondensed-Bold.ttf";
                break;
            case ROBOTO_CONDENSED_BOLD_ITALIC:
                typefaceFile = "fonts/roboto/RobotoCondensed-BoldItalic.ttf";
                break;
            case ROBOTO_CONDENSED_LIGHT:
                typefaceFile = "fonts/roboto/RobotoCondensed-Light.ttf";
                break;
            case ROBOTO_CONDENSED_LIGHT_ITALIC:
                typefaceFile = "fonts/roboto/RobotoCondensed-LightItalic.ttf";
                break;
            default:
               typefaceFile = "fonts/roboto/Roboto-Regular.ttf";
               break;
        }
        return typefaceFile;
    }
  
}




Java Source Code List

com.altinn.apps.fisher.AppContext.java
com.altinn.apps.fisher.CacheManager.java
com.altinn.apps.fisher.common.AppConstants.java
com.altinn.apps.fisher.common.IStatusMessage.java
com.altinn.apps.fisher.common.MenuItem.java
com.altinn.apps.fisher.common.StatusMessage.java
com.altinn.apps.fisher.db.DataBaseHelper.java
com.altinn.apps.fisher.db.FactoryDBHelper.java
com.altinn.apps.fisher.db.FishCategoryDBHelper.java
com.altinn.apps.fisher.db.FormDBHelper.java
com.altinn.apps.fisher.db.IDBHelper.java
com.altinn.apps.fisher.db.RegsDBHelper.java
com.altinn.apps.fisher.db.VesselDBHelper.java
com.altinn.apps.fisher.gps.CLocationProvider.java
com.altinn.apps.fisher.gps.ILocationUpdateListner.java
com.altinn.apps.fisher.models.CaughtInfoData.java
com.altinn.apps.fisher.models.InfoData.java
com.altinn.apps.fisher.models.ReportInfoData.java
com.altinn.apps.fisher.models.UserProfile.java
com.altinn.apps.fisher.net.AbstractWorkerTask.java
com.altinn.apps.fisher.net.CookieHelper.java
com.altinn.apps.fisher.net.IParser.java
com.altinn.apps.fisher.net.JSParser.java
com.altinn.apps.fisher.net.ParseManager.java
com.altinn.apps.fisher.net.TaskNotifier.java
com.altinn.apps.fisher.net.jsobj.AttachmentObj.java
com.altinn.apps.fisher.net.jsobj.FormObj.java
com.altinn.apps.fisher.net.jsobj.JSConstants.java
com.altinn.apps.fisher.net.jsobj.JsonObj.java
com.altinn.apps.fisher.net.jsobj.LinkItemObj.java
com.altinn.apps.fisher.net.jsobj.LinkObj.java
com.altinn.apps.fisher.net.jsobj.MessageObj.java
com.altinn.apps.fisher.net.jsobj.MessagesEmbedded.java
com.altinn.apps.fisher.net.jsobj.OrganisationObj.java
com.altinn.apps.fisher.net.tasks.LoginTask.java
com.altinn.apps.fisher.net.tasks.RefreshTokenTask.java
com.altinn.apps.fisher.net.tasks.SendReportTask.java
com.altinn.apps.fisher.net.tasks.UserProfileTask.java
com.altinn.apps.fisher.settings.FactoryDetails.java
com.altinn.apps.fisher.settings.FishDetails.java
com.altinn.apps.fisher.settings.SettingItem.java
com.altinn.apps.fisher.settings.VesselsDetails.java
com.altinn.apps.fisher.ui.component.DurationTimePickDialog.java
com.altinn.apps.fisher.ui.component.RAutoCompleteTextView.java
com.altinn.apps.fisher.ui.component.RButton.java
com.altinn.apps.fisher.ui.component.REditText.java
com.altinn.apps.fisher.ui.component.RTextView.java
com.altinn.apps.fisher.ui.screen.BaseActivity.java
com.altinn.apps.fisher.ui.screen.BrowserActivity.java
com.altinn.apps.fisher.ui.screen.FactoryDetailsActivity.java
com.altinn.apps.fisher.ui.screen.HomeActivity.java
com.altinn.apps.fisher.ui.screen.InformationActivity.java
com.altinn.apps.fisher.ui.screen.MenuNavigationActivity.java
com.altinn.apps.fisher.ui.screen.ReportActivity.java
com.altinn.apps.fisher.ui.screen.ReportReceivedFishActivity.java
com.altinn.apps.fisher.ui.screen.ReportSendDetailActivity.java
com.altinn.apps.fisher.ui.screen.SplashActivity.java
com.altinn.apps.fisher.ui.screen.UserProfileActivity.java
com.altinn.apps.fisher.utils.PreferenceUtils.java
com.altinn.apps.fisher.utils.Utils.java
net.simonvt.menudrawer.BuildLayerFrameLayout.java
net.simonvt.menudrawer.ColorDrawable.java
net.simonvt.menudrawer.DraggableDrawer.java
net.simonvt.menudrawer.FloatScroller.java
net.simonvt.menudrawer.MenuDrawer.java
net.simonvt.menudrawer.NoClickThroughFrameLayout.java
net.simonvt.menudrawer.OverlayDrawer.java
net.simonvt.menudrawer.PeekInterpolator.java
net.simonvt.menudrawer.Position.java
net.simonvt.menudrawer.Scroller.java
net.simonvt.menudrawer.SinusoidalInterpolator.java
net.simonvt.menudrawer.SlideDrawable.java
net.simonvt.menudrawer.SlidingDrawer.java
net.simonvt.menudrawer.SmoothInterpolator.java
net.simonvt.menudrawer.StaticDrawer.java
net.simonvt.menudrawer.ViewHelper.java
net.simonvt.menudrawer.compat.ActionBarHelperCompat.java
net.simonvt.menudrawer.compat.ActionBarHelperNative.java
net.simonvt.menudrawer.compat.ActionBarHelper.java