Search in sources :

Example 1 with SessionManager

use of dz.easy.androidclient.Util.SessionManager in project easy by MehdiBenmesa.

the class NoteAbsenceActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle("");
    ButterKnife.bind(this);
    final Toolbar toolbar = mViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }
    Intent intent = getIntent();
    String jsonString = intent.getStringExtra("user");
    try {
        user = new JSONObject(jsonString);
        SessionManager sessionManager = new SessionManager(this);
        sessionManager.createLoginSession(user.getString("name"), user.getString("mail"), user.getString("_id"));
        Resources res = getResources();
        String text = user.getString("lastname") + " " + user.getString("name");
        ((TextView) findViewById(R.id.logo_white)).setText(text);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    /*
        mViewPager.getViewPager().setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

            @Override
            public Fragment getItem(int position) {
                switch (position % 3) {
                    case 0:
                        return AbsenceFragment.newInstance(user);
                    case 1:
                        return AbsenceFragment.newInstance(user);
                    default:
                        return AbsenceFragment.newInstance(user);
                }
            }

            @Override
            public int getCount() {
                return 3;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                switch (position % 3) {
                    case 0:
                        return getResources().getString(R.string.NoteManager);
                    case 1:
                        return getResources().getString(R.string.AbsentManager);
                    case 2:
                        return getResources().getString(R.string.TimetableManager);

                }
                return "";
            }
        });
*/
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            switch(page) {
                case 0:
                    return HeaderDesign.fromColorResAndUrl(R.color.green, "http://phandroid.s3.amazonaws.com/wp-content/uploads/2014/06/android_google_moutain_google_now_1920x1080_wallpaper_Wallpaper-HD_2560x1600_www.paperhi.com_-640x400.jpg");
                case 1:
                    return HeaderDesign.fromColorResAndUrl(R.color.blue, "http://www.hdiphonewallpapers.us/phone-wallpapers/540x960-1/540x960-mobile-wallpapers-hd-2218x5ox3.jpg");
                case 2:
                    return HeaderDesign.fromColorResAndUrl(R.color.cyan, "http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
            }
            return null;
        }
    });
    mViewPager.getViewPager().setOffscreenPageLimit(mViewPager.getViewPager().getAdapter().getCount());
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    final View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
                Toast.makeText(getApplicationContext(), "Yes, the title is clickable", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) SessionManager(dz.easy.androidclient.Util.SessionManager) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) JSONException(org.json.JSONException) Intent(android.content.Intent) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) JSONObject(org.json.JSONObject) TextView(android.widget.TextView) Resources(android.content.res.Resources) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with SessionManager

use of dz.easy.androidclient.Util.SessionManager in project easy by MehdiBenmesa.

the class GroupFragment method newInstance.

public static GroupFragment newInstance(Context c, String module) {
    context = c;
    sessionManager = new SessionManager(context);
    try {
        user = new JSONObject(sessionManager.getUser());
    } catch (JSONException e) {
        e.printStackTrace();
    }
    System.out.println("NewInstance : ME FIRST ");
    Bundle bndl = new Bundle();
    bndl.putString("module", module);
    GroupFragment grF = new GroupFragment();
    grF.setArguments(bndl);
    return grF;
}
Also used : JSONObject(org.json.JSONObject) SessionManager(dz.easy.androidclient.Util.SessionManager) Bundle(android.os.Bundle) JSONException(org.json.JSONException)

Example 3 with SessionManager

use of dz.easy.androidclient.Util.SessionManager in project easy by MehdiBenmesa.

the class RendezVousActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rende_vous);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar3);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("Chercher un enseignant");
    toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
    lstView = (RecyclerView) findViewById(R.id.lstView);
    /*ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, lstSource);
    lstView.setAdapter(adapter);*/
    SessionManager sessionManager = new SessionManager(this);
    try {
        user = new JSONObject(sessionManager.getUser());
    } catch (JSONException e) {
        e.printStackTrace();
    }
    getTeachers();
    searcheView = (MaterialSearchView) findViewById(R.id.searche_view);
    searcheView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {

        @Override
        public void onSearchViewShown() {
        }

        @Override
        public void onSearchViewClosed() {
            lstView = (RecyclerView) findViewById(R.id.lstView);
        /*ArrayAdapter adapter = new ArrayAdapter(RendezVousActivity.this, android.R.layout.simple_list_item_1, lstSource);
        lstView.setAdapter(adapter);*/
        // getTeachers();
        }
    });
    searcheView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (newText != null && !newText.isEmpty()) {
                getTeachersSearcheed(newText);
            } else {
                getTeachers();
            }
            return true;
        }
    });
}
Also used : JSONObject(org.json.JSONObject) SessionManager(dz.easy.androidclient.Util.SessionManager) JSONException(org.json.JSONException) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Example 4 with SessionManager

use of dz.easy.androidclient.Util.SessionManager in project easy by MehdiBenmesa.

the class ModuleDetailFragment method onCreate.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReceiver = new DataReceiver(new Handler());
    mReceiver.setReceiver(this);
    exam = (TextView) getActivity().findViewById(R.id.exam);
    controle = (TextView) getActivity().findViewById(R.id.control);
    intero = (TextView) getActivity().findViewById(R.id.intero);
    tp = (TextView) getActivity().findViewById(R.id.tps);
    SessionManager sessionManager = new SessionManager(getContext());
    userID = sessionManager.getIdUser();
    // String Module = sessionManager
    NoteService.getNoteByStudent(getContext(), mReceiver);
    if (getArguments().containsKey(ARG_ITEM_ID)) {
    // load dummy item by using the passed item ID.
    // accident = AppContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
    }
    // Toast.makeText(getContext() , moduleID , Toast.LENGTH_LONG).show();
    setHasOptionsMenu(true);
}
Also used : SessionManager(dz.easy.androidclient.Util.SessionManager) Handler(android.os.Handler) DataReceiver(dz.easy.androidclient.Services.DataReceiver) RequiresApi(android.support.annotation.RequiresApi)

Example 5 with SessionManager

use of dz.easy.androidclient.Util.SessionManager in project easy by MehdiBenmesa.

the class ModuleListAdapter method onCreateViewHolder.

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = null;
    view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_card_big, parent, false);
    SessionManager sessionManager = new SessionManager(view.getContext());
    System.out.println("USER SESSION : " + sessionManager.getUser());
    user = sessionManager.getUser();
    return new MyViewHolder(view) {
    };
}
Also used : SessionManager(dz.easy.androidclient.Util.SessionManager) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

SessionManager (dz.easy.androidclient.Util.SessionManager)8 JSONException (org.json.JSONException)5 JSONObject (org.json.JSONObject)5 Intent (android.content.Intent)3 Toolbar (android.support.v7.widget.Toolbar)3 View (android.view.View)3 TextView (android.widget.TextView)3 Handler (android.os.Handler)2 RequiresApi (android.support.annotation.RequiresApi)2 RecyclerView (android.support.v7.widget.RecyclerView)2 BindView (butterknife.BindView)2 MaterialViewPager (com.github.florent37.materialviewpager.MaterialViewPager)2 HeaderDesign (com.github.florent37.materialviewpager.header.HeaderDesign)2 DataReceiver (dz.easy.androidclient.Services.DataReceiver)2 Resources (android.content.res.Resources)1 Bundle (android.os.Bundle)1 Fragment (android.support.v4.app.Fragment)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 CardView (android.support.v7.widget.CardView)1 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)1