欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

AndroidFM模塊學(xué)習(xí)之四源碼分析(九) - 新聞資訊 - 云南小程序開發(fā)|云南軟件開發(fā)|云南網(wǎng)站建設(shè)-昆明葵宇信息科技有限公司

159-8711-8523

云南網(wǎng)建設(shè)/小程序開發(fā)/軟件開發(fā)

知識

不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們在追求其視覺表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏壧峁┍憬莸闹С郑?

您當(dāng)前位置>首頁 » 新聞資訊 » 技術(shù)分享 >

AndroidFM模塊學(xué)習(xí)之四源碼分析(九)

發(fā)表時(shí)間:2020-10-19

發(fā)布人:葵宇科技

瀏覽次數(shù):72


接上一篇,接下來我們看看android\vendor\qcom\opensource\fm\fmapp2\src\com\caf\fmradio\PresetList.java
定義一個(gè)List列表List<PresetStation>mPresetList = new ArrayList<PresetStation>();
同步電臺數(shù)量
public synchronized int getStationCount(){
        return mPresetList.size();
    }

 
獲得電臺名字
 public synchronized String getStationName(int stationNum){
        String name = "";
        if (mPresetList.size() > stationNum){
            name = mPresetList.get(stationNum).getName();
        }
        return name;
    }

獲取電臺頻率
public synchronized int getStationFrequency(int stationNum){
        int frequency = 102100;
        if (mPresetList.size() > stationNum){
            frequency = mPresetList.get(stationNum).getFrequency();
        }
        return frequency;
    }

 
設(shè)置電臺頻率
public synchronized void setStationFrequency(int stationNum, int frequency){
        PresetStation mStation = mPresetList.get(stationNum);
        mStation.setFrequency(frequency);
    }
 
設(shè)置電臺名字
public synchronized void setStationName(int stationNum, String name){
        PresetStation mStation = mPresetList.get(stationNum);
        mStation.setName(name);
    }

 
經(jīng)由過程ID獲得電臺
public synchronized PresetStation getStationFromIndex(int index){
        int totalPresets = mPresetList.size();
        PresetStation station = null;
        if (index < totalPresets) {
            station = mPresetList.get(index);
        }
        return station;
    }

 
經(jīng)由過程頻率獲得電臺
public synchronized PresetStation getStationFromFrequency(int frequency){
        int totalPresets = mPresetList.size();
        for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
            PresetStation station = mPresetList.get(presetNum);
            if (station != null) {
                if(frequency == station.getFrequency()) {
                    return station;
                }
            }
        }
        return null;
    }

 
添加電臺名字和頻率
public synchronized PresetStation addStation(String name, int freq){
        PresetStation addStation = new PresetStation(name, freq);
        if(addStation != null) {
            mPresetList.add(addStation);
        }
        return addStation;
    }

添加電臺
public synchronized PresetStation addStation(PresetStation station){
        PresetStation addStation = null;
        if(station != null) {
            addStation = new PresetStation (station);
            mPresetList.add(addStation);
        }
        return addStation;
    }

 
刪除電臺
 public synchronized void removeStation(int index){
       int totalPresets = mPresetList.size();
       if((index >= 0) && (index < totalPresets))
       {
          mPresetList.remove(index);
       }
    }

 
清除調(diào)頻列表
public synchronized void clear(){
        mPresetList.clear();
    }

 
/ *如不雅用戶選擇一個(gè)新電臺在這個(gè)列表中,將調(diào)用這個(gè)函數(shù)來更新列表。
* /
public synchronized boolean setSelectedStation(PresetStation selectStation){
        int totalPresets = mPresetList.size();
        if (selectStation != null) {
            for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
                PresetStation station = mPresetList.get(presetNum);
                if (station != null) {
                    if(selectStation.getFrequency() == station.getFrequency()) {
                        if(selectStation.getName().equalsIgnoreCase(station.getName())) {
                            mCurrentStation = presetNum;
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }

 
/ *檢查是否有雷同電臺存在在列表中
* /
public synchronized boolean sameStationExists(PresetStation compareStation){
        int totalPresets = mPresetList.size();
        if (compareStation != null) {
            for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
                PresetStation station = mPresetList.get(presetNum);
                if (station != null) {
                    if(compareStation.getFrequency() == station.getFrequency()) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

 
/ *如不雅用戶在這個(gè)列表中選擇一個(gè)新電臺,將調(diào)用這個(gè)例程
*更新列表。
* /
public synchronized boolean setSelectedStation(int stationIndex){
        boolean foundStation = false;
        int totalPresets = mPresetList.size();
        if (stationIndex < totalPresets) {
            mCurrentStation = stationIndex;
            foundStation = true;
        }
        return foundStation;
    }

 
選擇電臺
<pre name="code" class="java">public synchronized void selectStation(PresetStation selectStation){
        int totalPresets = mPresetList.size();
        if (selectStation != null) {
            for (int presetNum = 0; presetNum < totalPresets; presetNum++ ) {
                PresetStation station = mPresetList.get(presetNum);
                if (station != null) {
                    if(selectStation.getFrequency() == station.getFrequency()) {
                        mCurrentStation    = presetNum;
                        return;
                    }
                }
            }
        }
    }






 
獲取選擇的┞肪
public synchronized PresetStation getSelectedStation(){
        int totalPresets = mPresetList.size();
        PresetStation station = null;
        if (mCurrentStation < totalPresets) {
            station = mPresetList.get(mCurrentStation);
        }
        return station;
    }

 
選擇下一電臺
public synchronized PresetStation selectNextStation(){
        int totalPresets = mPresetList.size();
        PresetStation station = null;
        if(totalPresets > 0) {
            mCurrentStation ++;
            if ( (mCurrentStation) >= totalPresets) {
                mCurrentStation =0;
            }
            station = mPresetList.get(mCurrentStation);
        }
        return station;
    }

 選擇上一個(gè)電臺
 public synchronized PresetStation selectPrevStation(){
        int totalPresets = mPresetList.size();
        PresetStation station = null;
        if(totalPresets > 0) {
            mCurrentStation --;
            if ( mCurrentStation < 0) {
                mCurrentStation = totalPresets-1;
            }
            station = mPresetList.get(mCurrentStation);
        }
        return station;
    }

相關(guān)案例查看更多