コード例 #1
0
 @Before
 public void setUp() {
   initMocks(this);
   context = mockApplication();
   Analytics.INSTANCES.clear();
   when(context.getApplicationContext()).thenReturn(context);
 }
コード例 #2
0
  /**
   * 构造插件信息
   *
   * @param
   */
  static void ensurePluginInited(PluginDescriptor pluginDescriptor) {
    if (pluginDescriptor != null) {
      DexClassLoader pluginClassLoader = pluginDescriptor.getPluginClassLoader();
      if (pluginClassLoader == null) {
        LogUtil.d("正在初始化插件Resources, DexClassLoader, Context, Application ");

        LogUtil.d("是否为独立插件", pluginDescriptor.isStandalone());

        Resources pluginRes =
            PluginCreator.createPluginResource(
                sApplication, pluginDescriptor.getInstalledPath(), pluginDescriptor.isStandalone());

        pluginClassLoader =
            PluginCreator.createPluginClassLoader(
                pluginDescriptor.getInstalledPath(), pluginDescriptor.isStandalone());
        Context pluginContext =
            PluginCreator.createPluginApplicationContext(
                pluginDescriptor, sApplication, pluginRes, pluginClassLoader);

        pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
        pluginDescriptor.setPluginContext(pluginContext);
        pluginDescriptor.setPluginClassLoader(pluginClassLoader);

        // 使用了openAtlasExtention之后就不需要Public.xml文件了
        // checkPluginPublicXml(pluginDescriptor, pluginRes);

        callPluginApplicationOnCreate(pluginDescriptor);

        LogUtil.d("初始化插件" + pluginDescriptor.getPackageName() + "完成");
      }
    }
  }
コード例 #3
0
 public static Context getNewPluginContext(Context pluginContext) {
   if (pluginContext != null) {
     pluginContext =
         PluginCreator.createPluginApplicationContext(
             ((PluginContextTheme) pluginContext).getPluginDescriptor(),
             sApplication,
             pluginContext.getResources(),
             (DexClassLoader) pluginContext.getClassLoader());
     pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
   }
   return pluginContext;
 }
コード例 #4
0
 /**
  * 根据当前class所在插件的默认Context, 为当前插件Class创建一个单独的context
  *
  * <p>原因在插件Activity中,每个Activity都应当建立独立的Context,
  *
  * <p>而不是都使用同一个defaultContext,避免不同界面的主题和样式互相影响
  *
  * @param clazz
  * @return
  */
 public static Context getNewPluginContext(@SuppressWarnings("rawtypes") Class clazz) {
   Context pluginContext = getDefaultPluginContext(clazz);
   if (pluginContext != null) {
     pluginContext =
         PluginCreator.createPluginApplicationContext(
             ((PluginContextTheme) pluginContext).getPluginDescriptor(),
             sApplication,
             pluginContext.getResources(),
             (DexClassLoader) pluginContext.getClassLoader());
     pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
   }
   return pluginContext;
 }
コード例 #5
0
 /**
  * 根据当前插件的默认Context, 为当前插件的组件创建一个单独的context
  *
  * @param pluginContext
  * @param base 由系统创建的Context。 其实际类型应该是ContextImpl
  * @return
  */
 /*package*/ static Context getNewPluginComponentContext(
     Context pluginContext, Context base, int theme) {
   Context newContext = null;
   if (pluginContext != null) {
     newContext =
         PluginCreator.createPluginContext(
             ((PluginContextTheme) pluginContext).getPluginDescriptor(),
             base,
             pluginContext.getResources(),
             (DexClassLoader) pluginContext.getClassLoader());
     newContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme);
   }
   return newContext;
 }
  @Before
  public void setUp() throws PackageManager.NameNotFoundException {
    initMocks(this);
    mockStatic(MoEHelper.class);
    when(analytics.getApplication()).thenReturn(context);

    when(context.getPackageManager()).thenReturn(manager);
    when(activity.getPackageManager()).thenReturn(manager);
    when(manager.getApplicationInfo(context.getPackageName(), 0)).thenReturn(applicationInfo);
    when(context.getApplicationContext()).thenReturn(RuntimeEnvironment.application);

    integration =
        new MoEngageIntegration(
            analytics,
            new ValueMap().putValue("pushSenderId", "12324441").putValue("apiKey", "ASJKSLJAL"));
    integration.helper = moeHelper;
  }
