NIMSDK-AOS  10.5.0
CaptureDeviceInfoConfig.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.model;
2 
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 
6 import androidx.annotation.Nullable;
7 
8 import org.json.JSONException;
9 import org.json.JSONObject;
10 
11 import java.io.Serializable;
12 
19 public class CaptureDeviceInfoConfig implements Serializable, Parcelable {
20  public static final String KEY_CAPTURE_MODEL = "KEY_CAPTURE_MODEL";
21  public static final String KEY_CAPTURE_MANUFACTURER = "KEY_CAPTURE_MANUFACTURER";
22  public static final String KEY_CAPTURE_BRAND = "KEY_CAPTURE_BRAND";
23 
24  private final boolean captureModel;
25  private final boolean captureManufacturer;
26  private final boolean captureBrand;
27 
28  public CaptureDeviceInfoConfig(boolean captureModel, boolean captureManufacturer, boolean captureBrand) {
29  this.captureModel = captureModel;
30  this.captureManufacturer = captureManufacturer;
31  this.captureBrand = captureBrand;
32  }
33 
39  public boolean isCaptureModel() {
40  return captureModel;
41  }
42 
48  public boolean isCaptureManufacturer() {
49  return captureManufacturer;
50  }
51 
57  public boolean isCaptureBrand() {
58  return captureBrand;
59  }
60 
61  public CaptureDeviceInfoConfig(Parcel in) {
62  captureModel = in.readInt() > 0;
63  captureManufacturer = in.readInt() > 0;
64  captureBrand = in.readInt() > 0;
65  }
66 
67  @Override
68  public int describeContents() {
69  return 0;
70  }
71 
72  @Override
73  public void writeToParcel(Parcel dest, int flags) {
74  dest.writeInt(captureModel ? 1 : 0);
75  dest.writeInt(captureManufacturer ? 1 : 0);
76  dest.writeInt(captureBrand ? 1 : 0);
77  }
78 
79  public static final Creator<CaptureDeviceInfoConfig> CREATOR = new Creator<CaptureDeviceInfoConfig>() {
80  @Override
81  public CaptureDeviceInfoConfig createFromParcel(Parcel in) {
82  return new CaptureDeviceInfoConfig(in);
83  }
84 
85  @Override
86  public CaptureDeviceInfoConfig[] newArray(int size) {
87  return new CaptureDeviceInfoConfig[size];
88  }
89  };
90 
91  public JSONObject toJson() {
92  JSONObject object = new JSONObject();
93  try {
94  object.putOpt(KEY_CAPTURE_MODEL, captureModel);
95  object.putOpt(KEY_CAPTURE_MANUFACTURER, captureManufacturer);
96  object.putOpt(KEY_CAPTURE_BRAND, captureBrand);
97  } catch (JSONException e) {
98  e.printStackTrace();
99  }
100  return object;
101  }
102 
103  public static CaptureDeviceInfoConfig fromJson(@Nullable JSONObject object) {
104  if (object == null) {
105  return null;
106  }
107 
108  final boolean captureModel = object.optBoolean(KEY_CAPTURE_MODEL, false);
109  final boolean captureManufacturer = object.optBoolean(KEY_CAPTURE_MANUFACTURER, false);
110  final boolean captureBrand = object.optBoolean(KEY_CAPTURE_BRAND, false);
111  return new CaptureDeviceInfoConfig(captureModel, captureManufacturer, captureBrand);
112  }
113 }
static final Creator< CaptureDeviceInfoConfig > CREATOR
static CaptureDeviceInfoConfig fromJson(@Nullable JSONObject object)
boolean isCaptureManufacturer()
是否获取制造商信息。
CaptureDeviceInfoConfig(boolean captureModel, boolean captureManufacturer, boolean captureBrand)