huaxunhuang
10/21/2017 - 6:35 AM

Anki Android #01

public class AudioView extends LinearLayout {

    /**
     * @param context Resources for images
     * @param resPlay
     * @param resPause
     * @param resStop
     * @param audioPath
     * @return
     */
    public static AudioView createPlayerInstance(Context context, int resPlay, int resPause, int resStop,
            String audioPath) {
        return new AudioView(context, resPlay, resPause, resStop, audioPath);
    }


    public static AudioView createRecorderInstance(Context context, int resPlay, int resPause, int resStop,
            int resRecord, int resRecordStop, String audioPath) {
        return new AudioView(context, resPlay, resPause, resStop, resRecord, resRecordStop, audioPath);
    }


    private AudioView(Context context, int resPlay, int resPause, int resStop, String audioPath) {
        super(context);

        mContext = context;

        mResPlayImage = resPlay;
        mResPauseImage = resPause;
        mResStopImage = resStop;
        mAudioPath = audioPath;

        this.setOrientation(HORIZONTAL);

        mPlayPause = new PlayPauseButton(context);
        addView(mPlayPause, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        mStop = new StopButton(context);
        addView(mStop, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    }

}