@@ -14,6 +14,8 @@ import android.widget.ImageView; |
||
| 14 | 14 |
import android.widget.ListView; |
| 15 | 15 |
|
| 16 | 16 |
import com.ptplib.usbcamera.BaselineInitiator; |
| 17 |
+import com.ptplib.usbcamera.DeviceInfo; |
|
| 18 |
+import com.ptplib.usbcamera.NameFactory; |
|
| 17 | 19 |
import com.ptplib.usbcamera.PTPException; |
| 18 | 20 |
import com.ptplib.usbcamera.eos.EosInitiator; |
| 19 | 21 |
import com.ptplib.usbcamera.nikon.NikonInitiator; |
@@ -27,6 +29,7 @@ public class MyTestActivity extends Activity {
|
||
| 27 | 29 |
|
| 28 | 30 |
private UsbManager mUsbManager; |
| 29 | 31 |
private BaselineInitiator bi; |
| 32 |
+ private NameFactory factory = new NameFactory(); |
|
| 30 | 33 |
|
| 31 | 34 |
private static final String TAG = "USBTest"; |
| 32 | 35 |
|
@@ -39,13 +42,22 @@ public class MyTestActivity extends Activity {
|
||
| 39 | 42 |
|
| 40 | 43 |
photoIv = (ImageView)findViewById(R.id.iv_latest_photo); |
| 41 | 44 |
infoListView = (ListView)findViewById(R.id.list_info); |
| 42 |
- adapter = new MyTestAdapter(this); |
|
| 45 |
+ adapter = new MyTestAdapter(this,infoListView); |
|
| 43 | 46 |
infoListView.setAdapter(adapter); |
| 44 | 47 |
|
| 45 | 48 |
findViewById(R.id.btn_get_devece_info).setOnClickListener(new View.OnClickListener() {
|
| 46 | 49 |
@Override |
| 47 | 50 |
public void onClick(View v) {
|
| 48 |
- |
|
| 51 |
+ if (bi== null || bi.getInfo() == null){
|
|
| 52 |
+ adapter.addInfo("USB设备未连接");
|
|
| 53 |
+ return; |
|
| 54 |
+ } |
|
| 55 |
+ DeviceInfo info = bi.getInfo(); |
|
| 56 |
+ if (info.getVendorExtensionId() != 0) {
|
|
| 57 |
+ factory = factory.updateFactory (info.getVendorExtensionId()); |
|
| 58 |
+ info.setFactory(factory); |
|
| 59 |
+ } |
|
| 60 |
+ adapter.addInfo(" 设备信息: "+ bi.getInfo().toString());
|
|
| 49 | 61 |
} |
| 50 | 62 |
}); |
| 51 | 63 |
|
@@ -5,6 +5,7 @@ import android.view.LayoutInflater; |
||
| 5 | 5 |
import android.view.View; |
| 6 | 6 |
import android.view.ViewGroup; |
| 7 | 7 |
import android.widget.BaseAdapter; |
| 8 |
+import android.widget.ListView; |
|
| 8 | 9 |
import android.widget.TextView; |
| 9 | 10 |
|
| 10 | 11 |
import com.strickling.usbcamera.R; |
@@ -17,11 +18,13 @@ public class MyTestAdapter extends BaseAdapter {
|
||
| 17 | 18 |
|
| 18 | 19 |
private ArrayList<String> infoList; |
| 19 | 20 |
private Context context; |
| 21 |
+ private ListView listView; |
|
| 20 | 22 |
private LayoutInflater inflater; |
| 21 | 23 |
private SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss\t");
|
| 22 | 24 |
|
| 23 |
- public MyTestAdapter(Context context) {
|
|
| 25 |
+ public MyTestAdapter(Context context, ListView listView) {
|
|
| 24 | 26 |
this.context = context; |
| 27 |
+ this.listView = listView; |
|
| 25 | 28 |
infoList = new ArrayList<>(); |
| 26 | 29 |
inflater = LayoutInflater.from(context); |
| 27 | 30 |
} |
@@ -44,6 +47,7 @@ public class MyTestAdapter extends BaseAdapter {
|
||
| 44 | 47 |
public void addInfo(String info){
|
| 45 | 48 |
infoList.add(formatter.format(new Date())+info); |
| 46 | 49 |
notifyDataSetChanged(); |
| 50 |
+ listView.smoothScrollToPosition(infoList.size()); |
|
| 47 | 51 |
} |
| 48 | 52 |
|
| 49 | 53 |
@Override |