Commit b3ea021f authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #156 from pulsejet/patch-2

Multiple fixes
parents 9246b5f9 5389583d
......@@ -217,7 +217,7 @@ public class BodyFragment extends BackHandledFragment {
/* Check if user is already following
* Initialize follow button */
followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite));
followButton.setText(EventFragment.getCountBadgeSpannable("Follow", body.getBodyFollowersCount()));
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()));
followButton.setOnClickListener(new View.OnClickListener() {
@Override
......
......@@ -235,8 +235,8 @@ public class EventFragment extends BackHandledFragment {
goingButton.setBackgroundColor(getResources().getColor(status == Constants.STATUS_GOING ? R.color.colorAccent : R.color.colorWhite));
// Show badges
interestedButton.setText(getCountBadgeSpannable("Interested", event.getEventInterestedCount()));
goingButton.setText(getCountBadgeSpannable("Going", event.getEventGoingCount()));
interestedButton.setText(getCountBadgeSpannable("INTERESTED", event.getEventInterestedCount()));
goingButton.setText(getCountBadgeSpannable("GOING", event.getEventGoingCount()));
}
/**
......@@ -271,6 +271,18 @@ public class EventFragment extends BackHandledFragment {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) {
/* TODO: Find a better way to change counts */
if (endStatus == 0) {
if (event.getEventUserUes() == 1) { event.setEventInterestedCount(event.getEventInterestedCount() - 1); }
if (event.getEventUserUes() == 2) { event.setEventGoingCount(event.getEventGoingCount() - 1); }
} else if (endStatus == 1) {
if (event.getEventUserUes() != 1) { event.setEventInterestedCount(event.getEventInterestedCount() + 1); }
if (event.getEventUserUes() == 2) { event.setEventGoingCount(event.getEventGoingCount() - 1); }
} else if (endStatus == 2) {
if (event.getEventUserUes() != 2) { event.setEventGoingCount(event.getEventGoingCount() + 1); }
if (event.getEventUserUes() == 1) { event.setEventInterestedCount(event.getEventInterestedCount() - 1); }
}
event.setEventUserUes(endStatus);
new updateDbEvent().execute(event);
setFollowButtonColors(endStatus);
......
......@@ -15,6 +15,7 @@ import android.location.LocationListener;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
......@@ -91,6 +92,7 @@ import app.insti.MainActivity;
import app.insti.R;
import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator;
import app.insti.data.AppDatabase;
import app.insti.data.Venue;
import retrofit2.Call;
import retrofit2.Callback;
......@@ -102,6 +104,7 @@ public class MapFragment extends Fragment implements TextWatcher,
TextView.OnEditorActionListener, AdapterView.OnItemClickListener, View.OnFocusChangeListener,
View.OnTouchListener, ExpandableListView.OnChildClickListener {
private static MapFragment mainactivity;
private AppDatabase appDatabase;
private SettingsManager settingsManager;
private FuzzySearchAdapter adapter;
private ExpandableListAdapter expAdapter;
......@@ -148,6 +151,7 @@ public class MapFragment extends Fragment implements TextWatcher,
public SoundPool soundPool;
public int[] soundPoolIds;
private boolean locationsShown = false;
private boolean GPSIsSetup = false;
private boolean followingUser = false;
private Marker user = new Marker("You", "", 0, 0, -10, "");
......@@ -194,22 +198,57 @@ public class MapFragment extends Fragment implements TextWatcher,
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("InstiMap");
/* Initialize */
appDatabase = AppDatabase.getAppDatabase(getContext());
getAPILocations();
new showLocationsFromDB().execute();
}
private void getAPILocations() {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getAllVenues().enqueue(new Callback<List<Venue>>() {
@Override
public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) {
if (response.isSuccessful()) {
setupWithData(response.body());
new updateDatabase().execute(response.body());
if (!locationsShown) {
setupWithData(response.body());
locationsShown = true;
}
}
}
@Override
public void onFailure(Call<List<Venue>> call, Throwable t) {
setupWithData(new ArrayList<Venue>());
// Do nothing
}
});
}
private class updateDatabase extends AsyncTask<List<Venue>, Void, Integer> {
@Override
protected Integer doInBackground(List<Venue>... venues) {
appDatabase.dbDao().deleteVenues();
appDatabase.dbDao().insertVenues(venues[0]);
return 1;
}
}
private class showLocationsFromDB extends AsyncTask<String, Void, List<Venue>> {
@Override
protected List<Venue> doInBackground(String... events) {
return appDatabase.dbDao().getAllVenues();
}
protected void onPostExecute(List<Venue> result) {
if (!locationsShown && result.size() > 0) {
setupWithData(result);
locationsShown = true;
}
}
}
void setupWithData(List<Venue> venues) {
if (getView() == null || getActivity() == null) return;
Locations mLocations = new Locations(venues);
......@@ -236,8 +275,12 @@ public class MapFragment extends Fragment implements TextWatcher,
if (!campusMapView.isAddedMarker(user)) {
campusMapView.addMarker(user);
}
SubsamplingScaleImageView.AnimationBuilder anim = campusMapView.animateCenter(user.getPoint());
if (anim != null) anim.start();
if (user.getPoint().x == 0) {
Toast.makeText(getContext(), "Searching for GPS!", Toast.LENGTH_LONG).show();
} else {
SubsamplingScaleImageView.AnimationBuilder anim = campusMapView.animateCenter(user.getPoint());
if (anim != null) anim.start();
}
}
}
......@@ -1175,7 +1218,7 @@ public class MapFragment extends Fragment implements TextWatcher,
} catch (IntentSender.SendIntentException e) { }
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Toast.makeText(getContext(), "GPS is not enabled!", Toast.LENGTH_LONG);
Toast.makeText(getContext(), "GPS is not enabled!", Toast.LENGTH_LONG).show();
break;
}
}
......
......@@ -37,6 +37,7 @@ public class QuickLinksFragment extends BaseFragment {
TextView Holidays = getActivity().findViewById(R.id.button_Holidays);
TextView Circulars = getActivity().findViewById(R.id.button_Circulars);
TextView Courses = getActivity().findViewById(R.id.button_Courselist);
TextView WebMail = getActivity().findViewById(R.id.button_WebMail);
TextView GPO = getActivity().findViewById(R.id.button_GPO);
TextView CAMP = getActivity().findViewById(R.id.button_CAMP);
TextView MSStore = getActivity().findViewById(R.id.button_MSStore);
......@@ -60,6 +61,7 @@ public class QuickLinksFragment extends BaseFragment {
Holidays.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/en/about-iit-bombay/iit-bombay-holidays-list"); } });
Circulars.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://www.iitb.ac.in/newacadhome/circular.jsp"); } });
Courses.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://portal.iitb.ac.in/asc/Courses"); } });
WebMail.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://webmail.iitb.ac.in"); } });
GPO.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://gpo.iitb.ac.in"); } });
CAMP.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("https://camp.iitb.ac.in/"); } });
MSStore.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToUrl("http://msstore.iitb.ac.in/"); } });
......
......@@ -99,11 +99,12 @@
<Button
android:id="@+id/follow_button"
style="?android:attr/buttonBarButtonStyle"
android:textAllCaps="false"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:text="Follow"
android:text="FOLLOW"
android:textColor="@color/secondaryTextColor" />
</LinearLayout>
......
......@@ -152,11 +152,12 @@
<Button
android:id="@+id/going_button"
style="?android:attr/buttonBarButtonStyle"
android:textAllCaps="false"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:text="Going"
android:text="GOING"
android:textColor="@color/secondaryTextColor" />
<View
......@@ -171,11 +172,12 @@
<Button
android:id="@+id/interested_button"
style="?android:attr/buttonBarButtonStyle"
android:textAllCaps="false"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1"
android:text="Interested"
android:text="INTERESTED"
android:textColor="@color/secondaryTextColor" />
</LinearLayout>
......
......@@ -97,6 +97,11 @@
style="@style/QuickLinksHeading"
android:text="Services" />
<TextView
android:id="@+id/button_WebMail"
style="@style/QuickLink"
android:text="WebMail" />
<TextView
android:id="@+id/button_GPO"
style="@style/QuickLink"
......
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