Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onReceive(Context context, Intent intent) {
- Calendar calendar = Calendar.getInstance();
- int year = calendar.get(Calendar.YEAR);
- int month = calendar.get(Calendar.MONTH);
- int dayOfMonth = calendar.get(Calendar.DATE);
- calendar.set(year, month, dayOfMonth);
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
- String glte = dateFormat.format(calendar.getTime());
- BaseAPIService service = UtilsAPI.getApiService();
- String type = intent.getStringExtra(EXTRA_TYPE);
- String message = intent.getStringExtra(EXTRA_MESSAGE);
- int idNotification = type.equalsIgnoreCase(TYPE_DAILY) ? ID_DAILY : ID_RELEASE;
- Log.d("type", " " + type);
- Log.d("message", " " + message);
- Log.d("id", " " + idNotification);
- if (idNotification == ID_DAILY) {
- showAlarmNotification(context, TYPE_DAILY, message, idNotification);
- } else {
- Log.d("masuk release a", " MASUKKKKK!!");
- //retrofit
- List<MovieResponse> listRelease = new ArrayList<>();
- service.getReleaseMovie(MyViewModel.api_key, glte, glte)
- .enqueue(new Callback<MovieResponse>() {
- @Override
- public void onResponse(Call<MovieResponse> call, Response<MovieResponse> response) {
- if (response.isSuccessful()) {
- listRelease.add(response.body());
- String result = response.toString();
- Log.d("Response", "not null" + response.toString());
- Log.d("cek alarm req", " Good");
- try {
- final ArrayList<MovieItem> list = new ArrayList<>();
- JSONObject object = new JSONObject(result);
- JSONArray array = object.getJSONArray("results");
- for (int i = 0; i < array.length(); i++) {
- JSONObject movieObj = array.getJSONObject(i);
- MovieItem item = new MovieItem(movieObj);
- list.add(item);
- Log.d("listMpvie", " "+ list.size());
- }
- }catch (JSONException e){
- e.printStackTrace();
- }
- } else {
- listRelease.add(null);
- Log.d("Response : ", "null");
- }
- }
- @Override
- public void onFailure(Call<MovieResponse> call, Throwable t) {
- listRelease.add(null);
- Log.d("Response : ", "null");
- }
- });
- // List<MovieItem> movieItems;
- // Log.d("bawah listmovie: ", " ");
- // for (MovieResponse movieResponse : listRelease ){
- // movieItems = movieResponse.getResults();
- // Log.d("movieitem al: ", " "+movieItems.size());
- // }
- // MainRepo repo = MainRepo.getInstance();
- // List<MovieResponse> movieResponses = repo.getMovieRelease(MyViewModel.api_key, glte, glte);
- // List<MovieItem> movieItems = new ArrayList<>();
- // for (MovieResponse movieResponse : movieResponses){
- // movieItems = movieResponse.getResults();
- // }
- // for (MovieItem item : movieItems){
- // Log.d("title", " " + item.getTitle());
- // }
- // new MainRepo.MyAsyncTask(output -> {
- // for (int i = 0; i < output.size(); i++) {
- // MovieItem item = output.get(i);
- // showAlarmNotification(context, item.getTitle(), message, idNotification + i);
- // }
- // }).execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement