Interface almost done!
This commit is contained in:
parent
d54aa3e2c1
commit
24e2c76bea
@ -1,10 +1,20 @@
|
|||||||
package fishrungames.bashgid;
|
package fishrungames.bashgid;
|
||||||
|
|
||||||
|
|
||||||
|
import it.sephiroth.android.library.widget.AdapterView.OnItemClickListener;
|
||||||
import it.sephiroth.android.library.widget.HListView;
|
import it.sephiroth.android.library.widget.HListView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.osmdroid.DefaultResourceProxyImpl;
|
||||||
|
import org.osmdroid.ResourceProxy;
|
||||||
|
import org.osmdroid.api.IMapController;
|
||||||
|
import org.osmdroid.util.GeoPoint;
|
||||||
|
import org.osmdroid.views.MapView;
|
||||||
|
|
||||||
|
import fishrungames.bashgid.OsmMapHolderFragment.CustomItemizedOverlay;
|
||||||
|
import fishrungames.bashgid.OsmMapHolderFragment.NoInteractionOverlay;
|
||||||
|
import fishrungames.bashgid.core.LocationHolder;
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
|
||||||
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
||||||
@ -21,12 +31,14 @@ import android.view.View.OnClickListener;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ArticleFragment extends Fragment
|
public class ArticleFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -258,21 +270,69 @@ public class ArticleFragment extends Fragment
|
|||||||
}
|
}
|
||||||
else if (getItemViewType(position) == 3)
|
else if (getItemViewType(position) == 3)
|
||||||
{
|
{
|
||||||
//TextView textView = (TextView) view.findViewById(R.id.textView);
|
double geoLat = articleLayout.get(position).geoLat;
|
||||||
|
double geoLon = articleLayout.get(position).geoLon;
|
||||||
|
|
||||||
//textView.setText(articleLayout.get(position).value);
|
MapView mapView = (MapView) view.findViewById(R.id.mapview);
|
||||||
|
|
||||||
|
mapView.setMaxZoomLevel(20);
|
||||||
|
mapView.setMinZoomLevel(4);
|
||||||
|
|
||||||
|
//mapView.setBuiltInZoomControls(true);
|
||||||
|
mapView.setMultiTouchControls(true);
|
||||||
|
|
||||||
|
|
||||||
|
IMapController mapController = mapView.getController();
|
||||||
|
|
||||||
|
|
||||||
|
GeoPoint markerPoint = new GeoPoint(geoLat, geoLon);
|
||||||
|
|
||||||
|
mapController.setZoom(16);
|
||||||
|
mapController.animateTo(markerPoint);
|
||||||
|
|
||||||
|
|
||||||
|
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
|
||||||
|
NoInteractionOverlay itemizedOverlay = new NoInteractionOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy);
|
||||||
|
|
||||||
|
itemizedOverlay.addOverlayItem(markerPoint);
|
||||||
|
|
||||||
|
mapView.getOverlays().add(itemizedOverlay);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (getItemViewType(position) == 4)
|
else if (getItemViewType(position) == 4)
|
||||||
{
|
{
|
||||||
//TextView textView = (TextView) view.findViewById(R.id.textView);
|
|
||||||
|
|
||||||
//textView.setText(articleLayout.get(position).value);
|
|
||||||
|
|
||||||
HListView hListView = (HListView) view.findViewById(R.id.hListView);
|
HListView hListView = (HListView) view.findViewById(R.id.hListView);
|
||||||
|
|
||||||
hListView.setAdapter(new MainPageHListViewAdapters.PhotoAlbumElementAdapter(getActivity(), article.albumArr.get(articleLayout.get(position).albumPos)));
|
hListView.setAdapter(new MainPageHListViewAdapters.PhotoAlbumElementAdapter(getActivity(), article.albumArr.get(articleLayout.get(position).albumPos)));
|
||||||
|
|
||||||
|
hListView.setOnItemClickListener(new OnItemClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(it.sephiroth.android.library.widget.AdapterView<?> parent, View view, int innerPosition, long id)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().SetLastArticleName(articleName);
|
||||||
|
|
||||||
|
String albumName = article.albumArr.get(articleLayout.get(position).albumPos).name;
|
||||||
|
|
||||||
|
MainActivity.getInstance().OpenPhotoScreen(albumName, innerPosition, MainActivity.TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
hListView.setOnItemClickListener(new OnItemClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().SetLastAlbumName(albumName);
|
||||||
|
MainActivity.getInstance().OpenPhotoScreen(albumName, position, MainActivity.TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});*/
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (getItemViewType(position) == 5)
|
else if (getItemViewType(position) == 5)
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,10 @@ import fishrungames.bashgid.core.ArticleManager;
|
|||||||
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
||||||
import fishrungames.bashgid.core.BookManager.BookRecord;
|
import fishrungames.bashgid.core.BookManager.BookRecord;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleFullData;
|
|
||||||
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
import fishrungames.bashgid.core.ArticleManager.ArticleShortData;
|
||||||
import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
|
import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
|
||||||
import fishrungames.bashgid.core.NewsDownloadTask;
|
import fishrungames.bashgid.core.NewsDownloadTask;
|
||||||
import fishrungames.bashgid.core.NewsManager.NewsRecord;
|
|
||||||
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
import fishrungames.bashgid.core.PhotoManager.PhotoRecordData;
|
||||||
import fishrungames.bashgid.core.VideoManager;
|
import fishrungames.bashgid.core.VideoManager;
|
||||||
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
import fishrungames.bashgid.core.VideoManager.VideoRecordData;
|
||||||
@ -29,12 +28,14 @@ import fishrungames.bashgid.core.db.JournalDataSource;
|
|||||||
import fishrungames.bashgid.core.db.NewsDataSource;
|
import fishrungames.bashgid.core.db.NewsDataSource;
|
||||||
import fishrungames.bashgid.core.db.PhotoDataSource;
|
import fishrungames.bashgid.core.db.PhotoDataSource;
|
||||||
import fishrungames.bashgid.core.db.VideoDataSource;
|
import fishrungames.bashgid.core.db.VideoDataSource;
|
||||||
|
|
||||||
import fishrungames.networkutils.ContextHolder;
|
import fishrungames.networkutils.ContextHolder;
|
||||||
import fishrungames.networkutils.ImageDownloadTask;
|
import fishrungames.networkutils.ImageDownloadTask;
|
||||||
import fishrungames.networkutils.ImageManager;
|
import fishrungames.networkutils.ImageManager;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -58,11 +59,19 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
public static final String TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT = "TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT";
|
public static final String TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT = "TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT";
|
||||||
public static final String TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT = "TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT";
|
public static final String TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT = "TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT";
|
||||||
|
|
||||||
|
public static final String TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT = "TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT";
|
||||||
|
public static final String TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT = "TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String TAG_TO_WELCOMEFRAGMENT = "WelcomeFragment";
|
public static final String TAG_TO_WELCOMEFRAGMENT = "WelcomeFragment";
|
||||||
public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
|
public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
|
||||||
public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
|
public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
|
||||||
public static final String TAG_TO_MAPFRAGMENT = "MapFragment";
|
public static final String TAG_TO_MAPFRAGMENT = "MapFragment";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String PREFS_MAIN = "PREFS_MAIN";
|
||||||
|
|
||||||
public static final int NEWS_DOWNLOADER_STATE_UPDATE = 10;
|
public static final int NEWS_DOWNLOADER_STATE_UPDATE = 10;
|
||||||
public static final int NEWS_DOWNLOADER_STATE_FINISHED = 11;
|
public static final int NEWS_DOWNLOADER_STATE_FINISHED = 11;
|
||||||
|
|
||||||
@ -208,8 +217,8 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
0,
|
0,
|
||||||
"Photos",
|
"Photos",
|
||||||
"Wow 2 photos",
|
"Wow 2 photos",
|
||||||
50,
|
54.779610,
|
||||||
50,
|
56.032101,
|
||||||
"http://www.yandex.ru/",
|
"http://www.yandex.ru/",
|
||||||
articleTestDate
|
articleTestDate
|
||||||
));
|
));
|
||||||
@ -479,7 +488,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
|
|
||||||
// getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
// getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||||
// new MapHolderFragment(), TAG_TO_MAINFRAGMENT).commit();
|
// new MapHolderFragment(), TAG_TO_MAINFRAGMENT).commit();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OsmMapHolderFragment(), TAG_TO_MAINFRAGMENT).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new OsmMapHolderFragment("news"), TAG_TO_MAINFRAGMENT).commit();
|
||||||
|
|
||||||
mNavigationDrawerFragment.EnableDrawer();
|
mNavigationDrawerFragment.EnableDrawer();
|
||||||
}
|
}
|
||||||
@ -511,6 +520,16 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
mNavigationDrawerFragment.EnableDrawer();
|
mNavigationDrawerFragment.EnableDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void OpenPhotoScreen(String albumName, int position, String tag)
|
||||||
|
{
|
||||||
|
ClearAllFragmentLinks();
|
||||||
|
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new PhotoFragment(albumName, position), tag).commit();
|
||||||
|
|
||||||
|
mNavigationDrawerFragment.EnableDrawer();
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenNewsRecordScreen(String articleName, String tag)
|
public void OpenNewsRecordScreen(String articleName, String tag)
|
||||||
{
|
{
|
||||||
// Xperimental -- addToBackStack provoke error "Class not found". Need
|
// Xperimental -- addToBackStack provoke error "Class not found". Need
|
||||||
@ -541,6 +560,7 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
mNavigationDrawerFragment.EnableDrawer();
|
mNavigationDrawerFragment.EnableDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OpenHtmlViewerScreen(String url)
|
public void OpenHtmlViewerScreen(String url)
|
||||||
{
|
{
|
||||||
ClearAllFragmentLinks();
|
ClearAllFragmentLinks();
|
||||||
@ -739,6 +759,18 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT) != null)
|
||||||
|
{
|
||||||
|
OpenPhotoAlbumScreen(GetLastAlbumName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_ARTICLEFRAGMENT_TO_PHOTOFRAGMENT) != null)
|
||||||
|
{
|
||||||
|
OpenArticleScreen(GetLastArticleName(), TAG_TO_MAINFRAGMENT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (getSupportFragmentManager().findFragmentByTag(TAG_TO_SEARCHFRAGMENT) != null)
|
if (getSupportFragmentManager().findFragmentByTag(TAG_TO_SEARCHFRAGMENT) != null)
|
||||||
{
|
{
|
||||||
OpenMainScreen();
|
OpenMainScreen();
|
||||||
@ -770,6 +802,36 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLastAlbumName(String lastAlbumName)
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putString("lastAlbumName", lastAlbumName);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetLastAlbumName()
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
return settings.getString("lastAlbumName", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLastArticleName(String lastArticleName)
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putString("lastArticleName", lastArticleName);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetLastArticleName()
|
||||||
|
{
|
||||||
|
SharedPreferences settings = MainActivity.getInstance().getSharedPreferences(PREFS_MAIN, 0);
|
||||||
|
return settings.getString("lastArticleName", "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
@ -783,4 +845,5 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
|||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,11 @@ public class NewsListFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
//Add position + 1, because first element of list is always title
|
||||||
|
if (position > 0)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().OpenArticleScreen(journal.articleArr.get(position - 1).name, MainActivity.TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,7 @@ package fishrungames.bashgid;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -13,6 +14,7 @@ import android.support.v4.app.Fragment;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
|
||||||
import org.osmdroid.DefaultResourceProxyImpl;
|
import org.osmdroid.DefaultResourceProxyImpl;
|
||||||
@ -27,14 +29,19 @@ import org.osmdroid.views.overlay.ItemizedOverlay;
|
|||||||
import org.osmdroid.views.overlay.OverlayItem;
|
import org.osmdroid.views.overlay.OverlayItem;
|
||||||
import org.osmdroid.views.overlay.OverlayItem.HotspotPlace;
|
import org.osmdroid.views.overlay.OverlayItem.HotspotPlace;
|
||||||
|
|
||||||
|
import fishrungames.bashgid.core.ArticleManager.ArticleRecordData;
|
||||||
import fishrungames.bashgid.core.LocationHolder;
|
import fishrungames.bashgid.core.LocationHolder;
|
||||||
|
import fishrungames.bashgid.core.JournalManager.JournalSemiFullData;
|
||||||
|
import fishrungames.networkutils.ImageManager;
|
||||||
|
|
||||||
|
|
||||||
public class OsmMapHolderFragment extends Fragment
|
public class OsmMapHolderFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
|
||||||
private class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem>{
|
public static class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem>{
|
||||||
|
|
||||||
private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();
|
private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();
|
||||||
|
private ArrayList<String> mArticles = new ArrayList<String>();
|
||||||
|
|
||||||
public CustomItemizedOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy) {
|
public CustomItemizedOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy) {
|
||||||
super(pDefaultMarker, pResourceProxy);
|
super(pDefaultMarker, pResourceProxy);
|
||||||
@ -51,22 +58,14 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOverlayItem(GeoPoint geoPoint){
|
public void addOverlayItem(GeoPoint geoPoint, String articleName, String title, String imageUrl){
|
||||||
|
|
||||||
|
OverlayItem item = new OverlayItem(title, imageUrl, geoPoint);
|
||||||
|
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
|
||||||
/*if(Preferences.DEBUG) Log.d("MapActivity", "Latitude: "+latitude+" Longitude: "+longitude);
|
|
||||||
MarkerDrawable drawable = new MarkerDrawable(MapActivity.this, bitmap);
|
|
||||||
OverlayItem item = new OverlayItem("a", "a", new GeoPoint((int)(latitude*1e6), (int)(longitude*1e6)));
|
|
||||||
item.setMarker(drawable);
|
|
||||||
item.setMarkerHotspot(HotspotPlace.CENTER);
|
|
||||||
mOverlayItems.add(item);*/
|
|
||||||
|
|
||||||
OverlayItem item = new OverlayItem("Title", "Lol, snippet", geoPoint);
|
|
||||||
item.setMarker(getResources().getDrawable(R.drawable.marker_default));
|
|
||||||
item.setMarkerHotspot(HotspotPlace.CENTER);
|
item.setMarkerHotspot(HotspotPlace.CENTER);
|
||||||
|
|
||||||
mOverlayItems.add(item);
|
mOverlayItems.add(item);
|
||||||
|
mArticles.add(articleName);
|
||||||
|
|
||||||
populateNow();
|
populateNow();
|
||||||
}
|
}
|
||||||
@ -83,21 +82,118 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onTap(int index) {
|
protected boolean onTap(final int index) {
|
||||||
OverlayItem item = mOverlayItems.get(index);
|
OverlayItem item = mOverlayItems.get(index);
|
||||||
AlertDialog.Builder dialog = new AlertDialog.Builder(OsmMapHolderFragment.this.getActivity());
|
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.getInstance());
|
||||||
dialog.setTitle(item.getTitle());
|
dialog.setTitle(item.getTitle());
|
||||||
dialog.setMessage(item.getSnippet());
|
//dialog.setMessage(item.getSnippet());
|
||||||
|
|
||||||
|
ImageView image = new ImageView(MainActivity.getInstance());
|
||||||
|
ImageManager.getInstance().ApplyImageToImageView(image, item.getSnippet());
|
||||||
|
//image.setImageResource(R.drawable.YOUR_IMAGE_ID);
|
||||||
|
|
||||||
|
dialog.setView(image);
|
||||||
|
|
||||||
|
|
||||||
|
dialog.setPositiveButton("Open", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
MainActivity.getInstance().OpenArticleScreen(mArticles.get(index), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class NoInteractionOverlay extends ItemizedOverlay<OverlayItem>{
|
||||||
|
private ArrayList<OverlayItem> mOverlayItems = new ArrayList<OverlayItem>();
|
||||||
|
|
||||||
|
public NoInteractionOverlay(Drawable pDefaultMarker, ResourceProxy pResourceProxy) {
|
||||||
|
super(pDefaultMarker, pResourceProxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected OverlayItem createItem(int pos) {
|
||||||
|
return mOverlayItems.get(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
if(mOverlayItems!=null) return mOverlayItems.size();
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addOverlayItem(GeoPoint geoPoint){
|
||||||
|
|
||||||
|
OverlayItem item = new OverlayItem("", "", geoPoint);
|
||||||
|
item.setMarker(MainActivity.getInstance().getResources().getDrawable(R.drawable.marker_default));
|
||||||
|
item.setMarkerHotspot(HotspotPlace.CENTER);
|
||||||
|
|
||||||
|
mOverlayItems.add(item);
|
||||||
|
|
||||||
|
populateNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populateNow(){
|
||||||
|
populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSnapToItem(int arg0, int arg1, Point arg2, IMapView arg3)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CustomItemizedOverlay itemizedOverlay;
|
CustomItemizedOverlay itemizedOverlay;
|
||||||
|
|
||||||
|
String journalName;
|
||||||
|
|
||||||
|
JournalSemiFullData journal;
|
||||||
|
|
||||||
|
|
||||||
|
public OsmMapHolderFragment()
|
||||||
|
{
|
||||||
|
journal = null;
|
||||||
|
journalName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public OsmMapHolderFragment(String journalName)
|
||||||
|
{
|
||||||
|
this.journalName = journalName;
|
||||||
|
RestoreJournal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(final Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putString("journalName", journalName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
journalName = savedInstanceState.getString("journalName");
|
||||||
|
RestoreJournal();
|
||||||
|
}
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_osm_map_page, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_osm_map_page, container, false);
|
||||||
|
|
||||||
MapView mapView = (MapView) rootView.findViewById(R.id.mapview);
|
MapView mapView = (MapView) rootView.findViewById(R.id.mapview);
|
||||||
@ -118,18 +214,37 @@ public class OsmMapHolderFragment extends Fragment
|
|||||||
mapController.animateTo(center);
|
mapController.animateTo(center);
|
||||||
|
|
||||||
|
|
||||||
GeoPoint markerPoint = new GeoPoint( LocationHolder.CONST_UFA_LATITUDE, LocationHolder.CONST_UFA_LONGITUDE);
|
|
||||||
|
|
||||||
|
|
||||||
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
|
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getActivity());
|
||||||
itemizedOverlay = new CustomItemizedOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy);
|
itemizedOverlay = new CustomItemizedOverlay(getResources().getDrawable(R.drawable.russia_icon), resourceProxy);
|
||||||
|
|
||||||
itemizedOverlay.addOverlayItem(markerPoint);
|
//JournalSemiFullData journal = MainActivity.getInstance().journalDataSource.GetJournalSemiFullData(journalName);
|
||||||
|
|
||||||
|
for (int i = 0; i < journal.articleArr.size(); i++)
|
||||||
|
//for (ArticleRecordData article : journal.articleArr)
|
||||||
|
{
|
||||||
|
ArticleRecordData article = journal.articleArr.get(i);
|
||||||
|
|
||||||
|
if (article.geoLat != 0 || article.geoLon != 0)
|
||||||
|
{
|
||||||
|
GeoPoint markerPoint = new GeoPoint(article.geoLat, article.geoLon);
|
||||||
|
|
||||||
|
|
||||||
|
itemizedOverlay.addOverlayItem(markerPoint, article.name, article.title, journal.previewImageArr.get(i));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//itemizedOverlay.addOverlayItem(markerPoint);
|
||||||
|
|
||||||
mapView.getOverlays().add(itemizedOverlay);
|
mapView.getOverlays().add(itemizedOverlay);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RestoreJournal()
|
||||||
|
{
|
||||||
|
journal = MainActivity.getInstance().journalDataSource.GetJournalSemiFullData(journalName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
import fishrungames.bashgid.core.AlbumManager;
|
import fishrungames.bashgid.core.AlbumManager;
|
||||||
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
||||||
@ -61,6 +63,18 @@ public class PhotoAlbumFragment extends Fragment
|
|||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
|
|
||||||
|
listView.setOnItemClickListener(new OnItemClickListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||||
|
{
|
||||||
|
MainActivity.getInstance().SetLastAlbumName(albumName);
|
||||||
|
MainActivity.getInstance().OpenPhotoScreen(albumName, position, MainActivity.TAG_FROM_PHOTOLISTFRAGMENT_TO_PHOTOFRAGMENT);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user