コード例 #7
0
ファイル: Coolx.java プロジェクト: fushenghua/CoolxLib
  public static void init(Application app) {
    Ioc.initApplication(app);

    ImageLoaderConfiguration imageconfig =
        new ImageLoaderConfiguration.Builder(app.getApplicationContext())
            .threadPoolSize(3)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .memoryCacheSize(1500000)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .build();
    ImageLoader.getInstance().init(imageconfig);

    // 数据库初始化
    CooDb.DaoConfig config = new CooDb.DaoConfig(app);
    config.setDbVersion(Const.DATABASE_VERSION);
    config.setDbName(Const.DATABASE_NAME);
    CooDb.create(config).configDebug(Const.DATABASE_DEBUG);
  }
コード例 #8
0
ファイル: MainActivity.java プロジェクト: colmsjo/androidsbx
  public void showToast(View v) {
    try {
      final Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
      final Method method = activityThreadClass.getMethod("currentApplication");
      Application a = (Application) method.invoke(null, (Object[]) null);

      Toast.makeText(
              a.getApplicationContext(),
              "Toast created using android.app.ActivityThread",
              Toast.LENGTH_SHORT)
          .show();

    } catch (final ClassNotFoundException e) {
      Log.e("getcontext", "ClassNotFoundException: " + e);
    } catch (final NoSuchMethodException e) {
      Log.e("getcontext", "NoSuchMethodException: " + e);
    } catch (final IllegalArgumentException e) {
      Log.e("getcontext", "IllegalArgumentException: " + e);
    } catch (final IllegalAccessException e) {
      Log.e("getcontext", "IllegalAccessException: " + e);
    } catch (final InvocationTargetException e) {
      Log.e("getcontext", "InvocationTargetException: " + e);
    }
  }
コード例 #9
0
 @Override
 public String getCurrentTimeString() {
   return DateFormat.getTimeFormat(myApplication.getApplicationContext()).format(new Date());
 }
