Skip to content

Commit 5617cfb

Browse files
author
Andrew Sosa
committed
icon stuff and maps buillshit
1 parent 5fdb34d commit 5617cfb

11 files changed

Lines changed: 158 additions & 38 deletions

File tree

mobile/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<application
1919
android:name=".HackFSU"
2020
android:allowBackup="true"
21-
android:icon="@mipmap/hackfsu_2016"
21+
android:icon="@mipmap/ic_launcher"
2222
android:label="@string/app_name"
2323
android:theme="@style/AppTheme">
2424
<activity

mobile/src/main/java/com/hackfsu/hackfsu_android/HackFSU.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ public class HackFSU extends Application {
1717
@Override
1818
public void onCreate() {
1919
super.onCreate();
20+
2021
ParseObject.registerSubclass(ScheduleFragment.ScheduleItem.class);
2122
ParseObject.registerSubclass(ScheduleFragment.ScheduleDivider.class);
2223
ParseObject.registerSubclass(UpdateFragment.UpdateItem.class);
2324
ParseObject.registerSubclass(SponsorsFragment.Sponsor.class);
25+
ParseObject.registerSubclass(MapsFragment.MapItem.class);
2426
ParseObject.registerSubclass(FeedFragment.CountdownItem.class);
25-
//Parse.enableLocalDatastore(this);
27+
2628
Parse.initialize(this, "7MgItVIkvSmADkIdIVPmEbIOOZQ84ilW224wXsgS", "hHoLbbe3SWIzt6JiXaNY5gdPQ47QBGH6AlbHHTih");
2729
ParseInstallation.getCurrentInstallation().saveInBackground();
30+
2831
ParsePush.subscribeInBackground("announcements");
2932
}
3033
}
Lines changed: 135 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,96 @@
11
package com.hackfsu.hackfsu_android;
22

3-
43
import android.content.Context;
54
import android.os.Bundle;
6-
import android.support.design.widget.TabLayout;
7-
import android.support.v4.app.Fragment;
8-
import android.support.v4.view.ViewPager;
5+
import android.support.design.widget.AppBarLayout;
6+
import android.support.v7.widget.LinearLayoutManager;
7+
import android.support.v7.widget.RecyclerView;
98
import android.support.v7.widget.Toolbar;
9+
import android.util.Log;
1010
import android.view.LayoutInflater;
1111
import android.view.View;
1212
import android.view.ViewGroup;
13+
import android.widget.TextView;
1314

15+
import com.parse.FindCallback;
16+
import com.parse.GetDataCallback;
17+
import com.parse.ParseClassName;
18+
import com.parse.ParseException;
19+
import com.parse.ParseFile;
20+
import com.parse.ParseImageView;
21+
import com.parse.ParseObject;
22+
import com.parse.ParseQuery;
23+
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
1424

