Search in sources :

Example 6 with BrainSentences

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

the class AllSentencesFragment method onCreateAdapterView.

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

Example 7 with BrainSentences

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

the class AllSentencesFragment 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> call, 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> call, Throwable t) {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
                }
            }
        });
    }
}
Also used : Retrofit(retrofit2.Retrofit) BrainSentences(com.gladysinc.gladys.Models.BrainSentences) RetrofitAPI(com.gladysinc.gladys.Utils.RetrofitAPI) SelfSigningClientBuilder(com.gladysinc.gladys.Utils.SelfSigningClientBuilder)

Example 8 with BrainSentences

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

the class ApprovedSentencesFragment 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> call, 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> call, Throwable t) {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_5));
                }
            }
        });
    }
}
Also used : Retrofit(retrofit2.Retrofit) BrainSentences(com.gladysinc.gladys.Models.BrainSentences) RetrofitAPI(com.gladysinc.gladys.Utils.RetrofitAPI) SelfSigningClientBuilder(com.gladysinc.gladys.Utils.SelfSigningClientBuilder)

Example 9 with BrainSentences

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

the class PendingSentencesFragment method onCreateAdapterView.

public void onCreateAdapterView() {
    List<BrainSentences> brainSentencesList = SugarRecord.find(BrainSentences.class, "status=?", "pending");
    if (brainSentencesList.size() > 0) {
        recycler_view.setVisibility(View.VISIBLE);
        no_data_pending.setVisibility(View.INVISIBLE);
        no_data_pending_ic.setVisibility(View.INVISIBLE);
        adapter = new BrainSentencesAdapter(brainSentencesList, this);
        AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
        recycler_view.setAdapter(new SlideInLeftAnimationAdapter(alphaAdapter));
    } else {
        recycler_view.setVisibility(View.INVISIBLE);
        no_data_pending.setVisibility(View.VISIBLE);
        no_data_pending_ic.setVisibility(View.VISIBLE);
    }
}
Also used : BrainSentences(com.gladysinc.gladys.Models.BrainSentences) AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter) BrainSentencesAdapter(com.gladysinc.gladys.Adapters.BrainSentencesAdapter)

Example 10 with BrainSentences

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

the class RejectedSentencesFragment method onCreateAdapterView.

public void onCreateAdapterView() {
    List<BrainSentences> brainSentencesList = SugarRecord.find(BrainSentences.class, "status=?", "rejected");
    if (brainSentencesList.size() > 0) {
        recycler_view.setVisibility(View.VISIBLE);
        no_data_rejected.setVisibility(View.INVISIBLE);
        no_data_rejected_ic.setVisibility(View.INVISIBLE);
        adapter = new BrainSentencesAdapter(brainSentencesList, this);
        AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
        recycler_view.setAdapter(new SlideInLeftAnimationAdapter(alphaAdapter));
    } else {
        recycler_view.setVisibility(View.INVISIBLE);
        no_data_rejected.setVisibility(View.VISIBLE);
        no_data_rejected_ic.setVisibility(View.VISIBLE);
    }
}
Also used : BrainSentences(com.gladysinc.gladys.Models.BrainSentences) AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter) BrainSentencesAdapter(com.gladysinc.gladys.Adapters.BrainSentencesAdapter)

Aggregations

BrainSentences (com.gladysinc.gladys.Models.BrainSentences)12 RetrofitAPI (com.gladysinc.gladys.Utils.RetrofitAPI)8 SelfSigningClientBuilder (com.gladysinc.gladys.Utils.SelfSigningClientBuilder)8 Retrofit (retrofit2.Retrofit)8 BrainSentencesAdapter (com.gladysinc.gladys.Adapters.BrainSentencesAdapter)4 AlphaInAnimationAdapter (jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter)4 SlideInLeftAnimationAdapter (jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter)4