コード例 #10
0
  @Inject
  public BitmapHandler(Application osmTemplateApplication) {
    context = osmTemplateApplication.getApplicationContext();

    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    // Use 1/8th of the available memory for this memory cache.
    final int cacheSize = maxMemory / 8;

    cache =
        new LruCache<String, Bitmap>(cacheSize) {
          @Override
          protected int sizeOf(String key, Bitmap bitmap) {
            // The cache size will be measured in kilobytes rather than items count
            return bitmap.getByteCount() / 1024;
          }
        };

    icons.put("administrative", R.drawable.administrative);
    icons.put("animal_shelter", R.drawable.pet2);
    icons.put("antique", R.drawable.archaeological);
    icons.put("gallery", R.drawable.art_gallery2);
    icons.put("boat_sharing", R.drawable.sailing);
    icons.put("books", R.drawable.library);
    icons.put("boutique", R.drawable.convenience);
    icons.put("brothel", R.drawable.hotel2);
    icons.put("bureau_de_change", R.drawable.currency_exchange);
    icons.put("camp_site", R.drawable.camping);
    icons.put("car_wash", R.drawable.ford);
    icons.put("car_sharing", R.drawable.car_share);
    icons.put("clinic", R.drawable.doctors2);
    icons.put("arts_centre", R.drawable.art_gallery2);
    icons.put("dry_cleaning", R.drawable.laundrette);
    icons.put("archaeological_site", R.drawable.archaeological2);
    icons.put("farm", R.drawable.marketplace);
    icons.put("variety_store", R.drawable.convenience);
    icons.put("food_court", R.drawable.marketplace);
    icons.put("fort", R.drawable.castle2);
    icons.put("general", R.drawable.department_store);
    icons.put("hardware", R.drawable.mine);
    icons.put("doityourself", R.drawable.diy);
    icons.put("organic", R.drawable.greengrocer);
    icons.put("laundry", R.drawable.laundrette);
    icons.put("kindergarten", R.drawable.nursery3);
    icons.put("manor", R.drawable.house);
    icons.put("alpine_hut", R.drawable.alpinehut);
    icons.put("wilderness_hut", R.drawable.alpinehut);
    icons.put("ship", R.drawable.sailing);
    icons.put("music_venue", R.drawable.music);
    icons.put("music_venue", R.drawable.music);
    icons.put("nursing_home", R.drawable.hotel2);
    icons.put("optician", R.drawable.opticians);
    icons.put("viewpoint", R.drawable.photo);
    icons.put("crossing", R.drawable.zebra_crossing);
    icons.put("guest_house", R.drawable.bed_and_breakfast2);
    icons.put("photo_booth", R.drawable.photo);
    icons.put("picnic_site", R.drawable.picnic);
    icons.put("services", R.drawable.picnic);
    icons.put("public_bookcase", R.drawable.library);
    icons.put("register_office", R.drawable.administrative);
    icons.put("mini_roundabout", R.drawable.roundabout_anticlockwise);
    icons.put("ruins", R.drawable.ruin);
    icons.put("caravan_site", R.drawable.caravan_park);
    icons.put("tailor", R.drawable.clothes);
    icons.put("taxi", R.drawable.taxi_rank);
    icons.put("tomb", R.drawable.memorial);
    icons.put("travel_agency", R.drawable.aerodrome);
    icons.put("video", R.drawable.video_rental);
    icons.put("waste_basket", R.drawable.waste_bin);
    icons.put("waste_basket", R.drawable.waste_bin);
    icons.put("artwork", R.drawable.art_gallery);
    icons.put("aerodrome", R.drawable.aerodrome);
    icons.put("aircraft", R.drawable.aerodrome);
    icons.put("alcohol", R.drawable.bar);
    icons.put("atm", R.drawable.atm);
    icons.put("attraction", R.drawable.attraction);
    icons.put("bank", R.drawable.bank);
    icons.put("bar", R.drawable.bar);
    icons.put("bus_stop", R.drawable.bus_stop);
    icons.put("bicycle_parking", R.drawable.bicycle_parking);
    icons.put("bicycle_rental", R.drawable.bicycle_rental);
    icons.put("biergarten", R.drawable.biergarten);
    icons.put("cafe", R.drawable.cafe);
    icons.put("car_rental", R.drawable.car_rental);
    icons.put("church", R.drawable.place_of_worship);
    icons.put("cinema", R.drawable.cinema);
    icons.put("city", R.drawable.town);
    icons.put("commercial", R.drawable.mall);
    icons.put("courthouse", R.drawable.courthouse);
    icons.put("dentist", R.drawable.dentist);
    icons.put("doctors", R.drawable.doctors);
    icons.put("drinking_water", R.drawable.drinking_water);
    icons.put("embassy", R.drawable.embassy);
    icons.put("fast_food", R.drawable.fast_food);
    icons.put("fire_station", R.drawable.fire_station);
    icons.put("fuel", R.drawable.fuel);
    icons.put("hamlet", R.drawable.town);
    icons.put("hospital", R.drawable.hospital);
    icons.put("hotel", R.drawable.hotel);
    icons.put("house", R.drawable.house);
    icons.put("housenumber", R.drawable.house);
    icons.put("hunting_stand", R.drawable.hunting_stand);
    icons.put("locality", R.drawable.town);
    icons.put("mall", R.drawable.mall);
    icons.put("nightclub", R.drawable.nightclub);
    icons.put("neighbourhood", R.drawable.house);
    icons.put("parking", R.drawable.parking);
    icons.put("pharmacy", R.drawable.pharmacy);
    icons.put("place_of_worship", R.drawable.place_of_worship);
    icons.put("police", R.drawable.police);
    icons.put("political", R.drawable.administrative);
    icons.put("primary", R.drawable.street);
    icons.put("prison", R.drawable.prison);
    icons.put("pub", R.drawable.pub);
    icons.put("recycling", R.drawable.recycling);
    icons.put("religious_administrative", R.drawable.place_of_worship);
    icons.put("residential", R.drawable.house);
    icons.put("restaurant", R.drawable.restaurant);
    icons.put("retail", R.drawable.mall);
    icons.put("road", R.drawable.street);
    icons.put("secondary", R.drawable.street);
    icons.put("stadium", R.drawable.stadium);
    icons.put("station", R.drawable.bus_stop);
    icons.put("street", R.drawable.street);
    icons.put("suburb", R.drawable.town);
    icons.put("subway_entrance", R.drawable.bus_stop);
    icons.put("supermarket", R.drawable.mall);
    icons.put("terminal", R.drawable.aerodrome);
    icons.put("tertiary", R.drawable.street);
    icons.put("theatre", R.drawable.theatre);
    icons.put("toilets", R.drawable.toilets);
    icons.put("town", R.drawable.town);
    icons.put("townhall", R.drawable.townhall);
    icons.put("track", R.drawable.street);
    icons.put("village", R.drawable.town);
    icons.put("phone", R.drawable.sos);
  }
コード例 #11
0
ファイル: Utils.java プロジェクト: qq24090467/Date_Android
 public static void initialize(Application app, String TAG) {
   mApplicationContent = app.getApplicationContext();
   Utils.TAG = TAG;
 }
コード例 #12
0
ファイル: ContextRetriever.java プロジェクト: Volcanoscar/Zen
 public Context getApplicationContext() {
   return application.getApplicationContext();
 }