com.blankj.utilcode.util.SPUtils Java Examples

The following examples show how to use com.blankj.utilcode.util.SPUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DebugActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.ll_title_menu:
            finish();
            break;
        case R.id.change_test:
            SPUtils.getInstance(Constant.SP_NAME).put(SELECT_STATUS, 1001);
            break;
        case R.id.change_preview:
            SPUtils.getInstance(Constant.SP_NAME).put(SELECT_STATUS, 2001);
            break;
        case R.id.change_release:
            SPUtils.getInstance(Constant.SP_NAME).put(SELECT_STATUS, 3001);
            break;
        case R.id.tv_restart_app:
            RestartAppUtils.restartAPP(this);
            break;
        default:
            break;
    }
}
 
Example #2
Source File: DebugActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public void initData() {
    int anInt = SPUtils.getInstance(Constant.SP_NAME).getInt(SELECT_STATUS);
    switch (anInt){
        case 1001:
            changeTest.setChecked(true);
            changePreview.setChecked(false);
            changeRelease.setChecked(false);
            break;
        case 2001:
            changeTest.setChecked(false);
            changePreview.setChecked(true);
            changeRelease.setChecked(false);
            break;
        case 3001:
            changeTest.setChecked(false);
            changePreview.setChecked(false);
            changeRelease.setChecked(true);
            break;
        default:
            changeTest.setChecked(true);
            changePreview.setChecked(false);
            changeRelease.setChecked(false);
            break;
    }
}
 
Example #3
Source File: PlayService.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 播放索引为position的音乐
 * @param position              索引
 */
public void play(int position) {
    if (audioMusics.isEmpty()) {
        return;
    }

    if (position < 0) {
        position = audioMusics.size() - 1;
    } else if (position >= audioMusics.size()) {
        //如果是最后一首音乐,则播放时直接播放第一首音乐
        position = 0;
    }

    mPlayingPosition = position;
    AudioBean music = audioMusics.get(mPlayingPosition);
    String id = music.getId();
    LogUtils.e("PlayService"+"----id----"+ id);
    //保存当前播放的musicId,下次进来可以记录状态
    long musicId = Long.parseLong(id);
    SPUtils.getInstance(Constant.SP_NAME).put(Constant.MUSIC_ID,musicId);
    play(music);
}
 
Example #4
Source File: AppInfoService.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public List<AppInfo> getAppInfo(String sign) throws RemoteException {
    List<AppInfo> list=new ArrayList<>();
    String aidlCheckAppInfoSign = AppToolUtils.getAidlCheckAppInfoSign();
    LogUtils.e("AppInfoService--AppInfoService",aidlCheckAppInfoSign+"-------------"+sign);
    if(!aidlCheckAppInfoSign.equals(sign)){
        return list;
    }
    list.add(new AppInfo("app版本号(versionName)", BuildConfig.VERSION_NAME));
    list.add(new AppInfo("app版本名称(versionCode)", BuildConfig.VERSION_CODE+""));
    list.add(new AppInfo("打包时间", BuildConfig.BUILD_TIME));
    list.add(new AppInfo("app包名", getPackageName()));
    list.add(new AppInfo("app作者", SPUtils.getInstance(Constant.SP_NAME).getString("name","杨充")));
    list.add(new AppInfo("app渠道", SPUtils.getInstance(Constant.SP_NAME).getString("channel")));
    list.add(new AppInfo("token", SPUtils.getInstance(Constant.SP_NAME).getString("token")));
    list.add(new AppInfo("App签名", AppToolUtils.getSingInfo(getApplicationContext(), getPackageName(), AppToolUtils.SHA1)));
    return list;
}
 
Example #5
Source File: PlayMusicFragment.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void switchPlayMode() {
    int playMode = SPUtils.getInstance(Constant.SP_NAME).getInt(Constant.PLAY_MODE, 0);
    PlayModeEnum mode = PlayModeEnum.valueOf(playMode);
    switch (mode) {
        case LOOP:
            mode = PlayModeEnum.SHUFFLE;
            ToastUtils.showShort(R.string.mode_shuffle);
            break;
        case SHUFFLE:
            mode = PlayModeEnum.SINGLE;
            ToastUtils.showShort(R.string.mode_one);
            break;
        case SINGLE:
            mode = PlayModeEnum.LOOP;
            ToastUtils.showShort(R.string.mode_loop);
            break;
        default:
            break;
    }
    SPUtils.getInstance(Constant.SP_NAME).put(Constant.PLAY_MODE, mode.value());
    initPlayMode();
}
 
