|
|
@@ -109,14 +109,14 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
|
|
|
//Request location permissions if not set
|
|
|
if (ActivityCompat.checkSelfPermission(view.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(view.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
|
- ActivityCompat.requestPermissions(this.getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION_LOCATION);
|
|
|
+ ActivityCompat.requestPermissions(this.getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION.LOCATION);
|
|
|
}
|
|
|
|
|
|
//Set Location manager
|
|
|
//TODO: Only do this if location is required
|
|
|
locationManager = (LocationManager) view.getContext().getSystemService(Context.LOCATION_SERVICE);
|
|
|
if (!(ActivityCompat.checkSelfPermission(view.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(view.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
|
|
|
- locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION_ACCURACY_TIME, GM.LOCATION_ACCURACY_SPACE, this);
|
|
|
+ locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
|
|
|
onLocationChanged(locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER));
|
|
|
}
|
|
|
|
|
|
@@ -165,7 +165,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
- SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
+ SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
Calendar calendarEnd;
|
|
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
|
|
|
@@ -226,7 +226,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
tvRowPlace.setText(cursorNow.getString(6));
|
|
|
|
|
|
//Set icon
|
|
|
- if (gm == GM.SECTION_LABLANCA_GM_SCHEDULE) {
|
|
|
+ if (gm == GM.SECTION.GM_SCHEDULE) {
|
|
|
ImageView pinPoint = (ImageView) entry.findViewById(R.id.iv_row_home_schedule_pinpoint);
|
|
|
pinPoint.setImageResource(getResources().getIdentifier("com.ivalentin.gm:drawable/pinpoint_gm", null, null));
|
|
|
}
|
|
|
@@ -270,7 +270,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
tvRowPlace.setText(cursorNext.getString(6));
|
|
|
|
|
|
//Set icon
|
|
|
- if (gm == GM.SECTION_LABLANCA_GM_SCHEDULE) {
|
|
|
+ if (gm == GM.SECTION.GM_SCHEDULE) {
|
|
|
ImageView pinPoint = (ImageView) entry.findViewById(R.id.iv_row_home_schedule_pinpoint);
|
|
|
pinPoint.setImageResource(getResources().getIdentifier("com.ivalentin.gm:drawable/pinpoint_gm", null, null));
|
|
|
}
|
|
|
@@ -293,7 +293,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
section.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA_GM_SCHEDULE);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.GM_SCHEDULE);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -301,7 +301,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
section.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA_SCHEDULE);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.SCHEDULE);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -429,12 +429,12 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
llSection.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.LABLANCA);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//Get data from the database of the future activities
|
|
|
- SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
+ SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
int year = Calendar.getInstance().get(Calendar.YEAR);
|
|
|
String lang = GM.getLang();
|
|
|
Cursor cursor = db.rawQuery("SELECT text_" + lang + ", img FROM festival WHERE year = " + year + ";", null);
|
|
|
@@ -475,7 +475,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
File fpath;
|
|
|
fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
|
|
|
fpath.mkdirs();
|
|
|
- new DownloadImage(GM.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, ivImage, GM.IMG_PREVIEW).execute();
|
|
|
+ new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, ivImage, GM.IMG.SIZE.PREVIEW).execute();
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
@@ -497,8 +497,8 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
*/
|
|
|
private boolean setUpLocation(Location location, View view) {
|
|
|
SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
|
|
|
- //Do this from db
|
|
|
- if (!preferences.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
|
|
|
+ //TODO Do this from db
|
|
|
+ /*if (!preferences.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
|
|
|
try {
|
|
|
Double lat = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LATITUDE, 0));
|
|
|
Double lon = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LONGITUDE, 0));
|
|
|
@@ -516,7 +516,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
Log.e("Location", "Couldn't set up home location section: " + ex.toString());
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -537,7 +537,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
llGallery.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_GALLERY);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.GALLERY);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -549,7 +549,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
ivPhoto[3] = (ImageView) view.findViewById(R.id.iv_home_section_gallery_3);
|
|
|
|
|
|
//Get data from the database of the future activities
|
|
|
- SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
+ SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
Cursor cursor = db.rawQuery("SELECT id, album, file, uploaded FROM photo, photo_album WHERE id = photo ORDER BY uploaded DESC LIMIT 4;", null);
|
|
|
|
|
|
while (cursor.moveToNext()) {
|
|
|
@@ -572,7 +572,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
File fpath;
|
|
|
fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
|
|
|
fpath.mkdirs();
|
|
|
- new DownloadImage(GM.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivPhoto[counter], GM.IMG_PREVIEW).execute();
|
|
|
+ new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivPhoto[counter], GM.IMG.SIZE.PREVIEW).execute();
|
|
|
}
|
|
|
|
|
|
//Set listeners for images
|
|
|
@@ -623,7 +623,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
String lang = GM.getLang();
|
|
|
|
|
|
//Get data from the database of the future activities
|
|
|
- SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
+ SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + lang + " AS title, text_" + lang + " AS text, price, after_" + lang + " AS after FROM activity WHERE date < date('now') ORDER BY date DESC LIMIT 2;", null);
|
|
|
|
|
|
//Show section
|
|
|
@@ -634,7 +634,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
llActivitiesPast.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_ACTIVITIES);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.ACTIVITIES);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -651,7 +651,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
|
|
|
//Set margins
|
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
- layoutParams.setMargins(GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN);
|
|
|
+ layoutParams.setMargins(GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN);
|
|
|
entry.setLayoutParams(layoutParams);
|
|
|
|
|
|
//Set title
|
|
|
@@ -705,7 +705,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
File fpath;
|
|
|
fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
|
|
|
fpath.mkdirs();
|
|
|
- new DownloadImage(GM.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG_MINIATURE).execute();
|
|
|
+ new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
|
|
|
}
|
|
|
}
|
|
|
cursorImage.close();
|
|
|
@@ -764,7 +764,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
LayoutInflater factory = LayoutInflater.from(getActivity());
|
|
|
|
|
|
//Get data from the database of the future activities
|
|
|
- SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
+ SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + lang + " AS title, text_" + lang + " AS text, price FROM activity WHERE date >= date('now') ORDER BY date LIMIT 2;", null);
|
|
|
|
|
|
//If there are future activities...
|
|
|
@@ -778,7 +778,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
llActivitiesFuture.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_ACTIVITIES);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.ACTIVITIES);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -789,7 +789,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
|
|
|
//Set margins
|
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
- layoutParams.setMargins(GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN);
|
|
|
+ layoutParams.setMargins(GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN);
|
|
|
entry.setLayoutParams(layoutParams);
|
|
|
|
|
|
//Set title
|
|
|
@@ -836,7 +836,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
File fpath;
|
|
|
fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
|
|
|
fpath.mkdirs();
|
|
|
- new DownloadImage(GM.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG_MINIATURE).execute();
|
|
|
+ new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -891,7 +891,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
llBlog.setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((MainActivity) getActivity()).loadSection(GM.SECTION_BLOG);
|
|
|
+ ((MainActivity) getActivity()).loadSection(GM.SECTION.BLOG);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -902,7 +902,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
//An inflater
|
|
|
LayoutInflater factory = LayoutInflater.from(getActivity());
|
|
|
|
|
|
- SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
+ SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
|
|
|
final Cursor cursor;
|
|
|
|
|
|
//Get data from the database
|
|
|
@@ -916,7 +916,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
|
|
|
//Set margins
|
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
- layoutParams.setMargins(GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN);
|
|
|
+ layoutParams.setMargins(GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN);
|
|
|
entry.setLayoutParams(layoutParams);
|
|
|
|
|
|
//Set title
|
|
|
@@ -955,7 +955,7 @@ public class HomeLayout extends Fragment implements LocationListener {
|
|
|
File fpath;
|
|
|
fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
|
|
|
fpath.mkdirs();
|
|
|
- new DownloadImage(GM.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG_MINIATURE).execute();
|
|
|
+ new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
|
|
|
}
|
|
|
}
|
|
|
|