Skip to content

Commit

Permalink
Added Campus Map
Browse files Browse the repository at this point in the history
  • Loading branch information
Saurabh Joshi committed Jul 1, 2014
1 parent c474a16 commit 9cbf490
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 5 deletions.
Binary file added vitinfo2/src/main/assets/vit_map.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions vitinfo2/src/main/java/com/karthikb351/vitinfo2/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.karthikb351.vitinfo2.fragments.FriendsFragments.NFCFragment;
import com.karthikb351.vitinfo2.fragments.FriendsFragments.QRCodeFragment;
import com.karthikb351.vitinfo2.fragments.FullTimeTableFragment;
import com.karthikb351.vitinfo2.fragments.MapFragment;
import com.karthikb351.vitinfo2.fragments.NotificationFragment;
import com.karthikb351.vitinfo2.fragments.NowFragment;
import com.karthikb351.vitinfo2.fragments.SettingsFragment;
Expand All @@ -57,9 +58,9 @@
public class Home extends ActionBarActivity {

//Initialize drawer tabs
private String[] titles = { "Today", "Courses", "Timetable","Friends", "Notifications", "Settings"};
private String[] subtitle = { "Realtime Overview", "Attendance|Marks|More", "Day|Week", "Check their status","Latest news", "Change credentials"};
private int[] imgs = new int[]{ R.drawable.ic_action_about, R.drawable.ic_action_sort_by_size, R.drawable.ic_action_event, R.drawable.ic_action_group, R.drawable.ic_action_unread, R.drawable.ic_action_settings};
private String[] titles = { "Today", "Courses", "Timetable","Friends", "Notifications", "Campus Map", "Settings"};
private String[] subtitle = { "Realtime Overview", "Attendance|Marks|More", "Day|Week", "Check their status","Latest news", "Find your way", "Change credentials"};
private int[] imgs = new int[]{ R.drawable.ic_action_about, R.drawable.ic_action_sort_by_size, R.drawable.ic_action_event, R.drawable.ic_action_group, R.drawable.ic_action_unread,R.drawable.ic_action_place, R.drawable.ic_action_settings};

//Drawer ListView
public DrawerLayout mDrawerLayout;
Expand Down Expand Up @@ -190,14 +191,16 @@ private class DrawerItemClickListener implements ListView.OnItemClickListener {
public void onItemClick(AdapterView parent, View view, int position, long id) {
// Highlight the selected item, update the title, and close the drawer
mDrawerList.setItemChecked(position, true);
if(position != 5)
if(position != 6)
setTitle(titles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
//Use Handler to avoid lag in the transaction
if(position == 4)
selectItem(9);
else if(position == 5)
else if(position == 6)
selectItem(4);
else if(position == 5)
selectItem(10);
else
selectItem(position);

Expand Down Expand Up @@ -277,6 +280,9 @@ public void selectItem_Async(int position) {
case 9:
fragment = new NotificationFragment();
break;
case 10:
fragment = new MapFragment();
break;
default:
fragment = new NowFragment();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.karthikb351.vitinfo2.fragments;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.karthikb351.vitinfo2.Home;
import com.karthikb351.vitinfo2.R;

/**
* Created by saurabh on 7/1/14.
*/
public class MapFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_map,container, false);
setHasOptionsMenu(true);

((Home) getActivity()).setSupportProgressBarIndeterminateVisibility(true);

WebView view = (WebView) v.findViewById(R.id.img_map);
view.setVisibility(View.GONE);


view.getSettings().setBuiltInZoomControls(true);

view.getSettings().setLoadWithOverviewMode(true);

view.setWebViewClient(new WebViewClient() {

@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
view.setVisibility(View.VISIBLE);
((Home) getActivity()).setSupportProgressBarIndeterminateVisibility(false);
}

@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
((Home) getActivity()).setSupportProgressBarIndeterminateVisibility(false);
}
});

view.loadUrl("file:///android_asset/vit_map.jpg");

return v;
}

@Override
public void onCreateOptionsMenu(
Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_fragment_map, menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle item selection
switch (item.getItemId()) {
case R.id.menu_gmaps:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://www.google.com/maps/place/Vellore+Institute+of+Technology/@12.971749,79.159694,17z/data=!3m1!4b1!4m2!3m1!1s0x3bad479f0ccbe067:0xfef222e5f36ecdeb"));
startActivity(intent);
break;
}
return true;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vitinfo2/src/main/res/drawable-mdpi/gmaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions vitinfo2/src/main/res/layout/fragment_map.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_margin="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView
android:id="@+id/img_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
12 changes: 12 additions & 0 deletions vitinfo2/src/main/res/menu/menu_fragment_map.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_gmaps"
android:icon="@drawable/gmaps"
android:title="Google Maps"
app:showAsAction = "always">
</item>

</menu>

0 comments on commit 9cbf490

Please sign in to comment.