Reformatting code and small refactoring.
diff --git a/app/src/main/java/org/climbingguide/dao/AreaDao.java b/app/src/main/java/org/climbingguide/dao/AreaDao.java
index fd3cbf8..6b69f15 100755
--- a/app/src/main/java/org/climbingguide/dao/AreaDao.java
+++ b/app/src/main/java/org/climbingguide/dao/AreaDao.java
@@ -12,87 +12,78 @@
import android.util.Log;
public class AreaDao {
-
- private static final String LOG = AreaDao.class.getName();
-
- private SQLiteDatabase db;
- private SQLHelper dbHelperArea;
-
- public AreaDao(Context context){
- dbHelperArea = new SQLHelper(context);
- }
-
- public void open(){
- db = dbHelperArea.getWritableDatabase();
- }
-
- public void close(){
- dbHelperArea.close();
- }
-//---------------GET-ALL-AREAS--------------------------------------------------------------------------------------------
- public List<Area> getAllAreas()
- {
- List<Area> areaList = new ArrayList<Area>();
-
-
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_AREAS;
-
- Log.i(LOG, selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Area area = new Area();
- area.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_AREA)));
- area.setName(c.getString(c.getColumnIndex(SQLHelper.AREA_NAME)));
- areaList.add(area);
-
- }while(c.moveToNext());
+ private static final String LOG = AreaDao.class.getName();
- }
- c.close();
- return areaList;
- }
-//----------------ADD-AREAS-----------------------------------------------------------------------------------------------
- public void addArea(Area area){
- ContentValues value = new ContentValues();
-
- value.put(SQLHelper.ID_AREA ,area.getId());
- value.put(SQLHelper.AREA_NAME,area.getName());
-
- Log.i(LOG,"Inster to table area -->" + value);
-
- db.insert(SQLHelper.TABLE_AREAS, null, value);
- db.close();
- }
-//-----------------SEARCH-------------------------------------------------------------------------------------------------
- public List<Area> areasSearch(String query)
- {
- List<Area> areaList = new ArrayList<Area>();
- String searchQuery = query + "%";
-
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_AREAS +" WHERE " + SQLHelper.AREA_NAME + " LIKE " + "'" + searchQuery +"'";
-
- Log.i(LOG,selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Area area = new Area();
- area.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_AREA)));
- area.setName(c.getString(c.getColumnIndex(SQLHelper.AREA_NAME)));
- areaList.add(area);
-
- }while(c.moveToNext());
+ private SQLiteDatabase db;
+ private SQLHelper dbHelperArea;
- }
- c.close();
- return areaList;
- }
+ public AreaDao(Context context) {
+ dbHelperArea = new SQLHelper(context);
+ }
+
+ public void open() {
+ db = dbHelperArea.getWritableDatabase();
+ }
+
+ public void close() {
+ dbHelperArea.close();
+ }
+
+ //---------------GET-ALL-AREAS--------------------------------------------------------------------------------------------
+ public List<Area> getAllAreas() {
+ List<Area> areaList = new ArrayList<Area>();
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_AREAS;
+
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Area area = new Area();
+ area.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_AREA)));
+ area.setName(c.getString(c.getColumnIndex(SQLHelper.AREA_NAME)));
+ areaList.add(area);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return areaList;
+ }
+
+ //----------------ADD-AREAS-----------------------------------------------------------------------------------------------
+ public void addArea(Area area) {
+ ContentValues value = new ContentValues();
+
+ value.put(SQLHelper.ID_AREA, area.getId());
+ value.put(SQLHelper.AREA_NAME, area.getName());
+
+ Log.i(LOG, "Inster to table area -->" + value);
+
+ db.insert(SQLHelper.TABLE_AREAS, null, value);
+ db.close();
+ }
+
+ //-----------------SEARCH-------------------------------------------------------------------------------------------------
+ public List<Area> areasSearch(String query) {
+ List<Area> areaList = new ArrayList<Area>();
+ String searchQuery = query + "%";
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_AREAS + " WHERE " + SQLHelper.AREA_NAME + " LIKE " + "'" + searchQuery + "'";
+
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Area area = new Area();
+ area.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_AREA)));
+ area.setName(c.getString(c.getColumnIndex(SQLHelper.AREA_NAME)));
+ areaList.add(area);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return areaList;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/dao/RouteDao.java b/app/src/main/java/org/climbingguide/dao/RouteDao.java
index 2def3d2..cb46a59 100755
--- a/app/src/main/java/org/climbingguide/dao/RouteDao.java
+++ b/app/src/main/java/org/climbingguide/dao/RouteDao.java
@@ -12,171 +12,163 @@
import android.util.Log;
public class RouteDao {
-
-private static final String LOG = RouteDao.class.getName();
-
- private SQLiteDatabase db;
- private SQLHelper dbHelperRoute;
-
- public RouteDao(Context context){
- dbHelperRoute = new SQLHelper(context);
- }
-
- public void open(){
- db = dbHelperRoute.getWritableDatabase();
- }
-
- public void close(){
- dbHelperRoute.close();
- }
-//------------GET-ALL-ROUTES----------------------------------------------------------------------------------------------
- public List<Route> getAllRoutes()
- {
- List<Route> routeList = new ArrayList<Route>();
-
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE;
- Log.i(LOG,selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Route route = new Route();
-
- route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
- route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
- route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
- route.setDificulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
- route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
- route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
- route.setLatitute(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
- route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
-
- routeList.add(route);
-
- }while(c.moveToNext());
- }
- c.close();
- return routeList;
- }
-//----------GET--BY--ID----ROUTES-----------------------------------------------------------------------------------------
- public List<Route> getRoute(int find){
-
- List<Route> routeList = new ArrayList<Route>();
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE + " WHERE "+SQLHelper.ID_OF_SECTOR + " = " + "'"+ find +"'" ;
- Log.i(LOG, selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Route route = new Route();
-
- route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
- route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
- route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
- route.setDificulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
- route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
- route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
- route.setLatitute(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
- route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
-
- routeList.add(route);
-
- }while(c.moveToNext());
- }
- c.close();
- return routeList;
-
- }
-//-----------ADD-ROUTE----------------------------------------------------------------------------------------------------
- public void addRoute(Route route)
- {
-
- ContentValues value = new ContentValues();
-
- value.put(SQLHelper.ROUTE_NAME,route.getName());
- value.put(SQLHelper.ID_OF_SECTOR,route.getIdOfSector());
- value.put(SQLHelper.DIFFICULTY,route.getDificulty());
- value.put(SQLHelper.BOLTS, route.getBolts());
- value.put(SQLHelper.LENGTH,route.getLength());
- value.put(SQLHelper.LATITUTE,route.getLatitute());
- value.put(SQLHelper.LONGITUDE, route.getLongitude());
-
- Log.i(LOG,"Inster to table route -->" + value);
-
- db.insert(SQLHelper.TABLE_ROUTE, null, value);
- db.close();
- }
-//-----------------SEARCH---------------------------------------------------------------------------------------------------
- public List<Route> routeSearch(String query)
- {
- List<Route> routeList = new ArrayList<Route>();
- String searchQuery = query + "%";
- String selectQuery;
- selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE +" WHERE " + SQLHelper.ROUTE_NAME + " LIKE " + "'" + searchQuery +"'";
-
- Log.i(LOG,selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Route route = new Route();
-
- route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
- route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
- route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
- route.setDificulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
- route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
- route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
- route.setLatitute(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
- route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
-
- routeList.add(route);
-
- }while(c.moveToNext());
- }
- c.close();
- return routeList;
- }
-//----------------SEARCH---ID-OF-SECTOR-----------------------------------------------------------------------------------------------
- public List<Route> routeSearchId(String query,int idOfSector)
- {
- List<Route> routeList = new ArrayList<Route>();
- String searchQuery = query + "%";
- String selectQuery;
-
- selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE +" WHERE " + SQLHelper.ROUTE_NAME + " LIKE " + "'" + searchQuery +"'" + " AND "+SQLHelper.ID_OF_SECTOR+" = "+idOfSector;
-
-
- Log.i(LOG,selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Route route = new Route();
-
- route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
- route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
- route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
- route.setDificulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
- route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
- route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
- route.setLatitute(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
- route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
-
- routeList.add(route);
-
- }while(c.moveToNext());
- }
- c.close();
- return routeList;
- }
+ private static final String LOG = RouteDao.class.getName();
+
+ private SQLiteDatabase db;
+ private SQLHelper dbHelperRoute;
+
+ public RouteDao(Context context) {
+ dbHelperRoute = new SQLHelper(context);
+ }
+
+ public void open() {
+ db = dbHelperRoute.getWritableDatabase();
+ }
+
+ public void close() {
+ dbHelperRoute.close();
+ }
+
+ //------------GET-ALL-ROUTES----------------------------------------------------------------------------------------------
+ public List<Route> getAllRoutes() {
+ List<Route> routeList = new ArrayList<Route>();
+
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE;
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Route route = new Route();
+
+ route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
+ route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
+ route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
+ route.setDifficulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
+ route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
+ route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
+ route.setLatitude(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
+ route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
+
+ routeList.add(route);
+
+ } while (c.moveToNext());
+ }
+ c.close();
+ return routeList;
+ }
+
+ //----------GET--BY--ID----ROUTES-----------------------------------------------------------------------------------------
+ public List<Route> getRoute(int find) {
+
+ List<Route> routeList = new ArrayList<Route>();
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE + " WHERE " + SQLHelper.ID_OF_SECTOR + " = " + "'" + find + "'";
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Route route = new Route();
+
+ route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
+ route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
+ route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
+ route.setDifficulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
+ route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
+ route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
+ route.setLatitude(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
+ route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
+
+ routeList.add(route);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return routeList;
+ }
+
+ //-----------ADD-ROUTE----------------------------------------------------------------------------------------------------
+ public void addRoute(Route route) {
+
+ ContentValues value = new ContentValues();
+
+ value.put(SQLHelper.ROUTE_NAME, route.getName());
+ value.put(SQLHelper.ID_OF_SECTOR, route.getIdOfSector());
+ value.put(SQLHelper.DIFFICULTY, route.getDifficulty());
+ value.put(SQLHelper.BOLTS, route.getBolts());
+ value.put(SQLHelper.LENGTH, route.getLength());
+ value.put(SQLHelper.LATITUTE, route.getLatitude());
+ value.put(SQLHelper.LONGITUDE, route.getLongitude());
+
+ Log.i(LOG, "Inster to table route -->" + value);
+
+ db.insert(SQLHelper.TABLE_ROUTE, null, value);
+ db.close();
+ }
+
+ //-----------------SEARCH---------------------------------------------------------------------------------------------------
+ public List<Route> routeSearch(String query) {
+ List<Route> routeList = new ArrayList<Route>();
+ String searchQuery = query + "%";
+ String selectQuery;
+
+ selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE + " WHERE " + SQLHelper.ROUTE_NAME + " LIKE " + "'" + searchQuery + "'";
+
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Route route = new Route();
+
+ route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
+ route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
+ route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
+ route.setDifficulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
+ route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
+ route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
+ route.setLatitude(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
+ route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
+
+ routeList.add(route);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return routeList;
+ }
+
+ //----------------SEARCH---ID-OF-SECTOR-----------------------------------------------------------------------------------------------
+ public List<Route> routeSearchId(String query, int idOfSector) {
+ List<Route> routeList = new ArrayList<Route>();
+ String searchQuery = query + "%";
+ String selectQuery;
+
+ selectQuery = " SELECT * FROM " + SQLHelper.TABLE_ROUTE + " WHERE " + SQLHelper.ROUTE_NAME + " LIKE " + "'" + searchQuery + "'" + " AND " + SQLHelper.ID_OF_SECTOR + " = " + idOfSector;
+
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Route route = new Route();
+
+ route.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_ROUTE)));
+ route.setName(c.getString(c.getColumnIndex(SQLHelper.ROUTE_NAME)));
+ route.setIdOfSector(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_SECTOR)));
+ route.setDifficulty(c.getString(c.getColumnIndex(SQLHelper.DIFFICULTY)));
+ route.setBolts(c.getInt(c.getColumnIndex(SQLHelper.BOLTS)));
+ route.setLength(c.getInt(c.getColumnIndex(SQLHelper.LENGTH)));
+ route.setLatitude(c.getDouble(c.getColumnIndex(SQLHelper.LATITUTE)));
+ route.setLongitude(c.getDouble(c.getColumnIndex(SQLHelper.LONGITUDE)));
+
+ routeList.add(route);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return routeList;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/dao/SQLHelper.java b/app/src/main/java/org/climbingguide/dao/SQLHelper.java
index a5ffcb2..ed56ef7 100755
--- a/app/src/main/java/org/climbingguide/dao/SQLHelper.java
+++ b/app/src/main/java/org/climbingguide/dao/SQLHelper.java
@@ -12,50 +12,46 @@
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "climbingGuide.db";
- public static final String TABLE_AREAS = "areas";
- public static final String ID_AREA = "id_area";
- public static final String AREA_NAME = "area_name";
- public static final String AREA_DATE = "area_date";
-
- private static final String CREATE_TABLE_AREAS = "CREATE TABLE " + TABLE_AREAS
- + " ( " + ID_AREA + " INTEGER PRIMARY KEY AUTOINCREMENT , "
- + AREA_NAME + " TEXT " + " ) ;";
- private static final String DROP_TABLE_AREAS = "DROP TABLE IF EXIST " + TABLE_AREAS;
-//-----------------------------------------------------------------------------------------------
- public static final String TABLE_SECTOR = "sectors";
- public static final String ID_SECTOR = "id_sector";
- public static final String SECTOR_NAME = "sector_name";
- public static final String ID_OF_AREA = "id_of_area";
- public static final String SECTOR_DATE = "sector_date";
-
- public static final String CREATE_TABLE_SECTOR = "CREATE TABLE " + TABLE_SECTOR
- + " ( " + ID_SECTOR + " INTEGER PRIMARY KEY AUTOINCREMENT , "
- + SECTOR_NAME + " TEXT , " + ID_OF_AREA + " INTEGER " + " ) ;";
- public static final String DROP_TABLE_SECTOR = "DROP TABLE IF EXIST" + TABLE_SECTOR;
-
- //---------------------------------------------------------------------------------------------
- public static final String TABLE_ROUTE = "routes";
- public static final String ID_ROUTE = "id_route";
- public static final String ROUTE_NAME = "route_name";
- public static final String ID_OF_SECTOR = "id_sector";
- public static final String DIFFICULTY = "difficulty";
- public static final String BOLTS = "bolts";
- public static final String LENGTH = "length";
- public static final String ROUTE_DATE = "route_date";
- public static final String LATITUTE = "lantitute";
- public static final String LONGITUDE = "longitude";
-
-
+ public static final String TABLE_AREAS = "areas";
+ public static final String ID_AREA = "id_area";
+ public static final String AREA_NAME = "area_name";
+ public static final String AREA_DATE = "area_date";
- public static final String CREATE_TABLE_ROUTE = "CREATE TABLE " + TABLE_ROUTE + " ( "
- + ID_ROUTE + " INTEGER PRIMARY KEY AUTOINCREMENT , " + ROUTE_NAME
- + " TEXT , " + ID_OF_SECTOR + " INTEGER , " + DIFFICULTY + " TEXT , "
- + BOLTS + " INTEGER , " + LENGTH + " INTEGER, " + LATITUTE + " DOUBLE, " + LONGITUDE +" DOUBLE " + " ) ;";
- private static final String DROP_TABLE_ROUTE = "DROP TABLE IF EXIST " + TABLE_ROUTE;
-
-
+ private static final String CREATE_TABLE_AREAS = "CREATE TABLE " + TABLE_AREAS
+ + " ( " + ID_AREA + " INTEGER PRIMARY KEY AUTOINCREMENT , "
+ + AREA_NAME + " TEXT " + " ) ;";
+ private static final String DROP_TABLE_AREAS = "DROP TABLE IF EXIST " + TABLE_AREAS;
+ //-----------------------------------------------------------------------------------------------
+ public static final String TABLE_SECTOR = "sectors";
+ public static final String ID_SECTOR = "id_sector";
+ public static final String SECTOR_NAME = "sector_name";
+ public static final String ID_OF_AREA = "id_of_area";
+ public static final String SECTOR_DATE = "sector_date";
- public SQLHelper(Context context) {
+ public static final String CREATE_TABLE_SECTOR = "CREATE TABLE " + TABLE_SECTOR
+ + " ( " + ID_SECTOR + " INTEGER PRIMARY KEY AUTOINCREMENT , "
+ + SECTOR_NAME + " TEXT , " + ID_OF_AREA + " INTEGER " + " ) ;";
+ public static final String DROP_TABLE_SECTOR = "DROP TABLE IF EXIST" + TABLE_SECTOR;
+
+ //---------------------------------------------------------------------------------------------
+ public static final String TABLE_ROUTE = "routes";
+ public static final String ID_ROUTE = "id_route";
+ public static final String ROUTE_NAME = "route_name";
+ public static final String ID_OF_SECTOR = "id_sector";
+ public static final String DIFFICULTY = "difficulty";
+ public static final String BOLTS = "bolts";
+ public static final String LENGTH = "length";
+ public static final String ROUTE_DATE = "route_date";
+ public static final String LATITUTE = "lantitute";
+ public static final String LONGITUDE = "longitude";
+
+ public static final String CREATE_TABLE_ROUTE = "CREATE TABLE " + TABLE_ROUTE + " ( "
+ + ID_ROUTE + " INTEGER PRIMARY KEY AUTOINCREMENT , " + ROUTE_NAME
+ + " TEXT , " + ID_OF_SECTOR + " INTEGER , " + DIFFICULTY + " TEXT , "
+ + BOLTS + " INTEGER , " + LENGTH + " INTEGER, " + LATITUTE + " DOUBLE, " + LONGITUDE + " DOUBLE " + " ) ;";
+ private static final String DROP_TABLE_ROUTE = "DROP TABLE IF EXIST " + TABLE_ROUTE;
+
+ public SQLHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@@ -63,13 +59,12 @@
public void onCreate(SQLiteDatabase db) {
Log.i(LOG, "Create areas database -> " + CREATE_TABLE_AREAS);
db.execSQL(CREATE_TABLE_AREAS);
-
+
Log.i(LOG, "Create sector database -> " + CREATE_TABLE_SECTOR);
db.execSQL(CREATE_TABLE_SECTOR);
-
+
Log.i(LOG, "Create route database -> " + CREATE_TABLE_ROUTE);
db.execSQL(CREATE_TABLE_ROUTE);
-
}
@Override
diff --git a/app/src/main/java/org/climbingguide/dao/SectorDao.java b/app/src/main/java/org/climbingguide/dao/SectorDao.java
index f90660b..577bab7 100755
--- a/app/src/main/java/org/climbingguide/dao/SectorDao.java
+++ b/app/src/main/java/org/climbingguide/dao/SectorDao.java
@@ -13,163 +13,152 @@
public class SectorDao {
- private static final String LOG = SectorDao.class.getName();
-
- private SQLiteDatabase db;
- private SQLHelper dbHelperSector;
-
- public SectorDao(Context context){
- dbHelperSector = new SQLHelper(context);
- }
-
- public void open(){
- db = dbHelperSector.getWritableDatabase();
- }
-
- public void close(){
- dbHelperSector.close();
- }
-//----------GET-ALL-SECTORS------------------------------------------------------------------------------------------------
- public List<Sector> getAllSectors()
- {
- List<Sector> sectorList = new ArrayList<Sector>();
-
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR;
- Log.i(LOG,selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Sector sector = new Sector();
-
-
- sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
- sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
- sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
-
- sectorList.add(sector);
- }while(c.moveToNext());
- }
- c.close();
- return sectorList;
- }
-//-------GET-BY-ID-SECTORS------------------------------------------------------------------------------------------------
- public List<Sector> getSector(int find){
-
- List<Sector> sectorList = new ArrayList<Sector>();
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR + " WHERE "+SQLHelper.ID_OF_AREA + " = " + "'"+ find +"'" ;
- Log.i(LOG, selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Sector sector = new Sector();
-
- sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
- sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
- sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
-
- sectorList.add(sector);
- }while(c.moveToNext());
- }
- c.close();
- return sectorList;
-
- }
-//---------------ADD-SECTOR-----------------------------------------------------------------------------------------------
- public void addSector(Sector sector)
- {
-
- ContentValues value = new ContentValues();
+ private static final String LOG = SectorDao.class.getName();
- value.put(SQLHelper.ID_SECTOR, sector.getId());
- value.put(SQLHelper.SECTOR_NAME,sector.getName());
- value.put(SQLHelper.ID_OF_AREA,sector.getIdOfArea());
-
- Log.i(LOG,"Inster to table sector -->" + value);
-
- db.insert(SQLHelper.TABLE_SECTOR, null, value);
- db.close();
- }
-//----------------SEARCH--------------------------------------------------------------------------------------------------
- public List<Sector> sectorSearch(String query){
-
- List<Sector> sectorList = new ArrayList<Sector>();
- String searchQuery = query + "%";
- String selectQuery;
-
- selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR +" WHERE " + SQLHelper.SECTOR_NAME + " LIKE " + "'" + searchQuery +"'";
+ private SQLiteDatabase db;
+ private SQLHelper dbHelperSector;
- Log.i(LOG, selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Sector sector = new Sector();
-
- sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
- sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
- sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
-
- sectorList.add(sector);
- }while(c.moveToNext());
- }
- c.close();
- return sectorList;
-
- }
-//------------------------SEARCH---ID-OF-AREA---------------------------------------------------------------------------
- public List<Sector> sectorSearchId(String query,int idOfArea){
-
- List<Sector> sectorList = new ArrayList<Sector>();
- String searchQuery = query + "%";
- String selectQuery;
-
- selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR +" WHERE " + SQLHelper.SECTOR_NAME + " LIKE " + "'" + searchQuery +"'" + " AND "+SQLHelper.ID_OF_AREA + "=" +idOfArea;
-
-
- Log.i(LOG, selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- if (c.moveToFirst())
- {
- do{
- Sector sector = new Sector();
-
- sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
- sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
- sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
-
- sectorList.add(sector);
- }while(c.moveToNext());
- }
- c.close();
- return sectorList;
-
- }
-
- public Sector getSectorById(int id){
- String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR + " WHERE "+SQLHelper.ID_OF_AREA + " = " + "'"+ id +"'" ;
- Log.i(LOG, selectQuery);
-
- Cursor c = db.rawQuery(selectQuery,null);
-
- Sector sector = new Sector();
-
- sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
- sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
- sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
-
-
- return sector;
-
-
- }
+ public SectorDao(Context context) {
+ dbHelperSector = new SQLHelper(context);
+ }
+
+ public void open() {
+ db = dbHelperSector.getWritableDatabase();
+ }
+
+ public void close() {
+ dbHelperSector.close();
+ }
+
+ //----------GET-ALL-SECTORS------------------------------------------------------------------------------------------------
+ public List<Sector> getAllSectors() {
+ List<Sector> sectorList = new ArrayList<Sector>();
+
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR;
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Sector sector = new Sector();
+
+ sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
+ sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
+ sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
+
+ sectorList.add(sector);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return sectorList;
+ }
+
+ //-------GET-BY-ID-SECTORS------------------------------------------------------------------------------------------------
+ public List<Sector> getSector(int find) {
+ List<Sector> sectorList = new ArrayList<Sector>();
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR + " WHERE " + SQLHelper.ID_OF_AREA + " = " + "'" + find + "'";
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Sector sector = new Sector();
+
+ sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
+ sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
+ sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
+
+ sectorList.add(sector);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return sectorList;
+ }
+
+ //---------------ADD-SECTOR-----------------------------------------------------------------------------------------------
+ public void addSector(Sector sector) {
+ ContentValues value = new ContentValues();
+
+ value.put(SQLHelper.ID_SECTOR, sector.getId());
+ value.put(SQLHelper.SECTOR_NAME, sector.getName());
+ value.put(SQLHelper.ID_OF_AREA, sector.getIdOfArea());
+
+ Log.i(LOG, "Inster to table sector -->" + value);
+
+ db.insert(SQLHelper.TABLE_SECTOR, null, value);
+ db.close();
+ }
+
+ //----------------SEARCH--------------------------------------------------------------------------------------------------
+ public List<Sector> sectorSearch(String query) {
+ List<Sector> sectorList = new ArrayList<Sector>();
+ String searchQuery = query + "%";
+ String selectQuery;
+
+ selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR + " WHERE " + SQLHelper.SECTOR_NAME + " LIKE " + "'" + searchQuery + "'";
+
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Sector sector = new Sector();
+
+ sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
+ sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
+ sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
+
+ sectorList.add(sector);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return sectorList;
+
+ }
+
+ //------------------------SEARCH---ID-OF-AREA---------------------------------------------------------------------------
+ public List<Sector> sectorSearchId(String query, int idOfArea) {
+ List<Sector> sectorList = new ArrayList<Sector>();
+ String searchQuery = query + "%";
+ String selectQuery;
+
+ selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR + " WHERE " + SQLHelper.SECTOR_NAME + " LIKE " + "'" + searchQuery + "'" + " AND " + SQLHelper.ID_OF_AREA + "=" + idOfArea;
+
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ if (c.moveToFirst()) {
+ do {
+ Sector sector = new Sector();
+
+ sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
+ sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
+ sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
+
+ sectorList.add(sector);
+ } while (c.moveToNext());
+ }
+ c.close();
+ return sectorList;
+
+ }
+
+ public Sector getSectorById(int id) {
+ String selectQuery = " SELECT * FROM " + SQLHelper.TABLE_SECTOR + " WHERE " + SQLHelper.ID_OF_AREA + " = " + "'" + id + "'";
+ Log.i(LOG, selectQuery);
+
+ Cursor c = db.rawQuery(selectQuery, null);
+
+ Sector sector = new Sector();
+
+ sector.setId(c.getInt(c.getColumnIndex(SQLHelper.ID_SECTOR)));
+ sector.setName(c.getString(c.getColumnIndex(SQLHelper.SECTOR_NAME)));
+ sector.setIdOfArea(c.getInt(c.getColumnIndex(SQLHelper.ID_OF_AREA)));
+
+ return sector;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentAreasAll.java b/app/src/main/java/org/climbingguide/gui/FragmentAreasAll.java
index 198299f..4184c25 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentAreasAll.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentAreasAll.java
@@ -15,52 +15,42 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
+public class FragmentAreasAll extends ListFragment {
-public class FragmentAreasAll extends ListFragment{
-
- private AreaDao getAreas;
- private List<Area> areaList = new ArrayList<Area>();
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Areas");
-
- getAreas = new AreaDao(getActivity());
+ private AreaDao m_areas;
+ private List<Area> m_areaList = new ArrayList<Area>();
-
- getAreas.open();
-
- areaList = getAreas.getAllAreas();
-
- getAreas.close();
-
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Areas");
- ArrayAdapter<Area> adapter = new ArrayAdapter<Area>(getActivity(),android.R.layout.simple_list_item_1,areaList);
+ m_areas = new AreaDao(getActivity());
+ m_areas.open();
+ m_areaList = m_areas.getAllAreas();
+ m_areas.close();
- setListAdapter(adapter);
- }
+ ArrayAdapter<Area> adapter = new ArrayAdapter<Area>(getActivity(), android.R.layout.simple_list_item_1, m_areaList);
+ setListAdapter(adapter);
+ }
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
- Area area = new Area();
- Bundle bundle = new Bundle();
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Area area = new Area();
+ Bundle bundle = new Bundle();
- area = areaList.get(position);
- Log.i(null, Integer.toString(area.getId()));
-
- bundle.putInt("idOfArea",area.getId());
- FragmentSectors fragobj = new FragmentSectors();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Sectors");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
-
+ area = m_areaList.get(position);
+ Log.i(null, Integer.toString(area.getId()));
+
+ bundle.putInt("idOfArea", area.getId());
+ FragmentSectors fragobj = new FragmentSectors();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Sectors");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentCreateArea.java b/app/src/main/java/org/climbingguide/gui/FragmentCreateArea.java
index 8e7118c..7f822ab 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentCreateArea.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentCreateArea.java
@@ -17,9 +17,6 @@
import android.annotation.SuppressLint;
import android.app.Fragment;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.LayoutInflater;
@@ -29,69 +26,66 @@
import android.widget.Button;
import android.widget.EditText;
-
@SuppressLint("ValidFragment")
-public class FragmentCreateArea extends Fragment{
-
- JSONObject json = new JSONObject();
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
+public class FragmentCreateArea extends Fragment {
- EditText e1;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- getActivity().setTitle("CreateArea");
- View view = inflater.inflate(R.layout.create_area,container, false);
- Button b1 = (Button) view.findViewById(R.id.button1);
- e1 = (EditText)view.findViewById(R.id.editText1);
-
- b1.setOnClickListener(onClickListener);
- return view;
- }
+ JSONObject json = new JSONObject();
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- private OnClickListener onClickListener = new OnClickListener() {
- @Override
- public void onClick(final View v) {
- StrictMode.setThreadPolicy(policy);
- try {
- json.put("area_name", e1.getText());
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- JSONObject json2 = new JSONObject();
- JSONArray array = new JSONArray();
- array.put(json);
- try {
- json2.put("areas", array);
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- final String CODEPAGE = "UTF-8";
- HttpPost post = new HttpPost("http://climbingguide.madzik.sk/area.php");
- try {
- post.setEntity(new StringEntity(json2.toString(), CODEPAGE));
- } catch (UnsupportedEncodingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- HttpResponse resp = null;
- HttpClient httpclient = new DefaultHttpClient();
- try {
- resp = httpclient.execute(post);
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ EditText e1;
- }
- };
-
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ getActivity().setTitle("CreateArea");
+ View view = inflater.inflate(R.layout.create_area, container, false);
+ Button b1 = (Button) view.findViewById(R.id.button1);
+ e1 = (EditText) view.findViewById(R.id.editText1);
+
+ b1.setOnClickListener(onClickListener);
+ return view;
+ }
+
+ private OnClickListener onClickListener = new OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ StrictMode.setThreadPolicy(policy);
+ try {
+ json.put("area_name", e1.getText());
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ JSONObject json2 = new JSONObject();
+ JSONArray array = new JSONArray();
+ array.put(json);
+ try {
+ json2.put("areas", array);
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ final String CODEPAGE = "UTF-8";
+ HttpPost post = new HttpPost("http://climbingguide.madzik.sk/area.php");
+ try {
+ post.setEntity(new StringEntity(json2.toString(), CODEPAGE));
+ } catch (UnsupportedEncodingException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ HttpResponse resp = null;
+ HttpClient httpclient = new DefaultHttpClient();
+ try {
+ resp = httpclient.execute(post);
+ } catch (ClientProtocolException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ };
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentCreateRoute.java b/app/src/main/java/org/climbingguide/gui/FragmentCreateRoute.java
index 016c10b..d05b19f 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentCreateRoute.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentCreateRoute.java
@@ -20,7 +20,6 @@
import android.app.Fragment;
import android.os.Bundle;
import android.os.StrictMode;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -28,119 +27,114 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
-import android.widget.Toast;
-public class FragmentCreateRoute extends Fragment{
- public int id;
- EditText e1;
- EditText e2;
- EditText e3;
- EditText e4;
- EditText e5;
- TextView v1;
- TextView v2;
- TextView v3;
- TextView v4;
- TextView v5;
- TextView v6;
- int i;
+public class FragmentCreateRoute extends Fragment {
+ public int id;
+ EditText eRouteName;
+ EditText eInSector;
+ EditText eRouteDifficulty;
+ EditText eRouteLength;
+ EditText eBoltsCount;
+ TextView vRouteName;
+ TextView vInSector;
+ TextView vRouteDifficulty;
+ TextView vRouteLength;
+ TextView vBoltsCount;
+ int m_sector_id;
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
-
-
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- getActivity().setTitle("CreateRoute");
- View view = inflater.inflate(R.layout.create_route,container, false);
- Button b1 = (Button) view.findViewById(R.id.button1);
- i = getArguments().getInt("idOfSector");
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- e1 = (EditText)view.findViewById(R.id.editText1);
- e2 = (EditText)view.findViewById(R.id.editText2);
- e3 = (EditText)view.findViewById(R.id.editText3);
- e4 = (EditText)view.findViewById(R.id.editText4);
- e5 = (EditText)view.findViewById(R.id.editText5);
- v1 = (TextView)view.findViewById(R.id.textView1);
- v2 = (TextView)view.findViewById(R.id.textView2);
- v3 = (TextView)view.findViewById(R.id.textView3);
- v4 = (TextView)view.findViewById(R.id.textView4);
- v5 = (TextView)view.findViewById(R.id.textView5);
-
- SectorDao dao = new SectorDao(getActivity());
- dao.open();
- List<Sector> sectorList = dao.getAllSectors();
- dao.close();
-
- for(int j=0;j<sectorList.size();j++){
- if(sectorList.get(j).getId()==i){
- e2.setText(sectorList.get(j).getName());
- }
- }
-
- b1.setOnClickListener(onClickListener);
- EditText e2 = (EditText)view.findViewById(R.id.editText2);
- e2.setEnabled(false);
- return view;
- }
-
- private OnClickListener onClickListener = new OnClickListener() {
- @Override
- public void onClick(final View v) {
-
- StrictMode.setThreadPolicy(policy);
- JSONObject json = new JSONObject();
- JSONArray array = new JSONArray();
- final String CODEPAGE = "UTF-8";
- HttpPost post = new HttpPost("http://climbingguide.madzik.sk/route.php");
- HttpResponse resp = null;
- HttpClient httpclient = new DefaultHttpClient();
-
- try {
- json.put("route_name", e1.getText());
- json.put("id_of_sector", (i));
- json.put("difficulty", e3.getText());
- json.put("bolts", e4.getText());
- json.put("length", e5.getText());
-
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- array.put(json);
- JSONObject json2 = new JSONObject();
- try {
- json2.put("routes", array);
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- try {
- post.setEntity(new StringEntity(json2.toString(), CODEPAGE));
- } catch (UnsupportedEncodingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- try {
- resp = httpclient.execute(post);
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- e1.setText(null);
- e3.setText(null);
- e4.setText(null);
- e5.setText(null);
- }
- };
-
- }
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ getActivity().setTitle("CreateRoute");
+ View view = inflater.inflate(R.layout.create_route, container, false);
+ Button bSend = (Button) view.findViewById(R.id.buttonSend);
+ m_sector_id = getArguments().getInt("idOfSector");
+
+ eRouteName = (EditText) view.findViewById(R.id.editTextRouteName);
+ eInSector = (EditText) view.findViewById(R.id.editTextInSector);
+ eRouteDifficulty = (EditText) view.findViewById(R.id.editTextRouteDifficulty);
+ eRouteLength = (EditText) view.findViewById(R.id.editTextRouteLength);
+ eBoltsCount = (EditText) view.findViewById(R.id.editTextBoltsCount);
+ vRouteName = (TextView) view.findViewById(R.id.textViewRouteName);
+ vInSector = (TextView) view.findViewById(R.id.textViewInSector);
+ vRouteDifficulty = (TextView) view.findViewById(R.id.textViewRouteDifficulty);
+ vRouteLength = (TextView) view.findViewById(R.id.textViewRouteLength);
+ vBoltsCount = (TextView) view.findViewById(R.id.textViewBoltsCount);
+
+ SectorDao dao = new SectorDao(getActivity());
+ dao.open();
+ List<Sector> sectorList = dao.getAllSectors();
+ dao.close();
+
+ for (int j = 0; j < sectorList.size(); j++) {
+ if (sectorList.get(j).getId() == m_sector_id) {
+ eInSector.setText(sectorList.get(j).getName());
+ }
+ }
+
+ bSend.setOnClickListener(onSendNewRoute);
+ eInSector.setEnabled(false);
+ return view;
+ }
+
+ private OnClickListener onSendNewRoute = new OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+
+ StrictMode.setThreadPolicy(policy);
+ JSONObject json = new JSONObject();
+ JSONArray array = new JSONArray();
+ final String CODEPAGE = "UTF-8";
+ HttpPost post = new HttpPost("http://climbingguide.madzik.sk/route.php");
+ HttpResponse resp = null;
+ HttpClient httpclient = new DefaultHttpClient();
+
+ try {
+ json.put("route_name", eRouteName.getText());
+ json.put("id_of_sector", (m_sector_id));
+ json.put("difficulty", eRouteDifficulty.getText());
+ json.put("bolts", eRouteLength.getText());
+ json.put("length", eBoltsCount.getText());
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ array.put(json);
+ JSONObject json2 = new JSONObject();
+ try {
+ json2.put("routes", array);
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ post.setEntity(new StringEntity(json2.toString(), CODEPAGE));
+ } catch (UnsupportedEncodingException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ try {
+ resp = httpclient.execute(post);
+ } catch (ClientProtocolException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ eRouteName.setText(null);
+ eRouteDifficulty.setText(null);
+ eRouteLength.setText(null);
+ eBoltsCount.setText(null);
+ }
+ };
+
+}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentCreateSector.java b/app/src/main/java/org/climbingguide/gui/FragmentCreateSector.java
index 857f1cb..c135b85 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentCreateSector.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentCreateSector.java
@@ -33,91 +33,89 @@
import android.widget.TextView;
@SuppressLint("ValidFragment")
-public class FragmentCreateSector extends Fragment{
+public class FragmentCreateSector extends Fragment {
- EditText e1;
- EditText e2;
- TextView t1;
- int i;
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
-
-
- JSONObject json = new JSONObject();
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- getActivity().setTitle("CreateSector");
- View view = inflater.inflate(R.layout.create_sector,container, false);
- i = getArguments().getInt("idOfArea");
- Button b1 = (Button) view.findViewById(R.id.button1);
-
- AreaDao dao = new AreaDao(getActivity());
- dao.open();
- List<Area> areaList = dao.getAllAreas();
- dao.close();
- e2 = (EditText)view.findViewById(R.id.editText2);
-
- for(int j=0;j<areaList.size();j++){
- if(areaList.get(j).getId()==i){
- e2.setText(areaList.get(j).getName());
- }
- }
-
- b1.setOnClickListener(onClickListener);
- e1 = (EditText)view.findViewById(R.id.editText1);
- t1 = (TextView)view.findViewById(R.id.textView1);
- e2.setEnabled(false);
- return view;
- }
-
- private OnClickListener onClickListener = new OnClickListener() {
- @Override
- public void onClick(final View v) {
- StrictMode.setThreadPolicy(policy);
- JSONObject json = new JSONObject();
-
- try {
- json.put("sector_name", e1.getText());
- json.put("id_of_area", (i));
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- JSONObject json2 = new JSONObject();
- JSONArray array = new JSONArray();
- array.put(json);
+ EditText e1;
+ EditText e2;
+ TextView t1;
+ int i;
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- try {
- json2.put("sectors", array);
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
+ JSONObject json = new JSONObject();
- final String CODEPAGE = "UTF-8";
- HttpPost post = new HttpPost("http://climbingguide.madzik.sk/sector.php");
- try {
- post.setEntity(new StringEntity(json2.toString(), CODEPAGE));
- } catch (UnsupportedEncodingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- HttpResponse resp = null;
- HttpClient httpclient = new DefaultHttpClient();
- try {
- resp = httpclient.execute(post);
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- };
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ getActivity().setTitle("CreateSector");
+ View view = inflater.inflate(R.layout.create_sector, container, false);
+ i = getArguments().getInt("idOfArea");
+ Button b1 = (Button) view.findViewById(R.id.button1);
+
+ AreaDao dao = new AreaDao(getActivity());
+ dao.open();
+ List<Area> areaList = dao.getAllAreas();
+ dao.close();
+ e2 = (EditText) view.findViewById(R.id.editText2);
+
+ for (int j = 0; j < areaList.size(); j++) {
+ if (areaList.get(j).getId() == i) {
+ e2.setText(areaList.get(j).getName());
+ }
+ }
+
+ b1.setOnClickListener(onClickListener);
+ e1 = (EditText) view.findViewById(R.id.editText1);
+ t1 = (TextView) view.findViewById(R.id.textView1);
+ e2.setEnabled(false);
+ return view;
+ }
+
+ private OnClickListener onClickListener = new OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ StrictMode.setThreadPolicy(policy);
+ JSONObject json = new JSONObject();
+
+ try {
+ json.put("sector_name", e1.getText());
+ json.put("id_of_area", (i));
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ JSONObject json2 = new JSONObject();
+ JSONArray array = new JSONArray();
+ array.put(json);
+
+ try {
+ json2.put("sectors", array);
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ final String CODEPAGE = "UTF-8";
+ HttpPost post = new HttpPost("http://climbingguide.madzik.sk/sector.php");
+ try {
+ post.setEntity(new StringEntity(json2.toString(), CODEPAGE));
+ } catch (UnsupportedEncodingException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ HttpResponse resp = null;
+ HttpClient httpclient = new DefaultHttpClient();
+ try {
+ resp = httpclient.execute(post);
+ } catch (ClientProtocolException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ };
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentRoute.java b/app/src/main/java/org/climbingguide/gui/FragmentRoute.java
index 8739a0c..5776920 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentRoute.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentRoute.java
@@ -1,11 +1,7 @@
package org.climbingguide.gui;
-
-
-
import org.climbingguide.main.R;
-
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -13,58 +9,47 @@
import android.view.ViewGroup;
import android.widget.TextView;
-
public class FragmentRoute extends Fragment {
-
- private String name;
- private String difficulty;
- private int bolts = 0;
- private int length = 0;
-
- private double latitude;
- private double longitude;
-
-
-// @Override
-// public void onActivityCreated(Bundle savedInstanceState) {
-// super.onActivityCreated(savedInstanceState);
-//
-//
-// }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- getActivity().setTitle("Route");
-
- name = getArguments().getString("name");
- difficulty = getArguments().getString("difficulty");
+ private String name;
+ private String difficulty;
+ private int bolts = 0;
+ private int length = 0;
- bolts = getArguments().getInt("bolts");
- length = getArguments().getInt("length");
+ private double latitude;
+ private double longitude;
- latitude = getArguments().getDouble("latitude");
- longitude = getArguments().getDouble("longitude");
-
- View view = inflater.inflate(R.layout.route,container, false);
-
- TextView nameView = (TextView) view.findViewById(R.id.textViewName);
- TextView difficultyView = (TextView) view.findViewById(R.id.textViewDifficulty);
- TextView boltsView = (TextView) view.findViewById(R.id.textViewBolts);
- TextView lengthView = (TextView) view.findViewById(R.id.textViewLength);
-// TextView latitudeView = (TextView) view.findViewById(R.id.textViewLatitude);
-// TextView longitudeView = (TextView) view.findViewById(R.id.textViewLongitude);
-
-
- nameView.setText("Name: "+name.toString());
- difficultyView.setText("Difficulty: "+difficulty);
-
- boltsView.setText("Bolts: "+bolts);
- lengthView.setText("Length: "+length);
-
-// latitudeView.setText("latitude: "+latitude);
-// longitudeView.setText("longitude: "+longitude);
-
- return view;
- }
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ getActivity().setTitle("Route");
+
+ name = getArguments().getString("name");
+ difficulty = getArguments().getString("difficulty");
+
+ bolts = getArguments().getInt("bolts");
+ length = getArguments().getInt("length");
+
+ latitude = getArguments().getDouble("latitude");
+ longitude = getArguments().getDouble("longitude");
+
+ View view = inflater.inflate(R.layout.route,container, false);
+
+ TextView nameView = (TextView) view.findViewById(R.id.textViewName);
+ TextView difficultyView = (TextView) view.findViewById(R.id.textViewDifficulty);
+ TextView boltsView = (TextView) view.findViewById(R.id.textViewBolts);
+ TextView lengthView = (TextView) view.findViewById(R.id.textViewLength);
+ TextView latitudeView = (TextView) view.findViewById(R.id.textViewLatitude);
+ TextView longitudeView = (TextView) view.findViewById(R.id.textViewLongitude);
+
+ nameView.setText("Name: "+name.toString());
+ difficultyView.setText("Difficulty: "+difficulty);
+
+ boltsView.setText("Bolts: "+bolts);
+ lengthView.setText("Length: "+length);
+
+ latitudeView.setText("latitude: "+latitude);
+ longitudeView.setText("longitude: "+longitude);
+
+ return view;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentRoutes.java b/app/src/main/java/org/climbingguide/gui/FragmentRoutes.java
index 74dc4a9..49004ed 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentRoutes.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentRoutes.java
@@ -4,10 +4,8 @@
import java.util.List;
import org.climbingguide.dao.RouteDao;
-
import org.climbingguide.model.Route;
-
import android.os.Bundle;
import android.app.FragmentTransaction;
import android.app.ListFragment;
@@ -18,66 +16,57 @@
import org.climbingguide.main.R;
-public class FragmentRoutes extends ListFragment{
+public class FragmentRoutes extends ListFragment {
- private RouteDao getRoutes;
- private List<Route> routeList = new ArrayList<Route>();
- private Route route = new Route();
- private int idOfSector;
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Routes");
-
- getRoutes = new RouteDao(getActivity());
- idOfSector = getArguments().getInt("idOfSector");
-
+ private RouteDao getRoutes;
+ private List<Route> routeList = new ArrayList<Route>();
+ private Route route = new Route();
+ private int idOfSector;
-
- getRoutes.open();
-
- routeList = getRoutes.getRoute(idOfSector); //get by sector
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Routes");
- getRoutes.close();
-
+ getRoutes = new RouteDao(getActivity());
+ idOfSector = getArguments().getInt("idOfSector");
- ArrayAdapter<Route> adapter = new ArrayAdapter<Route>(getActivity(),android.R.layout.simple_list_item_1,routeList);
+ getRoutes.open();
+ routeList = getRoutes.getRoute(idOfSector); //get by sector
+ getRoutes.close();
- setListAdapter(adapter);
- }
+ ArrayAdapter<Route> adapter = new ArrayAdapter<Route>(getActivity(), android.R.layout.simple_list_item_1, routeList);
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
-
- Bundle bundle = new Bundle();
+ setListAdapter(adapter);
+ }
- route = routeList.get(position);
-
- bundle.putString("name",route.getName());
- bundle.putString("difficulty",route.getDificulty());
- bundle.putInt("bolts",route.getBolts());
- bundle.putInt("length",route.getLength());
-
- bundle.putDouble("longitude",route.getLongitude());
- bundle.putDouble("latitude",route.getLatitute());
-
- //Toast.makeText(getActivity(), "Bundle"+bundle.toString(), Toast.LENGTH_LONG).show();
-
- FragmentRoute fragobj = new FragmentRoute();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Route");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- public int getIdOfSector()
- {
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Bundle bundle = new Bundle();
+
+ route = routeList.get(position);
+
+ bundle.putString("name", route.getName());
+ bundle.putString("difficulty", route.getDifficulty());
+ bundle.putInt("bolts", route.getBolts());
+ bundle.putInt("length", route.getLength());
+ bundle.putDouble("longitude", route.getLongitude());
+ bundle.putDouble("latitude", route.getLatitude());
+
+ //Toast.makeText(getActivity(), "Bundle"+bundle.toString(), Toast.LENGTH_LONG).show();
+
+ FragmentRoute fragobj = new FragmentRoute();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Route");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
+
+ public int getIdOfSector() {
// int i;
// if(routeList.isEmpty())
// {
@@ -88,6 +77,6 @@
// route = routeList.get(0);
// i = route.getIdOfSector();
// }
- return idOfSector;
- }
+ return idOfSector;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentRoutesAll.java b/app/src/main/java/org/climbingguide/gui/FragmentRoutesAll.java
index c8bfb63..5f017b6 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentRoutesAll.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentRoutesAll.java
@@ -14,73 +14,60 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class FragmentRoutesAll extends ListFragment{
+public class FragmentRoutesAll extends ListFragment {
- private RouteDao getRoutes;
- private List<Route> routeList = new ArrayList<Route>();
- private Route route = new Route();
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Routes");
-
- getRoutes = new RouteDao(getActivity());
+ private RouteDao getRoutes;
+ private List<Route> routeList = new ArrayList<Route>();
+ private Route route = new Route();
- getRoutes.open();
-
- routeList = getRoutes.getAllRoutes();
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Routes");
- getRoutes.close();
-
+ getRoutes = new RouteDao(getActivity());
+ getRoutes.open();
+ routeList = getRoutes.getAllRoutes();
+ getRoutes.close();
- ArrayAdapter<Route> adapter = new ArrayAdapter<Route>(getActivity(),android.R.layout.simple_list_item_1,routeList);
+ ArrayAdapter<Route> adapter = new ArrayAdapter<Route>(getActivity(), android.R.layout.simple_list_item_1, routeList);
+ setListAdapter(adapter);
+ }
- setListAdapter(adapter);
- }
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Bundle bundle = new Bundle();
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
-
- Bundle bundle = new Bundle();
+ route = routeList.get(position);
- route = routeList.get(position);
-
- bundle.putString("name",route.getName());
- bundle.putString("difficulty",route.getDificulty());
- bundle.putInt("bolts",route.getBolts());
- bundle.putInt("length",route.getLength());
-
- bundle.putDouble("longitude",route.getLongitude());
- bundle.putDouble("latitude",route.getLatitute());
-
- //Toast.makeText(getActivity(), "Bundle"+bundle.toString(), Toast.LENGTH_LONG).show();
-
- FragmentRoute fragobj = new FragmentRoute();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Route");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- public int getIdOfSector()
- {
- int i;
- if(routeList.isEmpty())
- {
- i = -1;
- }
- else
- {
- route = routeList.get(0);
- i = route.getIdOfSector();
- }
- return i;
- }
+ bundle.putString("name", route.getName());
+ bundle.putString("difficulty", route.getDifficulty());
+ bundle.putInt("bolts", route.getBolts());
+ bundle.putInt("length", route.getLength());
+ bundle.putDouble("longitude", route.getLongitude());
+ bundle.putDouble("latitude", route.getLatitude());
+
+ //Toast.makeText(getActivity(), "Bundle"+bundle.toString(), Toast.LENGTH_LONG).show();
+
+ FragmentRoute fragobj = new FragmentRoute();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Route");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
+
+ public int getIdOfSector() {
+ int i;
+ if (routeList.isEmpty()) {
+ i = -1;
+ } else {
+ route = routeList.get(0);
+ i = route.getIdOfSector();
+ }
+ return i;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentSectors.java b/app/src/main/java/org/climbingguide/gui/FragmentSectors.java
index 23a9922..2ebed6d 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentSectors.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentSectors.java
@@ -14,55 +14,48 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class FragmentSectors extends ListFragment{
-
- private SectorDao getSectors;
- private List<Sector> sectorList = new ArrayList<Sector>();
- private Sector sector = new Sector();
- private int idOfArea;
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Sectors");
-
- getSectors = new SectorDao(getActivity());
- idOfArea = getArguments().getInt("idOfArea");
+public class FragmentSectors extends ListFragment {
- getSectors.open();
+ private SectorDao getSectors;
+ private List<Sector> sectorList = new ArrayList<Sector>();
+ private Sector sector = new Sector();
+ private int idOfArea;
- sectorList = getSectors.getSector(idOfArea); //get by area
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Sectors");
- getSectors.close();
-
+ getSectors = new SectorDao(getActivity());
+ idOfArea = getArguments().getInt("idOfArea");
- ArrayAdapter<Sector> adapter = new ArrayAdapter<Sector>(getActivity(),android.R.layout.simple_list_item_1,sectorList);
+ getSectors.open();
+ sectorList = getSectors.getSector(idOfArea); //get by area
+ getSectors.close();
- setListAdapter(adapter);
- }
+ ArrayAdapter<Sector> adapter = new ArrayAdapter<Sector>(getActivity(), android.R.layout.simple_list_item_1, sectorList);
+ setListAdapter(adapter);
+ }
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
-
- Bundle bundle = new Bundle();
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Bundle bundle = new Bundle();
- sector = sectorList.get(position);
-
- bundle.putInt("idOfSector",sector.getId());
- FragmentRoutes fragobj = new FragmentRoutes();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Routes");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- public int getIdOfArea()
- {
+ sector = sectorList.get(position);
+
+ bundle.putInt("idOfSector", sector.getId());
+ FragmentRoutes fragobj = new FragmentRoutes();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Routes");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
+
+ public int getIdOfArea() {
// int i;
// if(sectorList.isEmpty())
// {
@@ -70,10 +63,10 @@
// }
// else{
// sector = sectorList.get(0);
-//
+//
// i = sector.getIdOfArea();
// }
- return idOfArea;
- }
-
+ return idOfArea;
+ }
+
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentSectorsAll.java b/app/src/main/java/org/climbingguide/gui/FragmentSectorsAll.java
index 154dcbf..9604898 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentSectorsAll.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentSectorsAll.java
@@ -14,65 +14,54 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class FragmentSectorsAll extends ListFragment{
-
- private SectorDao getSectors;
- private List<Sector> sectorList = new ArrayList<Sector>();
- private Sector sector = new Sector();
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Sectors");
-
- getSectors = new SectorDao(getActivity());
-
-
- getSectors.open();
-
- sectorList = getSectors.getAllSectors();
-
- getSectors.close();
-
+public class FragmentSectorsAll extends ListFragment {
- ArrayAdapter<Sector> adapter = new ArrayAdapter<Sector>(getActivity(),android.R.layout.simple_list_item_1,sectorList);
+ private SectorDao getSectors;
+ private List<Sector> sectorList = new ArrayList<Sector>();
+ private Sector sector = new Sector();
- setListAdapter(adapter);
- }
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Sectors");
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
-
- Bundle bundle = new Bundle();
+ getSectors = new SectorDao(getActivity());
+ getSectors.open();
+ sectorList = getSectors.getAllSectors();
+ getSectors.close();
- sector = sectorList.get(position);
-
- bundle.putInt("idOfSector",sector.getId());
- FragmentRoutes fragobj = new FragmentRoutes();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Routes");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- public int getIdOfArea()
- {
- int i;
- if(sectorList.isEmpty())
- {
- i = -1;
- }
- else{
- sector = sectorList.get(0);
-
- i = sector.getIdOfArea();
- }
- return i;
- }
-
+ ArrayAdapter<Sector> adapter = new ArrayAdapter<Sector>(getActivity(), android.R.layout.simple_list_item_1, sectorList);
+ setListAdapter(adapter);
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Bundle bundle = new Bundle();
+
+ sector = sectorList.get(position);
+
+ bundle.putInt("idOfSector", sector.getId());
+ FragmentRoutes fragobj = new FragmentRoutes();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Routes");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
+
+ public int getIdOfArea() {
+ int i;
+ if (sectorList.isEmpty()) {
+ i = -1;
+ } else {
+ sector = sectorList.get(0);
+
+ i = sector.getIdOfArea();
+ }
+ return i;
+ }
+
}
diff --git a/app/src/main/java/org/climbingguide/gui/FragmentSelectSector.java b/app/src/main/java/org/climbingguide/gui/FragmentSelectSector.java
index 9267142..63117db 100755
--- a/app/src/main/java/org/climbingguide/gui/FragmentSelectSector.java
+++ b/app/src/main/java/org/climbingguide/gui/FragmentSelectSector.java
@@ -1,6 +1,5 @@
package org.climbingguide.gui;
public class FragmentSelectSector extends FragmentSectorsAll{
-
}
diff --git a/app/src/main/java/org/climbingguide/gui/SearchAreas.java b/app/src/main/java/org/climbingguide/gui/SearchAreas.java
index 1204c3d..878fb4d 100755
--- a/app/src/main/java/org/climbingguide/gui/SearchAreas.java
+++ b/app/src/main/java/org/climbingguide/gui/SearchAreas.java
@@ -14,50 +14,43 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class SearchAreas extends ListFragment{
-
-private AreaDao getAreas;
-private List<Area> areaList = new ArrayList<Area>();
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Areas");
-
- getAreas = new AreaDao(getActivity());
- String query = getArguments().getString("query");
-
- getAreas.open();
+public class SearchAreas extends ListFragment {
- areaList = getAreas.areasSearch(query);
-
- getAreas.close();
-
+ private AreaDao getAreas;
+ private List<Area> areaList = new ArrayList<Area>();
- ArrayAdapter<Area> adapter = new ArrayAdapter<Area>(getActivity(),android.R.layout.simple_list_item_1,areaList);
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Areas");
- setListAdapter(adapter);
- }
+ getAreas = new AreaDao(getActivity());
+ String query = getArguments().getString("query");
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
+ getAreas.open();
+ areaList = getAreas.areasSearch(query);
+ getAreas.close();
- Area area = new Area();
- Bundle bundle = new Bundle();
+ ArrayAdapter<Area> adapter = new ArrayAdapter<Area>(getActivity(), android.R.layout.simple_list_item_1, areaList);
+ setListAdapter(adapter);
+ }
- area = areaList.get(position);
-
- bundle.putInt("idOfArea",area.getId());
- FragmentSectors fragobj = new FragmentSectors();
- fragobj.setArguments(bundle);
-
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Area area = new Area();
+ Bundle bundle = new Bundle();
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Sectors");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
+ area = areaList.get(position);
+ bundle.putInt("idOfArea", area.getId());
+ FragmentSectors fragobj = new FragmentSectors();
+ fragobj.setArguments(bundle);
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Sectors");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/SearchRoutes.java b/app/src/main/java/org/climbingguide/gui/SearchRoutes.java
index 75e437a..89a6859 100755
--- a/app/src/main/java/org/climbingguide/gui/SearchRoutes.java
+++ b/app/src/main/java/org/climbingguide/gui/SearchRoutes.java
@@ -14,87 +14,71 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class SearchRoutes extends ListFragment{
+public class SearchRoutes extends ListFragment {
- private RouteDao getRoutes;
- private List<Route> routeList = new ArrayList<Route>();
- private Route route = new Route();
- int idOfSector;
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Routes");
-
- getRoutes = new RouteDao(getActivity());
- String query = getArguments().getString("query");
- idOfSector = getArguments().getInt("idOfSector");
-
- getRoutes.open();
- if(idOfSector >= 0)
- {
- routeList = getRoutes.routeSearchId(query, idOfSector);
- }
- else
- {
- routeList = getRoutes.routeSearch(query);
- }
- getRoutes.close();
-
+ private RouteDao getRoutes;
+ private List<Route> routeList = new ArrayList<Route>();
+ private Route route = new Route();
+ int idOfSector;
- ArrayAdapter<Route> adapter = new ArrayAdapter<Route>(getActivity(),android.R.layout.simple_list_item_1,routeList);
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Routes");
- setListAdapter(adapter);
- }
+ getRoutes = new RouteDao(getActivity());
+ String query = getArguments().getString("query");
+ idOfSector = getArguments().getInt("idOfSector");
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
-
- Bundle bundle = new Bundle();
+ getRoutes.open();
+ if (idOfSector >= 0) {
+ routeList = getRoutes.routeSearchId(query, idOfSector);
+ } else {
+ routeList = getRoutes.routeSearch(query);
+ }
+ getRoutes.close();
- route = routeList.get(position);
-
- bundle.putString("name",route.getName());
- bundle.putString("difficulty",route.getDificulty());
- bundle.putInt("bolts",route.getBolts());
- bundle.putInt("length",route.getLength());
-
- bundle.putDouble("longitude",route.getLongitude());
- bundle.putDouble("latitude",route.getLatitute());
-
-
- FragmentRoute fragobj = new FragmentRoute();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Route");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- public int getIdOfSector()
- {
- int i;
- if(idOfSector >= 0)
- {
- i = idOfSector;
- }
- else
- {
- if(routeList.isEmpty())
- {
- i = -1;
- }
- else{
- route = routeList.get(0);
- i = route.getIdOfSector();
- }
- }
- return i;
- }
+ ArrayAdapter<Route> adapter = new ArrayAdapter<Route>(getActivity(), android.R.layout.simple_list_item_1, routeList);
+ setListAdapter(adapter);
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Bundle bundle = new Bundle();
+
+ route = routeList.get(position);
+
+ bundle.putString("name", route.getName());
+ bundle.putString("difficulty", route.getDifficulty());
+ bundle.putInt("bolts", route.getBolts());
+ bundle.putInt("length", route.getLength());
+ bundle.putDouble("longitude", route.getLongitude());
+ bundle.putDouble("latitude", route.getLatitude());
+
+ FragmentRoute fragobj = new FragmentRoute();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Route");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
+
+ public int getIdOfSector() {
+ int i;
+ if (idOfSector >= 0) {
+ i = idOfSector;
+ } else {
+ if (routeList.isEmpty()) {
+ i = -1;
+ } else {
+ route = routeList.get(0);
+ i = route.getIdOfSector();
+ }
+ }
+ return i;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/gui/SearchSectors.java b/app/src/main/java/org/climbingguide/gui/SearchSectors.java
index 49a82a4..bdab5d8 100755
--- a/app/src/main/java/org/climbingguide/gui/SearchSectors.java
+++ b/app/src/main/java/org/climbingguide/gui/SearchSectors.java
@@ -14,79 +14,67 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class SearchSectors extends ListFragment{
-
- private SectorDao getSectors;
- private List<Sector> sectorList = new ArrayList<Sector>();
- private Sector sector = new Sector();
- private int idOfArea;
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- getActivity().setTitle("Sectors");
-
- getSectors = new SectorDao(getActivity());
- String query = getArguments().getString("query");
- idOfArea = getArguments().getInt("idOfArea");
+public class SearchSectors extends ListFragment {
- getSectors.open();
- if(idOfArea >= 0)
- {
- sectorList = getSectors.sectorSearchId(query, idOfArea);
- }
- else
- {
- sectorList = getSectors.sectorSearch(query);
- }
- getSectors.close();
-
+ private SectorDao getSectors;
+ private List<Sector> sectorList = new ArrayList<Sector>();
+ private Sector sector = new Sector();
+ private int idOfArea;
- ArrayAdapter<Sector> adapter = new ArrayAdapter<Sector>(getActivity(),android.R.layout.simple_list_item_1,sectorList);
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getActivity().setTitle("Sectors");
- setListAdapter(adapter);
- }
+ getSectors = new SectorDao(getActivity());
+ String query = getArguments().getString("query");
+ idOfArea = getArguments().getInt("idOfArea");
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
-
-
- Bundle bundle = new Bundle();
+ getSectors.open();
+ if (idOfArea >= 0) {
+ sectorList = getSectors.sectorSearchId(query, idOfArea);
+ } else {
+ sectorList = getSectors.sectorSearch(query);
+ }
+ getSectors.close();
- sector = sectorList.get(position);
-
- bundle.putInt("idOfSector",sector.getId());
- FragmentRoutes fragobj = new FragmentRoutes();
- fragobj.setArguments(bundle);
-
-
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
-
- transaction.replace(R.id.frame_container, fragobj,"Routes");
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- public int getIdOfArea()
- {
- int i;
- if(idOfArea >= 0)
- {
- i = idOfArea;
- }
- else{
- if(sectorList.isEmpty())
- {
- i = -1;
- }else{
-
- sector = sectorList.get(0);
- i = sector.getIdOfArea();
- }
- }
- return i;
- }
-
+ ArrayAdapter<Sector> adapter = new ArrayAdapter<Sector>(getActivity(), android.R.layout.simple_list_item_1, sectorList);
+ setListAdapter(adapter);
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Bundle bundle = new Bundle();
+
+ sector = sectorList.get(position);
+
+ bundle.putInt("idOfSector", sector.getId());
+ FragmentRoutes fragobj = new FragmentRoutes();
+ fragobj.setArguments(bundle);
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+
+ transaction.replace(R.id.frame_container, fragobj, "Routes");
+ transaction.addToBackStack(null);
+
+ transaction.commit();
+ }
+
+ public int getIdOfArea() {
+ int i;
+ if (idOfArea >= 0) {
+ i = idOfArea;
+ } else {
+ if (sectorList.isEmpty()) {
+ i = -1;
+ } else {
+
+ sector = sectorList.get(0);
+ i = sector.getIdOfArea();
+ }
+ }
+ return i;
+ }
+
}
diff --git a/app/src/main/java/org/climbingguide/main/MainActivity.java b/app/src/main/java/org/climbingguide/main/MainActivity.java
index 5e30d60..ba8ad19 100755
--- a/app/src/main/java/org/climbingguide/main/MainActivity.java
+++ b/app/src/main/java/org/climbingguide/main/MainActivity.java
@@ -1,7 +1,5 @@
package org.climbingguide.main;
-
-
import java.util.ArrayList;
import java.util.List;
@@ -48,489 +46,424 @@
public class MainActivity extends Activity implements SearchView.OnQueryTextListener {
- private static final String LOG = AreaDao.class.getName();
- private DrawerLayout mDrawerLayout;
- private ListView mDrawerList;
- private ActionBarDrawerToggle mDrawerToggle;
-
- //menu item
- private SearchView mSearchView;
- //for fragment taging
- private String tagFragment = "FragmentName";
- // nav drawer title
- private CharSequence mDrawerTitle;
+ private static final String LOG = AreaDao.class.getName();
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawerList;
+ private ActionBarDrawerToggle mDrawerToggle;
- // used to store app title
- private CharSequence mTitle;
+ //menu item
+ private SearchView mSearchView;
+ //for fragment taging
+ private String tagFragment = "FragmentName";
+ // nav drawer title
+ private CharSequence mDrawerTitle;
- // slide menu items
- private String[] navMenuTitles;
- private TypedArray navMenuIcons;
+ // used to store app title
+ private CharSequence mTitle;
- //Dao object
- private AreaDao areaDao;
+ // slide menu items
+ private String[] navMenuTitles;
+ private TypedArray navMenuIcons;
-
- private ArrayList<NavDrawerItem> navDrawerItems;
- private NavDrawerListAdapter adapter;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- //Check for update
- areaDao = new AreaDao(getApplicationContext());
- areaDao.open();
- List<Area> areaList = new ArrayList<Area>();
- areaList = areaDao.getAllAreas();
- areaDao.close();
- //Update if db is empty
- if(areaList.isEmpty())
- {
- Update update = new Update();
- update.updateA(getApplicationContext());
- update.updateR(getApplicationContext());
- update.updateS(getApplicationContext());
- }
-
-
- mTitle = mDrawerTitle = getTitle();
+ //Dao object
+ private AreaDao areaDao;
- // load slide menu items
- navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
+ private ArrayList<NavDrawerItem> navDrawerItems;
+ private NavDrawerListAdapter adapter;
- // nav drawer icons from resources
- navMenuIcons = getResources()
- .obtainTypedArray(R.array.nav_drawer_icons);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
- mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
+ //Check for update
+ areaDao = new AreaDao(getApplicationContext());
+ areaDao.open();
+ List<Area> areaList = new ArrayList<Area>();
+ areaList = areaDao.getAllAreas();
+ areaDao.close();
+ //Update if db is empty
+ if (areaList.isEmpty()) {
+ Update update = new Update();
+ update.updateA(getApplicationContext());
+ update.updateR(getApplicationContext());
+ update.updateS(getApplicationContext());
+ }
- navDrawerItems = new ArrayList<NavDrawerItem>();
+ mTitle = mDrawerTitle = getTitle();
- // adding nav drawer items to array
- // Home
- navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1),true,getNumberOfAreas()));
- // Find People
- navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1),true,getNumberOfSectors()));
- // Photos
- navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1),true,getNumberOfRoutes()));
- // Communities, Will add a counter here
- navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
- // Pages
- navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
- // What's hot, We will add a counter here
- //navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
-
+ // load slide menu items
+ navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
- // Recycle the typed array
- navMenuIcons.recycle();
+ // nav drawer icons from resources
+ navMenuIcons = getResources()
+ .obtainTypedArray(R.array.nav_drawer_icons);
- mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
- // setting the nav drawer list adapter
- adapter = new NavDrawerListAdapter(getApplicationContext(),
- navDrawerItems);
- mDrawerList.setAdapter(adapter);
+ navDrawerItems = new ArrayList<NavDrawerItem>();
- // enabling action bar app icon and behaving it as toggle button
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
+ // adding nav drawer items to array
+ // Home
+ navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1), true, getNumberOfAreas()));
+ // Find People
+ navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1), true, getNumberOfSectors()));
+ // Photos
+ navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1), true, getNumberOfRoutes()));
+ // Communities, Will add a counter here
+ navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
+ // Pages
+ navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
+ // What's hot, We will add a counter here
+ //navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
- mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
- R.drawable.ic_drawer, //nav menu toggle icon
- R.string.app_name, // nav drawer open - description for accessibility
- R.string.app_name // nav drawer close - description for accessibility
- ) {
- public void onDrawerClosed(View view) {
- getActionBar().setTitle(mTitle);
- // calling onPrepareOptionsMenu() to show action bar icons
- invalidateOptionsMenu();
- }
+ // Recycle the typed array
+ navMenuIcons.recycle();
- public void onDrawerOpened(View drawerView) {
- getActionBar().setTitle(mDrawerTitle);
- // calling onPrepareOptionsMenu() to hide action bar icons
- invalidateOptionsMenu();
- }
- };
- mDrawerLayout.setDrawerListener(mDrawerToggle);
+ mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
- if (savedInstanceState == null) {
- // on first time display view for first nav item
- displayView(0);
- }
- }
+ // setting the nav drawer list adapter
+ adapter = new NavDrawerListAdapter(getApplicationContext(),
+ navDrawerItems);
+ mDrawerList.setAdapter(adapter);
- /**
- * Slide menu item click listener
- * */
- private class SlideMenuClickListener implements
- ListView.OnItemClickListener {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position,
- long id) {
- // display view for selected nav drawer item
- displayView(position);
- }
- }
- //Menu
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
-
- getMenuInflater().inflate(R.menu.main, menu);
-
-
+ // enabling action bar app icon and behaving it as toggle button
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActionBar().setHomeButtonEnabled(true);
+
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
+ R.drawable.ic_drawer, //nav menu toggle icon
+ R.string.app_name, // nav drawer open - description for accessibility
+ R.string.app_name // nav drawer close - description for accessibility
+ ) {
+ public void onDrawerClosed(View view) {
+ getActionBar().setTitle(mTitle);
+ // calling onPrepareOptionsMenu() to show action bar icons
+ invalidateOptionsMenu();
+ }
+
+ public void onDrawerOpened(View drawerView) {
+ getActionBar().setTitle(mDrawerTitle);
+ // calling onPrepareOptionsMenu() to hide action bar icons
+ invalidateOptionsMenu();
+ }
+ };
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+
+ if (savedInstanceState == null) {
+ // on first time display view for first nav item
+ displayView(0);
+ }
+ }
+
+ /**
+ * Slide menu item click listener
+ */
+ private class SlideMenuClickListener implements
+ ListView.OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position,
+ long id) {
+ // display view for selected nav drawer item
+ displayView(position);
+ }
+ }
+
+ //Menu
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+
+ getMenuInflater().inflate(R.menu.main, menu);
+
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setOnQueryTextListener(this);
-
+
return super.onCreateOptionsMenu(menu);
-
- }
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // toggle nav drawer on selecting action bar app icon/title
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
- // Handle action bar actions click
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // toggle nav drawer on selecting action bar app icon/title
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ // Handle action bar actions click
- switch (item.getItemId()) {
- case R.id.action_settings:
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
+ switch (item.getItemId()) {
+ case R.id.action_settings:
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+ @Override
+ public boolean onQueryTextChange(String newText) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ Bundle bundle = new Bundle();
+ bundle.putString("query", query);
- @Override
- public boolean onQueryTextChange(String newText) {
- // TODO Auto-generated method stub
- return false;
- }
+ FragmentAreasAll areaAll = (FragmentAreasAll) getFragmentManager().findFragmentByTag("AreasAll");
+ FragmentSectorsAll sectorAll = (FragmentSectorsAll) getFragmentManager().findFragmentByTag("SectorsAll");
+ FragmentRoutesAll routeAll = (FragmentRoutesAll) getFragmentManager().findFragmentByTag("RoutesAll");
- @Override
- public boolean onQueryTextSubmit(String query) {
- Bundle bundle = new Bundle();
- bundle.putString("query", query);
-
- FragmentAreasAll areaAll = (FragmentAreasAll)getFragmentManager().findFragmentByTag("AreasAll");
- FragmentSectorsAll sectorAll = (FragmentSectorsAll)getFragmentManager().findFragmentByTag("SectorsAll");
- FragmentRoutesAll routeAll = (FragmentRoutesAll)getFragmentManager().findFragmentByTag("RoutesAll");
-
- FragmentSectors sector = (FragmentSectors)getFragmentManager().findFragmentByTag("Sectors");
- FragmentRoutes route = (FragmentRoutes)getFragmentManager().findFragmentByTag("Routes");
+ FragmentSectors sector = (FragmentSectors) getFragmentManager().findFragmentByTag("Sectors");
+ FragmentRoutes route = (FragmentRoutes) getFragmentManager().findFragmentByTag("Routes");
- if(areaAll != null && areaAll.isVisible()){
+ if (areaAll != null && areaAll.isVisible()) {
+ SearchAreas fragment = new SearchAreas();
+ fragment.setArguments(bundle);
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ tagFragment = "AreasSearch";
+ transaction.replace(R.id.frame_container, fragment, tagFragment);
+ transaction.addToBackStack(null);
+ query = "";
+ transaction.commit();
+ } else if (sectorAll != null && sectorAll.isVisible()) {
+ SearchSectors fragment = new SearchSectors();
+ fragment.setArguments(bundle);
+ bundle.putInt("idOfArea", -1);
+ tagFragment = "SectorsSearch";
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.replace(R.id.frame_container, fragment, tagFragment);
+ transaction.addToBackStack(null);
+ transaction.commit();
+ } else if (routeAll != null && routeAll.isVisible()) {
+ SearchRoutes fragment = new SearchRoutes();
+ fragment.setArguments(bundle);
+ bundle.putInt("idOfSector", -1);
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ tagFragment = "RoutesSearch";
+ transaction.replace(R.id.frame_container, fragment, tagFragment);
+ transaction.addToBackStack(null);
+ transaction.commit();
+ } else if (sector != null && sector.isVisible()) {
+ SearchSectors fragment = new SearchSectors();
+ fragment.setArguments(bundle);
+ bundle.putInt("idOfArea", sector.getIdOfArea());
+ tagFragment = "SectorsSearch";
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.replace(R.id.frame_container, fragment, tagFragment);
+ transaction.addToBackStack(null);
+ transaction.commit();
+ } else if (route != null && route.isVisible()) {
+ SearchRoutes fragment = new SearchRoutes();
+ fragment.setArguments(bundle);
+ bundle.putInt("idOfSector", route.getIdOfSector());
+ tagFragment = "RoutesSearch";
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.replace(R.id.frame_container, fragment, tagFragment);
+ transaction.addToBackStack(null);
+ transaction.commit();
+ }
- SearchAreas fragment = new SearchAreas();
- fragment.setArguments(bundle);
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- tagFragment = "AreasSearch";
- transaction.replace(R.id.frame_container, fragment,tagFragment);
- transaction.addToBackStack(null);
- query = "";
- transaction.commit();
-
-
-
- }
- else
- if(sectorAll != null && sectorAll.isVisible()){
+ Log.i(LOG, "TagFragmentt = " + tagFragment);
+ return false;
+ }
- SearchSectors fragment = new SearchSectors();
- fragment.setArguments(bundle);
- bundle.putInt("idOfArea",-1);
- tagFragment="SectorsSearch";
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(R.id.frame_container, fragment,tagFragment);
- transaction.addToBackStack(null);
-
- transaction.commit();
-
-
- }
- else
- if(routeAll != null && routeAll.isVisible()){
+ /* *
+ * Called when invalidateOptionsMenu() is triggered
+ */
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ // if nav drawer is opened, hide the action items
+ boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
+ menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
+ menu.findItem(R.id.action_search).setVisible(!drawerOpen);
+ return super.onPrepareOptionsMenu(menu);
+ }
- SearchRoutes fragment = new SearchRoutes();
- fragment.setArguments(bundle);
- bundle.putInt("idOfSector",-1);
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- tagFragment="RoutesSearch";
- transaction.replace(R.id.frame_container, fragment,tagFragment);
- transaction.addToBackStack(null);
-
- transaction.commit();
-
-
- }
- else
- if(sector != null && sector.isVisible()){
+ /**
+ * Diplaying fragment view for selected nav drawer list item
+ */
+ private void displayView(int position) {
+ // update the main content by replacing fragments
+ Fragment fragment = null;
- SearchSectors fragment = new SearchSectors();
- fragment.setArguments(bundle);
- bundle.putInt("idOfArea",sector.getIdOfArea());
- tagFragment = "SectorsSearch";
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(R.id.frame_container, fragment,tagFragment);
- transaction.addToBackStack(null);
-
- transaction.commit();
+ switch (position) {
+ case 0:
+ fragment = new FragmentAreasAll();
+ tagFragment = "AreasAll";
+ break;
+ case 1:
+ fragment = new FragmentSectorsAll();
+ tagFragment = "SectorsAll";
+ break;
+ case 2:
+ fragment = new FragmentRoutesAll();
+ tagFragment = "RoutesAll";
+ break;
+ case 3:
+ Bundle bundle = new Bundle();
+ FragmentAreasAll areaAll = (FragmentAreasAll) getFragmentManager().findFragmentByTag("AreasAll");
+ FragmentSectorsAll sectorAll = (FragmentSectorsAll) getFragmentManager().findFragmentByTag("SectorsAll");
+ FragmentRoutesAll routeAll = (FragmentRoutesAll) getFragmentManager().findFragmentByTag("RoutesAll");
-
- }
- else
- if(route != null && route.isVisible() ){
+ FragmentSectors sector = (FragmentSectors) getFragmentManager().findFragmentByTag("Sectors");
+ FragmentRoutes route = (FragmentRoutes) getFragmentManager().findFragmentByTag("Routes");
- SearchRoutes fragment = new SearchRoutes();
- fragment.setArguments(bundle);
- bundle.putInt("idOfSector",route.getIdOfSector());
- tagFragment = "RoutesSearch";
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.replace(R.id.frame_container, fragment,tagFragment);
- transaction.addToBackStack(null);
-
- transaction.commit();
- }
-
- Log.i(LOG,"TagFragmentt = "+tagFragment);
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- /* *
- * Called when invalidateOptionsMenu() is triggered
- */
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- // if nav drawer is opened, hide the action items
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
- menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
- menu.findItem(R.id.action_search).setVisible(!drawerOpen);
- return super.onPrepareOptionsMenu(menu);
- }
-
- /**
- * Diplaying fragment view for selected nav drawer list item
- * */
- private void displayView(int position) {
- // update the main content by replacing fragments
- Fragment fragment = null;
-
- switch (position) {
- case 0:
- fragment = new FragmentAreasAll();
-
- tagFragment = "AreasAll";
- break;
- case 1:
- fragment = new FragmentSectorsAll();
- tagFragment = "SectorsAll";
- break;
- case 2:
- fragment = new FragmentRoutesAll();
- tagFragment = "RoutesAll";
- break;
- case 3:
- Bundle bundle = new Bundle();
- FragmentAreasAll areaAll = (FragmentAreasAll)getFragmentManager().findFragmentByTag("AreasAll");
- FragmentSectorsAll sectorAll = (FragmentSectorsAll)getFragmentManager().findFragmentByTag("SectorsAll");
- FragmentRoutesAll routeAll = (FragmentRoutesAll)getFragmentManager().findFragmentByTag("RoutesAll");
-
- FragmentSectors sector = (FragmentSectors)getFragmentManager().findFragmentByTag("Sectors");
- FragmentRoutes route = (FragmentRoutes)getFragmentManager().findFragmentByTag("Routes");
-
- if(areaAll != null && areaAll.isVisible()){
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo netInfo = cm.getActiveNetworkInfo();
- if (netInfo != null && netInfo.isConnectedOrConnecting()) {
- fragment = new FragmentCreateArea();
- tagFragment = "CreateArea";
- break;
- }else{
- Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
- }
- }
- else
- if(sectorAll != null && sectorAll.isVisible()){
- Toast.makeText(getApplicationContext(), "First select the area", Toast.LENGTH_LONG).show();
- break;
- }
- else
- if(routeAll != null && routeAll.isVisible()){
- Toast.makeText(getApplicationContext(), "First select the sector", Toast.LENGTH_LONG).show();
- break;
-
-
- }
- else
- if(sector != null && sector.isVisible()){
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo netInfo = cm.getActiveNetworkInfo();
- if (netInfo != null && netInfo.isConnectedOrConnecting()) {
- fragment = new FragmentCreateSector();
- bundle.putInt("idOfArea", sector.getIdOfArea());
- fragment.setArguments(bundle);
- tagFragment = "CreateSector";
- break;
- }else{
- Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
- }
-
- }
- else
- if(route != null && route.isVisible() ){
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo netInfo = cm.getActiveNetworkInfo();
- if (netInfo != null && netInfo.isConnectedOrConnecting()) {
- fragment = new FragmentCreateRoute();
- bundle.putInt("idOfSector", route.getIdOfSector());
- fragment.setArguments(bundle);
- tagFragment = "CreateRoute";
- break;
- }else{
- Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
- }
- }
- case 4:
- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo netInfo = cm.getActiveNetworkInfo();
- if (netInfo != null && netInfo.isConnectedOrConnecting()) {
- Update update = new Update();
- update.updateA(getApplicationContext());
- update.updateS(getApplicationContext());
- update.updateR(getApplicationContext());
- Intent intent = getIntent();
- finish();
- startActivity(intent);
- }else{
- Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
- }
-
- break;
+ if (areaAll != null && areaAll.isVisible()) {
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = cm.getActiveNetworkInfo();
+ if (netInfo != null && netInfo.isConnectedOrConnecting()) {
+ fragment = new FragmentCreateArea();
+ tagFragment = "CreateArea";
+ break;
+ } else {
+ Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
+ }
+ } else if (sectorAll != null && sectorAll.isVisible()) {
+ Toast.makeText(getApplicationContext(), "First select the area", Toast.LENGTH_LONG).show();
+ break;
+ } else if (routeAll != null && routeAll.isVisible()) {
+ Toast.makeText(getApplicationContext(), "First select the sector", Toast.LENGTH_LONG).show();
+ break;
+ } else if (sector != null && sector.isVisible()) {
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = cm.getActiveNetworkInfo();
+ if (netInfo != null && netInfo.isConnectedOrConnecting()) {
+ fragment = new FragmentCreateSector();
+ bundle.putInt("idOfArea", sector.getIdOfArea());
+ fragment.setArguments(bundle);
+ tagFragment = "CreateSector";
+ break;
+ } else {
+ Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
+ }
+ } else if (route != null && route.isVisible()) {
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = cm.getActiveNetworkInfo();
+ if (netInfo != null && netInfo.isConnectedOrConnecting()) {
+ fragment = new FragmentCreateRoute();
+ bundle.putInt("idOfSector", route.getIdOfSector());
+ fragment.setArguments(bundle);
+ tagFragment = "CreateRoute";
+ break;
+ } else {
+ Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
+ }
+ }
+ case 4:
+ ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = cm.getActiveNetworkInfo();
+ if (netInfo != null && netInfo.isConnectedOrConnecting()) {
+ Update update = new Update();
+ update.updateA(getApplicationContext());
+ update.updateS(getApplicationContext());
+ update.updateR(getApplicationContext());
+ Intent intent = getIntent();
+ finish();
+ startActivity(intent);
+ } else {
+ Toast.makeText(getApplicationContext(), "There is no network access", Toast.LENGTH_LONG).show();
+ }
+ break;
// case 5:
// fragment = new ();
// break;
- default:
- break;
- }
+ default:
+ break;
+ }
- if (fragment != null) {
+ if (fragment != null) {
- FragmentManager fragmentManager = getFragmentManager();
- fragmentManager.beginTransaction()
- .replace(R.id.frame_container, fragment,tagFragment).addToBackStack(null).commit();
+ FragmentManager fragmentManager = getFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.frame_container, fragment, tagFragment).addToBackStack(null).commit();
- // update selected item and title, then close the drawer
- mDrawerList.setItemChecked(position, true);
- mDrawerList.setSelection(position);
- setTitle(navMenuTitles[position]);
- mDrawerLayout.closeDrawer(mDrawerList);
- Log.i(LOG,"TagFragment = "+tagFragment);
+ // update selected item and title, then close the drawer
+ mDrawerList.setItemChecked(position, true);
+ mDrawerList.setSelection(position);
+ setTitle(navMenuTitles[position]);
+ mDrawerLayout.closeDrawer(mDrawerList);
+ Log.i(LOG, "TagFragment = " + tagFragment);
- } else {
- // error in creating fragment
- Log.e("MainActivity", "Error in creating fragment");
- }
+ } else {
+ // error in creating fragment
+ Log.e("MainActivity", "Error in creating fragment");
+ }
- }
-
- @Override
- public void setTitle(CharSequence title) {
- mTitle = title;
- getActionBar().setTitle(mTitle);
- }
+ }
- /**
- * When using the ActionBarDrawerToggle, you must call it during
- * onPostCreate() and onConfigurationChanged()...
- */
+ @Override
+ public void setTitle(CharSequence title) {
+ mTitle = title;
+ getActionBar().setTitle(mTitle);
+ }
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- // Sync the toggle state after onRestoreInstanceState has occurred.
- mDrawerToggle.syncState();
- }
+ /**
+ * When using the ActionBarDrawerToggle, you must call it during
+ * onPostCreate() and onConfigurationChanged()...
+ */
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ mDrawerToggle.syncState();
+ }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- // Pass any configuration change to the drawer toggls
- mDrawerToggle.onConfigurationChanged(newConfig);
- }
- //Get number of areas , sectors,routes
- public String getNumberOfAreas()
- {
- int numberOfareas = 0;
- AreaDao areaDao = new AreaDao(getApplicationContext());
- List<Area> areaList = new ArrayList<Area>();
-
- areaDao.open();
- areaList = areaDao.getAllAreas();
- areaDao.close();
-
- for(Area area : areaList)
- {
- numberOfareas++;
- }
-
-
- return Integer.toString(numberOfareas);
- }
-
- public String getNumberOfSectors()
- {
- int numberOfsectors = 0;
- SectorDao sectorDao = new SectorDao(getApplicationContext());
- List<Sector> sectorList = new ArrayList<Sector>();
-
- sectorDao.open();
- sectorList = sectorDao.getAllSectors();
- sectorDao.close();
-
- for(Sector sector : sectorList)
- {
- numberOfsectors++;
- }
-
- return Integer.toString(numberOfsectors);
- }
-
- public String getNumberOfRoutes()
- {
- int numberOfroutes = 0;
- RouteDao routeDao = new RouteDao(getApplicationContext());
- List<Route> routeList = new ArrayList<Route>();
-
- routeDao.open();
- routeList = routeDao.getAllRoutes();
- routeDao.close();
-
- for(Route route : routeList)
- {
- numberOfroutes++;
- }
- return Integer.toString(numberOfroutes);
- }
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ // Pass any configuration change to the drawer toggls
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
-
-}
\ No newline at end of file
+ //Get number of areas , sectors,routes
+ public String getNumberOfAreas() {
+ int numberOfareas = 0;
+ AreaDao areaDao = new AreaDao(getApplicationContext());
+ List<Area> areaList = new ArrayList<Area>();
+
+ areaDao.open();
+ areaList = areaDao.getAllAreas();
+ areaDao.close();
+
+ for (Area area : areaList) {
+ numberOfareas++;
+ }
+
+ return Integer.toString(numberOfareas);
+ }
+
+ public String getNumberOfSectors() {
+ int numberOfsectors = 0;
+ SectorDao sectorDao = new SectorDao(getApplicationContext());
+ List<Sector> sectorList = new ArrayList<Sector>();
+
+ sectorDao.open();
+ sectorList = sectorDao.getAllSectors();
+ sectorDao.close();
+
+ for (Sector sector : sectorList) {
+ numberOfsectors++;
+ }
+
+ return Integer.toString(numberOfsectors);
+ }
+
+ public String getNumberOfRoutes() {
+ int numberOfroutes = 0;
+ RouteDao routeDao = new RouteDao(getApplicationContext());
+ List<Route> routeList = new ArrayList<Route>();
+
+ routeDao.open();
+ routeList = routeDao.getAllRoutes();
+ routeDao.close();
+
+ for (Route route : routeList) {
+ numberOfroutes++;
+ }
+ return Integer.toString(numberOfroutes);
+ }
+}
diff --git a/app/src/main/java/org/climbingguide/main/NavDrawerItem.java b/app/src/main/java/org/climbingguide/main/NavDrawerItem.java
index 6b508ae..69c31e4 100755
--- a/app/src/main/java/org/climbingguide/main/NavDrawerItem.java
+++ b/app/src/main/java/org/climbingguide/main/NavDrawerItem.java
@@ -1,56 +1,57 @@
package org.climbingguide.main;
public class NavDrawerItem {
-
- private String title;
- private int icon;
- private String count = "0";
- // boolean to set visiblity of the counter
- private boolean isCounterVisible = false;
-
- public NavDrawerItem(){}
- public NavDrawerItem(String title, int icon){
- this.title = title;
- this.icon = icon;
- }
-
- public NavDrawerItem(String title, int icon, boolean isCounterVisible, String count){
- this.title = title;
- this.icon = icon;
- this.isCounterVisible = isCounterVisible;
- this.count = count;
- }
-
- public String getTitle(){
- return this.title;
- }
-
- public int getIcon(){
- return this.icon;
- }
-
- public String getCount(){
- return this.count;
- }
-
- public boolean getCounterVisibility(){
- return this.isCounterVisible;
- }
-
- public void setTitle(String title){
- this.title = title;
- }
-
- public void setIcon(int icon){
- this.icon = icon;
- }
-
- public void setCount(String count){
- this.count = count;
- }
-
- public void setCounterVisibility(boolean isCounterVisible){
- this.isCounterVisible = isCounterVisible;
- }
+ private String title;
+ private int icon;
+ private String count = "0";
+ // boolean to set visiblity of the counter
+ private boolean isCounterVisible = false;
+
+ public NavDrawerItem() {
+ }
+
+ public NavDrawerItem(String title, int icon) {
+ this.title = title;
+ this.icon = icon;
+ }
+
+ public NavDrawerItem(String title, int icon, boolean isCounterVisible, String count) {
+ this.title = title;
+ this.icon = icon;
+ this.isCounterVisible = isCounterVisible;
+ this.count = count;
+ }
+
+ public String getTitle() {
+ return this.title;
+ }
+
+ public int getIcon() {
+ return this.icon;
+ }
+
+ public String getCount() {
+ return this.count;
+ }
+
+ public boolean getCounterVisibility() {
+ return this.isCounterVisible;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setIcon(int icon) {
+ this.icon = icon;
+ }
+
+ public void setCount(String count) {
+ this.count = count;
+ }
+
+ public void setCounterVisibility(boolean isCounterVisible) {
+ this.isCounterVisible = isCounterVisible;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/main/NavDrawerListAdapter.java b/app/src/main/java/org/climbingguide/main/NavDrawerListAdapter.java
index 60640ae..312391b 100755
--- a/app/src/main/java/org/climbingguide/main/NavDrawerListAdapter.java
+++ b/app/src/main/java/org/climbingguide/main/NavDrawerListAdapter.java
@@ -12,55 +12,54 @@
import android.widget.TextView;
public class NavDrawerListAdapter extends BaseAdapter {
-
- private Context context;
- private ArrayList<NavDrawerItem> navDrawerItems;
-
- public NavDrawerListAdapter(Context context, ArrayList<NavDrawerItem> navDrawerItems){
- this.context = context;
- this.navDrawerItems = navDrawerItems;
- }
- @Override
- public int getCount() {
- return navDrawerItems.size();
- }
+ private Context context;
+ private ArrayList<NavDrawerItem> navDrawerItems;
- @Override
- public Object getItem(int position) {
- return navDrawerItems.get(position);
- }
+ public NavDrawerListAdapter(Context context, ArrayList<NavDrawerItem> navDrawerItems) {
+ this.context = context;
+ this.navDrawerItems = navDrawerItems;
+ }
- @Override
- public long getItemId(int position) {
- return position;
- }
+ @Override
+ public int getCount() {
+ return navDrawerItems.size();
+ }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
+ @Override
+ public Object getItem(int position) {
+ return navDrawerItems.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.drawer_list_item, null);
}
-
+
ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
-
- imgIcon.setImageResource(navDrawerItems.get(position).getIcon());
+
+ imgIcon.setImageResource(navDrawerItems.get(position).getIcon());
txtTitle.setText(navDrawerItems.get(position).getTitle());
-
+
// displaying count
// check whether it set visible or not
- if(navDrawerItems.get(position).getCounterVisibility()){
- txtCount.setText(navDrawerItems.get(position).getCount());
- }else{
- // hide the counter view
- txtCount.setVisibility(View.GONE);
+ if (navDrawerItems.get(position).getCounterVisibility()) {
+ txtCount.setText(navDrawerItems.get(position).getCount());
+ } else {
+ // hide the counter view
+ txtCount.setVisibility(View.GONE);
}
-
- return convertView;
- }
+ return convertView;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/model/Area.java b/app/src/main/java/org/climbingguide/model/Area.java
index c47af49..87d9deb 100755
--- a/app/src/main/java/org/climbingguide/model/Area.java
+++ b/app/src/main/java/org/climbingguide/model/Area.java
@@ -5,35 +5,38 @@
import android.app.Activity;
-public class Area extends Activity{
+public class Area extends Activity {
- private int id;
- private String name;
- private List <Sector> sectors = new ArrayList<Sector>();
-
- public List<Sector> getSectors() {
- return sectors;
- }
- public void setSectors(List<Sector> sectors) {
- this.sectors = sectors;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- @Override
- public String toString(){
- return name;
- }
-
-
-
+ private int id;
+ private String name;
+ private List<Sector> sectors = new ArrayList<Sector>();
+
+ public List<Sector> getSectors() {
+ return sectors;
+ }
+
+ public void setSectors(List<Sector> sectors) {
+ this.sectors = sectors;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/model/Route.java b/app/src/main/java/org/climbingguide/model/Route.java
index 1a4ef56..f8dc24b 100755
--- a/app/src/main/java/org/climbingguide/model/Route.java
+++ b/app/src/main/java/org/climbingguide/model/Route.java
@@ -2,70 +2,84 @@
import android.app.Activity;
-public class Route extends Activity{
+public class Route extends Activity {
- private int id;
- private String name;
- private int idOfSector;
- private String dificulty;
- private int bolts;
- private int length;
-
- private double latitute;
- private double longitude;
+ private int id;
+ private String name;
+ private int idOfSector;
+ private String difficulty;
+ private int bolts;
+ private int length;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getIdOfSector() {
- return idOfSector;
- }
- public void setIdOfSector(int idOfSector) {
- this.idOfSector = idOfSector;
- }
- public String getDificulty() {
- return dificulty;
- }
- public void setDificulty(String dificulty) {
- this.dificulty = dificulty;
- }
- public int getBolts() {
- return bolts;
- }
- public void setBolts(int bolts) {
- this.bolts = bolts;
- }
- public int getLength() {
- return length;
- }
- public void setLength(int length) {
- this.length = length;
- }
- public double getLatitute() {
- return latitute;
- }
- public void setLatitute(double latitute) {
- this.latitute = latitute;
- }
- public double getLongitude() {
- return longitude;
- }
- public void setLongitude(double longitude) {
- this.longitude = longitude;
- }
- @Override
- public String toString(){
- return name;
- }
-
-
+ private double latitude;
+ private double longitude;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getIdOfSector() {
+ return idOfSector;
+ }
+
+ public void setIdOfSector(int idOfSector) {
+ this.idOfSector = idOfSector;
+ }
+
+ public String getDifficulty() {
+ return difficulty;
+ }
+
+ public void setDifficulty(String difficulty) {
+ this.difficulty = difficulty;
+ }
+
+ public int getBolts() {
+ return bolts;
+ }
+
+ public void setBolts(int bolts) {
+ this.bolts = bolts;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/model/Sector.java b/app/src/main/java/org/climbingguide/model/Sector.java
index 7ce2423..4f9ceb2 100755
--- a/app/src/main/java/org/climbingguide/model/Sector.java
+++ b/app/src/main/java/org/climbingguide/model/Sector.java
@@ -5,41 +5,47 @@
import android.app.Activity;
-public class Sector extends Activity{
+public class Sector extends Activity {
- private int id;
- private String name;
- private int idOfArea;
- private List<Route> routes = new ArrayList <Route>();
-
- public List<Route> getRoutes() {
- return routes;
- }
- public void setRoutes(List<Route> routes) {
- this.routes = routes;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getIdOfArea() {
- return idOfArea;
- }
- public void setIdOfArea(int idOfArea) {
- this.idOfArea = idOfArea;
- }
- @Override
- public String toString(){
- return name;
- }
+ private int id;
+ private String name;
+ private int idOfArea;
+ private List<Route> routes = new ArrayList<Route>();
-
+ public List<Route> getRoutes() {
+ return routes;
+ }
+
+ public void setRoutes(List<Route> routes) {
+ this.routes = routes;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getIdOfArea() {
+ return idOfArea;
+ }
+
+ public void setIdOfArea(int idOfArea) {
+ this.idOfArea = idOfArea;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/app/src/main/java/org/climbingguide/update/Update.java b/app/src/main/java/org/climbingguide/update/Update.java
index 7669de7..03d2bef 100755
--- a/app/src/main/java/org/climbingguide/update/Update.java
+++ b/app/src/main/java/org/climbingguide/update/Update.java
@@ -29,168 +29,151 @@
import android.widget.Toast;
public class Update {
-
- StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
-
- public String readFeedFrom(String http){
- StrictMode.setThreadPolicy(policy);
- StringBuilder builder = new StringBuilder();
- HttpClient client = new DefaultHttpClient();
- HttpGet httpGet = new HttpGet(http);
- try {
- HttpResponse response = client.execute(httpGet);
- StatusLine statusLine = response.getStatusLine();
- int statusCode = statusLine.getStatusCode();
- if (statusCode == 200) {
- HttpEntity entity = response.getEntity();
- InputStream content = entity.getContent();
- BufferedReader reader = new BufferedReader(new InputStreamReader(content));
- String line;
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
- }
- } catch (ClientProtocolException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return builder.toString();
-
- }
- //----------------------------------------------------------
- public void updateA(Context context)
- {
- UpdateArea area = new UpdateArea();
- AreaDao daoa = new AreaDao(context);
- daoa.open();
- List <Area> listOfAreas = daoa.getAllAreas();
- daoa.close();
- int f=0;
-
- String primeAreas = readFeedFrom("http://climbingguide.madzik.sk/areas.php");
-
- try {
- JSONObject areas = new JSONObject(primeAreas);
- JSONArray arrayAreas = new JSONArray();
- arrayAreas = areas.getJSONArray("areas");
- int i =0;
- if(listOfAreas.size()<arrayAreas.length()){
- for(i=0;i<arrayAreas.length();i++){
- JSONObject HTTPArea = new JSONObject();
- HTTPArea = arrayAreas.getJSONObject(i);
- for(int j=0;j<listOfAreas.size();j++){
- if(HTTPArea.getInt("id_area")==listOfAreas.get(j).getId()){
- f=1;
- }
- }
- if(f==0){
- area.updateArea(HTTPArea.getInt("id_area"), HTTPArea.getString("area_name"), context);
- }
- else{
- f=0;
- }
- }
- Toast.makeText(context, "Your areas was updated", Toast.LENGTH_LONG).show();
- }
- else{
- Toast.makeText(context, "Your areas are up to date", Toast.LENGTH_LONG).show();
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-//---------------------------------------------------------------
- public void updateS(Context context)
- {
- UpdateSector sector = new UpdateSector();
-
- SectorDao daoa = new SectorDao(context);
- daoa.open();
- List <Sector> listOfSectors = daoa.getAllSectors();
- daoa.close();
- int f=0;
-
- String primeSectors = readFeedFrom("http://climbingguide.madzik.sk/sectors.php");
-
- try {
- JSONObject sectors = new JSONObject(primeSectors);
- JSONArray arraySectors = new JSONArray();
- arraySectors = sectors.getJSONArray("sectors");
- int i =0;
- Log.i("sector update", "Size of database sectors: " +listOfSectors.size()+ " and size of downloaded sectors: " +arraySectors.length());
- if(listOfSectors.size()<arraySectors.length()){
- for(i=0;i<arraySectors.length();i++){
-
- JSONObject HTTPSector = new JSONObject();
- HTTPSector = arraySectors.getJSONObject(i);
- for(int j=0;j<listOfSectors.size();j++){
- if(HTTPSector.getInt("id_sector")==listOfSectors.get(j).getId()){
- f=1;
- Log.i("sector update", HTTPSector.toString());
- }
- }
- if(f==0){
- Log.i("sector update", "2");
- sector.updateSector(HTTPSector.getInt("id_sector"), HTTPSector.getString("sector_name"), HTTPSector.getInt("id_of_area"), context);
- }
- else{
- f=0;
- }
- }
- }
- else{
- Toast.makeText(context, "Your sectors are up to date", Toast.LENGTH_LONG).show();
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-//---------------------------------------------------------------
- public void updateR(Context context)
- {
- UpdateRoute route = new UpdateRoute();
-
- RouteDao daoa = new RouteDao(context);
- daoa.open();
- List <Route> listOfRoutes = daoa.getAllRoutes();
- daoa.close();
-
- String primeRoutes = readFeedFrom("http://climbingguide.madzik.sk/routes.php");
-
- try {
- JSONObject routes = new JSONObject(primeRoutes);
- JSONArray arrayRoutes = new JSONArray();
- arrayRoutes = routes.getJSONArray("routes");
- int i =0;
- int f=0;
- if(listOfRoutes.size()<arrayRoutes.length()){
- for(i=0;i<arrayRoutes.length();i++){
-
- JSONObject HTTPRoute = new JSONObject();
- HTTPRoute = arrayRoutes.getJSONObject(i);
- for(int j=0;j<listOfRoutes.size();j++){
- if(HTTPRoute.getInt("id_route")==listOfRoutes.get(j).getId()){
- f=1;
- }
- }
- if(f==0){
- route.updateRoute(HTTPRoute.getInt("id_route"), HTTPRoute.getString("route_name"), HTTPRoute.getInt("id_of_sector"), HTTPRoute.getString("difficulty"), HTTPRoute.getInt("bolts"), HTTPRoute.getInt("length"), 48.9947059, 21.2347516, context);
- }
- else{
- f=0;
- }
- }
- }
- else{
- Toast.makeText(context, "Your routes are up to date", Toast.LENGTH_LONG).show();
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
+
+ public String readFeedFrom(String http) {
+ StrictMode.setThreadPolicy(policy);
+ StringBuilder builder = new StringBuilder();
+ HttpClient client = new DefaultHttpClient();
+ HttpGet httpGet = new HttpGet(http);
+ try {
+ HttpResponse response = client.execute(httpGet);
+ StatusLine statusLine = response.getStatusLine();
+ int statusCode = statusLine.getStatusCode();
+ if (statusCode == 200) {
+ HttpEntity entity = response.getEntity();
+ InputStream content = entity.getContent();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(content));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ builder.append(line);
+ }
+ }
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return builder.toString();
+ }
+
+ //----------------------------------------------------------
+ public void updateA(Context context) {
+ UpdateArea area = new UpdateArea();
+ AreaDao daoa = new AreaDao(context);
+ daoa.open();
+ List<Area> listOfAreas = daoa.getAllAreas();
+ daoa.close();
+ int f = 0;
+
+ String primeAreas = readFeedFrom("http://climbingguide.madzik.sk/areas.php");
+
+ try {
+ JSONObject areas = new JSONObject(primeAreas);
+ JSONArray arrayAreas = areas.getJSONArray("areas");
+ int i = 0;
+ if (listOfAreas.size() < arrayAreas.length()) {
+ for (i = 0; i < arrayAreas.length(); i++) {
+ JSONObject HTTPArea = arrayAreas.getJSONObject(i);
+ for (int j = 0; j < listOfAreas.size(); j++) {
+ if (HTTPArea.getInt("id_area") == listOfAreas.get(j).getId()) {
+ f = 1;
+ }
+ }
+ if (f == 0) {
+ area.updateArea(HTTPArea.getInt("id_area"), HTTPArea.getString("area_name"), context);
+ } else {
+ f = 0;
+ }
+ }
+ Toast.makeText(context, "Your areas was updated", Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(context, "Your areas are up to date", Toast.LENGTH_LONG).show();
+ }
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ //---------------------------------------------------------------
+ public void updateS(Context context) {
+ UpdateSector sector = new UpdateSector();
+
+ SectorDao daoa = new SectorDao(context);
+ daoa.open();
+ List<Sector> listOfSectors = daoa.getAllSectors();
+ daoa.close();
+ int f = 0;
+
+ String primeSectors = readFeedFrom("http://climbingguide.madzik.sk/sectors.php");
+
+ try {
+ JSONObject sectors = new JSONObject(primeSectors);
+ JSONArray arraySectors = sectors.getJSONArray("sectors");
+ Log.i("sector update", "Size of database sectors: " + listOfSectors.size() + " and size of downloaded sectors: " + arraySectors.length());
+ if (listOfSectors.size() < arraySectors.length()) {
+ for (int i = 0; i < arraySectors.length(); i++) {
+
+ JSONObject HTTPSector = arraySectors.getJSONObject(i);
+ for (int j = 0; j < listOfSectors.size(); j++) {
+ if (HTTPSector.getInt("id_sector") == listOfSectors.get(j).getId()) {
+ f = 1;
+ Log.i("sector update", HTTPSector.toString());
+ }
+ }
+ if (f == 0) {
+ Log.i("sector update", "2");
+ sector.updateSector(HTTPSector.getInt("id_sector"), HTTPSector.getString("sector_name"), HTTPSector.getInt("id_of_area"), context);
+ } else {
+ f = 0;
+ }
+ }
+ } else {
+ Toast.makeText(context, "Your sectors are up to date", Toast.LENGTH_LONG).show();
+ }
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ //---------------------------------------------------------------
+ public void updateR(Context context) {
+ UpdateRoute route = new UpdateRoute();
+
+ RouteDao daoa = new RouteDao(context);
+ daoa.open();
+ List<Route> listOfRoutes = daoa.getAllRoutes();
+ daoa.close();
+
+ String primeRoutes = readFeedFrom("http://climbingguide.madzik.sk/routes.php");
+
+ try {
+ JSONObject routes = new JSONObject(primeRoutes);
+ JSONArray arrayRoutes = routes.getJSONArray("routes");
+ int f = 0;
+ if (listOfRoutes.size() < arrayRoutes.length()) {
+ for (int i = 0; i < arrayRoutes.length(); i++) {
+ JSONObject HTTPRoute = arrayRoutes.getJSONObject(i);
+ for (int j = 0; j < listOfRoutes.size(); j++) {
+ if (HTTPRoute.getInt("id_route") == listOfRoutes.get(j).getId()) {
+ f = 1;
+ }
+ }
+ if (f == 0) {
+ route.updateRoute(HTTPRoute.getInt("id_route"), HTTPRoute.getString("route_name"), HTTPRoute.getInt("id_of_sector"), HTTPRoute.getString("difficulty"), HTTPRoute.getInt("bolts"), HTTPRoute.getInt("length"), 48.9947059, 21.2347516, context);
+ } else {
+ f = 0;
+ }
+ }
+ } else {
+ Toast.makeText(context, "Your routes are up to date", Toast.LENGTH_LONG).show();
+ }
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
diff --git a/app/src/main/java/org/climbingguide/update/UpdateArea.java b/app/src/main/java/org/climbingguide/update/UpdateArea.java
index bcc1cf2..0e6f355 100755
--- a/app/src/main/java/org/climbingguide/update/UpdateArea.java
+++ b/app/src/main/java/org/climbingguide/update/UpdateArea.java
@@ -6,20 +6,17 @@
import android.app.Activity;
import android.content.Context;
-
public class UpdateArea extends Activity {
+ public void updateArea(int id, String name, Context context) {
+ Area area = new Area();
- public void updateArea(int id, String name,Context context)
- {
- Area area = new Area();
-
- area.setId(id);
- area.setName(name);
-
- AreaDao daoa = new AreaDao(context);
- daoa.open();
- daoa.addArea(area);
- daoa.close();
- }
+ area.setId(id);
+ area.setName(name);
+
+ AreaDao daoa = new AreaDao(context);
+ daoa.open();
+ daoa.addArea(area);
+ daoa.close();
+ }
}
diff --git a/app/src/main/java/org/climbingguide/update/UpdateRoute.java b/app/src/main/java/org/climbingguide/update/UpdateRoute.java
index 617f686..a4734f2 100755
--- a/app/src/main/java/org/climbingguide/update/UpdateRoute.java
+++ b/app/src/main/java/org/climbingguide/update/UpdateRoute.java
@@ -7,24 +7,21 @@
public class UpdateRoute {
- public void updateRoute(int id, String name,int id_of_sector,String dificulty,int bolts,int length,double latitute,double longitude,Context context)
- {
- Route route = new Route ();
+ public void updateRoute(int id, String name, int id_of_sector, String dificulty, int bolts, int length, double latitute, double longitude, Context context) {
+ Route route = new Route();
- route.setId(id);
- route.setName(name);
- route.setIdOfSector(id_of_sector);
- route.setDificulty(dificulty);
- route.setBolts(bolts);
- route.setLength(length);
- route.setLatitute(latitute);
- route.setLongitude(longitude);
-
- RouteDao daor = new RouteDao(context);
- daor.open();
- daor.addRoute(route);
- daor.close();
-
- }
-
+ route.setId(id);
+ route.setName(name);
+ route.setIdOfSector(id_of_sector);
+ route.setDifficulty(dificulty);
+ route.setBolts(bolts);
+ route.setLength(length);
+ route.setLatitude(latitute);
+ route.setLongitude(longitude);
+
+ RouteDao daor = new RouteDao(context);
+ daor.open();
+ daor.addRoute(route);
+ daor.close();
+ }
}
diff --git a/app/src/main/java/org/climbingguide/update/UpdateSector.java b/app/src/main/java/org/climbingguide/update/UpdateSector.java
index 4193ec8..b4a0e6f 100755
--- a/app/src/main/java/org/climbingguide/update/UpdateSector.java
+++ b/app/src/main/java/org/climbingguide/update/UpdateSector.java
@@ -7,17 +7,16 @@
public class UpdateSector {
- public void updateSector(int id, String name,int idOfArea,Context context)
- {
- Sector sector = new Sector();
-
- sector.setId(id);
- sector.setName(name);
- sector.setIdOfArea(idOfArea);
-
- SectorDao daos = new SectorDao(context);
- daos.open();
- daos.addSector(sector);
- daos.close();
- }
+ public void updateSector(int id, String name, int idOfArea, Context context) {
+ Sector sector = new Sector();
+
+ sector.setId(id);
+ sector.setName(name);
+ sector.setIdOfArea(idOfArea);
+
+ SectorDao daos = new SectorDao(context);
+ daos.open();
+ daos.addSector(sector);
+ daos.close();
+ }
}
diff --git a/app/src/main/res/layout/create_route.xml b/app/src/main/res/layout/create_route.xml
index 729fc34..7a40733 100755
--- a/app/src/main/res/layout/create_route.xml
+++ b/app/src/main/res/layout/create_route.xml
@@ -6,72 +6,72 @@
android:orientation="vertical" >
<TextView
- android:id="@+id/textView1"
+ android:id="@+id/textViewRouteName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routeName" />
<EditText
- android:id="@+id/editText1"
+ android:id="@+id/editTextRouteName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textCapSentences" />
<TextView
- android:id="@+id/textView2"
+ android:id="@+id/textViewInSector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routeSector" />
<EditText
- android:id="@+id/editText2"
+ android:id="@+id/editTextInSector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" />
<TextView
- android:id="@+id/textView3"
+ android:id="@+id/textViewRouteDifficulty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routeDiff" />
<EditText
- android:id="@+id/editText3"
+ android:id="@+id/editTextRouteDifficulty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
- android:inputType="text" />"
+ android:inputType="text" />
<TextView
- android:id="@+id/textView4"
+ android:id="@+id/textViewRouteLength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routeLength" />
<EditText
- android:id="@+id/editText4"
+ android:id="@+id/editTextRouteLength"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" />
<TextView
- android:id="@+id/textView5"
+ android:id="@+id/textViewBoltsCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/routeBolts" />
<EditText
- android:id="@+id/editText5"
+ android:id="@+id/editTextBoltsCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" />
<Button
- android:id="@+id/button1"
+ android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send" />
diff --git a/app/src/main/res/layout/route.xml b/app/src/main/res/layout/route.xml
index 7a45054..57c5e32 100755
--- a/app/src/main/res/layout/route.xml
+++ b/app/src/main/res/layout/route.xml
@@ -29,16 +29,6 @@
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
- android:id="@+id/textViewLength"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/textViewBolts"
- android:layout_below="@+id/textViewBolts"
- android:layout_marginTop="20dp"
- android:text="@string/bolts_"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView
android:id="@+id/textViewBolts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -46,7 +36,37 @@
android:layout_below="@+id/textViewDifficulty"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
+ android:text="@string/bolts_"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/textViewLength"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/textViewBolts"
+ android:layout_below="@+id/textViewBolts"
+ android:layout_marginTop="20dp"
android:text="@string/length_"
android:textAppearance="?android:attr/textAppearanceMedium" />
-</RelativeLayout>
\ No newline at end of file
+ <TextView
+ android:id="@+id/textViewLatitude"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/textViewBolts"
+ android:layout_below="@+id/textViewLength"
+ android:layout_marginTop="20dp"
+ android:text="@string/latitude"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/textViewLongitude"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/textViewBolts"
+ android:layout_below="@+id/textViewLatitude"
+ android:layout_marginTop="20dp"
+ android:text="@string/longitude"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+</RelativeLayout>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c373e89..f664b78 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4,18 +4,20 @@
<string name="app_name">Climbing Guide</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
-
+
<string name="sector">Sector</string>
- <string name="update">Update</string>
- <string name="Update">Update</string>
- <string name="create">Create</string>
+ <string name="update">Update</string>
+ <string name="Update">Update</string>
+ <string name="create">Create</string>
<string name="search">Search</string>
- <string name="search_hint">Search</string>
- <string name="large_text">Large Text</string>
+ <string name="search_hint">Search</string>
+ <string name="large_text">Large Text</string>
<string name="difficulty_">"Difficulty: "</string>
- <string name="length_">"Length: "</string>
- <string name="bolts_">"Bolts: "</string>
-
+ <string name="length_">"Length: "</string>
+ <string name="bolts_">"Bolts: "</string>
+ <string name="latitude">"Latitude: "</string>
+ <string name="longitude">"Longitude: "</string>
+
<string name="action_update">Update</string>
<string name="drawer_open">Open Drawer</string>
<string name="drawer_close">Close Drawer</string>
@@ -32,7 +34,7 @@
<string name="sectorArea">In area</string>
<string name="areaName">Area name</string>
-
+
<string-array name="nav_drawer_items">
<item >Areas</item>
<item >Sectors</item>
@@ -41,7 +43,7 @@
<item >Update</item>
<item >GPS</item>
</string-array>
-
+
<array name="nav_drawer_icons">
<item>@drawable/ic_routes</item>
<item>@drawable/ic_sectors</item>
@@ -49,6 +51,6 @@
<item>@drawable/ic_create</item>
<item>@drawable/ic_update</item>
</array>
-
+
<string name="desc_list_item_icon">Item Icon</string>
</resources>