use of com.gladysinc.gladys.Models.BrainSentences in project Gladys-Android-App by LeptitGeek.
the class ApprovedSentencesFragment method onCreateAdapterView.
public void onCreateAdapterView() {
List<BrainSentences> brainSentencesList = SugarRecord.find(BrainSentences.class, "status=?", "approved");
if (brainSentencesList.size() > 0) {
recycler_view.setVisibility(View.VISIBLE);
no_data_approved.setVisibility(View.INVISIBLE);
no_data_approved_ic.setVisibility(View.INVISIBLE);
adapter = new BrainSentencesAdapter(brainSentencesList, this);
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
recycler_view.setAdapter(new SlideInLeftAnimationAdapter(alphaAdapter));
recycler_view.invalidate();
} else {
recycler_view.setVisibility(View.INVISIBLE);
no_data_approved.setVisibility(View.VISIBLE);
no_data_approved_ic.setVisibility(View.VISIBLE);
}
}
use of com.gladysinc.gladys.Models.BrainSentences in project Gladys-Android-App by LeptitGeek.
the class ApprovedSentencesFragment method setStatus.
public void setStatus(final Long id) {
getConnection();
if (connection) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
RetrofitAPI service = retrofit.create(RetrofitAPI.class);
Call<Void> call = service.setStatus(id, "rejected", pref_token);
call.enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.code() == 200) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.command_send));
}
BrainSentences brainSentences = (SugarRecord.find(BrainSentences.class, "sentencesid = ?", id.toString())).get(0);
brainSentences.setStatue("rejected");
SugarRecord.save(brainSentences);
onCreateAdapterView();
} else {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
}
}
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
}
}
});
}
}
use of com.gladysinc.gladys.Models.BrainSentences in project Gladys-Android-App by LeptitGeek.
the class PendingSentencesFragment method setStatus.
public void setStatus(final Long id, final String status) {
getConnection();
if (connection) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
RetrofitAPI service = retrofit.create(RetrofitAPI.class);
Call<Void> call = service.setStatus(id, status, pref_token);
call.enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.code() == 200) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.command_send));
}
BrainSentences brainSentences = (SugarRecord.find(BrainSentences.class, "sentencesid = ?", id.toString())).get(0);
brainSentences.setStatue(status);
SugarRecord.save(brainSentences);
onCreateAdapterView();
} else {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
}
}
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
}
}
});
}
}
use of com.gladysinc.gladys.Models.BrainSentences in project Gladys-Android-App by LeptitGeek.
the class PendingSentencesFragment method setLabel.
public void setLabel(final Long id, final String label) {
getConnection();
if (connection) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
RetrofitAPI service = retrofit.create(RetrofitAPI.class);
Call<BrainSentences> call = service.setLabel(id, label, pref_token);
call.enqueue(new Callback<BrainSentences>() {
@Override
public void onResponse(Call<BrainSentences> all, Response<BrainSentences> response) {
if (response.code() == 200) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.command_send));
}
BrainSentences brainSentences = (SugarRecord.find(BrainSentences.class, "sentencesid = ?", id.toString())).get(0);
brainSentences.setLabel(response.body().getLabel());
brainSentences.setService(response.body().getService());
SugarRecord.save(brainSentences);
onCreateAdapterView();
} else {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
}
}
}
@Override
public void onFailure(Call<BrainSentences> all, Throwable t) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
}
}
});
}
}
use of com.gladysinc.gladys.Models.BrainSentences in project Gladys-Android-App by LeptitGeek.
the class AllSentencesFragment method setStatus.
public void setStatus(final Long id, final String status) {
getConnection();
if (connection) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
RetrofitAPI service = retrofit.create(RetrofitAPI.class);
Call<Void> call = service.setStatus(id, status, pref_token);
call.enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.code() == 200) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.command_send));
}
BrainSentences brainSentences = (SugarRecord.find(BrainSentences.class, "sentencesid = ?", id.toString())).get(0);
brainSentences.setStatue(status);
SugarRecord.save(brainSentences);
onCreateAdapterView();
} else {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
}
}
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
if (getActivity() != null) {
SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
}
}
});
}
}
Aggregations