Search in sources :

Example 1 with Event

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

the class TimelineFragment method createEvent.

public void createEvent(final String name) {
    SharedPreferences pref1 = PreferenceManager.getDefaultSharedPreferences(getContext());
    pref_house = pref1.getString("idhouse", "1");
    pref_user = pref1.getString("iduser", "1");
    getConnection();
    if (connection) {
        getCode(name);
        Retrofit retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create()).client(SelfSigningClientBuilder.getUnsafeOkHttpClient()).build();
        RetrofitAPI service = retrofit.create(RetrofitAPI.class);
        Call<Event> call = service.createEvents(code, pref_house, pref_user, pref_token);
        call.enqueue(new Callback<Event>() {

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

            @Override
            public void onFailure(Call<Event> call, Throwable t) {
                if (getActivity() != null) {
                    SnackbarUtils.simpleSnackBar(getContext(), getView(), getContext().getString(R.string.error_code_4));
                }
            }
        });
    }
}
Also used : Retrofit(retrofit2.Retrofit) SharedPreferences(android.content.SharedPreferences) RetrofitAPI(com.gladysinc.gladys.Utils.RetrofitAPI) SelfSigningClientBuilder(com.gladysinc.gladys.Utils.SelfSigningClientBuilder) Event(com.gladysinc.gladys.Models.Event)

Example 2 with Event

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

the class TimelineFragment method onCreateAdapterView.

public void onCreateAdapterView() {
    long count = Event.count(Event.class);
    if (count > 0) {
        recycler_view.setVisibility(View.VISIBLE);
        no_data_timeline.setVisibility(View.INVISIBLE);
        no_data_timeline_ic.setVisibility(View.INVISIBLE);
        List<Event> data = Event.listAll(Event.class);
        adapter = new EventAdapter(data);
        AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
        recycler_view.setAdapter(new SlideInLeftAnimationAdapter(alphaAdapter));
        getAllEvents();
    } else {
        recycler_view.setVisibility(View.INVISIBLE);
        no_data_timeline.setVisibility(View.VISIBLE);
        no_data_timeline_ic.setVisibility(View.VISIBLE);
        getAllEvents();
    }
}
Also used : AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) Event(com.gladysinc.gladys.Models.Event) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter) EventAdapter(com.gladysinc.gladys.Adapters.EventAdapter)

Example 3 with Event

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

the class TimelineFragment method onRefreshAdapterView.

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

Aggregations

Event (com.gladysinc.gladys.Models.Event)3 EventAdapter (com.gladysinc.gladys.Adapters.EventAdapter)2 AlphaInAnimationAdapter (jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter)2 SlideInLeftAnimationAdapter (jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter)2 SharedPreferences (android.content.SharedPreferences)1 RetrofitAPI (com.gladysinc.gladys.Utils.RetrofitAPI)1 SelfSigningClientBuilder (com.gladysinc.gladys.Utils.SelfSigningClientBuilder)1 Retrofit (retrofit2.Retrofit)1