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();
}
}
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);
}
};
}
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;
}
Aggregations