Search in sources :

Example 1 with WhatsNewModel

use of com.manan.dev.ec2018app.Models.WhatsNewModel in project EC2018App by Manan-YMCA.

the class DashboardSliderFragment1 method attachDatabaseListener.

private void attachDatabaseListener() {
    if (mChildEventListener == null) {
        mChildEventListener = new ChildEventListener() {

            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                WhatsNewModel w = dataSnapshot.getValue(WhatsNewModel.class);
                whatsnewarraylist.add(w);
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                try {
                    WhatsNewModel w = dataSnapshot.getValue(WhatsNewModel.class);
                    whatsnewarraylist.add(w);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
                WhatsNewModel w = dataSnapshot.getValue(WhatsNewModel.class);
                whatsnewarraylist.remove(w);
            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        };
        mDatabaseReference.addChildEventListener(mChildEventListener);
        updateUI();
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) WhatsNewModel(com.manan.dev.ec2018app.Models.WhatsNewModel) DataSnapshot(com.google.firebase.database.DataSnapshot) ChildEventListener(com.google.firebase.database.ChildEventListener)

Example 2 with WhatsNewModel

use of com.manan.dev.ec2018app.Models.WhatsNewModel in project EC2018App by Manan-YMCA.

the class DashboardSliderFragment1 method updateUI.

private void updateUI() {
    i = 0;
    update = new Runnable() {

        @Override
        public void run() {
            if (!mIsRunning) {
                // stop when told to stop
                return;
            }
            WhatsNewModel mode = whatsnewarraylist.get(i);
            contenttv.setText(mode.getContent());
            contenttv.setTag(mode.getIntent());
            // timer.cancel();
            final navBarOpenStatus activity = (navBarOpenStatus) mContext;
            explore.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (contenttv.getTag().equals(0)) {
                        // startActivity(new Intent(mContext, XunbaoActivity.class));
                        startActivity(new Intent(getActivity(), XunbaoActivity.class).setFlags((Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)));
                        activity.openNavBar(false);
                    } else if (contenttv.getTag().equals(1)) {
                        startActivity(new Intent(mContext, CulmycaTimesActivity.class));
                        activity.openNavBar(false);
                    } else if (contenttv.getTag().equals(2)) {
                        startActivity(new Intent(mContext, MapsActivity.class));
                        activity.openNavBar(false);
                    } else if (contenttv.getTag().equals(7)) {
                        // if (!drawer.isDrawerOpen(GravityCompat.START)) {
                        // drawer.openDrawer(GravityCompat.START);
                        // }
                        activity.openNavBar(true);
                    }
                }
            });
            if (contenttv.getTag().equals(0)) {
                explore.setText("Xunbao");
            } else if (contenttv.getTag().equals(1)) {
                explore.setText("EC Times");
            } else if (contenttv.getTag().equals(2)) {
                explore.setText("Maps");
            } else {
                explore.setText("Explore");
            }
            // this function can change value of mInterval.
            i++;
            if (i == whatsnewarraylist.size()) {
                i = 0;
            }
            handler.postDelayed(update, 4000);
        }
    };
}
Also used : WhatsNewModel(com.manan.dev.ec2018app.Models.WhatsNewModel) Intent(android.content.Intent) MapsActivity(com.manan.dev.ec2018app.NavMenuViews.MapsActivity) View(android.view.View) TextView(android.widget.TextView)

Example 3 with WhatsNewModel

use of com.manan.dev.ec2018app.Models.WhatsNewModel in project EC2018App by Manan-YMCA.

the class DashboardSliderFragment1 method onCreateView.

// TODO: Rename parameter arguments, choose names that mat
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    handler = new Handler();
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_dashboard_slider_fragment1, container, false);
    if (mContext == null) {
        mContext = getActivity();
    }
    mAuth = FirebaseAuth.getInstance();
    WhatsNewModel w;
    whatsnewarraylist = new ArrayList<>();
    whatsnewarraylist.add(new WhatsNewModel("Explore the new Culmyca'18 App! Various cool features are added and don't forget to register yourself first!", 7, "j"));
    contenttv = rootView.findViewById(R.id.content_whatnew);
    explore = rootView.findViewById(R.id.buuton_explore);
    mDatabaseReference = FirebaseDatabase.getInstance().getReference().child("whatsnew");
    mDatabaseReference.keepSynced(true);
    int t1 = whatsnewarraylist.size();
    return rootView;
}
Also used : ViewGroup(android.view.ViewGroup) Handler(android.os.Handler) WhatsNewModel(com.manan.dev.ec2018app.Models.WhatsNewModel)

Aggregations

WhatsNewModel (com.manan.dev.ec2018app.Models.WhatsNewModel)3 Intent (android.content.Intent)1 Handler (android.os.Handler)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 ChildEventListener (com.google.firebase.database.ChildEventListener)1 DataSnapshot (com.google.firebase.database.DataSnapshot)1 DatabaseError (com.google.firebase.database.DatabaseError)1 MapsActivity (com.manan.dev.ec2018app.NavMenuViews.MapsActivity)1