Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-08-04 01:22:36 +02:00
commit 2fe54027b3
5 changed files with 45 additions and 29 deletions

View file

@ -41,6 +41,7 @@ public class FavoritesActivity extends TabActivity {
// private static final String SELECTED_TRACK = "SELECTED_TRACK";
public static String TAB_PARAM = "TAB_PARAM";
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
private int tabSize;
@Override
public void onCreate(Bundle icicle) {
@ -49,6 +50,33 @@ public class FavoritesActivity extends TabActivity {
getSupportActionBar().setTitle(R.string.shared_string_my_places);
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();
boolean hasGpx = false;
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>();
mTabs.add(getTabIndicator(R.string.shared_string_my_favorites, FavoritesTreeFragment.class));
if (hasGpx) {
mTabs.add(getTabIndicator(R.string.shared_string_my_tracks, AvailableGPXFragment.class));
}
OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent());
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;
}
}
setViewPagerAdapter(mViewPager, mTabs);
mSlidingTabLayout.setViewPager(mViewPager);
mViewPager.setCurrentItem(tab);
// setupHomeButton();
return mTabs;
}
@Override
@ -94,7 +105,10 @@ public class FavoritesActivity extends TabActivity {
@Override
protected void onResume() {
super.onResume();
List<TabItem> mTabs = getTabItems();
if(mTabs.size() != tabSize ) {
setTabs(mTabs);
}
}
public OsmandApplication getMyApplication() {

View file

@ -39,7 +39,10 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
public List<OsmNotesPoint> getOsmbugsPoints() {
if (cache == null) {
return checkOsmbugsPoints();
SQLiteDatabase db = getReadableDatabase();
List<OsmNotesPoint> res = checkOsmbugsPoints(db);
db.close();
return res;
}
return cache;
}
@ -52,8 +55,8 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
+ OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + ")" + " VALUES (?, ?, ?, ?, ?, ?)",
new Object[] { p.getId(), p.getText(), p.getLatitude(), p.getLongitude(),
OsmPoint.stringAction.get(p.getAction()), p.getAuthor() }); //$NON-NLS-1$ //$NON-NLS-2$
checkOsmbugsPoints(db);
db.close();
checkOsmbugsPoints();
return true;
}
return false;
@ -64,15 +67,14 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
if (db != null) {
db.execSQL("DELETE FROM " + OSMBUGS_TABLE_NAME +
" WHERE " + OSMBUGS_COL_ID + " = ?", new Object[] { p.getId() }); //$NON-NLS-1$ //$NON-NLS-2$
checkOsmbugsPoints(db);
db.close();
checkOsmbugsPoints();
return true;
}
return false;
}
private List<OsmNotesPoint> checkOsmbugsPoints(){
SQLiteDatabase db = getReadableDatabase();
private List<OsmNotesPoint> checkOsmbugsPoints(SQLiteDatabase db){
List<OsmNotesPoint> cachedOsmbugsPoints = new ArrayList<OsmNotesPoint>();
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$
@ -92,9 +94,8 @@ public class OsmBugsDbHelper extends SQLiteOpenHelper {
} while (query.moveToNext());
}
query.close();
db.close();
cache = cachedOsmbugsPoints;
}
cache = cachedOsmbugsPoints;
return cachedOsmbugsPoints;
}

View file

@ -77,7 +77,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
public OsmBugsLayer(MapActivity activity, OsmEditingPlugin plugin){
this.activity = activity;
this.plugin = plugin;
local = new OsmBugsLocalUtil(activity);
local = new OsmBugsLocalUtil(activity, plugin.getDBBug());
remote = new OsmBugsRemoteUtil(activity.getMyApplication());
}

View file

@ -12,9 +12,9 @@ public class OsmBugsLocalUtil implements OsmBugsUtil {
private final Context ctx;
private final OsmBugsDbHelper db;
public OsmBugsLocalUtil(Context uiContext) {
public OsmBugsLocalUtil(Context uiContext, OsmBugsDbHelper db) {
this.ctx = uiContext;
this.db = new OsmBugsDbHelper(ctx);
this.db = db;
}
@Override

View file

@ -371,6 +371,7 @@ public class OsmEditsFragment extends OsmAndListFragment {
public OsmEditsAdapter(List<OsmPoint> points) {
super(getActivity(), net.osmand.plus.R.layout.note, points);
dataPoints = points;
}
public void setNewList(List<OsmPoint> dp) {