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

Merge branch 'master' into back-navigation

parents 7544ef74 67138833
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
\ No newline at end of file
...@@ -2,7 +2,7 @@ apply plugin: 'com.android.application' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 26 compileSdkVersion 26
buildToolsVersion "26.0.2" buildToolsVersion '27.0.3'
defaultConfig { defaultConfig {
applicationId "in.ac.iitb.gymkhana.iitbapp" applicationId "in.ac.iitb.gymkhana.iitbapp"
manifestPlaceholders 'appAuthRedirectScheme': 'https' manifestPlaceholders 'appAuthRedirectScheme': 'https'
...@@ -35,29 +35,29 @@ ext { ...@@ -35,29 +35,29 @@ ext {
dependencies { dependencies {
implementation 'com.android.support:support-v4:26.1.0' implementation 'com.android.support:support-v4:26.1.0'
compile fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
compile "com.android.support:appcompat-v7:${supportLibVersion}" implementation "com.android.support:appcompat-v7:${supportLibVersion}"
compile "net.openid:appauth:${appAuthVersion}" implementation "net.openid:appauth:${appAuthVersion}"
testCompile "junit:junit:4.12" testImplementation "junit:junit:4.12"
compile "com.android.support:design:${supportLibVersion}" implementation "com.android.support:design:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}" implementation "com.android.support:support-v4:${supportLibVersion}"
compile "com.jakewharton:butterknife:${butterKnifeVersion}" implementation "com.jakewharton:butterknife:${butterKnifeVersion}"
compile "com.google.android.gms:play-services-gcm:${playServicesVersion}" implementation "com.google.android.gms:play-services-gcm:${playServicesVersion}"
compile "com.google.android.gms:play-services-maps:${playServicesVersion}" implementation "com.google.android.gms:play-services-maps:${playServicesVersion}"
compile "com.google.android.gms:play-services-location:${playServicesVersion}" implementation "com.google.android.gms:play-services-location:${playServicesVersion}"
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}" annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}" implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}" implementation "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
compile "com.squareup.okhttp3:okhttp:${okhttpVersion}" implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}"
compile "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}" implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
compile "com.squareup.picasso:picasso:${picassoVersion}" implementation "com.squareup.picasso:picasso:${picassoVersion}"
compile "com.android.support:customtabs:${supportLibVersion}" implementation "com.android.support:customtabs:${supportLibVersion}"
compile "android.arch.persistence.room:runtime:${archRoomVersion}" implementation "android.arch.persistence.room:runtime:${archRoomVersion}"
annotationProcessor "android.arch.persistence.room:compiler:${archRoomVersion}" annotationProcessor "android.arch.persistence.room:compiler:${archRoomVersion}"
implementation "com.android.support:cardview-v7:${supportLibVersion}" implementation "com.android.support:cardview-v7:${supportLibVersion}"
compile "de.hdodenhof:circleimageview:${circleImageViewVersion}" implementation "de.hdodenhof:circleimageview:${circleImageViewVersion}"
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.ac.iitb.gymkhana.iitbapp" > package="in.ac.iitb.gymkhana.iitbapp">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
......
package in.ac.iitb.gymkhana.iitbapp;
import android.app.Activity;
import java.util.ArrayList;
import java.util.List;
/**
* A class which maintains a list of transactions to occur when Context becomes available.
*/
public final class ActivityBuffer {
private final List<IRunnable> mRunnables;
/* Member Variables. */
private Activity mActivity;
/**
* Constructor.
*/
public ActivityBuffer() {
// Initialize Member Variables.
this.mActivity = null;
this.mRunnables = new ArrayList<IRunnable>();
}
/**
* Executes the Runnable if there's an available Context. Otherwise, defers execution until it becomes available.
*/
public final void safely(final IRunnable pRunnable) {
// Synchronize along the current instance.
synchronized (this) {
// Do we have a context available?
if (this.isContextAvailable()) {
// Fetch the Activity.
final Activity lActivity = this.getActivity();
// Execute the Runnable along the Activity.
lActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
pRunnable.run(lActivity);
}
});
} else {
// Buffer the Runnable so that it's ready to receive a valid reference.
this.getRunnables().add(pRunnable);
}
}
}
/**
* Called to inform the ActivityBuffer that there's an available Activity reference.
*/
public final void onContextGained(final Activity pActivity) {
// Synchronize along ourself.
synchronized (this) {
// Update the Activity reference.
this.setActivity(pActivity);
// Are there any Runnables awaiting execution?
if (!this.getRunnables().isEmpty()) {
// Iterate the Runnables.
for (final IRunnable lRunnable : this.getRunnables()) {
// Execute the Runnable on the UI Thread.
pActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
// Execute the Runnable.
lRunnable.run(pActivity);
}
});
}
// Empty the Runnables.
this.getRunnables().clear();
}
}
}
/**
* Called to inform the ActivityBuffer that the Context has been lost.
*/
public final void onContextLost() {
// Synchronize along ourself.
synchronized (this) {
// Remove the Context reference.
this.setActivity(null);
}
}
/**
* Defines whether there's a safe Context available for the ActivityBuffer.
*/
public final boolean isContextAvailable() {
// Synchronize upon ourself.
synchronized (this) {
// Return the state of the Activity reference.
return (this.getActivity() != null);
}
}
private final Activity getActivity() {
return this.mActivity;
}
/* Getters and Setters. */
private final void setActivity(final Activity pActivity) {
this.mActivity = pActivity;
}
private final List<IRunnable> getRunnables() {
return this.mRunnables;
}
/**
* A class which defines operations to execute once there's an available Context.
*/
public interface IRunnable {
/**
* Executes when there's an available Context. Ideally, will it operate immediately.
*/
void run(final Activity pActivity);
}
}
\ No newline at end of file
...@@ -3,8 +3,20 @@ package in.ac.iitb.gymkhana.iitbapp; ...@@ -3,8 +3,20 @@ package in.ac.iitb.gymkhana.iitbapp;
public class Constants { public class Constants {
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1; public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
public static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 2; public static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 2;
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 3;
public static final int RESULT_LOAD_IMAGE = 11; public static final int RESULT_LOAD_IMAGE = 11;
public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json"; public static final String NOTIFICATIONS_RESPONSE_JSON = "notifications_json";
public static final String EVENT_JSON = "event_json"; public static final String EVENT_JSON = "event_json";
public static final java.lang.String USER_ID = "user_id"; public static final String USER_ID = "user_id";
public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer";
public static final String REGISTRATION_COMPLETE = "registrationComplete";
public static final String PREF_NAME = "LoggedInPref";
public static final String IS_LOGGED_IN = "IsLoggedIn";
public static final String GCM_ID = "GcmId";
public static final String CURRENT_USER = "current_user";
public static final String SESSION_ID = "session_id";
public static final int STATUS_GOING = 2;
public static final int STATUS_INTERESTED = 1;
public static final int STATUS_NOT_GOING = 0;
} }
...@@ -40,8 +40,6 @@ import retrofit2.Response; ...@@ -40,8 +40,6 @@ import retrofit2.Response;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer";
public static final String REGISTRATION_COMPLETE = "registrationComplete";
private static final String TAG = "LoginActivity"; private static final String TAG = "LoginActivity";
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
//TODO: Change this to production before launch //TODO: Change this to production before launch
...@@ -67,7 +65,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -67,7 +65,7 @@ public class LoginActivity extends AppCompatActivity {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean sentToken = sharedPreferences.getBoolean(SENT_TOKEN_TO_SERVER, false); boolean sentToken = sharedPreferences.getBoolean(Constants.SENT_TOKEN_TO_SERVER, false);
if (sentToken) { if (sentToken) {
String token = intent.getStringExtra("Token"); String token = intent.getStringExtra("Token");
Log.d(TAG, "Going to login with :" + authCode + "\n" + token); Log.d(TAG, "Going to login with :" + authCode + "\n" + token);
...@@ -254,7 +252,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -254,7 +252,7 @@ public class LoginActivity extends AppCompatActivity {
private void registerReceiver() { private void registerReceiver() {
if (!isReceiverRegistered) { if (!isReceiverRegistered) {
LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver, LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(REGISTRATION_COMPLETE)); new IntentFilter(Constants.REGISTRATION_COMPLETE));
isReceiverRegistered = true; isReceiverRegistered = true;
} }
} }
......
...@@ -4,7 +4,6 @@ import android.Manifest; ...@@ -4,7 +4,6 @@ import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
...@@ -27,9 +26,6 @@ import android.widget.Toast; ...@@ -27,9 +26,6 @@ import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
import in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment;
...@@ -46,23 +42,19 @@ import in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment; ...@@ -46,23 +42,19 @@ import in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment; import in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION; import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE; import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static in.ac.iitb.gymkhana.iitbapp.Constants.RESULT_LOAD_IMAGE; import static in.ac.iitb.gymkhana.iitbapp.Constants.RESULT_LOAD_IMAGE;
import static in.ac.iitb.gymkhana.iitbapp.SessionManager.SESSION_ID;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private static final String TAG = "MainActivity"; private static final String TAG = "MainActivity";
private User currentUser;
SessionManager session; SessionManager session;
NotificationsResponse notificationsResponse; NotificationsResponse notificationsResponse;
private User currentUser;
private boolean showNotifications = false; private boolean showNotifications = false;
FeedFragment feedFragment; FeedFragment feedFragment;
...@@ -86,14 +78,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -86,14 +78,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
feedFragment = new FeedFragment(); feedFragment = new FeedFragment();
updateFragment(feedFragment); updateFragment(feedFragment);
fetchNotifications(); // fetchNotifications();
} }
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
if (session.isLoggedIn()) { if (session.isLoggedIn()) {
currentUser = User.fromString(session.pref.getString(SessionManager.CURRENT_USER, "Error")); currentUser = User.fromString(session.pref.getString(Constants.CURRENT_USER, "Error"));
updateNavigationView(); updateNavigationView();
} }
} }
...@@ -122,28 +114,28 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -122,28 +114,28 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Picasso.with(this).load(currentUser.getUserProfilePictureUrl()).into(profilePictureImageView); Picasso.with(this).load(currentUser.getUserProfilePictureUrl()).into(profilePictureImageView);
} }
private void fetchNotifications() { // private void fetchNotifications() {
NotificationsRequest notificationsRequest = new NotificationsRequest(0, 20); // NotificationsRequest notificationsRequest = new NotificationsRequest(0, 20);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); // RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getNotifications(notificationsRequest).enqueue(new Callback<NotificationsResponse>() { // retrofitInterface.getNotifications(notificationsRequest).enqueue(new Callback<NotificationsResponse>() {
@Override // @Override
public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) { // public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) {
if (response.isSuccessful()) { // if (response.isSuccessful()) {
notificationsResponse = response.body(); // notificationsResponse = response.body();
if (showNotifications) { // if (showNotifications) {
showNotifications(); // showNotifications();
showNotifications = false; // showNotifications = false;
} // }
} // }
//Server Error // //Server Error
} // }
//
@Override // @Override
public void onFailure(Call<NotificationsResponse> call, Throwable t) { // public void onFailure(Call<NotificationsResponse> call, Throwable t) {
//Network Error // //Network Error
} // }
}); // });
} // }
public void showNotifications() { public void showNotifications() {
String notificationsResponseJson = new Gson().toJson(notificationsResponse); String notificationsResponseJson = new Gson().toJson(notificationsResponse);
...@@ -184,7 +176,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -184,7 +176,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
//noinspection SimplifiableIfStatement //noinspection SimplifiableIfStatement
if (id == R.id.action_notifications) { if (id == R.id.action_notifications) {
showNotifications = true; showNotifications = true;
fetchNotifications(); // fetchNotifications();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
......
...@@ -9,11 +9,6 @@ import android.util.Log; ...@@ -9,11 +9,6 @@ import android.util.Log;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
public class SessionManager { public class SessionManager {
private static final String PREF_NAME = "LoggedInPref";
private static final String IS_LOGGED_IN = "IsLoggedIn";
private static final String GCM_ID = "GcmId";
public static final String CURRENT_USER = "current_user";
public static final String SESSION_ID = "session_id";
SharedPreferences pref; SharedPreferences pref;
Editor editor; Editor editor;
Context context; Context context;
...@@ -21,7 +16,7 @@ public class SessionManager { ...@@ -21,7 +16,7 @@ public class SessionManager {
public SessionManager(Context context) { public SessionManager(Context context) {
this.context = context; this.context = context;
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE); pref = context.getSharedPreferences(Constants.PREF_NAME, PRIVATE_MODE);
editor = pref.edit(); editor = pref.edit();
} }
...@@ -39,14 +34,14 @@ public class SessionManager { ...@@ -39,14 +34,14 @@ public class SessionManager {
public void createLoginSession(String gcmId, User currentUser, String sessionID) { public void createLoginSession(String gcmId, User currentUser, String sessionID) {
Log.d("SessionManager", "GcmId being stored"); Log.d("SessionManager", "GcmId being stored");
editor.putBoolean(IS_LOGGED_IN, true); editor.putBoolean(Constants.IS_LOGGED_IN, true);
editor.putString(GCM_ID, gcmId); editor.putString(Constants.GCM_ID, gcmId);
editor.putString(CURRENT_USER, currentUser.toString()); editor.putString(Constants.CURRENT_USER, currentUser.toString());
editor.putString(SESSION_ID, sessionID); editor.putString(Constants.SESSION_ID, sessionID);
editor.commit(); editor.commit();
} }
public boolean isLoggedIn() { public boolean isLoggedIn() {
return pref.getBoolean(IS_LOGGED_IN, false); return pref.getBoolean(Constants.IS_LOGGED_IN, false);
} }
} }
...@@ -10,18 +10,15 @@ import android.widget.TextView; ...@@ -10,18 +10,15 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import org.w3c.dom.Text;
import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.logging.SimpleFormatter;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener; import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.Event; import in.ac.iitb.gymkhana.iitbapp.data.Event;
import in.ac.iitb.gymkhana.iitbapp.data.Venue;
public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
...@@ -62,9 +59,14 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -62,9 +59,14 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
viewHolder.eventDate.setText(simpleDateFormatDate.format(Date)); viewHolder.eventDate.setText(simpleDateFormatDate.format(Date));
viewHolder.eventTime.setText(simpleDateFormatTime.format(Date)); viewHolder.eventTime.setText(simpleDateFormatTime.format(Date));
viewHolder.eventVenue.setText(currentEvent.getEventVenues().get(0).getVenueName()); StringBuilder eventVenueName = new StringBuilder();
for (Venue venue : currentEvent.getEventVenues()) {
eventVenueName.append(", ").append(venue.getVenueName());
}
if (!eventVenueName.toString().equals(""))
viewHolder.eventVenue.setText(eventVenueName.toString().substring(2));
Picasso.with(context).load(currentEvent.getEventImageURL()).resize(320,0).into(viewHolder.eventPicture); Picasso.with(context).load(currentEvent.getEventImageURL()).resize(320, 0).into(viewHolder.eventPicture);
} }
@Override @Override
...@@ -75,7 +77,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -75,7 +77,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
private ImageView eventPicture; private ImageView eventPicture;
private TextView eventTitle; private TextView eventTitle;
// private TextView eventDetails; // private TextView eventDetails;
private TextView eventDate; private TextView eventDate;
private TextView eventTime; private TextView eventTime;
private TextView eventVenue; private TextView eventVenue;
......
...@@ -6,8 +6,6 @@ import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadRequest; ...@@ -6,8 +6,6 @@ import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.ImageUploadResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.LoginResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse; import in.ac.iitb.gymkhana.iitbapp.api.model.NewsFeedResponse;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsRequest;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
...@@ -30,9 +28,12 @@ public interface RetrofitInterface { ...@@ -30,9 +28,12 @@ public interface RetrofitInterface {
@GET("users/{uuid}") @GET("users/{uuid}")
Call<User> getUser(@Header("Cookie") String sessionId, @Path("uuid") String uuid); Call<User> getUser(@Header("Cookie") String sessionId, @Path("uuid") String uuid);
@POST("getNotifications/")
Call<NotificationsResponse> getNotifications(@Body NotificationsRequest notificationsRequest);
@POST("upload") @POST("upload")
Call<ImageUploadResponse> uploadImage(@Header("Cookie") String sessionId, @Body ImageUploadRequest imageUploadRequest); Call<ImageUploadResponse> uploadImage(@Header("Cookie") String sessionID, @Body ImageUploadRequest imageUploadRequest);
@GET("user-me/ues/{eventID}")
Call<Void> updateUserEventStatus(@Header("Cookie") String sessionID, @Path("eventID") String eventID, @Query("status") int status);
// @POST("getNotifications/")
// Call<NotificationsResponse> getNotifications(@Body NotificationsRequest notificationsRequest);
} }
package in.ac.iitb.gymkhana.iitbapp.api.model; package in.ac.iitb.gymkhana.iitbapp.api.model;
import android.media.Image;
import android.support.annotation.Nullable;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp;
import java.util.List; import java.util.List;
public class EventCreateRequest { public class EventCreateRequest {
......
package in.ac.iitb.gymkhana.iitbapp.api.model; package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName;
/** /**
* Created by mrunz on 15/7/17. * Created by mrunz on 15/7/17.
*/ */
...@@ -13,9 +11,9 @@ public class EventCreateResponse { ...@@ -13,9 +11,9 @@ public class EventCreateResponse {
private String eventId; private String eventId;
public EventCreateResponse(String result,String eventId){ public EventCreateResponse(String result, String eventId) {
this.result=result; this.result = result;
this.eventId=eventId; this.eventId = eventId;
} }
public String getResult() { public String getResult() {
......
package in.ac.iitb.gymkhana.iitbapp.api.model; package in.ac.iitb.gymkhana.iitbapp.api.model;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
public class LoginResponse { public class LoginResponse {
......
...@@ -10,14 +10,12 @@ import android.content.Context; ...@@ -10,14 +10,12 @@ import android.content.Context;
* Created by mrunz on 14/3/18. * Created by mrunz on 14/3/18.
*/ */
@Database(entities = {Event.class, Body.class,Venue.class}, version = 1) @Database(entities = {Event.class, Body.class, Venue.class}, version = 1)
@TypeConverters({Converters.class}) @TypeConverters({Converters.class})
public abstract class AppDatabase extends RoomDatabase { public abstract class AppDatabase extends RoomDatabase {
private static AppDatabase INSTANCE; private static AppDatabase INSTANCE;
public abstract DbDao dbDao();
public static AppDatabase getAppDatabase(Context context) { public static AppDatabase getAppDatabase(Context context) {
if (INSTANCE == null) { if (INSTANCE == null) {
INSTANCE = INSTANCE =
...@@ -33,4 +31,6 @@ public abstract class AppDatabase extends RoomDatabase { ...@@ -33,4 +31,6 @@ public abstract class AppDatabase extends RoomDatabase {
public static void destroyInstance() { public static void destroyInstance() {
INSTANCE = null; INSTANCE = null;
} }
public abstract DbDao dbDao();
} }
...@@ -7,8 +7,6 @@ import com.google.gson.reflect.TypeToken; ...@@ -7,8 +7,6 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -18,7 +16,8 @@ import java.util.List; ...@@ -18,7 +16,8 @@ import java.util.List;
public class Converters { public class Converters {
@TypeConverter @TypeConverter
public static List<Event> eventsfromString(String value) { public static List<Event> eventsfromString(String value) {
Type listType = new TypeToken<List<Event>>() {}.getType(); Type listType = new TypeToken<List<Event>>() {
}.getType();
return new Gson().fromJson(value, listType); return new Gson().fromJson(value, listType);
} }
...@@ -31,7 +30,8 @@ public class Converters { ...@@ -31,7 +30,8 @@ public class Converters {
@TypeConverter @TypeConverter
public static List<User> usersfromString(String value) { public static List<User> usersfromString(String value) {
Type listType = new TypeToken<List<User>>() {}.getType(); Type listType = new TypeToken<List<User>>() {
}.getType();
return new Gson().fromJson(value, listType); return new Gson().fromJson(value, listType);
} }
...@@ -41,9 +41,11 @@ public class Converters { ...@@ -41,9 +41,11 @@ public class Converters {
String json = gson.toJson(list); String json = gson.toJson(list);
return json; return json;
} }
@TypeConverter @TypeConverter
public static List<Venue> venuesfromString(String value) { public static List<Venue> venuesfromString(String value) {
Type listType = new TypeToken<List<Venue>>() {}.getType(); Type listType = new TypeToken<List<Venue>>() {
}.getType();
return new Gson().fromJson(value, listType); return new Gson().fromJson(value, listType);
} }
...@@ -53,9 +55,11 @@ public class Converters { ...@@ -53,9 +55,11 @@ public class Converters {
String json = gson.toJson(list); String json = gson.toJson(list);
return json; return json;
} }
@TypeConverter @TypeConverter
public static List<Body> bodiesfromString(String value) { public static List<Body> bodiesfromString(String value) {
Type listType = new TypeToken<List<Body>>() {}.getType(); Type listType = new TypeToken<List<Body>>() {
}.getType();
return new Gson().fromJson(value, listType); return new Gson().fromJson(value, listType);
} }
......
...@@ -7,8 +7,6 @@ import android.arch.persistence.room.Query; ...@@ -7,8 +7,6 @@ import android.arch.persistence.room.Query;
import java.util.List; import java.util.List;
import retrofit2.http.DELETE;
/** /**
* Created by mrunz on 13/3/18. * Created by mrunz on 13/3/18.
*/ */
......
...@@ -10,8 +10,6 @@ import com.google.gson.annotations.SerializedName; ...@@ -10,8 +10,6 @@ import com.google.gson.annotations.SerializedName;
import java.util.List; import java.util.List;
import static android.content.ContentValues.TAG;
@Entity(tableName = "users") @Entity(tableName = "users")
public class User { public class User {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
...@@ -69,6 +67,10 @@ public class User { ...@@ -69,6 +67,10 @@ public class User {
this.userFollowedBodiesID = userFollowedBodiesID; this.userFollowedBodiesID = userFollowedBodiesID;
} }
public static User fromString(String json) {
return new Gson().fromJson(json, User.class);
}
public String getUserID() { public String getUserID() {
return userID; return userID;
} }
...@@ -169,9 +171,4 @@ public class User { ...@@ -169,9 +171,4 @@ public class User {
public String toString() { public String toString() {
return new Gson().toJson(this); return new Gson().toJson(this);
} }
public static User fromString(String json) {
Log.d(TAG, "fromString: " + json);
return new Gson().fromJson(json, User.class);
}
} }
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class AboutFragment extends Fragment { public class AboutFragment extends BaseFragment {
public AboutFragment() { public AboutFragment() {
......
...@@ -13,7 +13,6 @@ import android.net.Uri; ...@@ -13,7 +13,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
...@@ -38,6 +37,7 @@ import java.util.Calendar; ...@@ -38,6 +37,7 @@ import java.util.Calendar;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface; import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator; import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
...@@ -50,13 +50,11 @@ import retrofit2.Callback; ...@@ -50,13 +50,11 @@ import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
import static android.content.ContentValues.TAG;
import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE; import static in.ac.iitb.gymkhana.iitbapp.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static in.ac.iitb.gymkhana.iitbapp.Constants.RESULT_LOAD_IMAGE; import static in.ac.iitb.gymkhana.iitbapp.Constants.RESULT_LOAD_IMAGE;
import static in.ac.iitb.gymkhana.iitbapp.SessionManager.SESSION_ID;
public class AddEventFragment extends Fragment { public class AddEventFragment extends BaseFragment {
@BindView(R.id.button_createEvent) @BindView(R.id.button_createEvent)
Button createEvent; Button createEvent;
@BindView(R.id.tv_start) @BindView(R.id.tv_start)
...@@ -93,12 +91,23 @@ public class AddEventFragment extends Fragment { ...@@ -93,12 +91,23 @@ public class AddEventFragment extends Fragment {
View view; View view;
String base64Image; String base64Image;
ProgressDialog progressDialog; ProgressDialog progressDialog;
String TAG = "AddEventFragment";
public AddEventFragment() { public AddEventFragment() {
// Required empty public constructor // Required empty public constructor
} }
public static String convertImageToString(Bitmap imageBitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (imageBitmap != null) {
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} else {
return null;
}
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
...@@ -243,7 +252,7 @@ public class AddEventFragment extends Fragment { ...@@ -243,7 +252,7 @@ public class AddEventFragment extends Fragment {
progressDialog.setMessage("Uploading Image"); progressDialog.setMessage("Uploading Image");
ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image); ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.uploadImage("sessionid=" + getArguments().getString(SESSION_ID), imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() { retrofitInterface.uploadImage("sessionid=" + getArguments().getString(Constants.SESSION_ID), imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() {
@Override @Override
public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) { public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -264,7 +273,7 @@ public class AddEventFragment extends Fragment { ...@@ -264,7 +273,7 @@ public class AddEventFragment extends Fragment {
progressDialog.setMessage("Creating Event"); progressDialog.setMessage("Creating Event");
EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), eventImageURL, timestamp_start.toString(), timestamp_end.toString(), false, Arrays.asList(new String[]{venue.getText().toString()}), Arrays.asList(new String[]{"bde82d5e-f379-4b8a-ae38-a9f03e4f1c4a"})); EventCreateRequest eventCreateRequest = new EventCreateRequest(eventName.getText().toString(), details.getText().toString(), eventImageURL, timestamp_start.toString(), timestamp_end.toString(), false, Arrays.asList(new String[]{venue.getText().toString()}), Arrays.asList(new String[]{"bde82d5e-f379-4b8a-ae38-a9f03e4f1c4a"}));
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.createEvent("sessionid=" + getArguments().getString(SESSION_ID), eventCreateRequest).enqueue(new Callback<EventCreateResponse>() { retrofitInterface.createEvent("sessionid=" + getArguments().getString(Constants.SESSION_ID), eventCreateRequest).enqueue(new Callback<EventCreateResponse>() {
@Override @Override
public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) { public void onResponse(Call<EventCreateResponse> call, Response<EventCreateResponse> response) {
Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Event Created", Toast.LENGTH_SHORT).show();
...@@ -279,17 +288,6 @@ public class AddEventFragment extends Fragment { ...@@ -279,17 +288,6 @@ public class AddEventFragment extends Fragment {
}); });
} }
public static String convertImageToString(Bitmap imageBitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (imageBitmap != null) {
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
} else {
return null;
}
}
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
......
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;
import in.ac.iitb.gymkhana.iitbapp.ActivityBuffer;
/**
* A simple {@link Fragment} subclass.
*/
public class BaseFragment extends Fragment {
/* Member Variables. */
private ActivityBuffer mActivityBuffer;
public BaseFragment() {
// Implement the Parent.
super();
// Allocate the ActivityBuffer.
this.mActivityBuffer = new ActivityBuffer();
}
@Override
public final void onAttach(final Context pContext) {
// Handle as usual.
super.onAttach(pContext);
// Is the Context an Activity?
if (pContext instanceof Activity) {
// Cast Accordingly.
final Activity lActivity = (Activity) pContext;
// Inform the ActivityBuffer.
this.getActivityBuffer().onContextGained(lActivity);
}
}
@Deprecated
@Override
public final void onAttach(final Activity pActivity) {
// Handle as usual.
super.onAttach(pActivity);
// Inform the ActivityBuffer.
this.getActivityBuffer().onContextGained(pActivity);
}
@Override
public final void onDetach() {
// Handle as usual.
super.onDetach();
// Inform the ActivityBuffer.
this.getActivityBuffer().onContextLost();
}
/* Getters. */
public final ActivityBuffer getActivityBuffer() {
return this.mActivityBuffer;
}
}
\ No newline at end of file
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class CMSFragment extends Fragment { public class CMSFragment extends BaseFragment {
public CMSFragment() { public CMSFragment() {
......
...@@ -17,7 +17,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -17,7 +17,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class CalendarFragment extends Fragment { public class CalendarFragment extends BaseFragment {
FloatingActionButton fab; FloatingActionButton fab;
private View view; private View view;
......
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class ContactsFragment extends Fragment { public class ContactsFragment extends BaseFragment {
public ContactsFragment() { public ContactsFragment() {
......
...@@ -3,11 +3,14 @@ package in.ac.iitb.gymkhana.iitbapp.fragment; ...@@ -3,11 +3,14 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
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.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
...@@ -18,13 +21,23 @@ import java.util.Date; ...@@ -18,13 +21,23 @@ import java.util.Date;
import in.ac.iitb.gymkhana.iitbapp.Constants; import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.data.Event; import in.ac.iitb.gymkhana.iitbapp.data.Event;
import in.ac.iitb.gymkhana.iitbapp.data.Venue;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class EventFragment extends Fragment { public class EventFragment extends BaseFragment implements View.OnClickListener {
Event event;
Button goingButton;
Button interestedButton;
Button notGoingButton;
String TAG = "EventFragment";
public EventFragment() { public EventFragment() {
// Required empty public constructor // Required empty public constructor
...@@ -44,7 +57,8 @@ public class EventFragment extends Fragment { ...@@ -44,7 +57,8 @@ public class EventFragment extends Fragment {
Bundle bundle = getArguments(); Bundle bundle = getArguments();
String eventJson = bundle.getString(Constants.EVENT_JSON); String eventJson = bundle.getString(Constants.EVENT_JSON);
Event event = new Gson().fromJson(eventJson, Event.class); Log.d(TAG, "onStart: " + eventJson);
event = new Gson().fromJson(eventJson, Event.class);
inflateViews(event); inflateViews(event);
} }
...@@ -55,6 +69,9 @@ public class EventFragment extends Fragment { ...@@ -55,6 +69,9 @@ public class EventFragment extends Fragment {
TextView eventTime = (TextView) getActivity().findViewById(R.id.event_page_time); TextView eventTime = (TextView) getActivity().findViewById(R.id.event_page_time);
TextView eventVenue = (TextView) getActivity().findViewById(R.id.event_page_venue); TextView eventVenue = (TextView) getActivity().findViewById(R.id.event_page_venue);
TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description); TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description);
goingButton = getActivity().findViewById(R.id.going_button);
interestedButton = getActivity().findViewById(R.id.interested_button);
notGoingButton = getActivity().findViewById(R.id.not_going_button);
Picasso.with(getContext()).load(event.getEventImageURL()).into(eventPicture); Picasso.with(getContext()).load(event.getEventImageURL()).into(eventPicture);
eventTitle.setText(event.getEventName()); eventTitle.setText(event.getEventName());
...@@ -65,6 +82,50 @@ public class EventFragment extends Fragment { ...@@ -65,6 +82,50 @@ public class EventFragment extends Fragment {
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm a"); SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm a");
eventDate.setText(simpleDateFormatDate.format(Date)); eventDate.setText(simpleDateFormatDate.format(Date));
eventTime.setText(simpleDateFormatTime.format(Date)); eventTime.setText(simpleDateFormatTime.format(Date));
eventVenue.setText(event.getEventVenues().get(0).getVenueName()); StringBuilder eventVenueName = new StringBuilder();
for (Venue venue : event.getEventVenues()) {
eventVenueName.append(", ").append(venue.getVenueName());
}
if (!eventVenueName.toString().equals(""))
eventVenue.setText(eventVenueName.toString().substring(2));
goingButton.setOnClickListener(this);
interestedButton.setOnClickListener(this);
notGoingButton.setOnClickListener(this);
}
@Override
public void onClick(View view) {
goingButton.setBackgroundColor(getResources().getColor(R.color.colorWhite));
interestedButton.setBackgroundColor(getResources().getColor(R.color.colorWhite));
notGoingButton.setBackgroundColor(getResources().getColor(R.color.colorWhite));
view.setBackgroundColor(getResources().getColor(R.color.colorAccent));
int status = 0;
switch (view.getId()) {
case R.id.going_button:
status = Constants.STATUS_GOING;
break;
case R.id.interested_button:
status = Constants.STATUS_INTERESTED;
break;
case R.id.not_going_button:
status = Constants.STATUS_NOT_GOING;
break;
}
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.updateUserEventStatus("sessionid=" + getArguments().getString(Constants.SESSION_ID), event.getEventID(), status).enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) {
}
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
//TODO: Store the status offline and update when connected
Toast.makeText(getContext(), "Network Error", Toast.LENGTH_LONG).show();
}
});
} }
} }
package in.ac.iitb.gymkhana.iitbapp.fragment; package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.content.ContentValues; import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
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 com.google.gson.Gson; import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ActivityBuffer;
import in.ac.iitb.gymkhana.iitbapp.Constants; import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener; import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.MainActivity; import in.ac.iitb.gymkhana.iitbapp.MainActivity;
...@@ -35,16 +33,15 @@ import retrofit2.Call; ...@@ -35,16 +33,15 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static in.ac.iitb.gymkhana.iitbapp.SessionManager.SESSION_ID;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class FeedFragment extends Fragment { public class FeedFragment extends BaseFragment {
private RecyclerView feedRecyclerView; private RecyclerView feedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout; private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase; private AppDatabase appDatabase;
private FloatingActionButton fab;
public FeedFragment() { public FeedFragment() {
// Required empty public constructor // Required empty public constructor
...@@ -56,35 +53,35 @@ public class FeedFragment extends Fragment { ...@@ -56,35 +53,35 @@ public class FeedFragment extends Fragment {
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_feed, container, false); View view = inflater.inflate(R.layout.fragment_feed, container, false);
}
@Override fab = (FloatingActionButton) view.findViewById(R.id.fab);
public void onStart() {
super.onStart();
appDatabase= AppDatabase.getAppDatabase(getContext()); fab.setOnClickListener(new View.OnClickListener() {
final List<Event> events=appDatabase.dbDao().getAllEvents();
FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override @Override
public void onItemClick(View v, int position) { public void onClick(View v) {
String eventJson = new Gson().toJson(events.get(position)); AddEventFragment addEventFragment = new AddEventFragment();
Bundle bundle = new Bundle(); addEventFragment.setArguments(getArguments());
bundle.putString(Constants.EVENT_JSON, eventJson); FragmentTransaction ft = getChildFragmentManager().beginTransaction();
EventFragment eventFragment = new EventFragment(); ft.replace(R.id.relative_layout, addEventFragment);
eventFragment.setArguments(bundle); ft.addToBackStack("addEvent");
((MainActivity) getActivity()).updateFragment(eventFragment); ft.commit();
} }
}); });
feedRecyclerView = (RecyclerView) getActivity().findViewById(R.id.feed_recycler_view); return view;
feedRecyclerView.setAdapter(feedAdapter); }
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
@Override
public void onStart() {
super.onStart();
// } appDatabase = AppDatabase.getAppDatabase(getContext());
final List<Event> events = appDatabase.dbDao().getAllEvents();
displayEvents(events);
updateFeed(); updateFeed();
feedSwipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.feed_swipe_refresh_layout); feedSwipeRefreshLayout = getActivity().findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override
public void onRefresh() { public void onRefresh() {
...@@ -95,34 +92,20 @@ public class FeedFragment extends Fragment { ...@@ -95,34 +92,20 @@ public class FeedFragment extends Fragment {
private void updateFeed() { private void updateFeed() {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getNewsFeed("sessionid=" + getArguments().getString(SESSION_ID)).enqueue(new Callback<NewsFeedResponse>() { retrofitInterface.getNewsFeed("sessionid=" + getArguments().getString(Constants.SESSION_ID)).enqueue(new Callback<NewsFeedResponse>() {
@Override @Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) { public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
NewsFeedResponse newsFeedResponse = response.body(); NewsFeedResponse newsFeedResponse = response.body();
final List<Event> events = newsFeedResponse.getEvents(); List<Event> events = newsFeedResponse.getEvents();
displayEvents(events);
FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
String eventJson = new Gson().toJson(events.get(position));
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
((MainActivity) getActivity()).updateFragment(eventFragment);
}
});
feedRecyclerView = (RecyclerView) getActivity().findViewById(R.id.feed_recycler_view);
feedRecyclerView.setAdapter(feedAdapter);
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
appDatabase.dbDao().deleteEvents(); appDatabase.dbDao().deleteEvents();
appDatabase.dbDao().insertEvents(events); appDatabase.dbDao().insertEvents(events);
}
//Server Error //Server Error
feedSwipeRefreshLayout.setRefreshing(false); feedSwipeRefreshLayout.setRefreshing(false);
} }
}
@Override @Override
public void onFailure(Call<NewsFeedResponse> call, Throwable t) { public void onFailure(Call<NewsFeedResponse> call, Throwable t) {
...@@ -131,4 +114,32 @@ public class FeedFragment extends Fragment { ...@@ -131,4 +114,32 @@ public class FeedFragment extends Fragment {
} }
}); });
} }
private void displayEvents(final List<Event> events) {
FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
String eventJson = new Gson().toJson(events.get(position));
Bundle bundle = getArguments();
if (bundle == null)
bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.commit();
}
});
getActivityBuffer().safely(new ActivityBuffer.IRunnable() {
@Override
public void run(Activity pActivity) {
feedRecyclerView = pActivity.findViewById(R.id.feed_recycler_view);
}
});
feedRecyclerView.setAdapter(feedAdapter);
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
} }
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class GCRankingsFragment extends Fragment { public class GCRankingsFragment extends BaseFragment {
public GCRankingsFragment() { public GCRankingsFragment() {
......
...@@ -4,7 +4,6 @@ import android.Manifest; ...@@ -4,7 +4,6 @@ import android.Manifest;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
...@@ -12,13 +11,10 @@ import android.graphics.Color; ...@@ -12,13 +11,10 @@ import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.location.Location; import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -50,11 +46,12 @@ import com.google.android.gms.maps.model.MarkerOptions; ...@@ -50,11 +46,12 @@ import com.google.android.gms.maps.model.MarkerOptions;
import java.util.List; import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import static android.content.Context.LOCATION_SERVICE; import static android.content.Context.LOCATION_SERVICE;
public class MapFragment extends Fragment implements OnMapReadyCallback, LocationListener, public class MapFragment extends BaseFragment implements OnMapReadyCallback, LocationListener,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
SupportMapFragment gMapFragment; SupportMapFragment gMapFragment;
...@@ -65,7 +62,6 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -65,7 +62,6 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
LocationRequest mLocationRequest; LocationRequest mLocationRequest;
private FloatingActionButton locationButton; private FloatingActionButton locationButton;
private Location currentLocation; private Location currentLocation;
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99;
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
...@@ -77,8 +73,9 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -77,8 +73,9 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
return view; return view;
} }
@Override @Override
public void onStart(){ public void onStart() {
super.onStart(); super.onStart();
locationButton = (FloatingActionButton) getActivity().findViewById(R.id.location_button); locationButton = (FloatingActionButton) getActivity().findViewById(R.id.location_button);
locationButton.setImageResource(R.drawable.ic_my_location_black_24dp); locationButton.setImageResource(R.drawable.ic_my_location_black_24dp);
...@@ -87,7 +84,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -87,7 +84,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
locationButton.setOnClickListener(new View.OnClickListener() { locationButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Log.v("MapFragment", "Location button pressed" ); Log.v("MapFragment", "Location button pressed");
try { try {
LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
...@@ -95,19 +92,21 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -95,19 +92,21 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
boolean network_enabled = false; boolean network_enabled = false;
if (ActivityCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION); ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, Constants.MY_PERMISSIONS_REQUEST_LOCATION);
return; return;
} }
try { try {
gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch(Exception ex) {} } catch (Exception ex) {
}
try { try {
network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch(Exception ex) {} } catch (Exception ex) {
}
if(!gps_enabled && !network_enabled) { if (!gps_enabled && !network_enabled) {
LocationRequest locationRequest = LocationRequest.create(); LocationRequest locationRequest = LocationRequest.create();
...@@ -163,7 +162,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -163,7 +162,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
} }
} catch (Exception e){ } catch (Exception e) {
checkLocationPermission(); checkLocationPermission();
Toast.makeText(getContext(), "Please turn on Location from the Settings", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Please turn on Location from the Settings", Toast.LENGTH_SHORT).show();
...@@ -188,7 +187,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -188,7 +187,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION); Constants.MY_PERMISSIONS_REQUEST_LOCATION);
} }
//Get the last known location from the data provider //Get the last known location from the data provider
Location l = mLocationManager.getLastKnownLocation(provider); Location l = mLocationManager.getLastKnownLocation(provider);
...@@ -263,7 +262,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -263,7 +262,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
//Prompt the user once explanation has been shown //Prompt the user once explanation has been shown
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION); Constants.MY_PERMISSIONS_REQUEST_LOCATION);
} }
}) })
...@@ -274,7 +273,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -274,7 +273,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
} else { } else {
// No explanation needed, we can request the permission. // No explanation needed, we can request the permission.
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_LOCATION); Constants.MY_PERMISSIONS_REQUEST_LOCATION);
} }
} }
} }
...@@ -287,6 +286,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -287,6 +286,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
.build(); .build();
mGoogleApiClient.connect(); mGoogleApiClient.connect();
} }
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
mLastLocation = location; mLastLocation = location;
...@@ -298,13 +298,14 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -298,13 +298,14 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
//move map camera //move map camera
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap .animateCamera(CameraUpdateFactory.zoomTo(17)); googleMap.animateCamera(CameraUpdateFactory.zoomTo(17));
//stop location updates //stop location updates
if (mGoogleApiClient != null) { if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this); LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
} }
} }
@Override @Override
public void onConnectionSuspended(int i) { public void onConnectionSuspended(int i) {
} }
...@@ -313,7 +314,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -313,7 +314,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
public void onRequestPermissionsResult(int requestCode, public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) { String permissions[], int[] grantResults) {
switch (requestCode) { switch (requestCode) {
case MY_PERMISSIONS_REQUEST_LOCATION: { case Constants.MY_PERMISSIONS_REQUEST_LOCATION: {
// If request is cancelled, the result arrays are empty. // If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
...@@ -327,6 +328,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -327,6 +328,7 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
} }
} }
} }
@Override @Override
public void onConnectionFailed(ConnectionResult connectionResult) { public void onConnectionFailed(ConnectionResult connectionResult) {
} }
...@@ -345,5 +347,4 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio ...@@ -345,5 +347,4 @@ public class MapFragment extends Fragment implements OnMapReadyCallback, Locatio
} }
} }
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class MessMenuFragment extends Fragment { public class MessMenuFragment extends BaseFragment {
public MessMenuFragment() { public MessMenuFragment() {
......
...@@ -2,7 +2,9 @@ package in.ac.iitb.gymkhana.iitbapp.fragment; ...@@ -2,7 +2,9 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -12,8 +14,9 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,8 +14,9 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class MyEventsFragment extends Fragment { public class MyEventsFragment extends BaseFragment {
FloatingActionButton fab;
public MyEventsFragment() { public MyEventsFragment() {
// Required empty public constructor // Required empty public constructor
...@@ -24,7 +27,24 @@ public class MyEventsFragment extends Fragment { ...@@ -24,7 +27,24 @@ public class MyEventsFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_my_events, container, false); View view = inflater.inflate(R.layout.fragment_my_events, container, false);
fab = (FloatingActionButton) view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddEventFragment addEventFragment = new AddEventFragment();
addEventFragment.setArguments(getArguments());
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.replace(R.id.relative_layout, addEventFragment);
ft.addToBackStack("addEvent");
ft.commit();
}
});
return view;
} }
} }
...@@ -23,7 +23,7 @@ import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse; ...@@ -23,7 +23,7 @@ import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class NotificationsFragment extends Fragment { public class NotificationsFragment extends BaseFragment {
RecyclerView notificationsRecyclerView; RecyclerView notificationsRecyclerView;
......
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class PTCellFragment extends Fragment { public class PTCellFragment extends BaseFragment {
public PTCellFragment() { public PTCellFragment() {
......
...@@ -3,7 +3,6 @@ package in.ac.iitb.gymkhana.iitbapp.fragment; ...@@ -3,7 +3,6 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView; import android.support.v7.widget.SearchView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -20,7 +19,7 @@ import in.ac.iitb.gymkhana.iitbapp.PeopleSuggestionAdapter; ...@@ -20,7 +19,7 @@ import in.ac.iitb.gymkhana.iitbapp.PeopleSuggestionAdapter;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
public class PeopleFragment extends Fragment { public class PeopleFragment extends BaseFragment {
View view; View view;
SearchView searchView; SearchView searchView;
PeopleSuggestionAdapter adapter; PeopleSuggestionAdapter adapter;
......
...@@ -20,12 +20,10 @@ import retrofit2.Call; ...@@ -20,12 +20,10 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static in.ac.iitb.gymkhana.iitbapp.SessionManager.SESSION_ID;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class ProfileFragment extends Fragment { public class ProfileFragment extends BaseFragment {
User user; User user;
public ProfileFragment() { public ProfileFragment() {
...@@ -47,7 +45,7 @@ public class ProfileFragment extends Fragment { ...@@ -47,7 +45,7 @@ public class ProfileFragment extends Fragment {
String userID = bundle.getString(Constants.USER_ID); String userID = bundle.getString(Constants.USER_ID);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class); RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getUser("sessionid=" + getArguments().getString(SESSION_ID), userID).enqueue(new Callback<User>() { retrofitInterface.getUser("sessionid=" + getArguments().getString(Constants.SESSION_ID), userID).enqueue(new Callback<User>() {
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
......
...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R; ...@@ -12,7 +12,7 @@ import in.ac.iitb.gymkhana.iitbapp.R;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class TimetableFragment extends Fragment { public class TimetableFragment extends BaseFragment {
public TimetableFragment() { public TimetableFragment() {
......
...@@ -16,13 +16,11 @@ import android.widget.Toast; ...@@ -16,13 +16,11 @@ import android.widget.Toast;
import com.google.android.gms.gcm.GoogleCloudMessaging; import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID; import com.google.android.gms.iid.InstanceID;
import in.ac.iitb.gymkhana.iitbapp.Constants;
@TargetApi(Build.VERSION_CODES.CUPCAKE) @TargetApi(Build.VERSION_CODES.CUPCAKE)
public class RegistrationIntentService extends IntentService { public class RegistrationIntentService extends IntentService {
public static final String SENT_TOKEN_TO_SERVER = "sentTokenToServer";
public static final String REGISTRATION_COMPLETE = "registrationComplete";
private static final String TAG = "RegIntentService"; private static final String TAG = "RegIntentService";
...@@ -44,15 +42,15 @@ public class RegistrationIntentService extends IntentService { ...@@ -44,15 +42,15 @@ public class RegistrationIntentService extends IntentService {
Toast.makeText(this, "GCM Registration Token: " + token, Toast.LENGTH_SHORT).show(); Toast.makeText(this, "GCM Registration Token: " + token, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putBoolean(SENT_TOKEN_TO_SERVER, true).apply(); sharedPreferences.edit().putBoolean(Constants.SENT_TOKEN_TO_SERVER, true).apply();
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e); Log.d(TAG, "Failed to complete token refresh", e);
sharedPreferences.edit().putBoolean(SENT_TOKEN_TO_SERVER, false).apply(); sharedPreferences.edit().putBoolean(Constants.SENT_TOKEN_TO_SERVER, false).apply();
} }
//Notify UI that registration is complete //Notify UI that registration is complete
Intent registrationComplete = new Intent(REGISTRATION_COMPLETE); Intent registrationComplete = new Intent(Constants.REGISTRATION_COMPLETE);
registrationComplete.putExtra("Token", token); registrationComplete.putExtra("Token", token);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
} }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
card_view:cardElevation="4dp" android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"> android:layout_marginTop="4dp"
<LinearLayout card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="80dp"
...@@ -24,55 +25,60 @@ ...@@ -24,55 +25,60 @@
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="80dp" android:layout_height="80dp"
android:layout_gravity="center" android:layout_gravity="center"
android:scaleType="centerCrop"/> android:scaleType="centerCrop" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"> android:layout_weight="3"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/event_title" android:id="@+id/event_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Event Title"
android:textColor="@android:color/black" android:textColor="@android:color/black"
android:textSize="18sp" android:textSize="18sp" />
android:text="Event Title"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/event_date"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/event_date" android:text="26 May" />
android:text="26 May"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=" | " android:text=" | "
android:textSize="20dp"/> android:textSize="20dp" />
<TextView <TextView
android:id="@+id/event_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/event_time" android:text="6:00 PM" />
android:text="6:00 PM"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=" | " android:text=" | "
android:textSize="20dp"/> android:textSize="20dp" />
<TextView <TextView
android:id="@+id/event_venue"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/event_venue" android:ellipsize="end"
android:text="LH 101" android:text="LH 101" />
android:ellipsize="end"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -95,5 +101,5 @@ ...@@ -95,5 +101,5 @@
<!--android:layout_marginRight="16dp">--> <!--android:layout_marginRight="16dp">-->
<!--</View>--> <!--</View>-->
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.AddEventFragment"> tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.AddEventFragment">
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
...@@ -53,17 +54,18 @@ ...@@ -53,17 +54,18 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/tv_start"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:paddingRight="6dp" android:background="?attr/editTextBackground"
android:gravity="bottom" android:gravity="bottom"
android:layout_height="match_parent"
android:id="@+id/tv_start"
android:textSize="20sp"
android:hint="From " android:hint="From "
android:paddingRight="6dp"
android:paddingTop="8dp"
android:textSize="20sp" />
android:background="?attr/editTextBackground"
android:paddingTop="8dp"/>
<View <View
android:layout_width="3dp" android:layout_width="3dp"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -72,35 +74,33 @@ ...@@ -72,35 +74,33 @@
android:background="@color/common_google_signin_btn_text_dark_disabled" /> android:background="@color/common_google_signin_btn_text_dark_disabled" />
<TextView <TextView
android:id="@+id/tv_end"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:paddingRight="6dp" android:background="?attr/editTextBackground"
android:gravity="bottom" android:gravity="bottom"
android:layout_height="match_parent"
android:id="@+id/tv_end"
android:textSize="20sp"
android:hint="To " android:hint="To "
android:paddingRight="6dp"
android:background="?attr/editTextBackground" android:paddingTop="8dp"
android:paddingTop="8dp"/> android:textSize="20sp" />
</LinearLayout> </LinearLayout>
<EditText <EditText
android:layout_width="match_parent" android:id="@+id/et_venue"
android:paddingRight="6dp" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:textSize="20sp" android:hint="Venue"
android:id="@+id/et_venue" android:paddingRight="6dp"
android:hint="Venue"/> android:textSize="20sp" />
<EditText <EditText
android:id="@+id/et_eventDetails" android:id="@+id/et_eventDetails"
...@@ -111,72 +111,75 @@ ...@@ -111,72 +111,75 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="top" android:gravity="top"
android:textSize="20sp"
android:hint="Details" android:hint="Details"
android:paddingRight="6dp" /> android:paddingRight="6dp"
android:textSize="20sp" />
<RelativeLayout <RelativeLayout
android:id="@+id/advanced_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:id="@+id/advanced_menu">
<TextView android:layout_height="30dp" <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:text="Advanced Options" android:layout_height="30dp"
android:paddingLeft="18dp" android:paddingLeft="18dp"
android:textSize="20sp" android:paddingRight="16dp"
android:paddingRight="16dp"/> android:text="Advanced Options"
android:textSize="20sp" />
<ImageView <ImageView
android:id="@+id/close"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:id="@+id/close" android:src="@mipmap/advanced_menu_close" />
android:src="@mipmap/advanced_menu_close"/>
<ImageView <ImageView
android:id="@+id/open"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="30dp"
android:id="@+id/open"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:src="@mipmap/advanced_menu_open"/> android:src="@mipmap/advanced_menu_open" />
</RelativeLayout> </RelativeLayout>
<CheckBox <CheckBox
android:id="@+id/cb_public"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/cb_public"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:text="Outsiders Allowed "/> android:text="Outsiders Allowed " />
<EditText <EditText
android:id="@+id/map_location"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/map_location"
android:layout_marginLeft="22dp" android:layout_marginLeft="22dp"
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:hint="Map Location"/> android:hint="Map Location" />
<CheckBox <CheckBox
android:id="@+id/cb_permission"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Request User Info"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:id="@+id/cb_permission"/> android:text="Request User Info" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<Button <Button
android:id="@+id/button_createEvent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="40dp"
android:text="Create"
android:layout_margin="8dp" android:layout_margin="8dp"
android:background="@drawable/round_text_box" android:background="@drawable/round_text_box"
android:id="@+id/button_createEvent" android:gravity="center"
android:gravity="center"/> android:text="Create" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment"> tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment">
...@@ -10,82 +10,88 @@ ...@@ -10,82 +10,88 @@
android:id="@+id/event_picture_2" android:id="@+id/event_picture_2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:scaleType="centerCrop" android:layout_weight="1"
android:layout_weight="1"/> android:scaleType="centerCrop" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardBackgroundColor="@color/colorPrimary"> app:cardBackgroundColor="@color/colorPrimary">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="16dp" android:layout_marginBottom="12dp"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"> android:layout_weight="3"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/event_page_title" android:id="@+id/event_page_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="28sp" android:text="Event Title"
android:textColor="#fff" android:textColor="#fff"
android:text="Event Title"/> android:textSize="28sp" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/event_page_date"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/event_page_date" android:text="No Date Specified"
android:text="26 May" android:textColor="#fff"
android:textSize="16sp" android:textSize="16sp" />
android:textColor="#fff"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=" | " android:text=" | "
android:textSize="20sp" android:textColor="#fff"
android:textColor="#fff"/> android:textSize="20sp" />
<TextView <TextView
android:id="@+id/event_page_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/event_page_time" android:text="No Time Specified"
android:text="6:00 PM" android:textColor="#fff"
android:textSize="16sp" android:textSize="16sp" />
android:textColor="#fff"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=" | " android:text=" | "
android:textSize="20sp" android:textColor="#fff"
android:textColor="#fff"/> android:textSize="20sp" />
<TextView <TextView
android:id="@+id/event_page_venue"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/event_page_venue"
android:text="LH 101"
android:ellipsize="end" android:ellipsize="end"
android:textSize="16sp" android:text="No Venue Specified"
android:textColor="#fff"/> android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<LinearLayout <LinearLayout
style="?android:attr/buttonBarStyle" style="?android:attr/buttonBarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -93,56 +99,61 @@ ...@@ -93,56 +99,61 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/going_button"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="Going" android:text="Going"
android:layout_margin="0dp" android:textColor="@color/colorGray" />
android:textColor="@color/colorGray"/>
<View <View
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#aaa" android:layout_marginBottom="6dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="6dp"> android:background="#aaa">
</View> </View>
<Button <Button
android:id="@+id/interested_button"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="Interested" android:text="Interested"
android:layout_margin="0dp" android:textColor="@color/colorGray" />
android:textColor="@color/colorGray"/>
<View <View
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#aaa" android:layout_marginBottom="6dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="6dp"> android:background="#aaa">
</View> </View>
<Button <Button
android:id="@+id/not_going_button"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_weight="1" android:layout_weight="1"
android:text="Not Going" android:text="Not Going"
android:layout_margin="0dp" android:textColor="@color/colorGray" />
android:textColor="@color/colorGray"/>
</LinearLayout> </LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="#aaa"
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:layout_marginLeft="6dp" android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"> android:layout_marginRight="6dp"
android:background="#aaa">
</View> </View>
...@@ -150,10 +161,10 @@ ...@@ -150,10 +161,10 @@
android:id="@+id/event_page_description" android:id="@+id/event_page_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:textColor="#777" android:textColor="#777"
android:textSize="16sp"/> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/feed_swipe_refresh_layout" android:id="@+id/feed_swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -9,6 +14,16 @@ ...@@ -9,6 +14,16 @@
android:id="@+id/feed_recycler_view" android:id="@+id/feed_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingTop="8dp"/> android:paddingTop="8dp" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.v4.widget.SwipeRefreshLayout> <android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" />
</RelativeLayout>
\ No newline at end of file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/relative_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment">
<!-- TODO: Update blank fragment layout --> <android.support.design.widget.FloatingActionButton
<TextView android:id="@+id/fab"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:text="@string/hello_blank_fragment" /> android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
</FrameLayout> android:layout_margin="16dp"
android:src="@android:drawable/ic_input_add" />
</RelativeLayout>
...@@ -6,45 +6,45 @@ ...@@ -6,45 +6,45 @@
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment"> tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment">
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:layout_margin="32dp"
android:id="@+id/user_profile_picture_profile" android:id="@+id/user_profile_picture_profile"
android:layout_width="160dp" android:layout_width="160dp"
android:layout_height="160dp" /> android:layout_height="160dp"
android:layout_margin="32dp" />
<LinearLayout <LinearLayout
android:layout_marginTop="32dp"
android:orientation="vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:orientation="vertical">
<TextView <TextView
android:textSize="20sp"
android:layout_marginBottom="2dp"
android:id="@+id/user_name_profile" android:id="@+id/user_name_profile"
android:textStyle="bold"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="20sp"
android:textStyle="bold" />
<TextView <TextView
android:textSize="16sp"
android:layout_marginBottom="2dp"
android:id="@+id/user_rollno_profile" android:id="@+id/user_rollno_profile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="16sp" />
<TextView <TextView
android:textSize="16sp"
android:layout_marginBottom="2dp"
android:id="@+id/user_email_profile" android:id="@+id/user_email_profile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="16sp" />
<TextView <TextView
android:textSize="16sp"
android:layout_marginBottom="2dp"
android:id="@+id/user_contact_no_profile" android:id="@+id/user_contact_no_profile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
<color name="colorAccent">#ECF833</color> <color name="colorAccent">#ECF833</color>
<color name="colorCalendarWeek">#000000</color> <color name="colorCalendarWeek">#000000</color>
<color name="colorGray">#757575</color> <color name="colorGray">#757575</color>
<color name="colorWhite">#FFFFFF</color>
</resources> </resources>
...@@ -9,7 +9,7 @@ buildscript { ...@@ -9,7 +9,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.0' classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
......
#Fri Sep 22 00:09:34 IST 2017 #Wed Mar 28 12:02:24 IST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
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