Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christof Wolke
BIDL
Commits
e6b9f79e
Commit
e6b9f79e
authored
Aug 30, 2016
by
Christof Wolke
Browse files
menü in die BaseActivity ausgelagert
parent
f1c3df5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/BaseActivity.java
0 → 100644
View file @
e6b9f79e
package
de.uni_oldenburg.bidl
;
import
android.content.Intent
;
import
android.support.design.widget.NavigationView
;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v7.app.ActionBarDrawerToggle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.view.MenuItem
;
import
classes.Event
;
import
classes.LocalStorage
;
import
de.uni_oldenburg.bidl.guest_view.LoginActivity
;
import
de.uni_oldenburg.bidl.home_view.MainActivity
;
import
services.db.DBHelper
;
/**
* Created by Christof on 30.08.2016.
*/
public
class
BaseActivity
extends
AppCompatActivity
implements
NavigationView
.
OnNavigationItemSelectedListener
{
protected
LocalStorage
localStorage
;
protected
void
setMenu
()
{
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
ActionBarDrawerToggle
toggle
=
new
ActionBarDrawerToggle
(
this
,
drawer
,
toolbar
,
R
.
string
.
navigation_drawer_open
,
R
.
string
.
navigation_drawer_close
);
drawer
.
setDrawerListener
(
toggle
);
toggle
.
syncState
();
NavigationView
navigationView
=
(
NavigationView
)
findViewById
(
R
.
id
.
nav_view
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
}
@Override
public
void
onBackPressed
()
{
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
if
(
drawer
.
isDrawerOpen
(
GravityCompat
.
START
))
{
drawer
.
closeDrawer
(
GravityCompat
.
START
);
}
else
{
super
.
onBackPressed
();
}
}
@SuppressWarnings
(
"StatementWithEmptyBody"
)
@Override
public
boolean
onNavigationItemSelected
(
MenuItem
item
)
{
// Handle navigation view item clicks here.
int
id
=
item
.
getItemId
();
if
(
id
==
R
.
id
.
nav_search
)
{
//ToDo: toSearcheActivity
}
else
if
(
id
==
R
.
id
.
nav_home
)
{
toHomeActivity
();
}
else
if
(
id
==
R
.
id
.
nav_profil
)
{
//TODO: toProfilActivity
}
else
if
(
id
==
R
.
id
.
nav_favorite
)
{
//TODO: toFavoriteActivity
}
else
if
(
id
==
R
.
id
.
nav_logout
){
toLoginActivity
();
}
else
if
(
id
==
R
.
id
.
nav_share
)
{
shareEvent
();
}
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
drawer
.
closeDrawer
(
GravityCompat
.
START
);
return
true
;
}
protected
void
shareEvent
()
{
Intent
sendIntent
=
new
Intent
();
sendIntent
.
setAction
(
Intent
.
ACTION_SEND
);
Event
event
=
DBHelper
.
getEvent
();
sendIntent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
"Ich sitze gerade in der Veranstaltung "
+
event
.
getName
()+
"."
);
sendIntent
.
setType
(
"text/plain"
);
startActivity
(
sendIntent
);
}
protected
void
toLoginActivity
()
{
//löscht den Activity-History-Stack und öffnet LoginActivity
startActivity
(
new
Intent
(
this
,
LoginActivity
.
class
).
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
));
localStorage
.
deleteUserData
();
//löscht gespeicherte Events
DBHelper
.
clearAll
();
finish
();
}
protected
void
toHomeActivity
()
{
startActivity
(
new
Intent
(
this
,
MainActivity
.
class
));
}
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
View file @
e6b9f79e
...
...
@@ -5,14 +5,7 @@ import android.bluetooth.BluetoothAdapter;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.support.design.widget.NavigationView
;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v7.app.ActionBarDrawerToggle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.widget.AdapterView
;
import
android.widget.ArrayAdapter
;
import
android.widget.GridView
;
...
...
@@ -30,13 +23,12 @@ import java.util.UUID;
import
classes.Event
;
import
classes.LocalStorage
;
import
de.uni_oldenburg.bidl.BaseActivity
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.guest_view.LoginActivity
;
import
services.db.DBHelper
;
import
services.servercommunication.NetworkService
;
public
class
MainActivity
extends
AppCompatActivity
implements
NavigationView
.
OnNavigationItemSelectedListener
{
public
class
MainActivity
extends
BaseActivity
{
/** Tag for Logging **/
private
static
final
String
TAG
=
MainActivity
.
class
.
getSimpleName
();
...
...
@@ -64,7 +56,7 @@ public class MainActivity extends AppCompatActivity
private
Event
event
;
protected
LocalStorage
localStorage
;
private
ProgressDialog
progress
;
@Override
...
...
@@ -239,79 +231,6 @@ public class MainActivity extends AppCompatActivity
});
}
private
void
setMenu
()
{
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
ActionBarDrawerToggle
toggle
=
new
ActionBarDrawerToggle
(
this
,
drawer
,
toolbar
,
R
.
string
.
navigation_drawer_open
,
R
.
string
.
navigation_drawer_close
);
drawer
.
setDrawerListener
(
toggle
);
toggle
.
syncState
();
NavigationView
navigationView
=
(
NavigationView
)
findViewById
(
R
.
id
.
nav_view
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
}
@Override
public
void
onBackPressed
()
{
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
if
(
drawer
.
isDrawerOpen
(
GravityCompat
.
START
))
{
drawer
.
closeDrawer
(
GravityCompat
.
START
);
}
else
{
super
.
onBackPressed
();
}
}
@SuppressWarnings
(
"StatementWithEmptyBody"
)
@Override
public
boolean
onNavigationItemSelected
(
MenuItem
item
)
{
// Handle navigation view item clicks here.
int
id
=
item
.
getItemId
();
if
(
id
==
R
.
id
.
nav_search
)
{
//ToDo: toSearcheActivity
}
else
if
(
id
==
R
.
id
.
nav_home
)
{
toHomeActivity
();
}
else
if
(
id
==
R
.
id
.
nav_profil
)
{
//TODO: toProfilActivity
}
else
if
(
id
==
R
.
id
.
nav_favorite
)
{
//TODO: toFavoriteActivity
}
else
if
(
id
==
R
.
id
.
nav_logout
){
toLoginActivity
();
}
else
if
(
id
==
R
.
id
.
nav_share
)
{
shareEvent
();
}
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
drawer
.
closeDrawer
(
GravityCompat
.
START
);
return
true
;
}
protected
void
shareEvent
()
{
Intent
sendIntent
=
new
Intent
();
sendIntent
.
setAction
(
Intent
.
ACTION_SEND
);
sendIntent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
"Ich sitze gerade in der Veranstaltung "
+
event
.
getName
()+
"."
);
sendIntent
.
setType
(
"text/plain"
);
startActivity
(
sendIntent
);
}
protected
void
toLoginActivity
()
{
//löscht den Activity-History-Stack und öffnet LoginActivity
startActivity
(
new
Intent
(
this
,
LoginActivity
.
class
).
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
));
localStorage
.
deleteUserData
();
//löscht gespeicherte Events
DBHelper
.
clearAll
();
finish
();
}
protected
void
toHomeActivity
()
{
startActivity
(
new
Intent
(
this
,
MainActivity
.
class
));
}
public
void
setEvent
(
Event
event
)
{
this
.
event
=
event
;
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/ForumActivity.java
View file @
e6b9f79e
...
...
@@ -28,8 +28,7 @@ public class ForumActivity extends AppCompatActivity {
Event
event
=
DBHelper
.
getEvent
();
getForumObjectFromServer
(
event
.
getEventId
());
Comment
comment
=
forum
.
getComments
().
get
(
0
);
Log
.
d
(
TAG
,
"FORUMACTIVITY: "
+
comment
.
getText
());
}
...
...
@@ -37,7 +36,9 @@ public class ForumActivity extends AppCompatActivity {
NetworkService
.
forum
(
eventId
,
new
NetworkService
.
RequestForumHandler
()
{
@Override
public
void
done
(
final
Forum
forum
)
{
setForum
(
forum
);
setForum
(
forum
);
Comment
comment
=
forum
.
getComments
().
get
(
0
);
Log
.
d
(
TAG
,
"FORUMACTIVITY: "
+
comment
.
getText
());
}
});
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment