simple project
This commit is contained in:
@@ -1,51 +1,12 @@
|
|||||||
package com.ydd.sportfaceid.config;
|
package com.ydd.sportfaceid.config;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
|
|
||||||
public class SDAppConfig {
|
public class SDAppConfig {
|
||||||
|
|
||||||
public final static String TAG = "sanderConfig";
|
|
||||||
|
|
||||||
public static SDAppConfig config = null;
|
public static SDAppConfig config = null;
|
||||||
|
|
||||||
public static String Key_sace_cache = "save_cache";
|
|
||||||
|
|
||||||
public static String camera_rstp_first = "rtsp://192.168.1.161/user=admin&password=&channel=1&stream=0.sdp?";
|
|
||||||
public static String camera_rstp_sconde = "rtsp://192.168.1.160:8554/0/0/0";
|
|
||||||
|
|
||||||
|
|
||||||
public String camera_local_rstp_first;
|
|
||||||
public final static String key_camera_local_rstp_first = "key_camera_local_rstp_first";
|
|
||||||
|
|
||||||
public String camera_local_rstp_last;
|
|
||||||
public final static String key_camera_local_rstp_last = "key_camera_local_rstp_last";
|
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private SharedPreferences sp;
|
|
||||||
private SharedPreferences.Editor sp_editor;
|
|
||||||
|
|
||||||
public int getCurrent_selected_camera() {
|
|
||||||
if (this.current_selected_camera >= 0 ){
|
|
||||||
this.current_selected_camera = sp.getInt(key_current_selectd_camera,-1);
|
|
||||||
}
|
|
||||||
return current_selected_camera;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrent_selected_camera(int current_selected_camera) {
|
|
||||||
this.current_selected_camera = current_selected_camera;
|
|
||||||
sp_editor.putInt(key_current_selectd_camera, current_selected_camera);
|
|
||||||
sp_editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static String key_current_selectd_camera = "key_current_selectd_camera";
|
|
||||||
private int current_selected_camera = -1;
|
|
||||||
public static SDAppConfig getInstance(){
|
public static SDAppConfig getInstance(){
|
||||||
synchronized (SDAppConfig.class){
|
synchronized (SDAppConfig.class){
|
||||||
if (config == null){
|
if (config == null){
|
||||||
@@ -58,67 +19,8 @@ public class SDAppConfig {
|
|||||||
public void init(Context context){
|
public void init(Context context){
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
synchronized (SDAppConfig.class){
|
synchronized (SDAppConfig.class){
|
||||||
if (sp == null){
|
// Do SomeThing
|
||||||
sp = this.mContext.getSharedPreferences(Key_sace_cache, Context.MODE_PRIVATE);
|
|
||||||
sp_editor = sp.edit();
|
|
||||||
this.configData();
|
|
||||||
}else {
|
|
||||||
Log.e(TAG, "这里只能被执行一次");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void configData(){
|
|
||||||
this.camera_local_rstp_first = sp.getString(key_camera_local_rstp_first, "");
|
|
||||||
if (TextUtils.isEmpty(this.camera_local_rstp_first)){
|
|
||||||
this.setCamera_local_rstp_first(camera_rstp_first);
|
|
||||||
}
|
|
||||||
this.camera_local_rstp_last = sp.getString(key_camera_local_rstp_last, "");
|
|
||||||
if (TextUtils.isEmpty(this.camera_local_rstp_last)){
|
|
||||||
this.setCamera_local_rstp_last(camera_rstp_sconde);
|
|
||||||
}
|
|
||||||
this.current_selected_camera = sp.getInt(key_current_selectd_camera,-1);
|
|
||||||
if (this.current_selected_camera == -1){
|
|
||||||
this.setCurrent_selected_camera(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getCamera_local_rstp_first() {
|
|
||||||
if (TextUtils.isEmpty(camera_local_rstp_first)){
|
|
||||||
camera_local_rstp_first = sp.getString(key_camera_local_rstp_first, "");
|
|
||||||
}
|
|
||||||
return camera_local_rstp_first;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCamera_local_rstp_first(String camera_local_rstp_first) {
|
|
||||||
this.camera_local_rstp_first = camera_local_rstp_first;
|
|
||||||
sp_editor.putString(key_camera_local_rstp_first, camera_local_rstp_first);
|
|
||||||
sp_editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCamera_local_rstp_last() {
|
|
||||||
if (TextUtils.isEmpty(camera_local_rstp_last)){
|
|
||||||
camera_local_rstp_last = sp.getString(key_camera_local_rstp_last, "");
|
|
||||||
}
|
|
||||||
return camera_local_rstp_last;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCamera_local_rstp_last(String camera_local_rstp_last) {
|
|
||||||
this.camera_local_rstp_last = camera_local_rstp_last;
|
|
||||||
sp_editor.putString(key_camera_local_rstp_last, camera_local_rstp_last);
|
|
||||||
sp_editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCurrentCameraUrl(){
|
|
||||||
if (this.current_selected_camera == 1){
|
|
||||||
return this.getCamera_local_rstp_last();
|
|
||||||
}
|
|
||||||
return this.getCamera_local_rstp_first();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user