Skip to content

Commit

Permalink
Added strings to constants; removed deprecated method from checkstyle…
Browse files Browse the repository at this point in the history
….gradle; Removed code cleanup warnings
  • Loading branch information
Swati4star committed Jun 4, 2018
1 parent 9cd0b74 commit 1f9b6b4
Show file tree
Hide file tree
Showing 44 changed files with 277 additions and 182 deletions.
1 change: 0 additions & 1 deletion Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ dependencies {
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.github.ParkSangGwon:TedPicker:v1.0.10'

implementation 'com.estimote:sdk:0.9.4@aar'
implementation 'com.eftimoff:android-pathview:1.0.8@aar'
implementation 'com.squareup.picasso:picasso:2.5.2'

Expand Down
2 changes: 1 addition & 1 deletion Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
android:theme="@style/AppTheme_picker" />

<service android:enabled="true" android:name=".LocationService" />
<service android:enabled="true" android:name=".utils.GPSTracker" />
<service android:enabled="true" android:name="utils.GPSTracker" />

<activity
android:name=".SelectCity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {

final ViewHolder viewHolder;
if (convertView == null)
convertView = inflater.inflate(R.layout.flipper, (ViewGroup) null);
convertView = inflater.inflate(R.layout.flipper, parent, false);
if (convertView.getTag() != null) {
viewHolder = (ViewHolder) convertView.getTag();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

import java.util.Objects;

import utils.Constants;
import static utils.Constants.DESTINATION_CITY_LAT;
import static utils.Constants.DESTINATION_CITY_LON;

/**
* Created by swati on 17/10/15.
Expand Down Expand Up @@ -103,9 +104,9 @@ private boolean isBetterLocation(Location location, Location currentBestLocation

SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(LocationService.this);
Double m = distance(location.getLatitude(),
Double.parseDouble(sharedPreferences.getString(Constants.DESTINATION_CITY_LAT, "0.0")),
Double.parseDouble(sharedPreferences.getString(DESTINATION_CITY_LAT, "0.0")),
location.getLongitude(),
Double.parseDouble(sharedPreferences.getString(Constants.DESTINATION_CITY_LON, "0.0")));
Double.parseDouble(sharedPreferences.getString(DESTINATION_CITY_LON, "0.0")));
return m < 5000;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import io.github.project_travel_mate.travel.TravelFragment;
import io.github.project_travel_mate.utilities.EmergencyFragment;
import io.github.project_travel_mate.utilities.UtilitiesFragment;
import utils.Constants;

import static utils.Constants.USER_ID;

/**
* Launcher Activity; Handles fragment changes;
Expand Down Expand Up @@ -139,7 +140,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {

sharedPreferences
.edit()
.putString(Constants.USER_ID, null)
.putString(USER_ID, null)
.apply();
Intent i = new Intent(MainActivity.this, LoginActivity.class);
startActivity(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import utils.Constants;

import static utils.Constants.API_LINK;
import static utils.Constants.DESTINATION_CITY;
import static utils.Constants.DESTINATION_CITY_ID;
import static utils.Constants.DESTINATION_CITY_LAT;
import static utils.Constants.DESTINATION_CITY_LON;
import static utils.Constants.SOURCE_CITY;
import static utils.Constants.SOURCE_CITY_ID;
import static utils.Constants.SOURCE_CITY_LAT;
import static utils.Constants.SOURCE_CITY_LON;

@SuppressWarnings("WeakerAccess")
public class SelectCity extends AppCompatActivity {
Expand Down Expand Up @@ -77,14 +86,14 @@ public void okClicked(View view) {
Snackbar.make(view, "Source and destination cannot be same", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
} else {
editor.putString(Constants.DESTINATION_CITY_ID, id.get(dposition));
editor.putString(Constants.SOURCE_CITY_ID, id.get(sposition));
editor.putString(Constants.DESTINATION_CITY, names.get(dposition));
editor.putString(Constants.SOURCE_CITY, names.get(sposition));
editor.putString(Constants.DESTINATION_CITY_LAT, lat.get(dposition));
editor.putString(Constants.SOURCE_CITY_LAT, lat.get(sposition));
editor.putString(Constants.DESTINATION_CITY_LON, lon.get(dposition));
editor.putString(Constants.SOURCE_CITY_LON, lon.get(sposition));
editor.putString(DESTINATION_CITY_ID, id.get(dposition));
editor.putString(SOURCE_CITY_ID, id.get(sposition));
editor.putString(DESTINATION_CITY, names.get(dposition));
editor.putString(SOURCE_CITY, names.get(sposition));
editor.putString(DESTINATION_CITY_LAT, lat.get(dposition));
editor.putString(SOURCE_CITY_LAT, lat.get(sposition));
editor.putString(DESTINATION_CITY_LON, lon.get(dposition));
editor.putString(SOURCE_CITY_LON, lon.get(sposition));
SelectCity.this.startService(new Intent(SelectCity.this, LocationService.class));

editor.apply();
Expand All @@ -95,7 +104,7 @@ public void okClicked(View view) {
private void getcitytask() {

// to fetch city names
String uri = Constants.apilink + "all-cities.php";
String uri = API_LINK + "all-cities.php";
Log.v("EXECUTING : ", uri);

//Set up client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
import objects.City;
import views.FontTextView;

import static utils.Constants.EXTRA_MESSAGE_ID;
import static utils.Constants.EXTRA_MESSAGE_IMAGE;
import static utils.Constants.EXTRA_MESSAGE_NAME;

class CityAdapter extends BaseFlipAdapter<City> {

private Activity context;
private final int pages = 3;
private Typeface tex;
private final Activity context;
private final Typeface tex;
private final int[] idsInterest = {R.id.interest_1, R.id.interest_2, R.id.interest_3, R.id.interest_4};


Expand Down Expand Up @@ -93,6 +96,7 @@ public View getPage(int position, View convertView, ViewGroup parent, final City

@Override
public int getPagesCount() {
int pages = 3;
return pages;
}

Expand All @@ -116,9 +120,9 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Intent i = new Intent(context, FinalCityInfo.class);
i.putExtra("id_", friend.getId());
i.putExtra("name_", friend.getNickname());
i.putExtra("image_", friend.getAvatar());
i.putExtra(EXTRA_MESSAGE_ID, friend.getId());
i.putExtra(EXTRA_MESSAGE_NAME, friend.getNickname());
i.putExtra(EXTRA_MESSAGE_IMAGE, friend.getAvatar());
context.startActivity(i);
}
});
Expand All @@ -127,8 +131,8 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Intent i = new Intent(context, FunFacts.class);
i.putExtra("id_", friend.getId());
i.putExtra("name_", friend.getNickname());
i.putExtra(EXTRA_MESSAGE_ID, friend.getId());
i.putExtra(EXTRA_MESSAGE_NAME, friend.getNickname());
context.startActivity(i);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import utils.Constants;

import static utils.Constants.API_LINK;
import static utils.Constants.EXTRA_MESSAGE_ID;
import static utils.Constants.EXTRA_MESSAGE_IMAGE;
import static utils.Constants.EXTRA_MESSAGE_NAME;

public class CityFragment extends Fragment {

Expand All @@ -52,7 +56,7 @@ public class CityFragment extends Fragment {
@BindView(R.id.music_list)
ListView lv;

private List<String> image = new ArrayList<>();
private final List<String> image = new ArrayList<>();

private String nameyet;
private String cityid;
Expand Down Expand Up @@ -91,7 +95,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
private void tripAutoComplete() {

// to fetch city names
String uri = Constants.apilink +
String uri = API_LINK +
"city/autocomplete.php?search=" + nameyet.trim();
Log.v("executing", uri);

Expand Down Expand Up @@ -146,9 +150,9 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Log.e("jkjb", "uihgiug" + arg2);
cityid = id.get(arg2).toString();
Intent i = new Intent(activity, FinalCityInfo.class);
i.putExtra("id_", cityid);
i.putExtra("name_", name.get(arg2).toString());
i.putExtra("image_", image.get(arg2));
i.putExtra(EXTRA_MESSAGE_ID, cityid);
i.putExtra(EXTRA_MESSAGE_NAME, name.get(arg2).toString());
i.putExtra(EXTRA_MESSAGE_IMAGE, image.get(arg2));
startActivity(i);
}
});
Expand All @@ -168,7 +172,7 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
private void getCity() {

// to fetch city names
String uri = Constants.apilink +
String uri = API_LINK +
"all-cities.php";
Log.e("executing", uri + " ");

Expand Down Expand Up @@ -232,9 +236,9 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id1
City f = (City) lv.getAdapter().getItem(position);
Toast.makeText(activity, f.getNickname(), Toast.LENGTH_SHORT).show();
Intent i = new Intent(activity, FinalCityInfo.class);
i.putExtra("id_", f.getId());
i.putExtra("name_", f.getNickname());
i.putExtra("image_", f.getAvatar());
i.putExtra(EXTRA_MESSAGE_ID, f.getId());
i.putExtra(EXTRA_MESSAGE_NAME, f.getNickname());
i.putExtra(EXTRA_MESSAGE_IMAGE, f.getAvatar());
startActivity(i);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
import io.github.project_travel_mate.R;
import io.github.project_travel_mate.destinations.funfacts.FunFacts;

import static utils.Constants.EXTRA_MESSAGE_ID;
import static utils.Constants.EXTRA_MESSAGE_IMAGE;
import static utils.Constants.EXTRA_MESSAGE_LATITUDE;
import static utils.Constants.EXTRA_MESSAGE_LONGITUDE;
import static utils.Constants.EXTRA_MESSAGE_NAME;
import static utils.Constants.EXTRA_MESSAGE_TYPE;

/**
* Fetch city information for given city id
*/
Expand Down Expand Up @@ -82,9 +89,9 @@ protected void onCreate(Bundle savedInstanceState) {
mHandler = new Handler(Looper.getMainLooper());

Intent intent = getIntent();
mTitle = intent.getStringExtra("name_");
id = intent.getStringExtra("id_");
image = intent.getStringExtra("image_");
mTitle = intent.getStringExtra(EXTRA_MESSAGE_NAME);
id = intent.getStringExtra(EXTRA_MESSAGE_ID);
image = intent.getStringExtra(EXTRA_MESSAGE_IMAGE);

initUi();
initPresenter();
Expand Down Expand Up @@ -149,8 +156,8 @@ public void onClick(View v) {
switch (v.getId()) {
case R.id.funfact:
i = new Intent(FinalCityInfo.this, FunFacts.class);
i.putExtra("id_", id);
i.putExtra("name_", mTitle);
i.putExtra(EXTRA_MESSAGE_ID, id);
i.putExtra(EXTRA_MESSAGE_NAME, mTitle);
startActivity(i);
break;
case R.id.restau:
Expand All @@ -167,8 +174,8 @@ public void onClick(View v) {
break;
case R.id.trends:
i = new Intent(FinalCityInfo.this, Tweets.class);
i.putExtra("id_", id);
i.putExtra("name_", mTitle);
i.putExtra(EXTRA_MESSAGE_ID, id);
i.putExtra(EXTRA_MESSAGE_NAME, mTitle);
startActivity(i);
break;
}
Expand Down Expand Up @@ -197,7 +204,7 @@ public void onStop() {
@Override
public void showProgress() {
dialog = new MaterialDialog.Builder(FinalCityInfo.this)
.title(R.string.app_name)
.title(getString(R.string.app_name))
.content("Please wait...")
.progress(true, 0)
.show();
Expand Down Expand Up @@ -245,11 +252,11 @@ public void run() {
}

private void fireIntent(Intent intent, String type) {
intent.putExtra("id_", id);
intent.putExtra("lat_", lat);
intent.putExtra("lng_", lon);
intent.putExtra("name_", mTitle);
intent.putExtra("type_", type);
intent.putExtra(EXTRA_MESSAGE_ID, id);
intent.putExtra(EXTRA_MESSAGE_LATITUDE, lat);
intent.putExtra(EXTRA_MESSAGE_LONGITUDE, lon);
intent.putExtra(EXTRA_MESSAGE_NAME, mTitle);
intent.putExtra(EXTRA_MESSAGE_TYPE, type);
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import utils.Constants;

import static utils.Constants.API_LINK;

/**
* Created by niranjanb on 15/05/17.
Expand All @@ -32,7 +33,7 @@ public void attachView(FinalCityInfoView finalCityInfoView) {
public void fetchCityInfo(String id) {
mFinalCityInfoView.showProgress();

String uri = Constants.apilink + "city/info.php?id=" + id;
String uri = API_LINK + "city/info.php?id=" + id;
Request request = new Request.Builder()
.url(uri)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import utils.Constants;
import utils.GPSTracker;

import static utils.Constants.API_LINK;
import static utils.Constants.EXTRA_MESSAGE_ID;
import static utils.Constants.EXTRA_MESSAGE_LATITUDE;
import static utils.Constants.EXTRA_MESSAGE_LONGITUDE;
import static utils.Constants.EXTRA_MESSAGE_NAME;
import static utils.Constants.EXTRA_MESSAGE_TYPE;

public class PlacesOnMap extends AppCompatActivity implements OnMapReadyCallback {

@BindView(R.id.lv)
Expand All @@ -71,9 +77,9 @@ protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);

Intent intent = getIntent();
String name = intent.getStringExtra("name_");
String id = intent.getStringExtra("id_");
String type = intent.getStringExtra("type_");
String name = intent.getStringExtra(EXTRA_MESSAGE_NAME);
String id = intent.getStringExtra(EXTRA_MESSAGE_ID);
String type = intent.getStringExtra(EXTRA_MESSAGE_TYPE);
mHandler = new Handler(Looper.getMainLooper());

setTitle(name);
Expand All @@ -97,8 +103,8 @@ protected void onCreate(Bundle savedInstanceState) {
break;
}

deslat = intent.getStringExtra("lat_");
deslon = intent.getStringExtra("lng_");
deslat = intent.getStringExtra(EXTRA_MESSAGE_LATITUDE);
deslon = intent.getStringExtra(EXTRA_MESSAGE_LONGITUDE);

getPlaces();

Expand Down Expand Up @@ -145,7 +151,7 @@ private void getPlaces() {
progressDialog.show();

// to fetch city names
String uri = Constants.apilink + "places-api.php?lat=" + deslat + "&lng=" + deslon + "&mode=" + mode;
String uri = API_LINK + "places-api.php?lat=" + deslat + "&lng=" + deslon + "&mode=" + mode;
Log.v("executing", "URI : " + uri );

//Set up client
Expand Down Expand Up @@ -254,7 +260,7 @@ public long getItemId(int position) {
public View getView(final int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (vi == null)
vi = inflater.inflate(R.layout.city_infoitem, (ViewGroup) null);
vi = inflater.inflate(R.layout.city_infoitem, parent, false);

TextView title = vi.findViewById(R.id.item_name);
TextView description = vi.findViewById(R.id.item_address);
Expand Down
Loading

0 comments on commit 1f9b6b4

Please sign in to comment.