|
|
@@ -1,31 +1,73 @@
|
|
|
package com.example.yiupang.freefoodfinder;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.support.annotation.IdRes;
|
|
|
import android.support.design.widget.FloatingActionButton;
|
|
|
import android.support.design.widget.Snackbar;
|
|
|
+import android.support.v7.app.ActionBarActivity;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
import android.view.View;
|
|
|
+import com.roughike.bottombar.BottomBar;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
|
|
|
-public class MainActivity extends AppCompatActivity {
|
|
|
+import com.roughike.bottombar.BottomBar;
|
|
|
+import com.roughike.bottombar.BottomBarBadge;
|
|
|
+import com.roughike.bottombar.OnMenuTabClickListener;
|
|
|
|
|
|
+public class MainActivity extends ActionBarActivity
|
|
|
+{
|
|
|
+ BottomBar bottomBar;
|
|
|
@Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ protected void onCreate(Bundle savedInstanceState)
|
|
|
+ {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_main);
|
|
|
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
- setSupportActionBar(toolbar);
|
|
|
+ bottomBar = BottomBar.attach(this, savedInstanceState);
|
|
|
+ bottomBar.setItemsFromMenu(R.menu.menu_main, new OnMenuTabClickListener()
|
|
|
+ {
|
|
|
+ @Override
|
|
|
+ public void onMenuTabSelected(@IdRes int menuItemId)
|
|
|
+ {
|
|
|
+ if(menuItemId == R.id.BottomBarEvents)
|
|
|
+ {
|
|
|
+ EventsScreen es = new EventsScreen();
|
|
|
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame, es).commit();
|
|
|
+ }
|
|
|
+ else if(menuItemId == R.id.BottomBarItemMap)
|
|
|
+ {
|
|
|
+ MapScreen es = new MapScreen();
|
|
|
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame, es).commit();
|
|
|
+ }
|
|
|
+ else if(menuItemId == R.id.BottomBarItemMyEvent)
|
|
|
+ {
|
|
|
+ MyEventScreen es = new MyEventScreen();
|
|
|
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame, es).commit();
|
|
|
+ }
|
|
|
+ else if(menuItemId == R.id.BottomBarItemAboutUs)
|
|
|
+ {
|
|
|
+ AboutUsScreen es = new AboutUsScreen();
|
|
|
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame, es).commit();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
|
|
- fab.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
- public void onClick(View view) {
|
|
|
- Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
|
|
- .setAction("Action", null).show();
|
|
|
+ public void onMenuTabReSelected(@IdRes int menuItemId)
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ bottomBar.mapColorForTab(0, "#ff0000");
|
|
|
+ bottomBar.mapColorForTab(1, "#ff0000");
|
|
|
+ bottomBar.mapColorForTab(2, "#ff0000");
|
|
|
+ bottomBar.mapColorForTab(3, "#ff0000");
|
|
|
+
|
|
|
+ BottomBarBadge unread;
|
|
|
+ unread = bottomBar.makeBadgeForTabAt(3, "#FF0000", 13);
|
|
|
+ unread.show();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -42,10 +84,12 @@ public class MainActivity extends AppCompatActivity {
|
|
|
// as you specify a parent activity in AndroidManifest.xml.
|
|
|
int id = item.getItemId();
|
|
|
|
|
|
+/*
|
|
|
//noinspection SimplifiableIfStatement
|
|
|
if (id == R.id.action_settings) {
|
|
|
return true;
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|