diff --git a/app/src/main/java/adapters/LocationsList_Adapter.java b/app/src/main/java/adapters/LocationsList_Adapter.java index 962482be..66a88d55 100644 --- a/app/src/main/java/adapters/LocationsList_Adapter.java +++ b/app/src/main/java/adapters/LocationsList_Adapter.java @@ -31,8 +31,6 @@ class LocationsList_Adapter extends BaseExpandableListAdapter { public LocationsList_Adapter(Context context, ArrayList LocationItems) { this.context = context; this.LocationItems = LocationItems; - LayoutInflater inflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } diff --git a/app/src/main/java/adapters/MyFeedList.java b/app/src/main/java/adapters/MyFeedList.java index 14e51d13..ee553977 100644 --- a/app/src/main/java/adapters/MyFeedList.java +++ b/app/src/main/java/adapters/MyFeedList.java @@ -66,7 +66,7 @@ private class ViewHolder { @Override public View getView(final int position, View view, ViewGroup parent) { - ViewHolder holder = null; + ViewHolder holder; LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (view == null) { diff --git a/app/src/main/java/adapters/VideoList_Adapter.java b/app/src/main/java/adapters/VideoList_Adapter.java index dca68c4e..c13324fa 100644 --- a/app/src/main/java/adapters/VideoList_Adapter.java +++ b/app/src/main/java/adapters/VideoList_Adapter.java @@ -25,6 +25,8 @@ import org.json.JSONArray; import org.json.JSONException; +import java.util.Objects; + import functions.ButtonAnimation; import functions.ImageLoader; import nsit.app.com.nsitapp.R; @@ -39,7 +41,6 @@ public class VideoList_Adapter extends BaseAdapter { private static LayoutInflater inflater = null; public VideoList_Adapter(Context context, JSONArray FeedItems) { - Context context1 = context; this.FeedItems = FeedItems; imageLoader = new ImageLoader(context.getApplicationContext()); @@ -133,7 +134,7 @@ public View getView(int position, View convertView, ViewGroup parent) { try { Title.setText(FeedItems.getJSONObject(position).getJSONObject("snippet").getString("title")); String DescriptionText = FeedItems.getJSONObject(position).getJSONObject("snippet").getString("description"); - if (DescriptionText == "") { + if (Objects.equals(DescriptionText, "")) { Description.setText(R.string.no_description); } String publishedAt = processDate(FeedItems.getJSONObject(position).getJSONObject("snippet").getString("publishedAt")); diff --git a/app/src/main/java/functions/Constant.java b/app/src/main/java/functions/Constant.java index d96effae..4e4804b3 100644 --- a/app/src/main/java/functions/Constant.java +++ b/app/src/main/java/functions/Constant.java @@ -39,7 +39,7 @@ public interface Constant { String IS_TIME_TABLE_CHANGED = "timetablechanged"; String GET_TIME_TABLE = "timetable"; - String TIMETABLE_API = "****"; + String TIMETABLE_API = "http://nsitonline.in/NSITconnect/tt2/api/get-data.php?"; String id = "109315262061"; diff --git a/app/src/main/java/functions/GPSTracker.java b/app/src/main/java/functions/GPSTracker.java index 47b2958e..49133c2a 100644 --- a/app/src/main/java/functions/GPSTracker.java +++ b/app/src/main/java/functions/GPSTracker.java @@ -29,7 +29,7 @@ public class GPSTracker extends Service implements LocationListener { private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters // The minimum time between updates in milliseconds - private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute + private static final long MIN_TIME_BW_UPDATES = 1000 * 60; // 1 minute public GPSTracker(Context context) { this.mContext = context; @@ -59,13 +59,11 @@ private Location getLocation() { LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); - if (locationManager != null) { - location = locationManager - .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); - if (location != null) { - latitude = location.getLatitude(); - longitude = location.getLongitude(); - } + location = locationManager + .getLastKnownLocation(LocationManager.NETWORK_PROVIDER); + if (location != null) { + latitude = location.getLatitude(); + longitude = location.getLongitude(); } } // if GPS Enabled get lat/long using GPS Services @@ -75,13 +73,11 @@ private Location getLocation() { LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); - if (locationManager != null) { - location = locationManager - .getLastKnownLocation(LocationManager.GPS_PROVIDER); - if (location != null) { - latitude = location.getLatitude(); - longitude = location.getLongitude(); - } + location = locationManager + .getLastKnownLocation(LocationManager.GPS_PROVIDER); + if (location != null) { + latitude = location.getLatitude(); + longitude = location.getLongitude(); } } } diff --git a/app/src/main/java/functions/ImageLoader.java b/app/src/main/java/functions/ImageLoader.java index e54e7beb..f91e0ba3 100644 --- a/app/src/main/java/functions/ImageLoader.java +++ b/app/src/main/java/functions/ImageLoader.java @@ -69,7 +69,7 @@ private Bitmap getBitmap(String url) { //from web try { - Bitmap bitmap = null; + Bitmap bitmap; URL imageUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection(); conn.setConnectTimeout(30000); diff --git a/app/src/main/java/functions/Utils.java b/app/src/main/java/functions/Utils.java index ba0a2017..e5dd2efc 100644 --- a/app/src/main/java/functions/Utils.java +++ b/app/src/main/java/functions/Utils.java @@ -46,7 +46,7 @@ public static String readStream(InputStream in) { StringBuilder sb = new StringBuilder(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - String nextLine = ""; + String nextLine; while ((nextLine = reader.readLine()) != null) { sb.append(nextLine); } diff --git a/app/src/main/java/nsit/app/com/nsitapp/Calender.java b/app/src/main/java/nsit/app/com/nsitapp/Calender.java index 284a33a3..149021a4 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/Calender.java +++ b/app/src/main/java/nsit/app/com/nsitapp/Calender.java @@ -5,12 +5,15 @@ */ import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Typeface; -import android.os.AsyncTask; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.util.Log; @@ -33,18 +36,21 @@ import org.lucasr.twowayview.TwoWayView; import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import functions.Constant; import functions.Utils; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; public class Calender extends Fragment implements Constant { private static String timetable = null; private boolean loadingMore = false; + private static ArrayList days = new ArrayList(); private static ArrayList p0 = new ArrayList(); private static ArrayList p1 = new ArrayList(); @@ -56,11 +62,13 @@ public class Calender extends Fragment implements Constant { private static ArrayList p7 = new ArrayList(); private static ArrayList p8 = new ArrayList(); private static ArrayList p9 = new ArrayList(); - private CustomList_calendar adapter2; + + private CustomList_calendar adapter; private TwoWayView lvTest; - private SharedPreferences s; - private SharedPreferences.Editor e; - private static Activity activity; + private SharedPreferences sharedPreferences; + private SharedPreferences.Editor editor; + private Activity activity; + private Handler mHandler; @Override public void onCreate(Bundle savedInstanceState) { @@ -78,30 +86,39 @@ public void onAttach(Activity activity) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_calender, container, false); + lvTest = (TwoWayView) rootView.findViewById(R.id.lvItems); + mHandler = new Handler(Looper.getMainLooper()); + if (activity == null) return rootView; - s = PreferenceManager.getDefaultSharedPreferences(activity); - e = s.edit(); - Boolean is_class_already_set = s.getBoolean(IS_CLASS_SET, false); + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity); + editor = sharedPreferences.edit(); + + // If class is not selected, open activity + Boolean is_class_already_set = sharedPreferences.getBoolean(IS_CLASS_SET, false); if (!is_class_already_set) { Intent i = new Intent(activity, ChooseClass.class); startActivity(i); } + // Fetch the timetable we already have + Boolean is_time_table_changed = sharedPreferences.getBoolean(IS_TIME_TABLE_CHANGED, true); + timetable = sharedPreferences.getString(GET_TIME_TABLE, null); - Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true); - timetable = s.getString(GET_TIME_TABLE, null); - adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); - lvTest.setAdapter(adapter2); + // Set adapter + adapter = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); + lvTest.setAdapter(adapter); lvTest.setItemMargin(10); - if (a || timetable == null) { + // Update timetable if required + if (is_time_table_changed || timetable == null) { + // If internet is available if (Utils.isNetworkAvailable(activity)) - new DownloadTimeTable().execute(); + downloadTimeTable(); else { SnackbarManager.show( Snackbar.with(activity.getApplicationContext()) @@ -109,15 +126,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa .duration(Snackbar.SnackbarDuration.LENGTH_SHORT), activity); } } else { + // else load the previous saved timetable load(); } loadingMore = true; - new DownloadTimeTable().execute(); - - + // Set onscroll listener for infinite scrolling lvTest.setOnScrollListener(new TwoWayView.OnScrollListener() { @Override public void onScrollStateChanged(TwoWayView view, int scrollState) { @@ -130,100 +146,77 @@ public void onScroll(TwoWayView view, int firstVisibleItem, if ((lastInScreen == totalItemCount) && !(loadingMore)) { load(); // infinite scrolling } - adapter2.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); } }); + return rootView; } + // Convert timetable string to subject objects private void load() { - JSONObject ob; - JSONArray ar, ar2; - + JSONObject object; + JSONArray array1, array2; loadingMore = true; - timetable = s.getString(GET_TIME_TABLE, null); + timetable = sharedPreferences.getString(GET_TIME_TABLE, null); if (timetable == null) return; try { - ob = new JSONObject(timetable); - ar = ob.getJSONArray(GET_TIME_TABLE); + object = new JSONObject(timetable); + array1 = object.getJSONArray(GET_TIME_TABLE); - int len1 = ar.length(); + int len1 = array1.length(); for (int j = 0; j < len1; j++) { - ar2 = ar.getJSONArray(j); - + array2 = array1.getJSONArray(j); String value, proffh, subfh, roomfh, profsh, subsh, roomsh; - int len2 = ar2.length(); + int len2 = array2.length(); for (int i = 0; i < len2; i++) { - value = ar2.getJSONObject(i).getString("value"); - + value = array2.getJSONObject(i).getString("value"); //break or lunch break if (value.contains("break")) { proffh = subfh = roomfh = profsh = subsh = roomsh = null; } else if (value.contains("theory")) { //Theory - - - proffh = ar2.getJSONObject(i).getString("prof"); - roomfh = ar2.getJSONObject(i).getString("room"); - subfh = ar2.getJSONObject(i).getString("subject"); + proffh = array2.getJSONObject(i).getString("prof"); + roomfh = array2.getJSONObject(i).getString("room"); + subfh = array2.getJSONObject(i).getString("subject"); profsh = subsh = roomsh = null; } else { //Lab - proffh = ar2.getJSONObject(i).getString("prof_FH"); - roomfh = ar2.getJSONObject(i).getString("room_FH"); - subfh = ar2.getJSONObject(i).optString("subject_FH", ar2.getJSONObject(i).getString("subject")); - profsh = ar2.getJSONObject(i).getString("prof_SH"); - roomsh = ar2.getJSONObject(i).getString("room_SH"); - subsh = ar2.getJSONObject(i).optString("subject_SH", ar2.getJSONObject(i).getString("subject")); - + proffh = array2.getJSONObject(i).getString("prof_FH"); + roomfh = array2.getJSONObject(i).getString("room_FH"); + subfh = array2.getJSONObject(i).optString("subject_FH", array2.getJSONObject(i).getString("subject")); + profsh = array2.getJSONObject(i).getString("prof_SH"); + roomsh = array2.getJSONObject(i).getString("room_SH"); + subsh = array2.getJSONObject(i).optString("subject_SH", array2.getJSONObject(i).getString("subject")); } + // Create new subject object Subject_struct x = new Subject_struct(value, proffh, subfh, roomfh, profsh, subsh, roomsh); + // Assign it to particular period switch (i - 1) { - case -1: - p0.add(x); - break; - case 0: - p1.add(x); - break; - case 1: - p2.add(x); - break; - case 2: - p3.add(x); - break; - case 3: - p4.add(x); - break; - case 4: - p5.add(x); - break; - case 5: - p6.add(x); - break; - case 6: - p7.add(x); - break; - case 7: - p8.add(x); - break; - case 8: - p9.add(x); - break; - + case -1: p0.add(x); break; + case 0: p1.add(x); break; + case 1: p2.add(x); break; + case 2: p3.add(x); break; + case 3: p4.add(x); break; + case 4: p5.add(x); break; + case 5: p6.add(x); break; + case 6: p7.add(x); break; + case 7: p8.add(x); break; + case 8: p9.add(x); break; } } } } catch (JSONException e) { - Log.e("error", e.getMessage() + " "); + Log.e("ERROR : ", e.getMessage() + " "); } days.add("Monday"); days.add("Tuesday"); @@ -232,18 +225,19 @@ private void load() { days.add("Friday"); days.add("Saturday"); days.add("Sunday"); - adapter2.notifyDataSetChanged(); + adapter.notifyDataSetChanged(); loadingMore = false; - } @Override public boolean onOptionsItemSelected(MenuItem item) { + // View subjects if (item.getItemId() == R.id.subjects) { Intent i = new Intent(activity, SubjectsShow.class); startActivity(i); } + // Choose your class if (item.getItemId() == R.id.choose) { Intent i = new Intent(activity, ChooseClass.class); startActivity(i); @@ -252,127 +246,122 @@ public boolean onOptionsItemSelected(MenuItem item) { } - private class DownloadTimeTable extends AsyncTask { - - ProgressDialog progress; - - @Override - protected void onPreExecute() { - super.onPreExecute(); - p0.clear(); - p1.clear(); - p2.clear(); - p3.clear(); - p4.clear(); - p5.clear(); - p6.clear(); - p7.clear(); - p8.clear(); - p9.clear(); - lvTest.scrollTo(0, 0); - adapter2.notifyDataSetChanged(); - progress = new ProgressDialog(activity); - progress.setTitle("Loading"); - progress.setMessage("Fetching timetable..."); - progress.show(); - - } - - @Override - protected String doInBackground(String... urls) { - - int branch, sem, sec; - branch = s.getInt(CALENDAR_BRANCH, 1); - sec = s.getInt(CALENDAR_SECTION, 1); - sem = s.getInt(CALENDAR_SEM, 1); - - - // String URL; - String uri = TIMETABLE_API + - "branch=" + - branch + - "&semester=" + - sem + - "§ion=" + - sec; - - Log.e("calling", uri); - - URL url = null; - String readStream = null; - try { - url = new URL(uri); - HttpURLConnection con = (HttpURLConnection) url.openConnection(); - readStream = Utils.readStream(con.getInputStream()); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } catch (IOException e1) { - e1.printStackTrace(); + private void downloadTimeTable() { + + p0.clear(); p1.clear(); p2.clear(); + p3.clear(); p4.clear(); p5.clear(); + p6.clear(); p7.clear(); p8.clear(); p9.clear(); + + //Scroll to first column + lvTest.scrollTo(0, 0); + adapter.notifyDataSetChanged(); + final ProgressDialog progress = new ProgressDialog(activity); + progress.setTitle("Loading"); + progress.setMessage("Fetching timetable..."); + progress.show(); + + int branch, sem, sec; + branch = sharedPreferences.getInt(CALENDAR_BRANCH, 1); + sec = sharedPreferences.getInt(CALENDAR_SECTION, 1); + sem = sharedPreferences.getInt(CALENDAR_SEM, 1); + + + // URL to fetch timetable + String uri = TIMETABLE_API + + "branch=" + + branch + + "&semester=" + + sem + + "§ion=" + + sec; + + //Set up client + OkHttpClient client = new OkHttpClient(); + //Execute request + final Request request = new Request.Builder() + .url(uri) + .build(); + //Setup callback + client.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + Log.e("Request Failed", "Message : " + e.getMessage()); } + @Override + public void onResponse(Call call, Response response) throws IOException { + try { + timetable = response.body().string(); + editor.putBoolean(IS_TIME_TABLE_CHANGED, false); + editor.putString(GET_TIME_TABLE, response.body().string()); + editor.apply(); + + + JSONObject ob; + try { + ob = new JSONObject(timetable); + ob = ob.getJSONObject("metadata"); + String s = ob.optString("last_updated", "null"); + if (s.equals("null")) { + SnackbarManager.show( + Snackbar.with(activity.getApplicationContext()) + .text("Sorry, Time Table is not available now. It will be updated shortly.") + .duration(Snackbar.SnackbarDuration.LENGTH_SHORT), activity); + + } + + } catch (JSONException e) { + e.printStackTrace(); + Log.e("ERROR : ", e.getMessage() + " "); + } - return readStream; - - } - - @Override - protected void onPostExecute(String result) { - timetable = result; - progress.dismiss(); - Log.e("result", timetable + " "); - if (timetable == null) - return; - if (activity == null) - return; - - - e.putBoolean(IS_TIME_TABLE_CHANGED, false); - e.putString(GET_TIME_TABLE, result); - e.commit(); - - - JSONObject ob; - - if (timetable == null) - return; - try { - ob = new JSONObject(timetable); - ob = ob.getJSONObject("metadata"); - String s2 = ob.optString("last_updated", "null"); - if (s2.equals("null")) { - SnackbarManager.show( - Snackbar.with(activity.getApplicationContext()) - .text("Sorry, Time Table is not available now. It will be updated shortly.") - .duration(Snackbar.SnackbarDuration.LENGTH_SHORT), activity); + mHandler.post(new Runnable() { + @Override + public void run() { + progress.dismiss(); + adapter = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); + load(); + lvTest.setAdapter(adapter); + } + }); + } catch (final Exception e) { + mHandler.post(new Runnable() { + @Override + public void run() { + AlertDialog alertDialog = new AlertDialog.Builder(activity).create(); + alertDialog.setTitle("Can't connect."); + alertDialog.setMessage("We cannot connect to the internet right now. Please try again later. Exception e: " + e.toString()); + alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + alertDialog.show(); + } + }); + Log.e("Error : ", e.getMessage()); + e.printStackTrace(); } - - } catch (JSONException e) { - e.printStackTrace(); - Log.e("error", e.getMessage() + " "); } + }); + } - adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); - load(); - lvTest.setAdapter(adapter2); - - } - } @Override public void onResume() { if (activity != null) { - - Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true); - timetable = s.getString(GET_TIME_TABLE, null); - adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); - lvTest.setAdapter(adapter2); + Boolean a = sharedPreferences.getBoolean(IS_TIME_TABLE_CHANGED, true); + timetable = sharedPreferences.getString(GET_TIME_TABLE, null); + adapter = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); + lvTest.setAdapter(adapter); lvTest.setItemMargin(10); if (a || timetable == null) { if (Utils.isNetworkAvailable(activity)) - new DownloadTimeTable().execute(); + downloadTimeTable(); else { SnackbarManager.show( Snackbar.with(activity.getApplicationContext()) @@ -418,19 +407,16 @@ public CustomList_calendar(Activity context, ArrayList d, ArrayList newmessage = new ArrayList(); try { NotificationAdapter notify = new NotificationAdapter(this); diff --git a/app/src/main/java/nsit/app/com/nsitapp/PushNotification/NotificationAdapter.java b/app/src/main/java/nsit/app/com/nsitapp/PushNotification/NotificationAdapter.java index e275987e..27adfef2 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/PushNotification/NotificationAdapter.java +++ b/app/src/main/java/nsit/app/com/nsitapp/PushNotification/NotificationAdapter.java @@ -17,7 +17,6 @@ public class NotificationAdapter { public NotificationAdapter(Context mContext) throws SQLException{ - Context mContext1 = mContext; dbHelper = new DBHelper(mContext); } diff --git a/app/src/main/java/nsit/app/com/nsitapp/Sub_load.java b/app/src/main/java/nsit/app/com/nsitapp/Sub_load.java index 6a8f68d5..f423908d 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/Sub_load.java +++ b/app/src/main/java/nsit/app/com/nsitapp/Sub_load.java @@ -57,8 +57,6 @@ protected void onCreate(Bundle savedInstanceState) { public void onItemSelected(AdapterView parent, View view, int position, long id) { - String val = s3.getSelectedItem().toString(); - } @Override @@ -75,9 +73,6 @@ public void onNothingSelected(AdapterView parent) { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - String val = s4.getSelectedItem().toString(); - - if (s3.getSelectedItem().toString().equals("Branch")) { if (s4.getSelectedItem().toString().equals("Semester")) { diff --git a/app/src/main/java/nsit/app/com/nsitapp/SubjectRemove.java b/app/src/main/java/nsit/app/com/nsitapp/SubjectRemove.java index 595eee24..7cbbc218 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/SubjectRemove.java +++ b/app/src/main/java/nsit/app/com/nsitapp/SubjectRemove.java @@ -130,7 +130,7 @@ private class ViewHolder { @Override public View getView(final int position, View view, ViewGroup parent) { - ViewHolder holder = null; + ViewHolder holder; LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (view == null) { view = mInflater.inflate(R.layout.subject_list_item_remove, parent, false); diff --git a/app/src/main/java/nsit/app/com/nsitapp/Subject_struct.java b/app/src/main/java/nsit/app/com/nsitapp/Subject_struct.java index f8df9ef3..c664b10c 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/Subject_struct.java +++ b/app/src/main/java/nsit/app/com/nsitapp/Subject_struct.java @@ -6,10 +6,10 @@ class Subject_struct { public String value; - private String proffh; + public String proffh; public String subfh; public String roomfh; - private String profsh; + public String profsh; public String subsh; public String roomsh; diff --git a/app/src/main/java/nsit/app/com/nsitapp/SubjectsShow.java b/app/src/main/java/nsit/app/com/nsitapp/SubjectsShow.java index a4a78606..acd77a7b 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/SubjectsShow.java +++ b/app/src/main/java/nsit/app/com/nsitapp/SubjectsShow.java @@ -65,7 +65,6 @@ protected void onCreate(Bundle savedInstanceState) { SharedPreferences s = PreferenceManager.getDefaultSharedPreferences(this); int branch = s.getInt(CALENDAR_BRANCH, 1); - int sec = s.getInt(CALENDAR_SECTION, 1); int sem = s.getInt(CALENDAR_SEM, 1); diff --git a/app/src/main/java/nsit/app/com/nsitapp/Video.java b/app/src/main/java/nsit/app/com/nsitapp/Video.java index dc6cce9d..4a660073 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/Video.java +++ b/app/src/main/java/nsit/app/com/nsitapp/Video.java @@ -18,6 +18,7 @@ import org.json.JSONObject; import java.io.IOException; +import java.util.Objects; import adapters.VideoList_Adapter; import functions.ButtonAnimation; @@ -76,7 +77,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa btnNextPage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (nextPageToken != "") { + if (!Objects.equals(nextPageToken, "")) { Spinner.setVisibility(View.VISIBLE); navigateTo = "next"; ButtonAnimation btnAnimation = new ButtonAnimation(); @@ -89,7 +90,7 @@ public void onClick(View v) { btnPrevPage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (prevPageToken != "") { + if (!Objects.equals(prevPageToken, "")) { Spinner.setVisibility(View.VISIBLE); navigateTo = "prev"; ButtonAnimation btnAnimation = new ButtonAnimation(); @@ -102,14 +103,13 @@ public void onClick(View v) { return rootView; } - private void loadFeed() { // Youtube URI to fetch requests String uri = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUu445B5LTXzkNr5eft8wNHg&key=AIzaSyBgktirlOODUO9zWD-808D7zycmP7smp-Y"; - if (navigateTo == "next") { + if (Objects.equals(navigateTo, "next")) { uri = uri + "&pageToken=" + nextPageToken; - } else if (navigateTo == "prev") { + } else if (Objects.equals(navigateTo, "prev")) { uri = uri + "&pageToken=" + prevPageToken; } diff --git a/app/src/main/java/nsit/app/com/nsitapp/data/ContestProvider.java b/app/src/main/java/nsit/app/com/nsitapp/data/ContestProvider.java index e02ff6f7..05953698 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/data/ContestProvider.java +++ b/app/src/main/java/nsit/app/com/nsitapp/data/ContestProvider.java @@ -159,7 +159,7 @@ public int delete(Uri uri, String selection, String[] selectionArgs) { final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int match = sUriMatcher.match(uri); - int rowsDeleted = 0; + int rowsDeleted; switch(match) { case CONTEST: { @@ -185,7 +185,7 @@ public int update(Uri uri, ContentValues newValues, String selection, String[] s final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int match = sUriMatcher.match(uri); - int rowsUpdated = 0; + int rowsUpdated; switch(match) { case CONTEST: { diff --git a/app/src/main/java/nsit/app/com/nsitapp/model/Contest.java b/app/src/main/java/nsit/app/com/nsitapp/model/Contest.java index 2172b1ac..68558320 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/model/Contest.java +++ b/app/src/main/java/nsit/app/com/nsitapp/model/Contest.java @@ -77,7 +77,7 @@ public boolean equals(Object o) { Contest contest = (Contest) o; boolean isMatch = true; - isMatch = isMatch && (mTitle.equals(contest.getTitle())); + isMatch = mTitle.equals(contest.getTitle()); isMatch = isMatch && (mDescription.equals(contest.getDescription())); isMatch = isMatch && (mSource.equals(contest.getSource())); isMatch = isMatch && (mURL.equals(contest.getURL())); diff --git a/app/src/main/java/nsit/app/com/nsitapp/network/StringDownloader.java b/app/src/main/java/nsit/app/com/nsitapp/network/StringDownloader.java index 48e997ab..6d253546 100644 --- a/app/src/main/java/nsit/app/com/nsitapp/network/StringDownloader.java +++ b/app/src/main/java/nsit/app/com/nsitapp/network/StringDownloader.java @@ -19,7 +19,7 @@ protected void processData(InputStream inputStream) { try { final BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); try { - String line = null; + String line; while ((line=in.readLine())!=null) { out.append(line); } diff --git a/app/src/main/res/layout/department_list_item.xml b/app/src/main/res/layout/department_list_item.xml index 2223090c..1358fabe 100644 --- a/app/src/main/res/layout/department_list_item.xml +++ b/app/src/main/res/layout/department_list_item.xml @@ -45,5 +45,5 @@ + android:background="@color/colorPrimary"/> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_feedfinal.xml b/app/src/main/res/layout/fragment_feedfinal.xml index bf734a40..55a32987 100644 --- a/app/src/main/res/layout/fragment_feedfinal.xml +++ b/app/src/main/res/layout/fragment_feedfinal.xml @@ -11,7 +11,7 @@ android:id="@+id/progressBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center"> + android:layout_gravity="center"/> + android:layout_marginTop="5dp"/> + android:background="@color/colorPrimary" /> \ No newline at end of file diff --git a/app/src/main/res/layout/subject_list_item_remove.xml b/app/src/main/res/layout/subject_list_item_remove.xml index f6e041c5..8b0f2678 100644 --- a/app/src/main/res/layout/subject_list_item_remove.xml +++ b/app/src/main/res/layout/subject_list_item_remove.xml @@ -85,5 +85,5 @@ + android:background="@color/colorPrimary"/> \ No newline at end of file diff --git a/app/src/main/res/layout/video_listitem.xml b/app/src/main/res/layout/video_listitem.xml index 9934892e..358805cb 100644 --- a/app/src/main/res/layout/video_listitem.xml +++ b/app/src/main/res/layout/video_listitem.xml @@ -148,7 +148,7 @@ android:layout_height="2dp" android:layout_marginTop="10dp" android:background="#c7cfcecf" - android:orientation="horizontal"> + android:orientation="horizontal" />