Skip to content

Commit

Permalink
Code improved and using okhttp for calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Swati4star committed Oct 14, 2016
1 parent 41fc64e commit b740488
Show file tree
Hide file tree
Showing 32 changed files with 379 additions and 417 deletions.
2 changes: 0 additions & 2 deletions app/src/main/java/adapters/LocationsList_Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class LocationsList_Adapter extends BaseExpandableListAdapter {
public LocationsList_Adapter(Context context, ArrayList<Locations.LocationGroup> LocationItems) {
this.context = context;
this.LocationItems = LocationItems;
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/adapters/MyFeedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/adapters/VideoList_Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());

Expand Down Expand Up @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/functions/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
26 changes: 11 additions & 15 deletions app/src/main/java/functions/GPSTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/functions/ImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/functions/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit b740488

Please sign in to comment.