Example #6
Source File: PlayService.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 下一首
 * 记住有播放类型,单曲循环,顺序循环,随机播放
 * 逻辑:如果不是最后一首,则还有下一首;如果是最后一首,则切换回第一首
 */
public void next() {
    //建议都添加这个判断
    if (audioMusics.isEmpty()) {
        return;
    }
    int playMode = SPUtils.getInstance(Constant.SP_NAME).getInt(Constant.PLAY_MODE, 0);
    int size = audioMusics.size();
    PlayModeEnum mode = PlayModeEnum.valueOf(playMode);
    switch (mode) {
        //随机
        case SHUFFLE:
            mPlayingPosition = new Random().nextInt(size);
            play(mPlayingPosition);
            break;
        //单曲
        case SINGLE:
            play(mPlayingPosition);
            break;
        //顺序播放并且循环
        case LOOP:
        default:
            if (mPlayingPosition != size - 1) {
                // 如果不是最后一首,则还有下一首
                mPlayingPosition++;
            } else {
                // 如果是最后一首,则切换回第一首
                mPlayingPosition = 0;
            }
            LogUtils.e("PlayService"+"----mPlayingPosition----"+ mPlayingPosition);
            play(mPlayingPosition);
            break;
    }
}
 
Example #7
Source File: AppInfoService.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean setChannel(String sign, String channel) throws RemoteException {
    if(!AppToolUtils.getAidlCheckAppInfoSign().equals(sign)){
        return false;
    }
    SPUtils.getInstance(Constant.SP_NAME).put("channel",channel);
    LogUtils.i("AppInfoService--setChannel:"+ channel);
    return true;
}
 
Example #8
Source File: AppInfoService.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean setAppAuthorName(String sign, String name) throws RemoteException {
    if(!AppToolUtils.getAidlCheckAppInfoSign().equals(sign)){
        return false;
    }
    SPUtils.getInstance(Constant.SP_NAME).put("name",name);
    LogUtils.i("AppInfoService--setAppAuthorName:"+ name);
    return true;
}
 
Example #9
Source File: SplashActivity.java    From youqu_master with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    boolean isFirst=SPUtils.getInstance().getBoolean(AppConstant.IS_FIRST_ENTER,true);
    if(isFirst){
        TaskStackBuilder.create(SplashActivity.this)
                .addNextIntentWithParentStack(new Intent(SplashActivity.this, MainActivity.class))
                .addNextIntent(new Intent(SplashActivity.this, IntroActivity.class))
                .startActivities();
        finish();
    }else{
        startActivity(MainActivity.class);
        finish();
    }
}
 
Example #10
Source File: SplashPagerActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void initView() {
    if(SPUtils.getInstance(Constant.SP_NAME).getBoolean(Constant.KEY_FIRST_SPLASH,true)){
        initGetImage();
        initBanner();
    } else {
        ActivityUtils.startActivity(GuideActivity.class);
        finish();
    }
}
 
Example #11
Source File: ExoPlayerView.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
private void initViewBefore(Context context) {
    if (!(context instanceof AppCompatActivity)) {
        throw new IllegalArgumentException("Context must be AppCompatActivity");
    }
    //是否使用surface view
    isUseSurfaceView = SPUtils.getInstance().getBoolean("surface_renders", true);
    //获取绑定的Activity实例
    mAttachActivity = (AppCompatActivity) context;
    //加载布局
    View.inflate(context, R.layout.layout_exo_player_view, this);
    //获取播放器实例,ffmpeg扩展不支持TextureView
    exoPlayer = isUseSurfaceView
            ? new ExoFFmpegPlayer(mAttachActivity, trackSelector)
            : ExoPlayerFactory.newSimpleInstance(mAttachActivity, trackSelector);
    //屏幕翻转控制
    mOrientationListener = new OrientationEventListener(mAttachActivity) {
        @Override
        public void onOrientationChanged(int orientation) {
            if (mIsNeverPlay) {
                return;
            }
            // 根据角度进行横屏切换
            if (orientation >= 60 && orientation <= 120) {
                mAttachActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            } else if (orientation >= 240 && orientation <= 300) {
                mAttachActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }
        }
    };
    //声音管理器
    mAudioManager = (AudioManager) mAttachActivity.getSystemService(Context.AUDIO_SERVICE);
    if (mAudioManager != null)
        mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}
 