15-
/**
16-
* A simple {@link Fragment} subclass.
17-
*/
18-
public class MapsFragment extends BaseFragment {
25+
import java.util.ArrayList;
26+
import java.util.List;
1927

20-
private BaseFragment.OnFragmentInteractionListener mListener;
2128

22-
// View Items
29+
public class MapsFragment extends BaseFragment {
30+
2331
Toolbar mToolbar;
24-
TabLayout mTabLayout;
25-
ViewPager mViewPager;
32+
AppBarLayout mAppBar;
33+
RecyclerView mRecyclerView;
34+
LinearLayoutManager mLayoutManager;
35+
MapItemRecyclerAdapter mAdapter;
36+
BaseFragment.OnFragmentInteractionListener mListener;
2637

2738

2839
public static MapsFragment newInstance() {
2940
return new MapsFragment();
3041
}
3142

43+
// Required empty public constructor
3244
public MapsFragment() {}
3345

46+
3447
@Override
3548
public View onCreateView(LayoutInflater inflater, ViewGroup container,
3649
Bundle savedInstanceState) {
3750
// Inflate the layout for this fragment
38-
View v = inflater.inflate(R.layout.fragment_maps, container, false);
39-
51+
View v = inflater.inflate(R.layout.fragment_sponsors, container, false);
4052
mToolbar = (Toolbar) v.findViewById(R.id.toolbar);
41-
53+
mAppBar = (AppBarLayout) v.findViewById(R.id.app_bar);
54+
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
4255
return v;
4356
}
4457

4558
@Override
4659
public void onActivityCreated(Bundle savedInstanceState) {
4760
super.onActivityCreated(savedInstanceState);
4861

49-
62+
// Register toolbar
5063
mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
51-
//mToolbar.inflateMenu(R.menu.menu_main);
5264
mToolbar.setTitle("Venue Map");
5365
mListener.registerToolbar(mToolbar);
5466

67+
// use this setting to improve performance if you know that changes
68+
// in content do not change the layout size of the RecyclerView
69+
mRecyclerView.setHasFixedSize(true);
70+
71+
// use a linear layout manager
72+
mLayoutManager = new LinearLayoutManager(getActivity());
73+
mRecyclerView.setLayoutManager(mLayoutManager);
74+
mRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(getContext()).build());
75+
76+
// specify an adapter (see also next example)
77+
mAdapter = new MapItemRecyclerAdapter(new ArrayList<MapItem>());
78+
mRecyclerView.setAdapter(mAdapter);
79+
80+
ParseQuery<MapItem> query = ParseQuery.getQuery(ParseName.MAPITEM);
81+
query.setCachePolicy(ParseQuery.CachePolicy.CACHE_THEN_NETWORK);
82+
query.orderByAscending(ParseName.MAP_FLOOR);
83+
query.findInBackground(new FindCallback<MapItem>() {
84+
@Override
85+
public void done(List<MapItem> list, ParseException e) {
86+
if(e != null) {
87+
Log.e("HackFSU", "Error: " + e.getMessage());
88+
} else {
89+
mAdapter.replaceDataset(list);
90+
mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
91+
}
92+
}
93+
});
5594
}
5695

5796
@Override
@@ -71,19 +110,83 @@ public void onDetach() {
71110
mListener = null;
72111
}
73112

74-
/**
75-
* This interface must be implemented by activities that contain this
76-
* fragment to allow an interaction in this fragment to be communicated
77-
* to the activity and potentially other fragments contained in that
78-
* activity.
79-
* <p/>
80-
* See the Android Training lesson <a href=
81-
* "http://developer.android.com/training/basics/fragments/communicating.html"
82-
* >Communicating with Other Fragments</a> for more information.
83-
*/
84-
/*public interface OnFragmentInteractionListener {
85-
86-
void registerToolbar(Toolbar toolbar);
87-
88-
}*/
113+
// Adapter used by this fragment
114+
private class MapItemRecyclerAdapter extends
115+
RecyclerView.Adapter<MapItemRecyclerAdapter.ViewHolder> {
116+
117+
private List<MapItem> mDataset;
118+
119+
// Provide a reference to the views for each data item
120+
// Complex data items may need more than one view per item, and
121+
// you provide access to all the views for a data item in a view holder
122+
public class ViewHolder extends RecyclerView.ViewHolder {
123+
public View tile;
124+
public ParseImageView mMapItemImage;
125+
public ViewHolder(View v) {
126+
super(v);
127+
tile = v;
128+
mMapItemImage = (ParseImageView) v.findViewById(R.id.iv_map_image);
129+
}
130+
}
131+
132+
public MapItemRecyclerAdapter(ArrayList<MapItem> myDataset) {
133+
mDataset = myDataset;
134+
}
135+
136+
// Instantiate each viewholder
137+
@Override
138+
public MapItemRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
139+
int viewType) {
140+
// create a new view
141+
View v = LayoutInflater.from(parent.getContext())
142+
.inflate(R.layout.tile_map, parent, false);
143+
144+
return new ViewHolder(v);
145+
}
146+
147+
// Populate the viewholder with data
148+
@Override
149+
public void onBindViewHolder(ViewHolder holder, int position) {
150+
151+
holder.mMapItemImage.setParseFile(mDataset.get(position).getImage());
152+
holder.mMapItemImage.loadInBackground(new GetDataCallback() {
153+
@Override
154+
public void done(byte[] data, ParseException e) {
155+
if(e != null) {
156+
Log.e("HackFSU", e.getMessage());
157+
}
158+
}
159+
});
160+
161+
}
162+
163+
@Override
164+
public int getItemCount() {
165+
return mDataset.size();
166+
}
167+
168+
// Custom method for hot-swapping data
169+
public void replaceDataset(List<MapItem> data) {
170+
mDataset = data;
171+
}
172+
}
173+
174+
@ParseClassName(ParseName.MAPITEM)
175+
public static class MapItem extends ParseObject {
176+
177+
public MapItem(){}
178+
179+
public ParseFile getImage() {
180+
return getParseFile(ParseName.MAP_IMAGE);
181+
}
182+
183+
public int getFloor() {
184+
return getInt(ParseName.MAP_FLOOR);
185+
}
186+
187+
188+
}
189+
190+
191+
89192
}

mobile/src/main/java/com/hackfsu/hackfsu_android/SponsorsFragment.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ public class SponsorsFragment extends BaseFragment {
3636

3737
Toolbar mToolbar;
3838
AppBarLayout mAppBar;
39-
CollapsingToolbarLayout mCollapsing;
4039
RecyclerView mRecyclerView;
4140
LinearLayoutManager mLayoutManager;
4241
SponsorRecyclerAdapter mAdapter;
4342
BaseFragment.OnFragmentInteractionListener mListener;
4443

45-
int recyclerScroll = 0;
4644

4745
// TODO: Rename and change types and number of parameters
4846
public static SponsorsFragment newInstance() {
@@ -61,7 +59,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
6159
mToolbar = (Toolbar) v.findViewById(R.id.toolbar);
6260
mAppBar = (AppBarLayout) v.findViewById(R.id.app_bar);
6361
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
64-
//mCollapsing = (CollapsingToolbarLayout) v.findViewById(R.id.collapsing_toolbar);
6562
return v;
6663
}
6764

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical" android:layout_width="match_parent"
4+
android:layout_height="wrap_content">
5+
6+
<com.parse.ParseImageView
7+
android:layout_width="wrap_content"
8+
android:layout_height="wrap_content"
9+
android:id="@+id/iv_map_image"
10+
android:src="@drawable/diracfirst"
11+
android:scaleType="fitStart"
12+
android:adjustViewBounds="true"
13+
android:layout_marginTop="8dp"
14+
android:layout_marginBottom="8dp" />
15+
16+
</RelativeLayout>

mobile/src/main/res/layout/tile_sponsor.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
android:paddingLeft="12dp"
3434
android:paddingRight="12dp"
3535
android:paddingTop="4dp"
36-
android:paddingBottom="4dp">
36+
android:paddingBottom="4dp"
37+
android:visibility="gone">
3738

3839
<TextView
3940
android:layout_width="wrap_content"

mobile/src/main/res/mipmap-hdpi/ic_launcher.png

100644100755
-1.16 KB
Loading

mobile/src/main/res/mipmap-mdpi/ic_launcher.png

100644100755
-855 Bytes
Loading

mobile/src/main/res/mipmap-xhdpi/ic_launcher.png

100644100755
-1.68 KB
Loading

mobile/src/main/res/mipmap-xxhdpi/ic_launcher.png

100644100755
-2.29 KB
Loading

0 commit comments

Comments
 (0)