Skip to content

Commit

Permalink
MyTrip bug, placesonmap, main activity fragment bug fixes; remove unu…
Browse files Browse the repository at this point in the history
…sed resources; moved city trends to home"

Fixed bugs in MyTrips, Places on Map; Moved city trends to home page; Remove unused resources;

Fixed bugs in MyTrips, Places on Map; Moved city trends to home page; Remove unused resources;

Fixed bugs in MyTrips, Places on Map; Moved city trends to home page

Remove unused resources

Fixing few crashes

don't do anything when same fragment is pressed again

don't do anything when same fragment is pressed again

change menu to menuid
  • Loading branch information
Swati4star committed Jun 27, 2018
1 parent da3fe6c commit a0125fe
Show file tree
Hide file tree
Showing 29 changed files with 50 additions and 171 deletions.
4 changes: 2 additions & 2 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "io.github.project_travel_mate"
minSdkVersion 21
targetSdkVersion 27
versionCode 5
versionName "2.3"
versionCode 7
versionName "2.5"
}

buildTypes {
Expand Down
4 changes: 2 additions & 2 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/AppThemeNoBar" />
<activity
android:name="com.gun0912.tedpicker.ImagePickerActivity"
android:screenOrientation="portrait"
Expand Down Expand Up @@ -89,7 +89,7 @@
<activity
android:name=".Splash"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppThemeNoBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

private SharedPreferences mSharedPreferences;
private int mPreviousMenuItemId;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -48,6 +49,7 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);

mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mPreviousMenuItemId = R.id.nav_city; // This is default item

//Initially city fragment
Fragment fragment;
Expand Down Expand Up @@ -91,6 +93,13 @@ public void onBackPressed() {
// Change fragment on selecting naviagtion drawer item
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {

if (item.getItemId() == mPreviousMenuItemId) {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}

int id = item.getItemId();
Fragment fragment;
FragmentManager fragmentManager = getSupportFragmentManager();
Expand Down Expand Up @@ -122,7 +131,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
break;
case R.id.nav_signout: {

//set AlertDIalog before signout
//set AlertDialog before signout
ContextThemeWrapper crt = new ContextThemeWrapper(this, R.style.AlertDialog);
AlertDialog.Builder builder = new AlertDialog.Builder(crt);
builder.setMessage(R.string.signout_message)
Expand All @@ -136,7 +145,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
startActivity(i);
finish();
})
.setNegativeButton(R.string.negative_button,
.setNegativeButton(android.R.string.cancel,
(dialog, which) -> {

});
Expand All @@ -148,10 +157,11 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {

DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
mPreviousMenuItemId = item.getItemId();
return true;
}

void getRuntimePermissions() {
private void getRuntimePermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.CAMERA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public class Splash extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Objects.requireNonNull(getSupportActionBar()).hide();

final PathView pathView = findViewById(R.id.pathView);
pathView.getPathAnimator()
Expand All @@ -35,7 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
pathView.setFillAfter(true);

// TODO :: check for the user_token here & redirect to corresponding class
// If token is null -> LoginActivity, else Mainactivity
// If token is null -> LoginActivity, else MainActivity
new Handler().postDelayed(() -> {
Intent i = new Intent(Splash.this, LoginActivity.class);
startActivity(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import flipviewpager.utils.FlipSettings;
import io.github.project_travel_mate.R;
import io.github.project_travel_mate.destinations.description.FinalCityInfo;
import io.github.project_travel_mate.destinations.description.Tweets;
import io.github.project_travel_mate.destinations.funfacts.FunFacts;
import objects.City;
import views.FontTextView;
Expand Down Expand Up @@ -59,7 +60,7 @@ public View getPage(int position, View convertView, ViewGroup parent, final City
holder.fv4 = (FontTextView) holder.infoPage.findViewById(R.id.interest_4);

for (int id : mIdsInterest)
holder.interests.add((TextView) holder.infoPage.findViewById(id));
holder.interests.add(holder.infoPage.findViewById(id));

convertView.setTag(holder);
} else {
Expand Down Expand Up @@ -136,8 +137,9 @@ private void fillHolder(CitiesHolder holder, final City city) {
});

holder.fv4.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
mContext.startActivity(browserIntent);
Intent intent = new Intent(mContext, Tweets.class);
intent.putExtra(EXTRA_MESSAGE_CITY_OBJECT, city);
mContext.startActivity(intent);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@ public class CityFragment extends Fragment {
private Activity mActivity;
private Handler mHandler;
private String mToken;
private AppConnectivity mConnectivity;

public CityFragment() {
}

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mConnectivity = new AppConnectivity(getContext());
AppConnectivity mConnectivity = new AppConnectivity(getContext());
View view = inflater.inflate(R.layout.content_citylist, container, false);

ButterKnife.bind(this, view);
Expand Down Expand Up @@ -142,7 +141,7 @@ public void onResponse(Call call, final Response response) {
arr.getJSONObject(i).getString("image"),
arr.getJSONObject(i).getString("city_name"),
arr.getJSONObject(i).getInt("facts_count"),
"Know More", "View on Map", "Fun Facts", "View Website"));
"Know More", "View on Map", "Fun Facts", "City Trends"));
citynames.add(arr.getJSONObject(i).getString("city_name"));
} catch (JSONException e) {
e.printStackTrace();
Expand Down Expand Up @@ -211,7 +210,7 @@ public void onResponse(Call call, final Response response) {
ar.getJSONObject(i).optString("image"),
ar.getJSONObject(i).getString("city_name"),
ar.getJSONObject(i).getInt("facts_count"),
"Know More", "View on Map", "Fun Facts", "View Website"));
"Know More", "View on Map", "Fun Facts", "City Trends"));
}

