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));
}
}
}
});
}
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();
}
}
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));
}
}
}
});
}
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);
}
}
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));
}
}
}
});
}
Aggregations