@@ -1,10 +1,18 @@ |
||
| 1 | 1 |
package ai.pai.lensman.dslr; |
| 2 | 2 |
|
| 3 |
+import java.util.Random; |
|
| 4 |
+ |
|
| 5 |
+import ai.pai.lensman.BuildConfig; |
|
| 6 |
+ |
|
| 3 | 7 |
public class CameraJNIInterface {
|
| 4 | 8 |
|
| 5 | 9 |
|
| 6 | 10 |
static {
|
| 7 |
- System.loadLibrary("hello_jni");
|
|
| 11 |
+ try {
|
|
| 12 |
+ System.loadLibrary("hello_jni");
|
|
| 13 |
+ }catch (Throwable e){
|
|
| 14 |
+ e.printStackTrace(); |
|
| 15 |
+ } |
|
| 8 | 16 |
} |
| 9 | 17 |
|
| 10 | 18 |
private static CameraJNIInterface instance; |
@@ -25,4 +33,42 @@ public class CameraJNIInterface {
|
||
| 25 | 33 |
public native String mygpcameragetsummary(); |
| 26 | 34 |
public native String mygpcamerawaitforevent(String foldr_path); |
| 27 | 35 |
|
| 36 |
+ public int java_mygpcamerainit(){
|
|
| 37 |
+ try {
|
|
| 38 |
+ return mygpcamerainit(); |
|
| 39 |
+ }catch (Throwable t){
|
|
| 40 |
+ t.printStackTrace(); |
|
| 41 |
+ } |
|
| 42 |
+ if(BuildConfig.isTestMode){
|
|
| 43 |
+ return 0; |
|
| 44 |
+ }else{
|
|
| 45 |
+ return -1; |
|
| 46 |
+ } |
|
| 47 |
+ } |
|
| 48 |
+ public int java_mygpcameraexit(){
|
|
| 49 |
+ try {
|
|
| 50 |
+ return mygpcameraexit(); |
|
| 51 |
+ }catch (Throwable t){
|
|
| 52 |
+ t.printStackTrace(); |
|
| 53 |
+ } |
|
| 54 |
+ if(BuildConfig.isTestMode){
|
|
| 55 |
+ return 0; |
|
| 56 |
+ }else{
|
|
| 57 |
+ return -1; |
|
| 58 |
+ } |
|
| 59 |
+ } |
|
| 60 |
+ |
|
| 61 |
+ public String java_mygpcamerawaitforevent(String folder_path){
|
|
| 62 |
+ try{
|
|
| 63 |
+ return mygpcamerawaitforevent(folder_path); |
|
| 64 |
+ }catch (Throwable t){
|
|
| 65 |
+ t.printStackTrace(); |
|
| 66 |
+ } |
|
| 67 |
+ if(BuildConfig.isTestMode){
|
|
| 68 |
+ return new Random().nextInt(100)%2==0 ?"1.jpg":"2.jpg"; |
|
| 69 |
+ }else{
|
|
| 70 |
+ return "init error"; |
|
| 71 |
+ } |
|
| 72 |
+ } |
|
| 73 |
+ |
|
| 28 | 74 |
} |
@@ -14,14 +14,12 @@ import com.android.common.utils.DeviceUtils; |
||
| 14 | 14 |
import com.android.common.utils.LogHelper; |
| 15 | 15 |
import com.nostra13.universalimageloader.core.DisplayImageOptions; |
| 16 | 16 |
|
| 17 |
-import java.io.File; |
|
| 18 | 17 |
import java.util.ArrayList; |
| 19 | 18 |
|
| 20 | 19 |
import ai.pai.lensman.R; |
| 21 | 20 |
import ai.pai.lensman.bean.PhotoBean; |
| 22 | 21 |
import ai.pai.lensman.bean.SessionBean; |
| 23 | 22 |
import ai.pai.lensman.session.SessionActivity; |
| 24 |
-import ai.pai.lensman.utils.Constants; |
|
| 25 | 23 |
import ai.pai.lensman.utils.ImageLoaderUtils; |
| 26 | 24 |
import butterknife.BindView; |
| 27 | 25 |
import butterknife.ButterKnife; |
@@ -85,8 +83,7 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
| 85 | 83 |
ArrayList<PhotoBean> photoList = item.sessionPhotos; |
| 86 | 84 |
|
| 87 | 85 |
if(photoList!=null && photoList.size()>0){
|
| 88 |
- String path = Constants.APP_IMAGE_DIR + File.separator+item.sessionId+File.separator |
|
| 89 |
- +Constants.THUMBNAIL_DIR_NAME+File.separator+item.sessionPhotos.get(0).photoName; |
|
| 86 |
+ String path = item.sessionPhotos.get(0).photoPath; |
|
| 90 | 87 |
ImageLoaderUtils.displayLocalImage(path, holder.photo, options); |
| 91 | 88 |
int uploaded = 0; |
| 92 | 89 |
int error = 0; |
@@ -18,6 +18,7 @@ import com.umeng.analytics.MobclickAgent; |
||
| 18 | 18 |
|
| 19 | 19 |
import java.io.File; |
| 20 | 20 |
|
| 21 |
+import ai.pai.lensman.BuildConfig; |
|
| 21 | 22 |
import ai.pai.lensman.R; |
| 22 | 23 |
import ai.pai.lensman.activities.SessionQRCodeActivity; |
| 23 | 24 |
import ai.pai.lensman.base.BaseActivity; |
@@ -76,6 +77,9 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 76 | 77 |
setContentView(R.layout.activity_session); |
| 77 | 78 |
unbinder = ButterKnife.bind(this); |
| 78 | 79 |
sessionBean =(SessionBean)getIntent().getSerializableExtra("session");
|
| 80 |
+ if(BuildConfig.isTestMode){
|
|
| 81 |
+ sessionBean.sessionId="test"; |
|
| 82 |
+ } |
|
| 79 | 83 |
presenter = new SessionPresenter(sessionBean,this); |
| 80 | 84 |
|
| 81 | 85 |
titleTextView.setText(getString(R.string.scene)+sessionBean.sessionSeq); |
@@ -134,23 +138,41 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 134 | 138 |
|
| 135 | 139 |
@Override |
| 136 | 140 |
public synchronized void addNewPhoto(final PhotoBean bean) {
|
| 137 |
- LogHelper.d(TAG,"addNewPhoto to UI "+bean); |
|
| 138 |
- adapter.addPhotoBean(bean); |
|
| 139 |
- photosRecyclerView.smoothScrollToPosition(0); |
|
| 141 |
+ photosRecyclerView.post(new Runnable() {
|
|
| 142 |
+ @Override |
|
| 143 |
+ public void run() {
|
|
| 144 |
+ LogHelper.d(TAG,"addNewPhoto to UI "+bean); |
|
| 145 |
+ adapter.addPhotoBean(bean); |
|
| 146 |
+ photosRecyclerView.smoothScrollToPosition(0); |
|
| 147 |
+ } |
|
| 148 |
+ }); |
|
| 149 |
+ |
|
| 140 | 150 |
} |
| 141 | 151 |
|
| 142 | 152 |
@Override |
| 143 | 153 |
public void showPhotoRecyclerView() {
|
| 144 |
- qrcodeScanBtn.setVisibility(View.GONE); |
|
| 145 |
- noPhotoLayout.setVisibility(View.GONE); |
|
| 146 |
- photosRecyclerView.setVisibility(View.VISIBLE); |
|
| 154 |
+ photosRecyclerView.post(new Runnable() {
|
|
| 155 |
+ @Override |
|
| 156 |
+ public void run() {
|
|
| 157 |
+ qrcodeScanBtn.setVisibility(View.GONE); |
|
| 158 |
+ noPhotoLayout.setVisibility(View.GONE); |
|
| 159 |
+ photosRecyclerView.setVisibility(View.VISIBLE); |
|
| 160 |
+ } |
|
| 161 |
+ }); |
|
| 162 |
+ |
|
| 147 | 163 |
} |
| 148 | 164 |
|
| 149 | 165 |
@Override |
| 150 | 166 |
public void showEmptyView() {
|
| 151 |
- qrcodeScanBtn.setVisibility(View.VISIBLE); |
|
| 152 |
- photosRecyclerView.setVisibility(View.GONE); |
|
| 153 |
- noPhotoLayout.setVisibility(View.VISIBLE); |
|
| 167 |
+ photosRecyclerView.post(new Runnable() {
|
|
| 168 |
+ @Override |
|
| 169 |
+ public void run() {
|
|
| 170 |
+ qrcodeScanBtn.setVisibility(View.VISIBLE); |
|
| 171 |
+ photosRecyclerView.setVisibility(View.GONE); |
|
| 172 |
+ noPhotoLayout.setVisibility(View.VISIBLE); |
|
| 173 |
+ } |
|
| 174 |
+ }); |
|
| 175 |
+ |
|
| 154 | 176 |
} |
| 155 | 177 |
|
| 156 | 178 |
@Override |
@@ -64,7 +64,7 @@ public class SessionInteractor implements Callback{
|
||
| 64 | 64 |
+ File.separator + ai.pai.lensman.utils.Constants.ORIGIN_DIR_NAME; |
| 65 | 65 |
new File(sessionWorkingDirPath).mkdirs(); |
| 66 | 66 |
|
| 67 |
- int result = CameraJNIInterface.getInstance().mygpcamerainit(); |
|
| 67 |
+ int result = CameraJNIInterface.getInstance().java_mygpcamerainit(); |
|
| 68 | 68 |
if(result>=0){
|
| 69 | 69 |
listener.onSessionStartSuccess(sessionBean.sessionId); |
| 70 | 70 |
isWorking = true; |
@@ -106,7 +106,7 @@ public class SessionInteractor implements Callback{
|
||
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
isLastQueryReturned = false; |
| 109 |
- String photoName = CameraJNIInterface.getInstance().mygpcamerawaitforevent(sessionWorkingDirPath); |
|
| 109 |
+ String photoName = CameraJNIInterface.getInstance().java_mygpcamerawaitforevent(sessionWorkingDirPath); |
|
| 110 | 110 |
if(photoName!=null && photoName.length()>0){
|
| 111 | 111 |
String sub = photoName.substring(0,1); |
| 112 | 112 |
if(TextUtils.isDigitsOnly(sub)){
|
@@ -122,7 +122,7 @@ public class SessionInteractor implements Callback{
|
||
| 122 | 122 |
bean.sessionSeq = sessionBean.sessionSeq; |
| 123 | 123 |
bean.sessionDate = sessionBean.sessionDate; |
| 124 | 124 |
bean.sessionCreateTime = sessionBean.createTime; |
| 125 |
- bean.photoPath = Constants.APP_IMAGE_DIR+File.separator+photoName; |
|
| 125 |
+ bean.photoPath = sessionWorkingDirPath+File.separator+photoName; |
|
| 126 | 126 |
listener.onSessionPhotoCaptured(bean); |
| 127 | 127 |
} |
| 128 | 128 |
} |
@@ -138,7 +138,7 @@ public class SessionInteractor implements Callback{
|
||
| 138 | 138 |
photoCaptureTimer.cancel(); |
| 139 | 139 |
photoCaptureTimer = null; |
| 140 | 140 |
} |
| 141 |
- CameraJNIInterface.getInstance().mygpcameraexit(); |
|
| 141 |
+ CameraJNIInterface.getInstance().java_mygpcameraexit(); |
|
| 142 | 142 |
listener.onSessionEnd(sessionBean.sessionId); |
| 143 | 143 |
if(cameraInitHandler!=null){
|
| 144 | 144 |
cameraInitHandler.removeCallbacksAndMessages(null); |