lv.setAdapter(new CityAdapter(mActivity, cities, settings));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
mFeedItems.getJSONObject(position).getJSONArray("position").get(1).toString());
showMarker(latitude,
longitude,
mFeedItems.getJSONObject(position).getString("name"));
mFeedItems.getJSONObject(position).getString("title"));
} catch (JSONException e) {
e.printStackTrace();
}
Expand All @@ -329,7 +329,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
case Activity.RESULT_CANCELED:
//User chose not to make required location settings changes
Toast.makeText(getApplicationContext(),
R.string.location_not_enabled, Toast.LENGTH_LONG);
R.string.location_not_enabled, Toast.LENGTH_LONG).show();
break;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().hide();

Window window = this.getWindow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

public void getShoppingItems(final String item) {
private void getShoppingItems(final String item) {

String uri = API_LINK_V2 + "get-shopping-info/" + item;
uri = uri.replace(" ", "+");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ protected void onCreate(Bundle savedInstanceState) {
List<File> imagesuri = new ArrayList<>();
mFname = new ArrayList<>();

Picasso.with(this).load(mTrip.getImage()).into(iv);
Picasso.with(this).load(mTrip.getImage()).error(R.drawable.delhi)
.placeholder(R.drawable.delhi).into(iv);

mHandler = new Handler(Looper.getMainLooper());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void onResponse(Call call, final Response response) throws IOException {

if (response.isSuccessful() && response.body() != null) {
final String res = response.body().string();
Log.v("Response", res);
JSONArray arr;
try {
arr = new JSONArray(res);
Expand All @@ -103,7 +104,8 @@ public void onResponse(Call call, final Response response) throws IOException {
String end = arr.getJSONObject(i).optString("end_date", null);
String name = arr.getJSONObject(i).getJSONObject("city").getString("city_name");
String tname = arr.getJSONObject(i).getString("trip_name");
String image = arr.getJSONObject(i).getJSONObject("city").getString("image");
JSONArray array = arr.getJSONObject(i).getJSONObject("city").getJSONArray("images");
String image = array.length() > 1 ? array.getString(0) : null;
mTrips.add(new Trip(id, name, image, start, end, tname));
}
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

public class AppConnectivity {

Context context;

public AppConnectivity(Context context) {
this.context = context;
Context context1 = context;
}

public boolean isOnline() {
Expand All @@ -19,9 +17,7 @@ public boolean isOnline() {
int exitValue = ipProcess.waitFor();
return (exitValue == 0);

} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onItemClick(int position) {
}
}

List<CardItemEntity> getUtilityItems() {
private List<CardItemEntity> getUtilityItems() {
List<CardItemEntity> cardEntities = new ArrayList<>();
cardEntities.add(
new CardItemEntity(
Expand Down
9 changes: 1 addition & 8 deletions Android/app/src/main/java/objects/City.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class City implements Serializable {
private String mLatitude;
private String mLongitude;
private int mFunFactsCount;
private int mBackground;

/**
* Instantiates city object
Expand All @@ -27,21 +26,19 @@ public class City implements Serializable {
* @param avatar city image
* @param nickname city name
* @param description city description
* @param background Background color when card is opened
* @param lat latitude of city
* @param lon longitude of city
* @param funFactsCount count of fun facts for the city
* @param interest list of items when string is opened
*/
public City(String id, String avatar, String nickname, String description,
int background, String lat, String lon, int funFactsCount, String... interest) {
String lat, String lon, int funFactsCount, String... interest) {
this.mAvatar = avatar;
this.mId = id;
this.mLatitude = lat;
this.mLongitude = lon;
this.mNickname = nickname;
this.mDescription = description;
this.mBackground = background;
this.mFunFactsCount = funFactsCount;
mInterests.addAll(Arrays.asList(interest));
}
Expand Down Expand Up @@ -78,10 +75,6 @@ public String getLongitude() {
return mLongitude;
}

public int getBackground() {
return mBackground;
}

public List<String> getInterests() {
return mInterests;
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Android/app/src/main/res/drawable/bus.jpg
Binary file not shown.
87 changes: 0 additions & 87 deletions Android/app/src/main/res/layout-v4/activity_profile.xml

This file was deleted.

Loading

0 comments on commit a0125fe

Please sign in to comment.