refactoring code
This commit is contained in:
parent
2186d0411b
commit
4e84acf456
|
|
@ -13,11 +13,9 @@ public class Log {
|
|||
|
||||
public static void setup(Context context) {
|
||||
ctx = context;
|
||||
//setLevel(context);
|
||||
//setupBugsnag(context);
|
||||
}
|
||||
|
||||
public static ILogger getLogger(String tag){
|
||||
public static ILogger getLogger(String tag) {
|
||||
return new ILogger() {
|
||||
@Override
|
||||
public void d(String msg) {
|
||||
|
|
@ -33,7 +31,6 @@ public class Log {
|
|||
|
||||
public static void d(String msg) {
|
||||
d(TAG, msg);
|
||||
|
||||
}
|
||||
|
||||
public static void d(String tag, String msg) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import eu.csc.log.Log;
|
||||
import eu.csc.vehown.persist.localstorage.PersistenceFactory;
|
||||
import eu.csc.vehown.persist.localstorage.VehicleOwnerDatabase;
|
||||
import eu.csc.vehown.persist.localstorage.entity.EntityLog;
|
||||
import eu.csc.vehown.services.rest.vehownserver.VehOwnApiClientFactory;
|
||||
import lombok.var;
|
||||
|
||||
|
|
@ -16,29 +17,31 @@ public class ApplicationEx extends Application {
|
|||
public static VehicleOwnerDatabase db;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
android.util.Log.d("ApplicationEx", "item.toString()");
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
android.util.Log.d("ApplicationEx", "starting");
|
||||
|
||||
Log.setup(this);
|
||||
Log.setup(this);
|
||||
|
||||
VehOwnApiClientFactory.setUrl(this);
|
||||
VehOwnApiClientFactory.setUrl(this);
|
||||
|
||||
db = PersistenceFactory.generateDatabase(this);
|
||||
long from = new Date().getTime() - 24 * 3600 * 1000L;
|
||||
long from2 = new Date().getTime() * 3600 * 1000L;
|
||||
db = PersistenceFactory.generateDatabase(this);
|
||||
long from = new Date().getTime() - 24 * 3600 * 1000L;
|
||||
long from2 = new Date().getTime() * 3600 * 1000L;
|
||||
|
||||
|
||||
Log.d("ApplicationEx", "LOGS");
|
||||
for (EntityLog item : db.log().getLogs(from)) {
|
||||
android.util.Log.d("LOGS", item.toString());
|
||||
}
|
||||
|
||||
|
||||
Log.d("ApplicationEx", "DELETE OLD LOGS", db.log().countDeleteLogs(from2, 1000));
|
||||
|
||||
db.log().deleteLogs(from2, 1000);
|
||||
|
||||
android.util.Log.d("ApplicationEx", "ending");
|
||||
|
||||
|
||||
Log.d("ApplicationEx", "LOGS");
|
||||
for(var item:db.log().getLogs(from)){
|
||||
android.util.Log.d("LOGS", item.toString());
|
||||
}
|
||||
|
||||
|
||||
Log.d("ApplicationEx", "DELETE OLD LOGS", db.log().countDeleteLogs(from2, 1000));
|
||||
|
||||
db.log().deleteLogs(from2, 1000);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ public class UserProfileFragment extends AbstractFragment {
|
|||
|
||||
mViewModel = new ViewModelProvider(this, new AppViewModelFactory(getContext()))
|
||||
.get(UserProfileViewModel.class);
|
||||
|
||||
mViewModel.getMutableLiveDataSuccess().observe(getViewLifecycleOwner(), new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(Boolean aBoolean) {
|
||||
|
|
@ -97,6 +98,7 @@ public class UserProfileFragment extends AbstractFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
mViewModel.deleteVehicles();
|
||||
mViewModel.refreshVehicles();
|
||||
}
|
||||
});
|
||||
mViewModel.getMRefreshVehicles().observe(getViewLifecycleOwner(), new Observer<List<Vehicle>>() {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import eu.csc.log.Log;
|
|||
import eu.csc.vehown.data.model.CustomerDevice;
|
||||
import eu.csc.vehown.ui.registration.data.CustomerContentRepository;
|
||||
import eu.csc.vehown.ui.registration.data.CustomerVehicleRegistrationRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.csc.vehown.data.model.Vehicle;
|
||||
|
|
@ -47,15 +48,15 @@ public class UserProfileViewModel extends AbstractBaseViewModel {
|
|||
executorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
var result = repository.fetchCustomerVehiclesRemote();
|
||||
var result = repository.fetchCustomerVehiclesRemote();
|
||||
d(TAG, result.toString());
|
||||
|
||||
if(result instanceof Result.Success){
|
||||
if (result instanceof Result.Success) {
|
||||
mutableLiveDataSuccess.postValue(true);
|
||||
mRefreshVehicles.postValue(result.getSuccessBody());
|
||||
}else
|
||||
} else {
|
||||
mutableLiveDataSuccess.postValue(false);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ public class UserProfileViewModel extends AbstractBaseViewModel {
|
|||
|
||||
}
|
||||
|
||||
public void refreshContent(){
|
||||
public void refreshContent() {
|
||||
mVehicles.postValue(repository.getStoredUserVehicles());
|
||||
mStoredDevices.postValue(repository.getStoredUserDevices());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,10 @@ public class LoginActivity
|
|||
|
||||
// showing the back button in action bar
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void showPages() {
|
||||
//ToDo activate
|
||||
/*
|
||||
navView.getMenu().findItem(R.id.navigation_customer_register_login)
|
||||
.setVisible(!sharedPref.getIsLoggedIn());
|
||||
|
|
@ -100,17 +99,16 @@ public class LoginActivity
|
|||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()){
|
||||
case R.id.navigation_customer_register_login:{
|
||||
switch (item.getItemId()) {
|
||||
case R.id.navigation_customer_register_login: {
|
||||
switchFragment(R.id.content_frame, new LoginFragment());
|
||||
|
||||
break;
|
||||
}
|
||||
case R.id.navigation_customer_register_register:{
|
||||
case R.id.navigation_customer_register_register: {
|
||||
switchFragment(R.id.content_frame, new FragmentCustomerRegistration());
|
||||
break;
|
||||
}
|
||||
case R.id.navigation_customer_register_profile:{
|
||||
case R.id.navigation_customer_register_profile: {
|
||||
switchFragment(R.id.content_frame, new UserProfileFragment());
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ import lombok.var;
|
|||
/**
|
||||
* A fragment representing a list of Items.
|
||||
*/
|
||||
public class LogsFragment extends AbstractFragment {
|
||||
public class LogsFragment
|
||||
extends AbstractFragment {
|
||||
|
||||
// TODO: Customize parameter argument names
|
||||
private static final String ARG_COLUMN_COUNT = "column-count";
|
||||
|
|
@ -70,6 +71,7 @@ public class LogsFragment extends AbstractFragment {
|
|||
} else {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
|
||||
}
|
||||
|
||||
recyclerView.setAdapter(new LogItemRecyclerViewAdapter(getDatabase().log().getLogs()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
// Passing each menu ID as a set of Ids because each
|
||||
// menu should be considered as top level destinations.
|
||||
mAppBarConfiguration = new AppBarConfiguration.Builder(
|
||||
R.id.nav_dashboard, R.id.nav_show_vehicles_devices, R.id.nav_downloaded_events, R.id.nav_reported_events)
|
||||
R.id.nav_dashboard,
|
||||
R.id.nav_show_vehicles_devices,
|
||||
R.id.nav_downloaded_events,
|
||||
R.id.nav_reported_events)
|
||||
.setDrawerLayout(drawer)
|
||||
.build();
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
|
||||
|
|
@ -85,12 +88,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
setup();
|
||||
checkRegistration();
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
//DataServiceIntent.startUploadingRequestHelp(this, i + "", "");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void checkRegistration() {
|
||||
|
|
@ -142,13 +139,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
showLogs();
|
||||
break;
|
||||
case R.id.nav_list_content:
|
||||
;
|
||||
intent = new Intent(this, ActivityLocalContentNavigation.class);
|
||||
|
||||
break;
|
||||
case R.id.nav_register_base:
|
||||
Log.d("MainA", "Starting Base Activity")
|
||||
;
|
||||
Log.d("MainA", "Starting Base Activity") ;
|
||||
intent = new Intent(this, BaseRegistrationActivity.class);
|
||||
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue