Search in sources :

Example 1 with Alarm

use of com.gladysinc.gladys.Models.Alarm in project Gladys-Android-App by LeptitGeek.

the class AlarmFragment method createAlarmRec.

public void createAlarmRec() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
    RetrofitAPI service = retrofit.create(RetrofitAPI.class);
    Call<Alarm> call = service.createAlarmRec(rec_name, time, id_of_day, true, pref_token);
    call.enqueue(new Callback<Alarm>() {

        @Override
        public void onResponse(Call<Alarm> call, Response<Alarm> response) {
            if (response.code() == 201) {
                getAllAlarms();
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.alarm_created));
                }
            } else {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
                }
            }
        }

        @Override
        public void onFailure(Call<Alarm> call, Throwable t) {
            if (!Objects.equals(t.getMessage(), "java.net.SocketTimeoutException")) {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
                }
            }
        }
    });
}
Also used : Retrofit(retrofit2.Retrofit) RetrofitAPI(com.gladysinc.gladys.Utils.RetrofitAPI) SelfSigningClientBuilder(com.gladysinc.gladys.Utils.SelfSigningClientBuilder) Alarm(com.gladysinc.gladys.Models.Alarm)

Example 2 with Alarm

use of com.gladysinc.gladys.Models.Alarm in project Gladys-Android-App by LeptitGeek.

the class AlarmFragment method onCreateAdapterView.

public void onCreateAdapterView() {
    long count = SugarRecord.count(Alarm.class);
    if (count > 0) {
        recycler_view.setVisibility(View.VISIBLE);
        no_data_alarm.setVisibility(View.INVISIBLE);
        no_data_alarm_ic.setVisibility(View.INVISIBLE);
        List<Alarm> data = SugarRecord.listAll(Alarm.class);
        adapter = new AlarmAdapter(data, this);
        AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
        recycler_view.setAdapter(new SlideInLeftAnimationAdapter(alphaAdapter));
        getAllAlarms();
    } else {
        recycler_view.setVisibility(View.INVISIBLE);
        no_data_alarm.setVisibility(View.VISIBLE);
        no_data_alarm_ic.setVisibility(View.VISIBLE);
        // no_data.setText(R.string.no_data);
        getAllAlarms();
    }
}
Also used : AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) Alarm(com.gladysinc.gladys.Models.Alarm) AlarmAdapter(com.gladysinc.gladys.Adapters.AlarmAdapter) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter)

Example 3 with Alarm

use of com.gladysinc.gladys.Models.Alarm in project Gladys-Android-App by LeptitGeek.

the class AlarmFragment method createAlarmSpe.

public void createAlarmSpe() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
    RetrofitAPI service = retrofit.create(RetrofitAPI.class);
    Call<Alarm> call = service.createAlarmSpe(spe_name, date_time, true, pref_token);
    call.enqueue(new Callback<Alarm>() {

        @Override
        public void onResponse(Call<Alarm> call, Response<Alarm> response) {
            if (response.code() == 201) {
                getAllAlarms();
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.alarm_created));
                }
            } else {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
                }
            }
        }

        @Override
        public void onFailure(Call<Alarm> call, Throwable t) {
            if (!Objects.equals(t.getMessage(), "java.net.SocketTimeoutException")) {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
                }
            }
        }
    });
}
Also used : Retrofit(retrofit2.Retrofit) RetrofitAPI(com.gladysinc.gladys.Utils.RetrofitAPI) SelfSigningClientBuilder(com.gladysinc.gladys.Utils.SelfSigningClientBuilder) Alarm(com.gladysinc.gladys.Models.Alarm)

Example 4 with Alarm

use of com.gladysinc.gladys.Models.Alarm in project Gladys-Android-App by LeptitGeek.

the class AlarmFragment method onRefreshAdapterView.

public void onRefreshAdapterView() {
    long count = SugarRecord.count(Alarm.class);
    if (count > 0) {
        recycler_view.setVisibility(View.VISIBLE);
        no_data_alarm.setVisibility(View.INVISIBLE);
        no_data_alarm_ic.setVisibility(View.INVISIBLE);
        List<Alarm> data = SugarRecord.listAll(Alarm.class);
        adapter = new AlarmAdapter(data, this);
        AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
        recycler_view.setAdapter(new SlideInLeftAnimationAdapter(alphaAdapter));
    } else {
        recycler_view.setVisibility(View.INVISIBLE);
        no_data_alarm.setVisibility(View.VISIBLE);
        no_data_alarm_ic.setVisibility(View.VISIBLE);
    }
}
Also used : AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) Alarm(com.gladysinc.gladys.Models.Alarm) AlarmAdapter(com.gladysinc.gladys.Adapters.AlarmAdapter) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter)

Example 5 with Alarm

use of com.gladysinc.gladys.Models.Alarm in project Gladys-Android-App by LeptitGeek.

the class AlarmFragment method createCronRule.

public void createCronRule(String name, String rule) {
    Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
    RetrofitAPI service = retrofit.create(RetrofitAPI.class);
    Call<Alarm> call = service.createCronRule(name, rule, pref_token);
    call.enqueue(new Callback<Alarm>() {

        @Override
        public void onResponse(Call<Alarm> call, Response<Alarm> response) {
            if (response.code() == 201) {
                getAllAlarms();
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.alarm_created));
                }
            } else {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
                }
            }
        }

        @Override
        public void onFailure(Call<Alarm> call, Throwable t) {
            if (!Objects.equals(t.getMessage(), "java.net.SocketTimeoutException")) {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
                }
            }
        }
    });
}
Also used : Retrofit(retrofit2.Retrofit) RetrofitAPI(com.gladysinc.gladys.Utils.RetrofitAPI) SelfSigningClientBuilder(com.gladysinc.gladys.Utils.SelfSigningClientBuilder) Alarm(com.gladysinc.gladys.Models.Alarm)

Aggregations

Alarm (com.gladysinc.gladys.Models.Alarm)5 RetrofitAPI (com.gladysinc.gladys.Utils.RetrofitAPI)3 SelfSigningClientBuilder (com.gladysinc.gladys.Utils.SelfSigningClientBuilder)3 Retrofit (retrofit2.Retrofit)3 AlarmAdapter (com.gladysinc.gladys.Adapters.AlarmAdapter)2 AlphaInAnimationAdapter (jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter)2 SlideInLeftAnimationAdapter (jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter)2