package com.ht.gate; import android.app.Application; import android.content.SharedPreferences; import androidx.annotation.NonNull; import com.ht.gate.domain.Meeting; import com.ht.gate.domain.Room; import com.ht.gate.domain.RoomMeetings; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.Timer; import java.util.TimerTask; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; public class MyApplication extends Application { public static List todayMeetings; @Override public void onCreate() { super.onCreate(); SharedPreferences sharedPreferences = getSharedPreferences(SettingsActivity.PREF_NAME_SETTINGS, MODE_PRIVATE); String spaceName = sharedPreferences.getString(SettingsActivity.PREF_KEY_SPACE_NAME, null); if (spaceName == null) { spaceName = "财富管理室"; sharedPreferences.edit().putString(SettingsActivity.PREF_KEY_SPACE_NAME, spaceName).apply(); } RetrofitManager.getInstance().init(); if (todayMeetings == null) { todayMeetings = new ArrayList<>(); } Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { Room room = Room.fromBase64(sharedPreferences.getString("room", null)); if (room != null) { Date date = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); String dateStr = simpleDateFormat.format(date); RetrofitManager.getInstance().getRetrofit().create(ApiService.class) .roomMeetings(dateStr + "00:00:00", dateStr + "23:59:59", room.getRoomNo()).enqueue(new Callback>() { @Override public void onResponse(@NonNull Call> call, @NonNull Response> response) { } @Override public void onFailure(@NonNull Call> call, @NonNull Throwable t) { } }); } } }, 0, 60 * 1000); } }