Commit 6c2fa89e authored by Varun Patil's avatar Varun Patil

Remove dead code

parent f81fe80e
......@@ -27,7 +27,6 @@ import com.google.gson.Gson;
import com.squareup.picasso.Picasso;
import app.insti.api.UnsafeOkHttpClient;
import app.insti.api.model.NotificationsResponse;
import app.insti.data.User;
import app.insti.fragment.CalendarFragment;
import app.insti.fragment.FeedFragment;
......@@ -52,7 +51,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private static final String TAG = "MainActivity";
SessionManager session;
NotificationsResponse notificationsResponse;
FeedFragment feedFragment;
private User currentUser;
private boolean showNotifications = false;
......@@ -126,38 +124,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
.into(profilePictureImageView);
}
// private void fetchNotifications() {
// NotificationsRequest notificationsRequest = new NotificationsRequest(0, 20);
// RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
// retrofitInterface.getNotifications(notificationsRequest).enqueue(new Callback<NotificationsResponse>() {
// @Override
// public void onResponse(Call<NotificationsResponse> call, Response<NotificationsResponse> response) {
// if (response.isSuccessful()) {
// notificationsResponse = response.body();
// if (showNotifications) {
// showNotifications();
// showNotifications = false;
// }
// }
// //Server Error
// }
//
// @Override
// public void onFailure(Call<NotificationsResponse> call, Throwable t) {
// //Network Error
// }
// });
// }
public void showNotifications() {
String notificationsResponseJson = new Gson().toJson(notificationsResponse);
Bundle bundle = new Bundle();
bundle.putString(Constants.NOTIFICATIONS_RESPONSE_JSON, notificationsResponseJson);
NotificationsFragment notificationsFragment = new NotificationsFragment();
notificationsFragment.setArguments(bundle);
updateFragment(notificationsFragment);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
......
......@@ -15,7 +15,6 @@ import java.util.List;
import app.insti.ItemClickListener;
import app.insti.R;
import app.insti.api.model.AppNotification;
import app.insti.data.Event;
import app.insti.data.Notification;
......
package app.insti.api.model;
import com.google.gson.annotations.SerializedName;
public class AppNotification {
@SerializedName("notification_type")
private int notificationType;
@SerializedName("notification_id")
private String notificationId;
@SerializedName("notification_related_id")
private String notificationRelatedId;
@SerializedName("notification_name")
private String notificationName;
@SerializedName("notification_description")
private String notificationDescription;
@SerializedName("notification_image")
private String notificationImage;
public AppNotification(int notificationType, String notificationId, String notificationRelatedId, String notificationName, String notificationDescription, String notificationImage) {
this.notificationType = notificationType;
this.notificationId = notificationId;
this.notificationRelatedId = notificationRelatedId;
this.notificationName = notificationName;
this.notificationDescription = notificationDescription;
this.notificationImage = notificationImage;
}
public int getNotificationType() {
return notificationType;
}
public void setNotificationType(int notificationType) {
this.notificationType = notificationType;
}
public String getNotificationId() {
return notificationId;
}
public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}
public String getNotificationRelatedId() {
return notificationRelatedId;
}
public void setNotificationRelatedId(String notificationRelatedId) {
this.notificationRelatedId = notificationRelatedId;
}
public String getNotificationName() {
return notificationName;
}
public void setNotificationName(String notificationName) {
this.notificationName = notificationName;
}
public String getNotificationDescription() {
return notificationDescription;
}
public void setNotificationDescription(String notificationDescription) {
this.notificationDescription = notificationDescription;
}
public String getNotificationImage() {
return notificationImage;
}
public void setNotificationImage(String notificationImage) {
this.notificationImage = notificationImage;
}
}
package app.insti.api.model;
public class NotificationsRequest {
private int from;
private int to;
public NotificationsRequest(int from, int to) {
this.from = from;
this.to = to;
}
public int getFrom() {
return from;
}
public void setFrom(int from) {
this.from = from;
}
public int getTo() {
return to;
}
public void setTo(int to) {
this.to = to;
}
}
package app.insti.api.model;
import java.util.List;
public class NotificationsResponse {
private String result;
private List<AppNotification> notifications;
public NotificationsResponse(String result, List<AppNotification> notifications) {
this.result = result;
this.notifications = notifications;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public List<AppNotification> getNotifications() {
return notifications;
}
public void setNotifications(List<AppNotification> notifications) {
this.notifications = notifications;
}
}
......@@ -11,7 +11,6 @@ import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.google.gson.Gson;
......@@ -24,8 +23,6 @@ import app.insti.R;
import app.insti.adapter.NotificationsAdapter;
import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator;
import app.insti.api.model.AppNotification;
import app.insti.api.model.NotificationsResponse;
import app.insti.data.Notification;
import retrofit2.Call;
import retrofit2.Callback;
......
package app.insti.gcm;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.android.gms.gcm.GcmListenerService;
import app.insti.MainActivity;
import app.insti.R;
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
@Override
public void onMessageReceived(String s, Bundle bundle) {
String message = bundle.getString("message");
Log.d(TAG, "From: " + s);
Log.d(TAG, "Message: " + message);
sendNotification(message);
}
public void sendNotification(String message) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
//TODO Change the notification icon
.setSmallIcon(R.drawable.ic_notifications_white_24dp)
.setContentTitle("GCM Message")
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
package app.insti.gcm;
import android.content.Intent;
import com.google.android.gms.iid.InstanceIDListenerService;
public class MyInstanceIDListenerService extends InstanceIDListenerService {
@Override
public void onTokenRefresh() {
// Fetch updated Instance ID token and notify our app's server of any changes (if applicable).
Intent intent = new Intent(this, RegistrationIntentService.class);
startService(intent);
}
}
package app.insti.gcm;
import android.annotation.TargetApi;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import app.insti.Constants;
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public class RegistrationIntentService extends IntentService {
private static final String TAG = "RegIntentService";
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
public RegistrationIntentService() {
super(TAG);
}
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
@Override
protected void onHandleIntent(@Nullable Intent intent) {
String token = null;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
try {
InstanceID instanceID = InstanceID.getInstance(this);
token = instanceID.getToken("306601329049",
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Log.i(TAG, "GCM Registration Token: " + token);
Toast.makeText(this, "GCM Registration Token: " + token, Toast.LENGTH_SHORT).show();
sharedPreferences.edit().putBoolean(Constants.SENT_TOKEN_TO_SERVER, true).apply();
} catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e);
sharedPreferences.edit().putBoolean(Constants.SENT_TOKEN_TO_SERVER, false).apply();
}
//Notify UI that registration is complete
Intent registrationComplete = new Intent(Constants.REGISTRATION_COMPLETE);
registrationComplete.putExtra("Token", token);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
}
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