Example #12
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
/**
 * 上次播放的视频
 */
public String getLastPlayVideo() {
    if (lastPlayPath == null) {
        lastPlayPath = SPUtils.getInstance().getString(Constants.Config.LAST_PLAY_VIDEO_PATH, "");
    }
    return lastPlayPath;
}
 
Example #13
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
/**
 * 上次使用的SMB连接工具
 */
public SmbType getSmbTools() {
    String typeStr = SPUtils.getInstance().getString(Constants.Config.SMB_TOOLS_TYPE);
    if (!TextUtils.isEmpty(typeStr)){
        return SmbType.valueOf(typeStr);
    }
    return SmbType.SMBJ_RPC;
}
 
Example #14
Source File: LoginActivity.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
protected void initView() {
    super.initView();


    userName.setText(SPUtils.getInstance().getString("username"));
    password.setText(SPUtils.getInstance().getString("password"));
}
 
Example #15
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setOpenMediaCodeCH265(boolean isUse) {
    SPUtils.getInstance().put(Constants.PlayerConfig.SHARE_MEDIA_CODE_C_H265, isUse);
}
 
Example #16
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * Token
 */
public String getToken() {
    return SPUtils.getInstance().getString(Constants.UserConfig.TOKEN, "");
}
 
Example #17
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * 开启H265硬解码
 */
public boolean isOpenMediaCodeCH265() {
    return SPUtils.getInstance().getBoolean(Constants.PlayerConfig.SHARE_MEDIA_CODE_C_H265);
}
 
Example #18
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void saveSeasonSortType(int type) {
    SPUtils.getInstance().put(Constants.Config.SEASON_SORT, type);
}
 
Example #19
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setDownloadFolder(String path) {
    SPUtils.getInstance().put(Constants.Config.LOCAL_DOWNLOAD_FOLDER, path);
}
 
Example #20
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * 下载目录
 */
public String getDownloadFolder() {
    return SPUtils.getInstance().getString(Constants.Config.LOCAL_DOWNLOAD_FOLDER, Constants.DefaultConfig.downloadPath);
}
 
Example #21
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * 开启硬解码
 */
public boolean isOpenMediaCodeC() {
    return SPUtils.getInstance().getBoolean(Constants.PlayerConfig.SHARE_MEDIA_CODE_C);
}
 
Example #22
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setOpenMediaCodeC(boolean isUse) {
    SPUtils.getInstance().put(Constants.PlayerConfig.SHARE_MEDIA_CODE_C, isUse);
}
 
Example #23
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setCloseSplashPage(boolean isClose) {
    SPUtils.getInstance().put(Constants.Config.CLOSE_SPLASH_PAGE, isClose);
}
 
Example #24
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setShowOuterChainDanmuDialog(boolean isShow) {
    SPUtils.getInstance().put(Constants.PlayerConfig.SHOW_OUTER_CHAIN_DANMU_DIALOG, isShow);
}
 
Example #25
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * 上次更新云过滤的时间
 */
public long getUpdateFilterTime() {
    return SPUtils.getInstance().getLong(Constants.Config.UPDATE_FILTER_TIME, 0);
}
 
Example #26
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * smb文件排序是否为grid layout
 */
public boolean smbIsGridLayout() {
    return SPUtils.getInstance().getBoolean(Constants.Config.SMB_IS_GRID_LAYOUT, true);
}
 
Example #27
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setSurfaceRenders(boolean isUse) {
    SPUtils.getInstance().put(Constants.PlayerConfig.SHARE_SURFACE_RENDERS, isUse);
}
 
Example #28
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
 * PlayerType
 */
public int getPlayerType() {
    return SPUtils.getInstance().getInt(Constants.PlayerConfig.SHARE_PLAYER_TYPE, com.xyoye.player.commom.utils.Constants.IJK_PLAYER);
}
 
Example #29
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void saveToken(String token) {
    SPUtils.getInstance().put(Constants.UserConfig.TOKEN, token);
}
 
Example #30
Source File: AppConfig.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
public void setPlayerType(int type) {
    SPUtils.getInstance().put(Constants.PlayerConfig.SHARE_PLAYER_TYPE, type);
}