Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2fe54027b3
5 changed files with 45 additions and 29 deletions
|
@ -41,6 +41,7 @@ public class FavoritesActivity extends TabActivity {
|
||||||
// private static final String SELECTED_TRACK = "SELECTED_TRACK";
|
// private static final String SELECTED_TRACK = "SELECTED_TRACK";
|
||||||
public static String TAB_PARAM = "TAB_PARAM";
|
public static String TAB_PARAM = "TAB_PARAM";
|
||||||
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||||
|
private int tabSize;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
|
@ -49,6 +50,33 @@ public class FavoritesActivity extends TabActivity {
|
||||||
getSupportActionBar().setTitle(R.string.shared_string_my_places);
|
getSupportActionBar().setTitle(R.string.shared_string_my_places);
|
||||||
getSupportActionBar().setElevation(0);
|
getSupportActionBar().setElevation(0);
|
||||||
|
|
||||||
|
|
||||||
|
setContentView(R.layout.tab_content);
|
||||||
|
List<TabItem> mTabs = getTabItems();
|
||||||
|
setTabs(mTabs);
|
||||||
|
// setupHomeButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void setTabs(List<TabItem> mTabs) {
|
||||||
|
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
||||||
|
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
|
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
|
Integer tabId = settings.FAVORITES_TAB.get();
|
||||||
|
int tab = 0;
|
||||||
|
for(int i = 0; i < mTabs.size(); i++) {
|
||||||
|
if(mTabs.get(i).resId == tabId) {
|
||||||
|
tab = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tabSize = mTabs.size();
|
||||||
|
setViewPagerAdapter(mViewPager, mTabs);
|
||||||
|
mSlidingTabLayout.setViewPager(mViewPager);
|
||||||
|
mViewPager.setCurrentItem(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TabItem> getTabItems() {
|
||||||
File[] lf = ((OsmandApplication) getApplication()).getAppPath(TRACKS).listFiles();
|
File[] lf = ((OsmandApplication) getApplication()).getAppPath(TRACKS).listFiles();
|
||||||
boolean hasGpx = false;
|
boolean hasGpx = false;
|
||||||
if (lf != null) {
|
if (lf != null) {
|
||||||
|
@ -60,30 +88,13 @@ public class FavoritesActivity extends TabActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setContentView(R.layout.tab_content);
|
|
||||||
|
|
||||||
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
|
||||||
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
|
||||||
|
|
||||||
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
|
|
||||||
|
|
||||||
List<TabItem> mTabs = new ArrayList<TabItem>();
|
List<TabItem> mTabs = new ArrayList<TabItem>();
|
||||||
mTabs.add(getTabIndicator(R.string.shared_string_my_favorites, FavoritesTreeFragment.class));
|
mTabs.add(getTabIndicator(R.string.shared_string_my_favorites, FavoritesTreeFragment.class));
|
||||||
if (hasGpx) {
|
if (hasGpx) {
|
||||||
mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class));
|
mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class));
|
||||||
}
|
}
|
||||||
OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent());
|
OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent());
|
||||||
Integer tabId = settings.FAVORITES_TAB.get();
|
return mTabs;
|
||||||
int tab = 0;
|
|
||||||
for(int i = 0; i < mTabs.size(); i++) {
|
|
||||||
if(mTabs.get(i).resId == tabId) {
|
|
||||||
tab = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setViewPagerAdapter(mViewPager, mTabs);
|
|
||||||
mSlidingTabLayout.setViewPager(mViewPager);
|
|
||||||
mViewPager.setCurrentItem(tab);
|
|
||||||
// setupHomeButton();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,7 +105,10 @@ public class FavoritesActivity extends TabActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
List<TabItem> mTabs = getTabItems();
|
||||||
|
if(mTabs.size() != tabSize ) {
|
||||||
|
setTabs(mTabs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandApplication getMyApplication() {
|
public OsmandApplication getMyApplication() {
|
||||||
|
|
|
@ -39,7 +39,10 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public List<OsmNotesPoint> getOsmbugsPoints() {
|
public List<OsmNotesPoint> getOsmbugsPoints() {
|
||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
return checkOsmbugsPoints();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
List<OsmNotesPoint> res = checkOsmbugsPoints(db);
|
||||||
|
db.close();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +55,8 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
+ OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + ")" + " VALUES (?, ?, ?, ?, ?, ?)",
|
+ OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + ")" + " VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
new Object[] { p.getId(), p.getText(), p.getLatitude(), p.getLongitude(),
|
new Object[] { p.getId(), p.getText(), p.getLatitude(), p.getLongitude(),
|
||||||
OsmPoint.stringAction.get(p.getAction()), p.getAuthor() }); //$NON-NLS-1$ //$NON-NLS-2$
|
OsmPoint.stringAction.get(p.getAction()), p.getAuthor() }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
checkOsmbugsPoints(db);
|
||||||
db.close();
|
db.close();
|
||||||
checkOsmbugsPoints();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -64,15 +67,14 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
db.execSQL("DELETE FROM " + OSMBUGS_TABLE_NAME +
|
db.execSQL("DELETE FROM " + OSMBUGS_TABLE_NAME +
|
||||||
" WHERE " + OSMBUGS_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
" WHERE " + OSMBUGS_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
checkOsmbugsPoints(db);
|
||||||
db.close();
|
db.close();
|
||||||
checkOsmbugsPoints();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OsmNotesPoint> checkOsmbugsPoints(){
|
private List<OsmNotesPoint> checkOsmbugsPoints(SQLiteDatabase db){
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
|
||||||
List<OsmNotesPoint> cachedOsmbugsPoints = new ArrayList<OsmNotesPoint>();
|
List<OsmNotesPoint> cachedOsmbugsPoints = new ArrayList<OsmNotesPoint>();
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
Cursor query = db.rawQuery("SELECT " + OSMBUGS_COL_ID + ", " + OSMBUGS_COL_TEXT + ", " + OSMBUGS_COL_LAT + "," + OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
Cursor query = db.rawQuery("SELECT " + OSMBUGS_COL_ID + ", " + OSMBUGS_COL_TEXT + ", " + OSMBUGS_COL_LAT + "," + OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
@ -92,9 +94,8 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
|
||||||
} while (query.moveToNext());
|
} while (query.moveToNext());
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
db.close();
|
cache = cachedOsmbugsPoints;
|
||||||
}
|
}
|
||||||
cache = cachedOsmbugsPoints;
|
|
||||||
return cachedOsmbugsPoints;
|
return cachedOsmbugsPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
||||||
public OsmBugsLayer(MapActivity activity, OsmEditingPlugin plugin){
|
public OsmBugsLayer(MapActivity activity, OsmEditingPlugin plugin){
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
local = new OsmBugsLocalUtil(activity);
|
local = new OsmBugsLocalUtil(activity, plugin.getDBBug());
|
||||||
remote = new OsmBugsRemoteUtil(activity.getMyApplication());
|
remote = new OsmBugsRemoteUtil(activity.getMyApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ public class OsmBugsLocalUtil implements OsmBugsUtil {
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
private final OsmBugsDbHelper db;
|
private final OsmBugsDbHelper db;
|
||||||
|
|
||||||
public OsmBugsLocalUtil(Context uiContext) {
|
public OsmBugsLocalUtil(Context uiContext, OsmBugsDbHelper db) {
|
||||||
this.ctx = uiContext;
|
this.ctx = uiContext;
|
||||||
this.db = new OsmBugsDbHelper(ctx);
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -371,6 +371,7 @@ public class OsmEditsFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
public OsmEditsAdapter(List<OsmPoint> points) {
|
public OsmEditsAdapter(List<OsmPoint> points) {
|
||||||
super(getActivity(), net.osmand.plus.R.layout.note, points);
|
super(getActivity(), net.osmand.plus.R.layout.note, points);
|
||||||
|
dataPoints = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewList(List<OsmPoint> dp) {
|
public void setNewList(List<OsmPoint> dp) {
|
||||||
|
|
Loading…
Reference in a new issue