| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 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<Meeting> 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<List<RoomMeetings>>() {
- @Override
- public void onResponse(@NonNull Call<List<RoomMeetings>> call, @NonNull Response<List<RoomMeetings>> response) {
- }
- @Override
- public void onFailure(@NonNull Call<List<RoomMeetings>> call, @NonNull Throwable t) {
- }
- });
- }
- }
- }, 0, 60 * 1000);
- }
- }
|