Commit 7514fbaf authored by Eryk Leniart's avatar Eryk Leniart

api list + map (all just started)

parent 8f2cb67a
...@@ -43,4 +43,20 @@ ...@@ -43,4 +43,20 @@
<component name="ProjectType"> <component name="ProjectType">
<option name="id" value="Android" /> <option name="id" value="Android" />
</component> </component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project> </project>
\ No newline at end of file
...@@ -2,6 +2,5 @@ ...@@ -2,6 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="" /> <mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<option name="ALLOW_USER_CONFIGURATION" value="false" /> <option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/debug/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration> </configuration>
</facet> </facet>
...@@ -73,8 +73,37 @@ ...@@ -73,8 +73,37 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/cn.pedant.sweetalert/library/1.3/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/cn.pedant.sweetalert/library/1.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.medyo/fancybuttons/1.5/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.medyo/fancybuttons/1.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-appinvite/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-appstate/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-auth/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-cast/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-drive/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-fitness/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-games/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-identity/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-measurement/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-nearby/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-panorama/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-safetynet/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-vision/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-wallet/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services/8.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.pnikosis/materialish-progress/1.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.pnikosis/materialish-progress/1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
...@@ -93,13 +122,42 @@ ...@@ -93,13 +122,42 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="library-1.3" level="project" /> <orderEntry type="library" exported="" name="mediarouter-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" /> <orderEntry type="library" exported="" name="play-services-location-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-plus-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-appindexing-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-auth-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-8.3.0" level="project" />
<orderEntry type="library" exported="" name="fancybuttons-1.5" level="project" /> <orderEntry type="library" exported="" name="fancybuttons-1.5" level="project" />
<orderEntry type="library" exported="" name="play-services-base-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-measurement-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-identity-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-vision-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-wallet-8.3.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-analytics-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-drive-8.3.0" level="project" />
<orderEntry type="library" exported="" name="httpclient-4.3.6" level="project" /> <orderEntry type="library" exported="" name="httpclient-4.3.6" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" /> <orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.9" level="project" /> <orderEntry type="library" exported="" name="play-services-cast-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-appinvite-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-appstate-8.3.0" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-games-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-safetynet-8.3.0" level="project" />
<orderEntry type="library" exported="" name="materialish-progress-1.0" level="project" /> <orderEntry type="library" exported="" name="materialish-progress-1.0" level="project" />
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />
<orderEntry type="library" exported="" name="library-1.3" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-nearby-8.3.0" level="project" />
<orderEntry type="library" exported="" name="play-services-fitness-8.3.0" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.9" level="project" />
<orderEntry type="library" exported="" name="play-services-panorama-8.3.0" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -6,7 +6,7 @@ android { ...@@ -6,7 +6,7 @@ android {
defaultConfig { defaultConfig {
applicationId "anotherlineofcode.com.jointhecityapp" applicationId "anotherlineofcode.com.jointhecityapp"
minSdkVersion 15 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
...@@ -25,4 +25,9 @@ dependencies { ...@@ -25,4 +25,9 @@ dependencies {
compile 'com.loopj.android:android-async-http:1.4.9' compile 'com.loopj.android:android-async-http:1.4.9'
compile 'cn.pedant.sweetalert:library:1.3' compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.github.medyo:fancybuttons:1.5@aar' compile 'com.github.medyo:fancybuttons:1.5@aar'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
} }
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=25:22:9C:09:F0:8F:2C:87:22:4E:8E:75:BA:C7:3B:C4:C0:D5:4E:AF%3Banotherlineofcode.com.jointhecityapp
You can also add your credentials to an existing key, using this line:
25:22:9C:09:F0:8F:2C:87:22:4E:8E:75:BA:C7:3B:C4:C0:D5:4E:AF;anotherlineofcode.com.jointhecityapp
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
AIzaSyAKbhGUdcjjDMiPW4OW_zAlE85GgaOQ7p8
</string>
</resources>
...@@ -5,11 +5,18 @@ ...@@ -5,11 +5,18 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme" android:theme="@style/Theme.AppCompat.Light"
tools:replace="android:icon" > tools:replace="android:icon" >
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
...@@ -25,6 +32,34 @@ ...@@ -25,6 +32,34 @@
android:name=".LoginAndRegistrationActivity" android:name=".LoginAndRegistrationActivity"
android:label="@string/title_activity_login_and_registration" > android:label="@string/title_activity_login_and_registration" >
</activity> </activity>
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="anotherlineofcode.com.jointhecityapp.MainActivity" />
</activity>
<activity
android:name=".FriendsActivity"
android:label="@string/title_activity_friends"
android:parentActivityName=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="anotherlineofcode.com.jointhecityapp.MainActivity" />
</activity>
</application> </application>
</manifest> </manifest>
package anotherlineofcode.com.jointhecityapp;
public class ApiObject {
private String name;
private int photo;
ApiObject (String name, int photo){
this.name = name;
this.photo = photo;
}
public String getName() {
return name;
}
public int getPhoto() {
return photo;
}
}
package anotherlineofcode.com.jointhecityapp;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class FriendsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_friends);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
package anotherlineofcode.com.jointhecityapp; package anotherlineofcode.com.jointhecityapp;
import android.app.FragmentTransaction;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.google.android.gms.maps.MapFragment;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
public final static int LOGIN_REQUEST = 1; public final static int LOGIN_REQUEST = 1;
private MapFragment mMapFragment;
private SharedPreferences sharedPreferences;
private GridLayoutManager lLayout;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
getSupportActionBar().setDisplayShowTitleEnabled(false);
sharedPreferences = getSharedPreferences("JoinTheCityPreferences", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt("lat",50);
editor.putInt("lng", 19);
editor.commit();
// Check if user is logged in, if not open login activity // Check if user is logged in, if not open login activity
if (!isLoggedIn()) { if (!isLoggedIn()) {
Intent intent = new Intent(this, LoginAndRegistrationActivity.class); Intent intent = new Intent(this, LoginAndRegistrationActivity.class);
startActivityForResult(intent, LOGIN_REQUEST); startActivityForResult(intent, LOGIN_REQUEST);
} }
if (savedInstanceState == null) {
// Add header and main menu fragments
getFragmentManager().beginTransaction().add(R.id.content, new MainContentFragment(), "MainContentFragment").commit();
}
List<ApiObject> rowListItem = getAllItemList();
lLayout = new GridLayoutManager(MainActivity.this, 4);
RecyclerView rView = (RecyclerView)findViewById(R.id.recycler_view);
rView.setHasFixedSize(true);
rView.setLayoutManager(lLayout);
RecyclerViewAdapter rcAdapter = new RecyclerViewAdapter(MainActivity.this, rowListItem);
rView.setAdapter(rcAdapter);
}
private List<ApiObject> getAllItemList(){
List<ApiObject> allItems = new ArrayList<ApiObject>();
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
allItems.add(new ApiObject("Kina", R.drawable.cinema512));
allItems.add(new ApiObject("Wypadki drogowe", R.drawable.invert512));
return allItems;
} }
@Override @Override
...@@ -36,7 +96,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -36,7 +96,6 @@ public class MainActivity extends AppCompatActivity {
} }
private boolean isLoggedIn() { private boolean isLoggedIn() {
SharedPreferences sharedPreferences = getSharedPreferences("JoinTheCityPreferences", Context.MODE_PRIVATE);
return !sharedPreferences.getString("token", "").isEmpty(); return !sharedPreferences.getString("token", "").isEmpty();
} }
...@@ -54,8 +113,15 @@ public class MainActivity extends AppCompatActivity { ...@@ -54,8 +113,15 @@ public class MainActivity extends AppCompatActivity {
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); int id = item.getItemId();
//noinspection SimplifiableIfStatement if (id == R.id.map_view) {
if (id == R.id.action_settings) { Intent intent = new Intent(this, MapsActivity.class);
startActivity(intent);
return true;
}
if (id == R.id.friends) {
Intent intent = new Intent(this, FriendsActivity.class);
startActivity(intent);
return true; return true;
} }
......
package anotherlineofcode.com.jointhecityapp;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
*/
public class MainContentFragment extends Fragment {
public MainContentFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_main_content, container, false);
return view;
}
}
package anotherlineofcode.com.jointhecityapp;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private SharedPreferences sharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
sharedPreferences = getSharedPreferences("JoinTheCityPreferences", Context.MODE_PRIVATE);
int lat = sharedPreferences.getInt("lat", 0);
int lng = sharedPreferences.getInt("lng", 0);
LatLng camera = new LatLng(lat, lng);
// // Add a marker in Sydney and move the camera
// LatLng sydney = new LatLng(lat, lng);
// mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(camera));
}
}
package anotherlineofcode.com.jointhecityapp;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
private List<ApiObject> itemList;
private Context context;
public RecyclerViewAdapter(Context context, List<ApiObject> itemList) {
this.itemList = itemList;
this.context = context;
}
@Override
public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_list, null);
RecyclerViewHolders rcv = new RecyclerViewHolders(layoutView);
return rcv;
}
@Override
public void onBindViewHolder(RecyclerViewHolders holder, int position) {
holder.countryName.setText(itemList.get(position).getName());
holder.countryPhoto.setImageResource(itemList.get(position).getPhoto());
}
@Override
public int getItemCount() {
return this.itemList.size();
}
}
package anotherlineofcode.com.jointhecityapp;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class RecyclerViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView countryName;
public ImageView countryPhoto;
public RecyclerViewHolders(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
countryName = (TextView)itemView.findViewById(R.id.country_name);
countryPhoto = (ImageView)itemView.findViewById(R.id.country_photo);
}
@Override
public void onClick(View view) {
Toast.makeText(view.getContext(), "Clicked position = " + getPosition(), Toast.LENGTH_SHORT).show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context="anotherlineofcode.com.jointhecityapp.FriendsActivity">
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
android:layout_width="match_parent" android:theme="@style/AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_friends" />
<android.support.design.widget.FloatingActionButton android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content" <android.support.v7.widget.RecyclerView
android:layout_height="wrap_content" /> android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</RelativeLayout> <FrameLayout android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</FrameLayout>
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/map"
tools:context="anotherlineofcode.com.jointhecityapp.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="80dp"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="8dp"
android:layout_marginBottom="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/country_photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:padding="5dp"
android:contentDescription="@string/action_settings"
android:src="@drawable/common_google_signin_btn_icon_dark_normal"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/country_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:text="Description"
android:gravity="center"
android:layout_below="@+id/country_photo"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:layout_alignParentBottom="true"
android:background="@color/common_plus_signin_btn_text_dark_default"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_friends"
tools:context="anotherlineofcode.com.jointhecityapp.FriendsActivity">
</RelativeLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="anotherlineofcode.com.jointhecityapp.MainContentFragment">
<!-- TODO: Update blank fragment layout -->
<TextView android:layout_width="match_parent" android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="anotherlineofcode.com.jointhecityapp.MapFragment">
<!-- TODO: Update blank fragment layout -->
<TextView android:layout_width="match_parent" android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" /> <item
android:id="@+id/api_list"
android:icon="@drawable/ic_launcher"
android:title="Lista API"
app:showAsAction="always"/>
<item
android:id="@+id/friends"
android:icon="@drawable/ic_launcher"
android:title="Znajomi"
app:showAsAction="always"/>
<item
android:id="@+id/messages"
android:icon="@drawable/ic_launcher"
android:title="Wiadomości"
app:showAsAction="always"/>
<item
android:id="@+id/map_view"
android:icon="@drawable/ic_launcher"
android:title="Mapa"
app:showAsAction="always"/>
<item
android:id="@+id/logo"
android:icon="@drawable/ic_launcher"
android:title="Logo"
app:showAsAction="always"/>
</menu> </menu>
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
<!-- Default screen margins, per the Android Design guidelines. --> <!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources> </resources>
...@@ -9,4 +9,9 @@ ...@@ -9,4 +9,9 @@
<string name="api_url">http://jointhecity.telemabk.pl/</string> <string name="api_url">http://jointhecity.telemabk.pl/</string>
<string name="action_sign_in">Zaloguj się</string> <string name="action_sign_in">Zaloguj się</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="title_activity_maps">Map</string>
<string name="title_activity_friends">FriendsActivity</string>
</resources> </resources>
...@@ -4,5 +4,7 @@ ...@@ -4,5 +4,7 @@
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </style>
<style name="AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources> </resources>
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=25:22:9C:09:F0:8F:2C:87:22:4E:8E:75:BA:C7:3B:C4:C0:D5:4E:AF%3Banotherlineofcode.com.jointhecityapp
You can also add your credentials to an existing key, using this line:
25:22:9C:09:F0:8F:2C:87:22:4E:8E:75:BA:C7:3B:C4:C0:D5:4E:AF;anotherlineofcode.com.jointhecityapp
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">
YOUR_KEY_HERE
</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment