Sha256: 9701e72639ee08651f787b5e10bdf696ef15f4228ffcf7d08718cbe475ffb345

Contents?: true

Size: 1.97 KB

Versions: 15

Compression:

Stored size: 1.97 KB

Contents

package com.rho.camera;

import android.hardware.Camera;
import android.os.Build;

import com.rhomobile.rhodes.Logger;
import com.rhomobile.rhodes.osfunctionality.OsVersionManager;

public class CameraFactory implements ICameraFactory {
    private static final String TAG = CameraFactory.class.getSimpleName();
    
    private ICameraSingletonObject mSingleton;
    private ICameraObject[] mCameraList;
    private CameraRhoListener mRhoListener;
    
    public CameraFactory(CameraRhoListener rhoListener) {
        mRhoListener = rhoListener;

        OsVersionManager.registerSelector(ICameraSingletonObject.class, CameraSingletonObject.class.getCanonicalName());
        OsVersionManager.registerSelector(Build.VERSION_CODES.ECLAIR, ICameraSingletonObject.class, CameraSingletonEclair.class.getCanonicalName());
        OsVersionManager.registerSelector(Build.VERSION_CODES.GINGERBREAD, ICameraSingletonObject.class, CameraSingletonGingerbread.class.getCanonicalName());
    }

    @Override
    public ICameraSingleton getApiSingleton() {
        return getCameraSingleton();
    }

    @Override
    public ICamera getApiObject(String id) {
        return getCameraObject(id);
    }
    
    ICameraSingletonObject getCameraSingleton() {
        if (mSingleton == null) {
            mSingleton = OsVersionManager.getFeature(ICameraSingletonObject.class);
            
            int count = mSingleton.getCameraCount();
            mCameraList = new ICameraObject[count];
        }
        return mSingleton;
    }
    
    ICameraObject getCameraObject(String id) {
        int idx = CameraSingletonObject.getCameraIndex(id);

        if (idx >= mCameraList.length) {
            Logger.E(TAG, "Unknown camera id: " + id);
            return null;
        }

        if (mCameraList[idx] == null) {
            mCameraList[idx] = getCameraSingleton().createCameraObject(id);
        }
        return mCameraList[idx];
    }
    
    CameraRhoListener getRhoListener() {
        return mRhoListener;
    }
}

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
rhodes-7.4.1 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-7.1.17 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-6.2.0 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-6.0.11 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.18 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.17 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.15 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.0.22 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.2 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.0.7 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.0.3 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
rhodes-5.5.0 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
tauplatform-1.0.3 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
tauplatform-1.0.2 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java
tauplatform-1.0.1 lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java