修复问题
This commit is contained in:
parent
9c7bb9e568
commit
c2f2e44c42
|
@ -81,7 +81,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||
String CREATE_TURBINE_TABLE = "CREATE TABLE " + TABLE_TURBINES + "("
|
||||
+ COLUMN_TURBINE_ID + " TEXT PRIMARY KEY,"
|
||||
+ COLUMN_TURBINE_NAME + " TEXT,"
|
||||
+ COLUMN_PROJECT_NAME + " TEXT,"
|
||||
+ COLUMN_PROJECT_ID + " TEXT,"
|
||||
+ COLUMN_LAST_UPDATED + " INTEGER" + ")";
|
||||
db.execSQL(CREATE_TURBINE_TABLE);
|
||||
String CREATE_PARTS_TABLE = "CREATE TABLE " + TABLE_PARTS + "("
|
||||
|
@ -169,7 +169,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||
String CREATE_TURBINE_TABLE = "CREATE TABLE " + TABLE_TURBINES + "("
|
||||
+ COLUMN_TURBINE_ID + " TEXT PRIMARY KEY,"
|
||||
+ COLUMN_TURBINE_NAME + " TEXT,"
|
||||
+ COLUMN_PROJECT_NAME + " TEXT,"
|
||||
+ COLUMN_PROJECT_ID + " TEXT,"
|
||||
+ COLUMN_LAST_UPDATED + " INTEGER" + ")";
|
||||
db.execSQL(CREATE_TURBINE_TABLE);
|
||||
}
|
||||
|
|
|
@ -315,8 +315,8 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
private static final String PREF_REMEMBER = "remember";
|
||||
private final String AUTH_TOKEN_KEY = "auth_token";
|
||||
private String authToken = "";
|
||||
private final String BASE_URL = "http://10.2.1.20:8888";
|
||||
// private final String BASE_URL = "http://pms.dtyx.net:9158";
|
||||
// private final String BASE_URL = "http://10.2.1.20:8888";
|
||||
private final String BASE_URL = "http://pms.dtyx.net:9158";
|
||||
|
||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
||||
@Override
|
||||
|
@ -469,6 +469,10 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
|
||||
private void clearProject() {
|
||||
projectId = "";
|
||||
projectName = "";
|
||||
sharedPreferences.edit().putString(PREF_PROJECT, "").apply();
|
||||
dataManager.setProjectId("");
|
||||
actvProject.setText("");
|
||||
loadProjects();
|
||||
projectAdapter.getFilter().filter("");
|
||||
|
@ -477,6 +481,11 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
|
||||
private void clearTurbine() {
|
||||
turbineId = "";
|
||||
turbineName = "";
|
||||
sharedPreferences.edit().putString(PREF_TURBINE, "").apply();
|
||||
dataManager.setTurbineId("");
|
||||
dataManager.setTurbineName("");
|
||||
actvTurbine.setText("");
|
||||
loadTurbines();
|
||||
turbineAdapter.getFilter().filter("");
|
||||
|
@ -484,6 +493,11 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
|
||||
private void clearPart() {
|
||||
partId = "";
|
||||
partName = "";
|
||||
sharedPreferences.edit().putString(PREF_PART, "").apply();
|
||||
dataManager.setPartId("");
|
||||
dataManager.setPartName("");
|
||||
actvPart.setText("");
|
||||
loadParts();
|
||||
partAdapter.getFilter().filter("");
|
||||
|
@ -552,21 +566,10 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
}
|
||||
|
||||
private Retrofit initRetrofit() {
|
||||
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.writeTimeout(30, TimeUnit.SECONDS);
|
||||
okHttpClientBuilder.addInterceptor(new AuthInterceptor(authToken));
|
||||
// 2. 初始化Retrofit
|
||||
|
||||
return RetrofitClient.getClient(authToken);
|
||||
}
|
||||
|
||||
private void loadProjects() {
|
||||
try {
|
||||
// 2. 初始化Retrofit
|
||||
Retrofit retrofit = initRetrofit();
|
||||
Retrofit retrofit = RetrofitClient.getClient(authToken);
|
||||
// 3. 创建API服务
|
||||
ProjectApi projectApi = retrofit.create(ProjectApi.class);
|
||||
// 4. 执行网络请求
|
||||
|
@ -584,7 +587,7 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
try {
|
||||
// 2. 初始化Retrofit
|
||||
Retrofit retrofit = initRetrofit();
|
||||
Retrofit retrofit = RetrofitClient.getClient(authToken);
|
||||
// 3. 创建API服务
|
||||
TurbineApiService turbine = retrofit.create(TurbineApiService.class);
|
||||
// 4. 执行网络请求
|
||||
|
@ -602,7 +605,7 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
try {
|
||||
// 2. 初始化Retrofit
|
||||
Retrofit retrofit = initRetrofit();
|
||||
Retrofit retrofit = RetrofitClient.getClient(authToken);
|
||||
// 3. 创建API服务
|
||||
PartService part = retrofit.create(PartService.class);
|
||||
// 4. 执行网络请求
|
||||
|
@ -892,7 +895,7 @@ public class MainActivity extends AppCompatActivity implements ViewModelStoreOwn
|
|||
}
|
||||
|
||||
private void executePartRequest(PartService partApi) {
|
||||
retrofit2.Call<ApiResponse<List<PartResponse>>> call = partApi.getPartList(projectId, null, null, null, null);
|
||||
retrofit2.Call<ApiResponse<List<PartResponse>>> call = partApi.getPartList(projectId, turbineId, null, null, null, null);
|
||||
|
||||
call.enqueue(new retrofit2.Callback<>() {
|
||||
@Override
|
||||
|
|
|
@ -122,8 +122,7 @@ public class PartListFetcher {
|
|||
}
|
||||
private List<PartResponse> fetchFromServer() throws IOException, ApiException {
|
||||
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
||||
projectId,
|
||||
|
||||
projectId, null,
|
||||
null, null, null, null
|
||||
|
||||
);
|
||||
|
@ -143,7 +142,7 @@ public class PartListFetcher {
|
|||
}
|
||||
private void fetchFromServerAsync(final PartListCallback callback) {
|
||||
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
||||
projectId,
|
||||
projectId, null,
|
||||
|
||||
null, null, null, null
|
||||
|
||||
|
@ -194,7 +193,7 @@ public class PartListFetcher {
|
|||
PartListCallback callback) {
|
||||
Call<ApiResponse<List<PartResponse>>> call = partService.getPartList(
|
||||
projectId,
|
||||
|
||||
null,
|
||||
keyword,
|
||||
manufacturer,
|
||||
model,
|
||||
|
|
|
@ -13,6 +13,7 @@ public interface PartService {
|
|||
@GET("/part/list")
|
||||
Call<ApiResponse<List<PartResponse>>> getPartList(
|
||||
@Query("projectId") String projectId,
|
||||
@Query("turbineId") String turbineId,
|
||||
@Query("keyword") String keyword,
|
||||
@Query("partManufacturer") String partManufacturer,
|
||||
@Query("partModel") String partModel,
|
||||
|
|
|
@ -17,8 +17,8 @@ dependencyResolutionManagement {
|
|||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://chaquo.com/maven") }
|
||||
maven("https://maven.aliyun.com/repository/google")
|
||||
maven("https://maven.aliyun.com/repository/central")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue