diff --git a/MyApplicationVolume/app/build.gradle b/MyApplicationVolume/app/build.gradle index 4da30acb2..6b671f6c6 100644 --- a/MyApplicationVolume/app/build.gradle +++ b/MyApplicationVolume/app/build.gradle @@ -22,7 +22,7 @@ android { versionCode 1 multiDexEnabled true - versionName "2.7.4" + versionName "1.3.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/MyApplicationVolume/app/src/main/AndroidManifest.xml b/MyApplicationVolume/app/src/main/AndroidManifest.xml index 36f2a8d40..bc4f15724 100644 --- a/MyApplicationVolume/app/src/main/AndroidManifest.xml +++ b/MyApplicationVolume/app/src/main/AndroidManifest.xml @@ -50,14 +50,15 @@ android:name=".core.Myapplication" android:allowBackup="true" android:exported="true" - android:icon="@mipmap/ic_launcher" - android:label="@string/app_name" + android:icon="@mipmap/ic_car_launcher_square" + android:label="@string/app_name_linshi" android:largeHeap="true" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" - android:roundIcon="@mipmap/ic_launcher_round" + android:roundIcon="@mipmap/ic_car_launcher_circle" android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar" + tools:replace="android:icon, android:label" tools:ignore="AllowBackup,GoogleAppIndexingWarning"> result = executorService.submit(new Callable() { - @Override - public Boolean call() throws Exception { - try { - OutputStream out = socket.getOutputStream(); - - String data = message; - if(!message.startsWith("/login")) - data = message + "\n"; - int dataLength = data.getBytes(StandardCharsets.UTF_8).length; - - /* - msg header = type + dataLength - */ - String header = String.format("DataTypeWithSize:%d %s\n",0, dataLength); -// if (!data.startsWith("HeartBeat")){ -// Log.d(TAG,"header: " + header.trim() + ", data: " + data); -//// Logcat.w("sender", data); -// } - - String finalMsg = header + data; - out.write(finalMsg.getBytes(StandardCharsets.UTF_8)); - out.flush(); - - /* - * show the progressbar - */ -// if (message.startsWith("/Imgblock:")){ -// MainActivity.showDownloadingPopupView(); -// } - - }catch (Exception e){ - Log.d(TAG, "Something wrong when send message to server"); - e.printStackTrace(); - if (resend){ - reconnectionInterface.onReconnection(message); - } - return false; - } + Future result = ExecutorServiceProvider.getExecutorService().submit(() -> { + try { + OutputStream out = socket.getOutputStream(); + String data = !message.startsWith("/login") ? message + "\n" : message; + int dataLength = data.getBytes(StandardCharsets.UTF_8).length; + String header = String.format("DataTypeWithSize:%d %s\n", 0, dataLength); + String finalMsg = header + data; + out.write(finalMsg.getBytes(StandardCharsets.UTF_8)); + out.flush(); return true; + } catch (Exception e) { + Log.e(TAG, "Error when sending message", e); + if (resend) { + reconnectionInterface.onReconnection(message); + } + return false; } }); - try { - if (waited){ + if (waited) { + try { return result.get(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + Log.e(TAG, "Thread was interrupted", e); + return false; + } catch (Exception e) { + Log.e(TAG, "Error waiting for result", e); + return false; } - } catch (Exception e){ - e.printStackTrace(); - return false; } - return true; + return true; // Assuming async submission without waiting is considered successful } - - public boolean testConnection(Socket socket){ - Future result = executorService.submit(new Callable() { + Future result = ExecutorServiceProvider.getExecutorService().submit(new Callable() { @Override public Boolean call() throws Exception { try { @@ -203,6 +179,6 @@ public byte[] longToBytes(long x) { } public void close(){ - executorService.shutdown(); + ExecutorServiceProvider.shutdownService(); } } diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/BasicConnector.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/BasicConnector.java index 3b1049a70..cf0cfd2fb 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/BasicConnector.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/BasicConnector.java @@ -60,6 +60,7 @@ public void run() { */ if (mSocket.isConnected()) { Log.e(TAG, "Connect Server Successfully !"); + } else { ToastEasy("Can't Connect Server, Try Again Please!"); } diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/ExecutorServiceProvider.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/ExecutorServiceProvider.java new file mode 100644 index 000000000..e24c9d318 --- /dev/null +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/connector/ExecutorServiceProvider.java @@ -0,0 +1,26 @@ +package com.penglab.hi5.core.collaboration.connector; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ExecutorServiceProvider { + private static ExecutorService executorService; + + private ExecutorServiceProvider () {} + + public static synchronized ExecutorService getExecutorService() { + if(executorService == null || executorService.isShutdown()) { + executorService = Executors.newFixedThreadPool(4); + + } + return executorService; + } + + public static synchronized void shutdownService() { + if(executorService !=null && !executorService.isShutdown()) { + executorService.shutdown(); + } + } + + +} diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/BasicService.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/BasicService.java index bbfb00760..4debfccbe 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/BasicService.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/BasicService.java @@ -27,7 +27,7 @@ public abstract class BasicService extends Service { // private static String TAG = BasicService.class.getSimpleName(); protected String TAG; - private ReceiveMsgInterface receiveMsgInterface; + private volatile ReceiveMsgInterface receiveMsgInterface; // Binder given to clients private final IBinder binder = new LocalBinder(); @@ -136,7 +136,7 @@ public void sendMsg(final String msg) { * thread for read and process msg */ class ReadThread extends Thread { - private Socket mSocket; + private volatile Socket mSocket; private InputStream is; private boolean isReconnect = false; /* when the something wrong with the connect, and need to reconnect in the service */ private boolean isReset = false; /* when the connector release the connect, and need to reset connect in this thread */ @@ -204,6 +204,9 @@ public void resetConnection() { @Override public void run() { super.run(); + while(mSocket == null){ + + } if (mSocket != null) { try { is = mSocket.getInputStream(); @@ -342,7 +345,9 @@ private void onRead(String tag) { } out.close(); + while(receiveMsgInterface==null){ + } receiveMsgInterface.onRecMessage("File:" + dataType.filepath + "/" + dataType.filename); @@ -465,6 +470,9 @@ private boolean processMsg(final String msg) { if (msg.endsWith("\n")) { Log.e(TAG,"ProcessMsg: "+msg); resetDataType(); + while(receiveMsgInterface==null){ + + } receiveMsgInterface.onRecMessage(msg.trim()); return true; diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/CollaborationService.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/CollaborationService.java index 7f6b8f4b3..25c8a7bf2 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/CollaborationService.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/collaboration/service/CollaborationService.java @@ -53,6 +53,7 @@ public void onDestroy() { // The service is no longer used and is being destroyed Log.d(TAG, "onDestroy"); super.onDestroy(); + isReleased = false; } @@ -81,7 +82,7 @@ public static void resetConnection(){ } /* when fail to send msg in service, reConnect the socket; use synchronized to avoid the using conflict of socket */ - public void reConnection(){ + public void reConnection() { Log.e(TAG,"Start to reConnect"); synchronized (lockForMsgSocket){ if(!mBasicConnector.checkConnection()){ diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsCollaborate.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsCollaborate.java index 796077251..12e02c5a5 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsCollaborate.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsCollaborate.java @@ -1,7 +1,5 @@ package com.penglab.hi5.core.net; -import android.util.Log; - import org.json.JSONObject; import okhttp3.Callback; @@ -11,25 +9,11 @@ * Created by Jackiexing on 06/24/21 */ public class HttpUtilsCollaborate extends HttpUtils{ - private static final String URL_GET_IMAGES = SERVER_IP + "/release/collaborate/getanoimage"; private static final String URL_GET_NEURONS = SERVER_IP + "/release/collaborate/getanoneuron"; - private static final String URL_GET_ANOS = SERVER_IP + "/release/collaborate/getano"; - private static final String URL_GET_AllSWCMETAINFO = DBMS_SERVER_IP + "/proto.DBMS/GetAllSwcMetaInfo"; + private static final String URL_GET_GetProjectSwcNamesByProjectUuid = DBMS_SERVER_IP + "/proto.DBMS/GetProjectSwcNamesByProjectUuid"; + private static final String URL_GET_AllProject = DBMS_SERVER_IP + "/proto.DBMS/GetAllProject"; private static final String URL_LOAD_ANO = SERVER_IP + "/release/collaborate/inheritother"; - public static void getImageListWithOkHttp(JSONObject userInfo, Callback callback) { - try { - RequestBody body = RequestBody.create(JSON,String.valueOf(new JSONObject() - .put("user", userInfo))); - asyncPostRequest(URL_GET_IMAGES, body, callback); - Log.e("body","getImageListCollaborate"+String.valueOf(new JSONObject() - .put("user",userInfo))); - - } catch (Exception e) { - e.printStackTrace(); - } - } - public static void getNeuronsWithOkHttp(JSONObject userInfo,String brianList,Callback callback) { try { RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject() @@ -41,34 +25,33 @@ public static void getNeuronsWithOkHttp(JSONObject userInfo,String brianList,Cal } } - public static void getAnoWithOkHttp(JSONObject userInfo,String neuron,Callback callback) { + public static void getProjectSwcNamesByProjectUuid(JSONObject param, Callback callback) { try { - RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject() - .put("neuron", neuron) - .put("user", userInfo))); - asyncPostRequest(URL_GET_ANOS, body, callback); + RequestBody body = RequestBody.create(JSON, String.valueOf(param)); + asyncPostRequest(URL_GET_GetProjectSwcNamesByProjectUuid, body, callback); } catch (Exception e) { e.printStackTrace(); } } - public static void getAllSwcMetaInfoWithOkHttp(JSONObject param, Callback callback) { + public static void getAllProject(JSONObject param, Callback callback) { try { RequestBody body = RequestBody.create(JSON, String.valueOf(param)); - asyncPostRequest(URL_GET_AllSWCMETAINFO, body, callback); + asyncPostRequest(URL_GET_AllProject, body, callback); } catch (Exception e) { e.printStackTrace(); } } - public static void loadAnoWithOkHttp(JSONObject userInfo,String brainList,String neuron,String ano,Callback callback) { + public static void loadAnoWithOkHttp(JSONObject userInfo,String brainList,String neuron,String ano, String projectName, Callback callback) { try { RequestBody body = RequestBody.create(JSON, String.valueOf(new JSONObject() .put("image",brainList) .put("neuron", neuron) .put("ano",ano) - .put("user", userInfo))); + .put("user", userInfo) + .put("project",projectName))); asyncPostRequest(URL_LOAD_ANO, body, callback); } catch (Exception e) { e.printStackTrace(); diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsUser.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsUser.java index 92446afd0..6dd815f74 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsUser.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/net/HttpUtilsUser.java @@ -11,7 +11,7 @@ public class HttpUtilsUser extends HttpUtils { private static final String URL_REGISTER = SERVER_IP + "/release/user/register"; private static final String URL_LOGIN = SERVER_IP + "/release/user/login"; - private static final String URL_GETUSERID = DBMS_SERVER_IP + "/proto.DBMS/GetUser"; + private static final String URL_GETUSERID = DBMS_SERVER_IP + "/proto.DBMS/GetUserByName"; private static final String URL_UPDATE_PASSWORD = SERVER_IP + "/release/user/updatepassword"; private static final String URL_FIND_PASSWORD = SERVER_IP + "/release/user/forgetpassword"; diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/BoutonDetection/BoutonDetectionActivity.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/BoutonDetection/BoutonDetectionActivity.java index c649e4157..c1ec39291 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/BoutonDetection/BoutonDetectionActivity.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/BoutonDetection/BoutonDetectionActivity.java @@ -134,10 +134,12 @@ public void run() { toolbar = (Toolbar) findViewById(R.id.toolbar_quality_control); setSupportActionBar(toolbar); + getSupportActionBar().setTitle("Synapse Validation"); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); - downloadingPopupView = new XPopup.Builder(this).asLoading("Downloading......"); + downloadingPopupView = new XPopup.Builder(this).asLoading("Call Hi5 programming......"); boutonDetectionViewModel = new ViewModelProvider(this, new ViewModelFactory()).get(BoutonDetectionViewModel.class); boutonDetectionViewModel.getAnnotationMode().observe(this, new Observer() { @Override diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/ImageClassify/ImageClassifyViewModel.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/ImageClassify/ImageClassifyViewModel.java index 39db4724d..2d0496eb6 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/ImageClassify/ImageClassifyViewModel.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/ImageClassify/ImageClassifyViewModel.java @@ -171,6 +171,7 @@ public RatingImageInfo acquireNextImage() { // synchronized (mLock) { if (mNextRatingImagesInfoDeque.isEmpty()) { + RequestGetImages(1); return null; } diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationActivity.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationActivity.java index f361e4043..36226473c 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationActivity.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationActivity.java @@ -8,7 +8,6 @@ import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; import android.os.Build; @@ -37,10 +36,9 @@ import androidx.lifecycle.ViewModelProvider; import com.jaredrummler.android.colorpicker.ColorPickerDialog; +import com.jaredrummler.android.colorpicker.ColorPickerDialogListener; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BasePopupView; -import com.lxj.xpopup.interfaces.OnCancelListener; -import com.lxj.xpopup.interfaces.OnConfirmListener; import com.lxj.xpopup.interfaces.OnSelectListener; import com.michaldrabik.tapbarmenulib.TapBarMenu; import com.netease.nimlib.sdk.Observer; @@ -52,7 +50,6 @@ import com.penglab.hi5.R; import com.penglab.hi5.basic.NeuronTree; import com.penglab.hi5.basic.image.ImageMarker; -import com.penglab.hi5.basic.image.XYZ; import com.penglab.hi5.basic.tracingfunc.gd.V_NeuronSWC_unit; import com.penglab.hi5.chat.nim.InfoCache; import com.penglab.hi5.chat.nim.main.helper.SystemMessageUnreadManager; @@ -61,6 +58,7 @@ import com.penglab.hi5.core.BaseActivity; import com.penglab.hi5.core.collaboration.Communicator; import com.penglab.hi5.core.collaboration.basic.ReceiveMsgInterface; +import com.penglab.hi5.core.collaboration.connector.ExecutorServiceProvider; import com.penglab.hi5.core.collaboration.connector.MsgConnector; import com.penglab.hi5.core.collaboration.connector.ServerConnector; import com.penglab.hi5.core.collaboration.service.BasicService; @@ -68,12 +66,13 @@ import com.penglab.hi5.core.collaboration.service.ManageService; import com.penglab.hi5.core.fileReader.annotationReader.ApoReader; import com.penglab.hi5.core.render.view.AnnotationGLSurfaceView; -import com.penglab.hi5.core.ui.ResourceResult; +import com.penglab.hi5.core.ui.BoutonDetection.BoutonDetectionActivity; import com.penglab.hi5.core.ui.ViewModelFactory; import com.penglab.hi5.core.ui.annotation.EditMode; +import com.penglab.hi5.core.ui.login.LoginActivity; +import com.penglab.hi5.core.ui.marker.MarkerFactoryActivity; import com.penglab.hi5.data.Result; import com.penglab.hi5.data.model.img.CollaborateNeuronInfo; -import com.jaredrummler.android.colorpicker.ColorPickerDialogListener; import java.util.ArrayList; import java.util.Arrays; @@ -82,8 +81,6 @@ import java.util.Objects; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -92,12 +89,9 @@ public class CollaborationActivity extends BaseActivity implements ReceiveMsgInt private static final String TAG = "CollaborationActivity"; private AnnotationGLSurfaceView annotationGLSurfaceView; private CollaborationViewModel collaborationViewModel; - - private static String conPath = ""; private static String port = ""; public static boolean firstLoad = true; private boolean firstJoinRoom = true; - private boolean copyFile = false; private boolean mBoundManagement = false; private boolean mBoundCollaboration = false; private static Context mainContext; @@ -146,9 +140,8 @@ public class CollaborationActivity extends BaseActivity implements ReceiveMsgInt public enum ShiftDirection { RIGHT, LEFT, UP, DOWN, FRONT, BACK } - - private ImageButton ROI_i; private ImageButton editModeIndicator; + private ImageButton ROI_i; private static BasePopupView downloadingPopupView; private static BasePopupView syncingPopupView; @@ -160,10 +153,6 @@ public enum ShiftDirection { private List neuronNumberList = new ArrayList<>(); - private final ExecutorService executorService = Executors.newFixedThreadPool(3); - - - @RequiresApi(api = Build.VERSION_CODES.O) @Override public void onRecMessage(String msg) { if (msg.startsWith("TestSocketConnection")) { @@ -314,25 +303,23 @@ public void onRecMessage(String msg) { String header = listWithHeader.get(0); String sender = header.split(" ")[0].trim(); listWithHeader2.remove(0); - if(sender.equals("server")){ + if (sender.equals("server")) { System.out.println("enter 1111111111111111111"); - if(reason.equals("TipUndone") || reason.equals("CrossingError") || reason.equals("MulBifurcation") || - reason.equals("BranchingError") || reason.equals("NearBifurcation")){ + if (reason.equals("TipUndone") || reason.equals("CrossingError") || reason.equals("MulBifurcation") || + reason.equals("BranchingError") || reason.equals("NearBifurcation")) { Communicator communicator = Communicator.getInstance(); annotationGLSurfaceView.syncAddMarker(communicator.syncMarker(String.join(",", listWithHeader2))); // annotationGLSurfaceView.syncAddMarkerGlobal(communicator.syncMarkerGlobal(marker)); annotationGLSurfaceView.requestRender(); - } - else if(reason.equals("Loop")){ + } else if (reason.equals("Loop")) { int result = Integer.parseInt(header.split(" ")[1].trim()); - if(result == 0){ + if (result == 0) { Communicator communicator = Communicator.getInstance(); annotationGLSurfaceView.syncAddMarker(communicator.syncMarker(String.join(",", listWithHeader2))); // annotationGLSurfaceView.syncAddMarkerGlobal(communicator.syncMarkerGlobal(marker)); annotationGLSurfaceView.requestRender(); } - } - else{ + } else { Toast_in_Thread_static("error from DBMS!"); } } @@ -364,9 +351,9 @@ else if(reason.equals("Loop")){ String request_userid = header.split(" ")[1].trim(); int result = Integer.parseInt(header.split(" ")[2].trim()); listWithHeader2.remove(0); - if(sender.equals("server")){ - if(reason.equals("ColorMutation") || reason.equals("Dissociative")|| reason.equals("Angle")){ - if(result == 0){ + if (sender.equals("server")) { + if (reason.equals("ColorMutation") || reason.equals("Dissociative") || reason.equals("Angle")) { + if (result == 0) { Communicator communicator = Communicator.getInstance(); annotationGLSurfaceView.syncAddMarker(communicator.syncMarker(String.join(",", listWithHeader2))); // annotationGLSurfaceView.syncAddMarkerGlobal(communicator.syncMarkerGlobal(marker)); @@ -454,7 +441,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { toolbar = findViewById(R.id.toolbar_collaboration); setSupportActionBar(toolbar); - + Objects.requireNonNull(getSupportActionBar()).setTitle("Collaboration"); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); @@ -462,7 +449,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { collaborationViewModel = new ViewModelProvider(this, new ViewModelFactory()).get(CollaborationViewModel.class); downloadingPopupView = new XPopup.Builder(this) - .asLoading("Downloading......"); + .asLoading("Call Hi5 Programming......"); syncingPopupView = new XPopup.Builder(this) .asLoading("Syncing......"); @@ -473,136 +460,129 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mainContext = this; - collaborationViewModel.getAnnotationMode().observe(this, new androidx.lifecycle.Observer() { - @RequiresApi(api = Build.VERSION_CODES.N) - @Override - public void onChanged(CollaborationViewModel.AnnotationMode annotationMode) { - if (annotationMode == null) { - return; - } - updateUI(annotationMode); - updateOptionsMenu(annotationMode); + collaborationViewModel.getAnnotationMode().observe(this, annotationMode -> { + if (annotationMode == null) { + return; } + updateUI(annotationMode); + updateOptionsMenu(annotationMode); }); - collaborationViewModel.getCollorationDataSource().getNeuronListCollaborate().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(Result result) { - if (result instanceof Result.Success) { - int index = 0; - List potentialDownloadNeuronInfoList = (List) ((Result.Success) result).getData(); - neuronNumberList.clear(); - for (int i = 0; i < potentialDownloadNeuronInfoList.size(); i++) { - CollaborateNeuronInfo item = potentialDownloadNeuronInfoList.get(i); - neuronNumberList.add(item.getNeuronName()); - if(item.getNeuronName().equals(collaborationViewModel.getPotentialDownloadNeuronInfo().getNeuronName())){ - index = i; - } + collaborationViewModel.getCollorationDataSource().getNeuronListCollaborate().observe(this, result -> { + if (result instanceof Result.Success) { + int index = 0; + List potentialDownloadNeuronInfoList = (List) ((Result.Success) result).getData(); + neuronNumberList.clear(); + for (int i = 0; i < potentialDownloadNeuronInfoList.size(); i++) { + CollaborateNeuronInfo item = potentialDownloadNeuronInfoList.get(i); + neuronNumberList.add(item.getNeuronName()); + if (item.getNeuronName().equals(collaborationViewModel.getPotentialDownloadNeuronInfo().getNeuronName())) { + index = i; } - collaborationViewModel.handleLoadImage(potentialDownloadNeuronInfoList.get(index)); } + collaborationViewModel.handleLoadImage(potentialDownloadNeuronInfoList.get(index)); } }); - collaborationViewModel.getCollorationDataSource().getAnoListCollaborate().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(Result result) { - if (result instanceof Result.Success) { - List data = (List) ((Result.Success) result).getData(); - String[] str = new String[data.size()]; - String[] anoListShow = data.toArray(str); - new XPopup.Builder(CollaborationActivity.this). - maxHeight(1350). - maxWidth(800). - asCenterList("Ano Number", - anoListShow, new OnSelectListener() { - @Override - public void onSelect(int position, String text) { - ToastEasy("Click" + text); - collaborationViewModel.handleAnoResult(text.trim()); - } - }).show(); - } else if (result instanceof Result.Error) { - ToastEasy(result.toString()); + collaborationViewModel.getCollorationDataSource().getAllProjectListCollaborate().observe(this, result -> { + if (result instanceof Result.Success) { + List> list = (List>) ((Result.Success) result).getData(); + String[] data = new String[list.size()]; + for (int i = 0; i < list.size(); i++) { + data[i] = list.get(i).second; // Get the Name from the Pair } - } - }); - collaborationViewModel.getCollorationDataSource().getDownloadAnoResult().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(Result result) { - collaborationViewModel.handleLoadAnoResult(result); + new XPopup.Builder(CollaborationActivity.this). + maxHeight(1350). + maxWidth(800). + asCenterList("Project Number", data, (position, text) -> { + ToastEasy("Click" + text); + String uuid = list.get(position).first; // Get the Uuid from the Pair + collaborationViewModel.handleProjectResult(uuid, list.get(position).second); // Use Uuid instead of Name + }).show(); + } else if (result instanceof Result.Error) { + ToastEasy(result.toString()); } }); - collaborationViewModel.getPortResult().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(String s) { - port = s; + collaborationViewModel.getCollorationDataSource().getAnoListCollaborate().observe(this, result -> { + if (result instanceof Result.Success) { + List> list = (List>) ((Result.Success) result).getData(); + String[] data = new String[list.size()]; + + for (int i = 0; i < list.size(); i++) { + String swcName = list.get(i).second;// Get the Name from the Pair + int removedLen = ".ano.eswc".length(); + int len = swcName.length(); + String anoName = swcName.substring(0, len - removedLen); + data[i] = anoName; + } + + new XPopup.Builder(CollaborationActivity.this). + maxHeight(1350). + maxWidth(800). + asCenterList("Ano Number", data, (position, text) -> { + ToastEasy("Click" + text); + String uuid = list.get(position).first; // Get the Uuid from the Pair + collaborationViewModel.handleAnoResult(uuid, text); // Use Uuid instead of Name + }).show(); + } else if (result instanceof Result.Error) { + ToastEasy(result.toString()); } + }); + collaborationViewModel.getCollorationDataSource().getDownloadAnoResult().observe(this, result -> collaborationViewModel.handleLoadAnoResult(result)); - collaborationViewModel.getImageDataSource().getBrainListResult().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(Result result) { - Log.e(TAG, "enter getBrainListResult()"); - if (result == null) { - return; - } - collaborationViewModel.handleBrainListResult(result); + collaborationViewModel.getPortResult().observe(this, s -> port = s); + + collaborationViewModel.getImageDataSource().getBrainListResult().observe(this, result -> { + Log.e(TAG, "enter getBrainListResult()"); + if (result == null) { + return; } + collaborationViewModel.handleBrainListResult(result); }); - collaborationViewModel.getImageDataSource().getDownloadImageResult().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(Result result) { - if (result == null) { - return; - } - collaborationViewModel.handleDownloadImageResult(result); - - initMsgConnector(port); - if (firstJoinRoom) { - initMsgService(); - firstJoinRoom = false; - } else { - CollaborationService.resetConnection(); - } + collaborationViewModel.getImageDataSource().getDownloadImageResult().observe(this, result -> { + if (result == null) { + return; + } + collaborationViewModel.handleDownloadImageResult(result); + + initMsgConnector(port); + if (firstJoinRoom) { + initMsgService(); + firstJoinRoom = false; + } else { + CollaborationService.resetConnection(); + } - id = collaborationViewModel.getCollorationDataSource().getUserId(); - Log.e(TAG, collaborationViewModel.getResMap().toString()); - List roiList = collaborationViewModel.getResMap().get(collaborationViewModel.getPotentialDownloadNeuronInfo().getBrainName()); + id = collaborationViewModel.getCollorationDataSource().getUserId(); + Log.e(TAG, collaborationViewModel.getResMap().toString()); + List roiList = collaborationViewModel.getResMap().get(collaborationViewModel.getPotentialDownloadNeuronInfo().getBrainName()); - assert roiList != null; - MsgConnector.getInstance().sendMsg("/login:" + id + " " + InfoCache.getAccount() + " " + InfoCache.getToken() + " " + roiList.get(0) + " " + 2); - } + assert roiList != null; + MsgConnector.getInstance().sendMsg("/login:" + id + " " + InfoCache.getAccount() + " " + InfoCache.getToken() + " " + roiList.get(0) + " " + collaborationViewModel.getCollorationDataSource().CurrentSwcInfo.first + " " + 2); }); - collaborationViewModel.getImageResult().observe(this, new androidx.lifecycle.Observer() { - @RequiresApi(api = Build.VERSION_CODES.N) - @Override - public void onChanged(ResourceResult resourceResult) { - if (resourceResult == null) { - return; - } - if (resourceResult.isSuccess()) { - annotationGLSurfaceView.openFile(); - } else { - ToastEasy(resourceResult.getError()); - } - + collaborationViewModel.getImageResult().observe(this, resourceResult -> { + if (resourceResult == null) { + return; } + if (resourceResult.isSuccess()) { + annotationGLSurfaceView.openFile(); + } else { + ToastEasy(resourceResult.getError()); + } + }); - collaborationViewModel.getCollaborationArborInfoState().getCenterLocation().observe(this, new androidx.lifecycle.Observer() { - @Override - public void onChanged(XYZ centerLocation) { + collaborationViewModel.getCollaborationArborInfoState().getCenterLocation().observe(this, centerLocation -> { - collaborationViewModel.navigateAndZoomInBlock((int) centerLocation.x, (int) centerLocation.y, (int) centerLocation.z); - annotationGLSurfaceView.convertCoordsForMarker(collaborationViewModel.getCoordinateConvert()); - annotationGLSurfaceView.convertCoordsForSWC(collaborationViewModel.getCoordinateConvert()); - } + collaborationViewModel.navigateAndZoomInBlock((int) centerLocation.x, (int) centerLocation.y, (int) centerLocation.z); + annotationGLSurfaceView.convertCoordsForMarker(collaborationViewModel.getCoordinateConvert()); + annotationGLSurfaceView.convertCoordsForSWC(collaborationViewModel.getCoordinateConvert()); }); } @@ -757,7 +737,7 @@ public static Context getContext() { * 注册/注销系统消息未读数变化 */ - private Observer sysMsgUnreadCountChangedObserver = (Observer) unreadCount -> { + private Observer sysMsgUnreadCountChangedObserver = unreadCount -> { Log.e("Observer", "Observer unreadCount"); SystemMessageUnreadManager.getInstance().setSysMsgUnreadCount(unreadCount); ReminderManager.getInstance().updateContactUnreadNum(unreadCount); @@ -803,28 +783,21 @@ private static void invitePopup(Context context, String invitor, String path, St .dismissOnTouchOutside(false) .dismissOnBackPressed(false) .asConfirm("INVITE", invitor + " is inviting you to join game in room " + roomName, "Reject", "Join", - new OnConfirmListener() { - @Override - public void onConfirm() { + () -> { - Communicator communicator = Communicator.getInstance(); - communicator.initSoma(soma); - communicator.setPath(path); - Communicator.BrainNum = path.split("/")[1]; - conPath = path; - firstLoad = true; + Communicator communicator = Communicator.getInstance(); + communicator.initSoma(soma); + communicator.setPath(path); + Communicator.BrainNum = path.split("/")[1]; + firstLoad = true; - ServerConnector serverConnector = ServerConnector.getInstance(); - serverConnector.sendMsg("LOADFILES:2 " + path); + ServerConnector serverConnector = ServerConnector.getInstance(); + serverConnector.sendMsg("LOADFILES:2 " + path); // String[] list = path.split("/"); - serverConnector.setRoomName(roomName); - } - }, new OnCancelListener() { - @Override - public void onCancel() { + serverConnector.setRoomName(roomName); + }, () -> { - } }, false) .show(); } @@ -839,7 +812,7 @@ public void showUserList(Activity activity) { // Convert the online user list to a string array String[] userList = MsgConnector.userList.toArray(new String[0]); - Log.e(TAG,"Userlist"+userList); + Log.e(TAG, "Userlist" + userList); // Create the AlertDialog only if it's null if (dialog == null) { @@ -1008,9 +981,10 @@ private void showCommonUI() { FrameLayout.LayoutParams lp_ROI_i = new FrameLayout.LayoutParams(120, 120); lp_ROI_i.gravity = Gravity.BOTTOM | Gravity.LEFT; lp_ROI_i.setMargins(20, 0, 300, 480); - this.addContentView(ROI_i,lp_ROI_i); + this.addContentView(ROI_i, lp_ROI_i); editModeIndicator = findViewById(R.id.edit_mode_indicator_collaborate); + ImageButton editModeIndicator = findViewById(R.id.edit_mode_indicator_collaborate); tapBarMenu = findViewById(R.id.tapBarMenu_collaborate); addCurve = tapBarMenu.findViewById(R.id.draw_i_collaborate); addMarker = tapBarMenu.findViewById(R.id.pinpoint_collaborate); @@ -1023,17 +997,14 @@ private void showCommonUI() { collaborateResButton.setOnClickListener(new CollaborateButtonClickListener()); btnUserList.setOnClickListener(new CollaborateButtonClickListener()); - ROI_i.setOnClickListener(new Button.OnClickListener() { - @Override - public void onClick(View v) { - if(annotationGLSurfaceView.getEditMode().getValue() == EditMode.ZOOM_IN_ROI){ - annotationGLSurfaceView.setEditMode(EditMode.NONE); - ROI_i.setImageResource(R.drawable.ic_roi_stop); - }else{ - annotationGLSurfaceView.setEditMode(EditMode.ZOOM_IN_ROI); - ROI_i.setImageResource(R.drawable.ic_roi); - } - } + ROI_i.setOnClickListener(v -> { + if (annotationGLSurfaceView.getEditMode().getValue() == EditMode.ZOOM_IN_ROI) { + annotationGLSurfaceView.setEditMode(EditMode.NONE); + ROI_i.setImageResource(R.drawable.ic_roi_stop); + } else { + annotationGLSurfaceView.setEditMode(EditMode.ZOOM_IN_ROI); + ROI_i.setImageResource(R.drawable.ic_roi); + } }); tapBarMenu.setOnClickListener(v -> tapBarMenu.toggle()); @@ -1056,17 +1027,16 @@ public void onClick(View v) { // boomMenuButton.addBuilder(new TextOutsideCircleButton.Builder().listener(index -> { // ToastEasy("App2 tracing algorithm start !"); -// executorService.submit(() -> annotationGLSurfaceView.APP2()); +// ExecutorServiceProvider.getExecutorService().submit(() -> annotationGLSurfaceView.APP2()); // }).normalImageRes(R.drawable.ic_neuron)); // -// // boomMenuButton.addBuilder(new TextOutsideCircleButton.Builder() // .listener(index -> annotationGLSurfaceView.setEditMode(EditMode.DELETE_MULTI_MARKER)) // .normalImageRes(R.drawable.ic_delete_multimarker).normalText("Delete Multi Markers")); // // boomMenuButton.addBuilder(new TextOutsideCircleButton.Builder().listener(index -> { // ToastEasy("GD tracing algorithm start !"); -// executorService.submit(() -> annotationGLSurfaceView.GD()); +// ExecutorServiceProvider.getExecutorService().submit(() -> annotationGLSurfaceView.GD()); // }).normalImageRes(R.drawable.ic_gd_tracing).normalText("GD-Tracing")); // // boomMenuButton.addBuilder(new TextOutsideCircleButton.Builder() @@ -1078,7 +1048,6 @@ public void onClick(View v) { } } - @RequiresApi(api = Build.VERSION_CODES.N) @SuppressLint("NonConstantResourceId") private void onMenuItemClick(View view) { // resetUI @@ -1206,7 +1175,7 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - finish(); + LoginActivity.start(CollaborationActivity.this); return true; // case R.id.undo: @@ -1220,7 +1189,9 @@ public boolean onOptionsItemSelected(MenuItem item) { case R.id.file: openFile(); return true; - + case R.id.more: + moreFunctions(); + return true; // case R.id.share: // annotationGLSurfaceView.screenCapture(); // return true; @@ -1281,18 +1252,10 @@ public void onClick(View v) { private void openFile() { new XPopup.Builder(this) - .asCenterList("File Open", new String[]{"Open BigData"}, - new OnSelectListener() { - @Override - public void onSelect(int position, String item) { - switch (item) { - case "Open BigData": - collaborationViewModel.getAno(); -// collaborationViewModel.getImageList(); - break; - default: - ToastEasy("Something wrong in function openFile !"); - } + .asCenterList("File Open", new String[]{"Open Project"}, + (position, item) -> { + if (item.equals("Open Project")) { + collaborationViewModel.getCollorationDataSource().getAllProject(); } }) .show(); @@ -1307,22 +1270,48 @@ private void showResListPopup() { List roiList = collaborationViewModel.getResMap().get(collaborationViewModel.getPotentialDownloadNeuronInfo().getBrainName()); assert roiList != null; String[] rois = roiList.toArray(new String[]{}); - rois[collaborationViewModel.getCoordinateConvert().getResIndex()-1]=rois[collaborationViewModel.getCoordinateConvert().getResIndex()-1] + " √"; + rois[collaborationViewModel.getCoordinateConvert().getResIndex() - 1] = rois[collaborationViewModel.getCoordinateConvert().getResIndex() - 1] + " √"; new XPopup.Builder(CollaborationActivity.this). maxHeight(1350). maxWidth(800). - asCenterList("Res List", rois, new OnSelectListener() { - @Override - public void onSelect(int position, String text) { - ToastEasy("Click" + text); - collaborationViewModel.switchRes(position, text.trim()); - annotationGLSurfaceView.convertCoordsForMarker(collaborationViewModel.getCoordinateConvert()); - annotationGLSurfaceView.convertCoordsForSWC(collaborationViewModel.getCoordinateConvert()); + asCenterList("Res List", rois, (position, text) -> { + ToastEasy("Click" + text); + collaborationViewModel.switchRes(position, text.trim()); + annotationGLSurfaceView.convertCoordsForMarker(collaborationViewModel.getCoordinateConvert()); + annotationGLSurfaceView.convertCoordsForSWC(collaborationViewModel.getCoordinateConvert()); // annotationGLSurfaceView.requestRender(); - } }).show(); } + private void moreFunctions() { + new XPopup.Builder(this) + .maxHeight(1500) + .asCenterList("More Collaborations...", new String[]{"Soma Pinpointing", "Synapse Validation"}, + new OnSelectListener() { + @Override + public void onSelect(int position, String text) { + switch (text) { + case "Soma Pinpointing": + somaPinpointing(); + break; + case "Synapse Validation": + synapseValidation(); + break; + default: + ToastEasy("Something wrong with more functions..."); + } + } + }) + .show(); + } + + private void somaPinpointing(){ + MarkerFactoryActivity.start(CollaborationActivity.this); + } + + private void synapseValidation() { + BoutonDetectionActivity.start(CollaborationActivity.this); + } } diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationViewModel.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationViewModel.java index 0de345be2..c0a7210ae 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationViewModel.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/collaboration/CollaborationViewModel.java @@ -3,38 +3,28 @@ import static com.penglab.hi5.core.Myapplication.ToastEasy; import static com.penglab.hi5.core.ui.collaboration.CollaborationActivity.Toast_in_Thread_static; -import android.content.Context; import android.util.Log; +import android.util.Pair; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; -import com.huawei.hms.support.api.PendingResultImpl; -import com.lxj.xpopup.XPopup; -import com.lxj.xpopup.interfaces.OnSelectListener; import com.penglab.hi5.basic.image.XYZ; import com.penglab.hi5.basic.utils.FileManager; -import com.penglab.hi5.chat.nim.InfoCache; import com.penglab.hi5.core.Myapplication; import com.penglab.hi5.core.collaboration.Communicator; -import com.penglab.hi5.core.collaboration.basic.ImageInfo; import com.penglab.hi5.core.collaboration.connector.MsgConnector; -import com.penglab.hi5.core.collaboration.service.CollaborationService; -import com.penglab.hi5.core.ui.QualityInspection.QualityInspectionViewModel; import com.penglab.hi5.core.ui.ResourceResult; -import com.penglab.hi5.core.ui.annotation.AnnotationViewModel; import com.penglab.hi5.core.ui.marker.CoordinateConvert; import com.penglab.hi5.data.CollorationDataSource; import com.penglab.hi5.data.ImageDataSource; import com.penglab.hi5.data.ImageInfoRepository; -import com.penglab.hi5.data.QualityInspectionDataSource; import com.penglab.hi5.data.Result; import com.penglab.hi5.data.UserInfoRepository; import com.penglab.hi5.data.model.img.CollaborateNeuronInfo; import com.penglab.hi5.data.model.img.FilePath; import com.penglab.hi5.data.model.img.FileType; -import com.penglab.hi5.data.model.user.LoggedInUser; import org.json.JSONArray; import org.json.JSONException; @@ -44,8 +34,6 @@ import java.util.HashMap; import java.util.List; -import io.agora.rtc.internal.RtcEngineMessage; - public class CollaborationViewModel extends ViewModel { private final String TAG = "CollaborationViewModel"; private final int DEFAULT_IMAGE_SIZE = 128; @@ -53,8 +41,6 @@ public class CollaborationViewModel extends ViewModel { private boolean firstJoinRoom = true; public static final String ip_TencentCloud = "114.117.165.134"; private final int DEFAULT_RES_INDEX = 2; - private boolean isDownloading = false; - private boolean noFileLeft = false; private final HashMap> resMap = new HashMap<>(); private volatile CollaborateNeuronInfo potentialDownloadNeuronInfo = new CollaborateNeuronInfo(); @@ -107,12 +93,6 @@ public CollaborationArborInfoState getCollaborationArborInfoState() { return collaborationArborInfoState; } - public void handleBrainNumber(String brainNumber) { - Log.e(TAG, "handleBrainNumber" + brainNumber); - potentialDownloadNeuronInfo.setBrainNumber(brainNumber); - getNeuronList(brainNumber); - } - public LiveData getImageResult() { return imageResult; } @@ -123,7 +103,6 @@ public MutableLiveData getPortResult() { public void handleBrainListResult(Result result) { if (result == null) { - isDownloading = false; Log.e(TAG, "Fail to handle brain list result"); } if (result instanceof Result.Success) { @@ -142,9 +121,12 @@ public void handleBrainListResult(Result result) { detail = detail.substring(1, detail.length() - 1); String[] rois = detail.split(", "); List roiList = new ArrayList<>(); - for (int j = 0; j < rois.length; j++) { - rois[j] = rois[j].substring(1, rois[j].length() - 1); - roiList.add(rois[j]); + for (String s : rois) { + if (s.isEmpty()) { + continue; + } + String res = s.substring(1, s.length() - 1); + roiList.add(res); } if (rois.length >= 1) { resMap.put(imageId, roiList); @@ -155,24 +137,19 @@ public void handleBrainListResult(Result result) { } downloadImage(); } else { - isDownloading = false; } } else { - isDownloading = false; } } - public void handleNeuronNumber(String neuronNumber) { - potentialDownloadNeuronInfo.setNeuronNumber(neuronNumber); - getAno(neuronNumber); - } - public LiveData getAnnotationMode() { return annotationMode; } - public void handleAnoResult(String anoName) { + public void handleAnoResult(String swcUuid, String anoName) { + collorationDataSource.CurrentSwcInfo = new Pair<>(swcUuid,anoName); + getDownloadAno(anoName); getNeuronList(potentialDownloadNeuronInfo.getBrainName()); @@ -180,6 +157,11 @@ public void handleAnoResult(String anoName) { } + public void handleProjectResult(String projectUuid, String projectName) { + collorationDataSource.CurrentProjectInfo = new Pair<>(projectUuid,projectName); + collorationDataSource.getSwcNameAndUuidByProject(projectUuid); + } + public void handleLoadAnoResult(Result result) { if (result instanceof Result.Success) { Object data = ((Result.Success) result).getData(); @@ -207,10 +189,6 @@ public CollaborateNeuronInfo getPotentialDownloadNeuronInfo() { return potentialDownloadNeuronInfo; } - public void getImageList() { - collorationDataSource.getImageList(); - } - public void getNeuronList(String brainNumber) { collorationDataSource.getNeuron(brainNumber); } @@ -223,27 +201,26 @@ public void handleLoadImage(CollaborateNeuronInfo collaborateNeuronInfo) { } - public void getAno() { - collorationDataSource.getAno(); - } - - public void getAno(String neuronNumber) { - collorationDataSource.getAno(neuronNumber); - } - public void getDownloadAno(String anoName) { String[] parts = anoName.split("_"); - String brainName = parts[0]; - String neuronName = parts[0]; - if(parts.length >= 2) { - brainName = parts[0]; - neuronName = parts[0] + "_" + parts[1]; + String image="", neuron=""; + + // Check if image has a suffix + if(parts.length >= 3 && parts[1].length() == 1){ + image = parts[0] + "_" + parts[1]; + neuron = image + "_" + parts[2]; + } + else if(parts.length >= 2) { + image = parts[0]; + neuron = image + "_" + parts[1]; + }else{ + throw new IllegalArgumentException("Invalid annotation name"); } - potentialDownloadNeuronInfo.setBrainNumber(brainName); - potentialDownloadNeuronInfo.setNeuronNumber(neuronName); - Log.e("brainName", brainName); - Log.e("neuronName", neuronName); + potentialDownloadNeuronInfo.setBrainNumber(image); + potentialDownloadNeuronInfo.setNeuronNumber(neuron); + Log.e("brainName", image); + Log.e("neuronName", neuron); } private void getBrainList() { @@ -261,7 +238,6 @@ public void downloadImage() { if (resList.size() == 0) { ToastEasy("Fail to download image, something wrong with res list !"); - isDownloading = false; return; } // for (int i = 0; i < resList.size(); i++) { @@ -275,7 +251,6 @@ public void downloadImage() { public void handleDownloadImageResult(Result result) { if (result == null) { - isDownloading = false; } if (result instanceof Result.Success) { Object data = ((Result.Success) result).getData(); @@ -284,9 +259,7 @@ public void handleDownloadImageResult(Result result) { openFile(downloadCoordinateConvert.getResIndex()); } - } - } public void openFile(int resIndex) { diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/login/LoginActivity.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/login/LoginActivity.java index 203f6d20c..4a29f25ee 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/login/LoginActivity.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/login/LoginActivity.java @@ -35,6 +35,7 @@ import com.penglab.hi5.R; import com.penglab.hi5.chat.nim.InfoCache; import com.penglab.hi5.core.ui.ViewModelFactory; +import com.penglab.hi5.core.ui.collaboration.CollaborationActivity; import com.penglab.hi5.core.ui.home.screens.HomeActivity; import com.penglab.hi5.core.ui.password.FindPasswordActivity; import com.penglab.hi5.core.ui.register.RegisterActivity; @@ -98,7 +99,7 @@ public void onCreate(Bundle savedInstanceState) { mIvLoginPwdDel = findViewById(R.id.iv_login_pwd_del); mLayBackBar = findViewById(R.id.ly_retrieve_bar); - mIvLoginLogo = findViewById(R.id.iv_login_logo); +// mIvLoginLogo = findViewById(R.id.iv_login_logo); /* load local user info */ if (preferenceLogin.getRem_or_not()){ @@ -137,7 +138,8 @@ public void onChanged(@Nullable LoginResult loginResult) { preferenceLogin.setPref(usernameEditText.getText().toString(), passwordEditText.getText().toString(),id,true,true); updateUiWithUser(loginResult.getSuccess()); - showHomeActivity(); + showCollaborateActivity(); +// showHomeActivity(); setResult(Activity.RESULT_OK); } } @@ -211,7 +213,7 @@ public void afterTextChanged(Editable s) { mIvLoginUsernameDel.setOnClickListener(new MyClick()); mIvLoginPwdDel.setOnClickListener(new MyClick()); - mLayBackBar.getViewTreeObserver().addOnGlobalLayoutListener(new MyViewTreeObserver()); +// mLayBackBar.getViewTreeObserver().addOnGlobalLayoutListener(new MyViewTreeObserver()); } @@ -225,11 +227,11 @@ public void onClick(View v) { loginViewModel.login(usernameEditText.getText().toString(), passwordEditText.getText().toString()); break; case R.id.visitor_login: - playButtonSound(); - ifGuestLogin = true; - HomeActivity.start(LoginActivity.this); - Toast.makeText(getApplicationContext(),"you are now logged in as a visitor",Toast.LENGTH_SHORT).show(); - finish(); +// playButtonSound(); +// ifGuestLogin = true; +// HomeActivity.start(LoginActivity.this); + Toast.makeText(getApplicationContext(),"you need to login first to use the collaborate function",Toast.LENGTH_SHORT).show(); +// finish(); break; case R.id.goto_register: RegisterActivity.start(LoginActivity.this); @@ -275,71 +277,71 @@ public void onFocusChange(View v, boolean hasFocus) { } // 显示或隐藏logo - public class MyViewTreeObserver implements ViewTreeObserver.OnGlobalLayoutListener { - - private int mLogoHeight; - private int mLogoWidth; - - @Override - public void onGlobalLayout() { - final ImageView ivLogo =mIvLoginLogo; - Rect KeypadRect = new Rect(); - - mLayBackBar.getWindowVisibleDisplayFrame(KeypadRect); - - int screenHeight = mLayBackBar.getRootView().getHeight(); - int keypadHeight = screenHeight - KeypadRect.bottom; - - // 隐藏logo - if (keypadHeight > 300 && ivLogo.getTag() == null) { - final int height = ivLogo.getHeight(); - final int width = ivLogo.getWidth(); - this.mLogoHeight = height; - this.mLogoWidth = width; - - ivLogo.setTag(true); - - ValueAnimator valueAnimator = ValueAnimator.ofFloat(1, 0); - valueAnimator.setDuration(400).setInterpolator(new DecelerateInterpolator()); - valueAnimator.addUpdateListener(animation -> { - float animatedValue = (float) animation.getAnimatedValue(); - ViewGroup.LayoutParams layoutParams = ivLogo.getLayoutParams(); - layoutParams.height = (int) (height * animatedValue); - layoutParams.width = (int) (width * animatedValue); - ivLogo.requestLayout(); - ivLogo.setAlpha(animatedValue); - }); - - if (valueAnimator.isRunning()) { - valueAnimator.cancel(); - } - valueAnimator.start(); - } - // 显示logo - else if (keypadHeight < 300 && ivLogo.getTag() != null) { - final int height = mLogoHeight; - final int width = mLogoWidth; - - ivLogo.setTag(null); - - ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1); - valueAnimator.setDuration(400).setInterpolator(new DecelerateInterpolator()); - valueAnimator.addUpdateListener(animation -> { - float animatedValue = (float) animation.getAnimatedValue(); - ViewGroup.LayoutParams layoutParams = ivLogo.getLayoutParams(); - layoutParams.height = (int) (height * animatedValue); - layoutParams.width = (int) (width * animatedValue); - ivLogo.requestLayout(); - ivLogo.setAlpha(animatedValue); - }); - - if (valueAnimator.isRunning()) { - valueAnimator.cancel(); - } - valueAnimator.start(); - } - } - } +// public class MyViewTreeObserver implements ViewTreeObserver.OnGlobalLayoutListener { +// +// private int mLogoHeight; +// private int mLogoWidth; +// +// @Override +// public void onGlobalLayout() { +// final ImageView ivLogo =mIvLoginLogo; +// Rect KeypadRect = new Rect(); +// +// mLayBackBar.getWindowVisibleDisplayFrame(KeypadRect); +// +// int screenHeight = mLayBackBar.getRootView().getHeight(); +// int keypadHeight = screenHeight - KeypadRect.bottom; +// +// // 隐藏logo +// if (keypadHeight > 300 && ivLogo.getTag() == null) { +// final int height = ivLogo.getHeight(); +// final int width = ivLogo.getWidth(); +// this.mLogoHeight = height; +// this.mLogoWidth = width; +// +// ivLogo.setTag(true); +// +// ValueAnimator valueAnimator = ValueAnimator.ofFloat(1, 0); +// valueAnimator.setDuration(400).setInterpolator(new DecelerateInterpolator()); +// valueAnimator.addUpdateListener(animation -> { +// float animatedValue = (float) animation.getAnimatedValue(); +// ViewGroup.LayoutParams layoutParams = ivLogo.getLayoutParams(); +// layoutParams.height = (int) (height * animatedValue); +// layoutParams.width = (int) (width * animatedValue); +// ivLogo.requestLayout(); +// ivLogo.setAlpha(animatedValue); +// }); +// +// if (valueAnimator.isRunning()) { +// valueAnimator.cancel(); +// } +// valueAnimator.start(); +// } +// // 显示logo +// else if (keypadHeight < 300 && ivLogo.getTag() != null) { +// final int height = mLogoHeight; +// final int width = mLogoWidth; +// +// ivLogo.setTag(null); +// +// ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1); +// valueAnimator.setDuration(400).setInterpolator(new DecelerateInterpolator()); +// valueAnimator.addUpdateListener(animation -> { +// float animatedValue = (float) animation.getAnimatedValue(); +// ViewGroup.LayoutParams layoutParams = ivLogo.getLayoutParams(); +// layoutParams.height = (int) (height * animatedValue); +// layoutParams.width = (int) (width * animatedValue); +// ivLogo.requestLayout(); +// ivLogo.setAlpha(animatedValue); +// }); +// +// if (valueAnimator.isRunning()) { +// valueAnimator.cancel(); +// } +// valueAnimator.start(); +// } +// } +// } @Override protected void onDestroy() { @@ -348,15 +350,19 @@ protected void onDestroy() { private void updateUiWithUser(LoggedInUserView model) { String welcome = getString(R.string.welcome) + model.getNickName() + " !"; - Toast.makeText(getApplicationContext(), welcome, Toast.LENGTH_LONG).show(); + Toast.makeText(getApplicationContext(), "welcome to enter the CAR_Mobile", Toast.LENGTH_LONG).show(); } private void showLoginFailed(@Nullable String errorString) { Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show(); } - private void showHomeActivity(){ - HomeActivity.start(LoginActivity.this); +// private void showHomeActivity(){ +// HomeActivity.start(LoginActivity.this); +// finish(); +// } + private void showCollaborateActivity(){ + CollaborationActivity.start(LoginActivity.this); finish(); } diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/marker/MarkerFactoryActivity.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/marker/MarkerFactoryActivity.java index a26696c00..a1fd93396 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/marker/MarkerFactoryActivity.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/marker/MarkerFactoryActivity.java @@ -155,11 +155,12 @@ public void run() { imageIdLocationTextView = findViewById(R.id.imageid_location_text_view); toolbar = (Toolbar) findViewById(R.id.toolbar_marker_factory); setSupportActionBar(toolbar); + getSupportActionBar().setTitle("Soma Pinpointing"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); - downloadingPopupView = new XPopup.Builder(this).asLoading("Downloading......"); + downloadingPopupView = new XPopup.Builder(this).asLoading("Call Hi5 programming......"); markerFactoryViewModel = new ViewModelProvider(this, new ViewModelFactory()).get(MarkerFactoryViewModel.class); markerFactoryViewModel.getAnnotationMode().observe(this, new Observer() { @Override diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/splash/SplashScreenActivity.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/splash/SplashScreenActivity.java index 422977860..0f6f78e5e 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/splash/SplashScreenActivity.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/core/ui/splash/SplashScreenActivity.java @@ -23,6 +23,7 @@ import com.penglab.hi5.chat.nim.InfoCache; import com.penglab.hi5.core.ui.ResourceResult; import com.penglab.hi5.core.ui.ViewModelFactory; +import com.penglab.hi5.core.ui.collaboration.CollaborationActivity; import com.penglab.hi5.core.ui.home.screens.HomeActivity; import com.penglab.hi5.core.ui.login.LoggedInUserView; import com.penglab.hi5.core.ui.login.LoginActivity; @@ -92,7 +93,8 @@ public void onChanged(LoginResult loginResult) { } if (loginResult.getSuccess() != null) { updateUiWithUser(loginResult.getSuccess()); - showHomeActivity(); + showCollaborateActivity(); +// showHomeActivity(); } setResult(Activity.RESULT_OK); } @@ -133,19 +135,20 @@ public void run() { new Handler().postDelayed(this, 100); return; } - - if (canAutoLogin()) { - autoLogin(); - } else { - LoginActivity.start(SplashScreenActivity.this); - } +// if (canAutoLogin()) { +//// Log.e(TAG,"Temperaly"); +//// autoLogin(); +// } else { + LoginActivity.start(SplashScreenActivity.this); + finish(); +// } } }, 1500); } - private boolean canAutoLogin() { - return PreferenceLogin.getInstance().getAutoLogin(); - } +// private boolean canAutoLogin() { +// return PreferenceLogin.getInstance().getAutoLogin(); +// } private void autoLogin() { if (!TextUtils.isEmpty(preferenceLogin.getUsername()) && !TextUtils.isEmpty(preferenceLogin.getPassword())) { @@ -157,7 +160,7 @@ private void autoLogin() { } private void updateUiWithUser(LoggedInUserView model) { - String welcome = getString(R.string.welcome) + model.getNickName() + " !"; + String welcome = "Welcome entering in CAR_Mobile !"; Toast.makeText(getApplicationContext(), welcome, Toast.LENGTH_LONG).show(); } @@ -170,5 +173,10 @@ private void showHomeActivity(){ finish(); } + private void showCollaborateActivity() { + CollaborationActivity.start(SplashScreenActivity.this); + finish(); + } + } diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/CollorationDataSource.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/CollorationDataSource.java index 64143b9c6..9df6eae0e 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/CollorationDataSource.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/CollorationDataSource.java @@ -1,19 +1,16 @@ package com.penglab.hi5.data; import android.util.Log; +import android.util.Pair; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; -import com.netease.nim.uikit.common.util.C; import com.penglab.hi5.basic.image.XYZ; import com.penglab.hi5.chat.nim.InfoCache; import com.penglab.hi5.core.net.HttpUtilsCollaborate; -import com.penglab.hi5.core.net.HttpUtilsQualityInspection; import com.penglab.hi5.core.net.HttpUtilsUser; import com.penglab.hi5.data.model.img.CollaborateNeuronInfo; -import com.penglab.hi5.data.model.img.PotentialArborMarkerInfo; -import com.penglab.hi5.data.model.img.PotentialSomaInfo; import org.json.JSONArray; import org.json.JSONException; @@ -21,8 +18,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import okhttp3.Call; @@ -31,13 +26,10 @@ public class CollorationDataSource { - public static final String UPLOAD_SUCCESSFULLY = "Upload result successfully !"; public static final String NO_MORE_FILE = "No more file need to process !"; private final String TAG = "CollorationDataSource"; - private String responseData; - private int userId; public int getUserId(){ return userId; @@ -45,66 +37,28 @@ public int getUserId(){ public void setUserId(int id){ userId = id; } - private final MutableLiveData brianListResult = new MutableLiveData<>(); + + public Pair CurrentProjectInfo; + public Pair CurrentSwcInfo; + private final MutableLiveData neuronListResult = new MutableLiveData<>(); private final MutableLiveData anoListResult = new MutableLiveData<>(); + private final MutableLiveData projectListResult = new MutableLiveData<>(); // Uuid, Name pair private final MutableLiveData downloadAnoResult = new MutableLiveData<>(); - - public LiveData getBrainListCollaborate() { - return brianListResult; - } public LiveData getNeuronListCollaborate() { return neuronListResult; } public LiveData getAnoListCollaborate() { return anoListResult; } + public LiveData getAllProjectListCollaborate() { + return projectListResult; + } public LiveData getDownloadAnoResult() { return downloadAnoResult; } - public void getImageList() { - try { - Log.e(TAG,"getImageList"); - JSONObject userInfo = new JSONObject().put("name", InfoCache.getAccount()).put("passwd", InfoCache.getToken()); - HttpUtilsCollaborate.getImageListWithOkHttp(userInfo, new Callback() { - @Override - public void onFailure(Call call, IOException e) { - brianListResult.postValue(new Result.Error(new Exception("Connect failed when get potential location !"))); - } - @Override - public void onResponse(Call call, Response response) throws IOException { - int responseCode = response.code(); - if (responseCode == 200) { - responseData = response.body().string(); - Log.e(TAG, "responseData: " + responseData); - try { - String[] brainNumber = responseData.split(","); - Log.e("brainNumberSize",""+brainNumber.length); - brianListResult.postValue(new Result.Success(brainNumber)); - } catch (Exception e) { - e.printStackTrace(); - brianListResult.postValue(new Result.Error(new Exception("Fail to parse brain list info !"))); - } - response.body().close(); - response.close(); - } else if (responseCode == 502) { - responseData = response.body().string(); - if (responseData.trim().equals("Empty")) { - Log.e(TAG,"get Empty response"); - brianListResult.postValue(new Result.Success(NO_MORE_FILE)); - } - } else { - brianListResult.postValue(new Result.Error(new Exception("Fail to get brain list info !"))); - } - } - }); - } catch (Exception e) { - e.printStackTrace(); - } - } - public void getNeuron(String brainNum) { try { @@ -119,7 +73,7 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) throws IOException { Log.e(TAG, "responseCode" + response.code()); int responseCode = response.code(); - responseData = response.body().string(); + String responseData = response.body().string(); Log.e(TAG, "response getNeuron: " + responseData); if (responseCode == 200) { @@ -134,7 +88,7 @@ public void onResponse(Call call, Response response) throws IOException { (float)neuronInfo.getDouble("y"), (float)neuronInfo.getDouble("z")))); } - neuronListResult.postValue(new Result.Success>(neuronList)); + neuronListResult.postValue(new Result.Success<>(neuronList)); } catch (Exception exception) { exception.printStackTrace(); neuronListResult.postValue(new Result.Error(new Exception("Fail to parse query arbor result !"))); @@ -142,7 +96,7 @@ public void onResponse(Call call, Response response) throws IOException { response.body().close(); response.close(); } else if (responseCode == 502) { - neuronListResult.postValue(new Result.Success(NO_MORE_FILE)); + neuronListResult.postValue(new Result.Success<>(NO_MORE_FILE)); // } } else { Log.e(TAG, "response update arbor result: " + response.body().string()); @@ -157,26 +111,26 @@ public void onResponse(Call call, Response response) throws IOException { } } - public void getAno() { + public void getAllProject() { try { - JSONObject userVerifyInfo = new JSONObject().put("UserName", InfoCache.getAccount()).put("UserToken", ""); - JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.01.19"); + JSONObject userVerifyInfo = new JSONObject().put("UserName", InfoCache.getAccount()).put("UserPassword", InfoCache.getToken()); + JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.05.06"); JSONObject param = new JSONObject(); param.put("UserVerifyInfo",userVerifyInfo); param.put("metaInfo",metaInfo); - HttpUtilsCollaborate.getAllSwcMetaInfoWithOkHttp(param, new Callback() { + HttpUtilsCollaborate.getAllProject(param, new Callback() { @Override public void onFailure(Call call, IOException e) { - anoListResult.postValue(new Result.Error(new Exception("Connect failed when getAllSwcMetaInfo result !"))); + projectListResult.postValue(new Result.Error(new Exception("Connect failed when getAllProject result !"))); } @Override public void onResponse(Call call, Response response) throws IOException { Log.e(TAG, "responseCode" + response.code()); int responseCode = response.code(); - responseData = response.body().string(); + String responseData = response.body().string(); if (responseCode == 200) { - Log.e(TAG, "response getAno: " + responseData); + Log.e(TAG, "response getAllProject: " + responseData); // process response try { JSONObject resultJson = new JSONObject(responseData); @@ -184,30 +138,28 @@ public void onResponse(Call call, Response response) throws IOException { boolean status = metaInfo.getBoolean("Status"); String message = metaInfo.getString("Message"); if(!status){ - anoListResult.postValue(new Result.Error(new Exception("Get SwcMetaInfo Failed" + message))); + projectListResult.postValue(new Result.Error(new Exception("Get getAllProject Failed with " + message))); } - JSONArray swcInfos = resultJson.getJSONArray("SwcInfo"); - List anoNameList = new ArrayList(); - for(int i =0;i> projectList = new ArrayList<>(); + for(int i =0;i(projectUuid, projectName)); } - anoListResult.postValue(new Result.Success>(anoNameList)); + projectListResult.postValue(new Result.Success<>(projectList)); } catch (Exception exception) { exception.printStackTrace(); - anoListResult.postValue(new Result.Error(new Exception("Fail to parse GetSwcMetaInfo result !"))); + projectListResult.postValue(new Result.Error(new Exception("Fail to parse getAllProject result !"))); } response.body().close(); response.close(); } else { - Log.e(TAG, "response update arbor result: " + response.body().string()); - anoListResult.postValue(new Result.Error(new Exception("Fail to get swcmetainfo !"))); + Log.e(TAG, "Fail to getAllProject with: " + response.body().string()); + projectListResult.postValue(new Result.Error(new Exception("Fail to getAllProject !"))); } } }); @@ -218,46 +170,56 @@ public void onResponse(Call call, Response response) throws IOException { } } - public void getAno(String neuronNum) { + public void getSwcNameAndUuidByProject(String projectUuid) { try { - JSONObject userInfo = new JSONObject().put("name", InfoCache.getAccount()).put("passwd", InfoCache.getToken()); - HttpUtilsCollaborate.getAnoWithOkHttp(userInfo, neuronNum, new Callback() { + JSONObject userVerifyInfo = new JSONObject().put("UserName", InfoCache.getAccount()).put("UserPassword", InfoCache.getToken()); + JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.05.06"); + JSONObject param = new JSONObject(); + param.put("UserVerifyInfo",userVerifyInfo); + param.put("metaInfo",metaInfo); + param.put("ProjectUuid", projectUuid); + HttpUtilsCollaborate.getProjectSwcNamesByProjectUuid(param, new Callback() { @Override public void onFailure(Call call, IOException e) { - anoListResult.postValue(new Result.Error(new Exception("Connect failed when update get ano result !"))); + anoListResult.postValue(new Result.Error(new Exception("Connect failed when getSwcNameAndUuidByProject result !"))); } @Override public void onResponse(Call call, Response response) throws IOException { Log.e(TAG, "responseCode" + response.code()); int responseCode = response.code(); - responseData = response.body().string(); + String responseData = response.body().string(); if (responseCode == 200) { - Log.e(TAG, "response getAno: " + responseData); + Log.e(TAG, "response getSwcNameAndUuidByProject: " + responseData); // process response try { - JSONArray anoNameArray = new JSONArray(responseData); - List anoNameList = new ArrayList(); - for(int i =0;i>(anoNameList)); + + JSONArray projectInfos = resultJson.getJSONArray("swcUuidName"); + List> projectList = new ArrayList<>(); + for(int i =0;i(swcUuid, swcName)); + } + anoListResult.postValue(new Result.Success<>(projectList)); } catch (Exception exception) { exception.printStackTrace(); - anoListResult.postValue(new Result.Error(new Exception("Fail to parse anolist result !"))); + anoListResult.postValue(new Result.Error(new Exception("Fail to parse getSwcNameAndUuidByProject result !"))); } response.body().close(); response.close(); - } else if (responseCode == 502) { - responseData = response.body().string(); - if (responseData.trim().equals("Empty")) { - Log.e(TAG, "get Empty response"); - anoListResult.postValue(new Result.Success(NO_MORE_FILE)); - } - } else { - Log.e(TAG, "response update arbor result: " + response.body().string()); - anoListResult.postValue(new Result.Error(new Exception("Fail to get ano list !"))); + } + else { + Log.e(TAG, "Fail to getSwcNameAndUuidByProject with: " + response.body().string()); + anoListResult.postValue(new Result.Error(new Exception("Fail to getSwcNameAndUuidByProject !"))); } } }); @@ -272,7 +234,7 @@ public void loadAno(String brainNumber,String neuronNumber,String ano) { try { JSONObject userInfo = new JSONObject().put("name", InfoCache.getAccount()).put("passwd", InfoCache.getToken()); - HttpUtilsCollaborate.loadAnoWithOkHttp(userInfo, brainNumber, neuronNumber, ano, new Callback() { + HttpUtilsCollaborate.loadAnoWithOkHttp(userInfo, brainNumber, neuronNumber, ano, CurrentProjectInfo.second,new Callback() { @Override public void onFailure(Call call, IOException e) { downloadAnoResult.postValue(new Result.Error(new Exception("Connect failed when update arbor result !"))); @@ -282,13 +244,13 @@ public void onFailure(Call call, IOException e) { public void onResponse(Call call, Response response) throws IOException { Log.e(TAG, "responseCode_loadano" + response.code()); int responseCode = response.code(); - responseData = response.body().string(); + String responseData = response.body().string(); if (responseCode == 200) { // Log.e(TAG, "response loadano: " + responseData); // process response try { JSONObject loadAnoArray = new JSONObject(responseData); - downloadAnoResult.postValue(new Result.Success(loadAnoArray)); + downloadAnoResult.postValue(new Result.Success<>(loadAnoArray)); } catch (Exception exception) { exception.printStackTrace(); downloadAnoResult.postValue(new Result.Error(new Exception("Fail to parse query arbor result !"))); @@ -299,7 +261,7 @@ public void onResponse(Call call, Response response) throws IOException { responseData = response.body().string(); if (responseData.trim().equals("Empty")) { Log.e(TAG, "get Empty response"); - downloadAnoResult.postValue(new Result.Success(NO_MORE_FILE)); + downloadAnoResult.postValue(new Result.Success<>(NO_MORE_FILE)); } } else { // Log.e(TAG, "response update arbor result: " + response.body().string()); @@ -316,12 +278,12 @@ public void onResponse(Call call, Response response) throws IOException { public void getUserId(String username){ try { - JSONObject userVerifyInfo = new JSONObject().put("UserName", username).put("UserToken", ""); - JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.01.19"); + JSONObject userVerifyInfo = new JSONObject().put("UserName", username).put("UserPassword", InfoCache.getToken()); + JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.05.06"); JSONObject param = new JSONObject(); - param.put("UserName",username); - param.put("UserVerifyInfo",userVerifyInfo); param.put("metaInfo",metaInfo); + param.put("UserVerifyInfo",userVerifyInfo); + param.put("UserName", username); HttpUtilsUser.getUserIdWithOKHttp(param, new Callback() { @Override public void onFailure(Call call, IOException e) { @@ -333,7 +295,7 @@ public void onResponse(Call call, Response response) throws IOException { int responseCode = response.code(); Log.e(TAG,"responsecode of getuserid"+responseCode); if (responseCode == 200) { - responseData = response.body().string(); + String responseData = response.body().string(); Log.e(TAG, "responseData_getuserid: " + responseData); try { JSONObject resultJson = new JSONObject(responseData); diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/UserDataSource.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/UserDataSource.java index 119b719dc..9de0fc2d1 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/UserDataSource.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/UserDataSource.java @@ -97,7 +97,7 @@ public void onResponse(Call call, Response response) throws IOException { public void getUserId(String username) { try { JSONObject userVerifyInfo = new JSONObject().put("UserName", username).put("UserToken", ""); - JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.01.19"); + JSONObject metaInfo = new JSONObject().put("ApiVersion","2024.05.06"); JSONObject param = new JSONObject(); param.put("UserName",username); param.put("UserVerifyInfo",userVerifyInfo); diff --git a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/model/img/CollaborateNeuronInfo.java b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/model/img/CollaborateNeuronInfo.java index b97436200..66d1ed27f 100644 --- a/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/model/img/CollaborateNeuronInfo.java +++ b/MyApplicationVolume/app/src/main/java/com/penglab/hi5/data/model/img/CollaborateNeuronInfo.java @@ -7,15 +7,13 @@ public class CollaborateNeuronInfo { private String name; private XYZ loc; private String[] resolutionList; - private String currentRes; - public CollaborateNeuronInfo(String image, String name, XYZ loc) { this.imageId = image; this.name = name; this.loc = loc; this.resolutionList = null; - this.currentRes = ""; + String currentRes = ""; } public CollaborateNeuronInfo(){ @@ -24,9 +22,6 @@ public CollaborateNeuronInfo(){ this.loc = new XYZ(); } - - - public String getBrainName() { return imageId; } @@ -51,11 +46,4 @@ public void setLocation(XYZ xyz){ this.loc = xyz; } - public String[] getResolutionList() { - return resolutionList; - } - - public void setResolutionList(String[] resolutionList) { - this.resolutionList = resolutionList; - } } diff --git a/MyApplicationVolume/app/src/main/res/drawable/newlogo.png b/MyApplicationVolume/app/src/main/res/drawable/newlogo.png new file mode 100644 index 000000000..8e6205a93 Binary files /dev/null and b/MyApplicationVolume/app/src/main/res/drawable/newlogo.png differ diff --git a/MyApplicationVolume/app/src/main/res/drawable/splash_screen_background.xml b/MyApplicationVolume/app/src/main/res/drawable/splash_screen_background.xml index 6604d6352..a8ddd4a5c 100644 --- a/MyApplicationVolume/app/src/main/res/drawable/splash_screen_background.xml +++ b/MyApplicationVolume/app/src/main/res/drawable/splash_screen_background.xml @@ -2,16 +2,16 @@ - + + android:height="140dp" > + android:src="@drawable/newlogo"/> \ No newline at end of file diff --git a/MyApplicationVolume/app/src/main/res/layout/activity_login.xml b/MyApplicationVolume/app/src/main/res/layout/activity_login.xml index cab3cd51b..90f57ddf3 100644 --- a/MyApplicationVolume/app/src/main/res/layout/activity_login.xml +++ b/MyApplicationVolume/app/src/main/res/layout/activity_login.xml @@ -1,40 +1,34 @@ - + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:background="@mipmap/bg_car_logo"> + android:paddingBottom="16dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent"> - - @@ -43,21 +37,22 @@ android:id="@+id/iv_login_username_icon" android:layout_width="24dp" android:layout_height="24dp" - android:layout_marginLeft="14dp" - android:layout_marginRight="14dp" + android:layout_marginStart="14dp" + android:layout_marginEnd="14dp" android:contentDescription="@null" app:srcCompat="@mipmap/ic_login_username" /> + + android:background="@color/black_alpha_60" /> @@ -79,21 +74,23 @@ android:id="@+id/iv_login_username_del" android:layout_width="20dp" android:layout_height="20dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" android:contentDescription="@null" android:scaleType="fitCenter" android:visibility="gone" app:srcCompat="@mipmap/ic_clear" /> + + @@ -102,21 +99,22 @@ android:id="@+id/iv_login_pwd_icon" android:layout_width="24dp" android:layout_height="24dp" - android:layout_marginLeft="14dp" - android:layout_marginRight="14dp" + android:layout_marginStart="14dp" + android:layout_marginEnd="14dp" android:contentDescription="@null" app:srcCompat="@mipmap/ic_login_password" /> + + android:background="@color/black_alpha_60" /> + - - -