From 7421da5b079e5d9a0608c3fa134ca4ac27155ff6 Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Sun, 26 Apr 2015 12:43:56 +0530 Subject: [PATCH] reformat code --- .../tosc/studddin/fragments/ListingsFragment.java | 10 ++++------ .../fragments/listings/ListingsSearchFragment.java | 14 +++++++------- .../fragments/listings/ListingsUploadFragment.java | 8 ++++---- .../fragments/listings/MyListingsFragment.java | 13 ++++++------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/in/tosc/studddin/fragments/ListingsFragment.java b/app/src/main/java/in/tosc/studddin/fragments/ListingsFragment.java index 7bb8c05..4379f95 100644 --- a/app/src/main/java/in/tosc/studddin/fragments/ListingsFragment.java +++ b/app/src/main/java/in/tosc/studddin/fragments/ListingsFragment.java @@ -9,7 +9,6 @@ import android.os.Bundle; import android.provider.MediaStore; import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBarActivity; @@ -61,7 +60,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, fragmentPagerAdapter = new FragmentStatePagerAdapter(getChildFragmentManager()) { @Override public Fragment getItem(int position) { - Log.d(TAG,"getItem called"); + Log.d(TAG, "getItem called"); switch (position) { case 0: return new ListingsSearchFragment(); @@ -95,11 +94,9 @@ public CharSequence getPageTitle(int position) { listingsPager = (ViewPager) rootView.findViewById(R.id.listings_pager); - - try { listingsPager.setAdapter(fragmentPagerAdapter); - listingsPager.setOffscreenPageLimit(2); + listingsPager.setOffscreenPageLimit(2); tabs = (SlidingTabLayout) rootView.findViewById(R.id.tabs); tabs.setDistributeEvenly(true); tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { @@ -124,7 +121,8 @@ public void goToOtherFragment(int position) { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - if (DEBUG) Log.d(TAG, "onActivityResult call ho raha hai" + resultCode + " " + requestCode); + if (DEBUG) + Log.d(TAG, "onActivityResult call ho raha hai" + resultCode + " " + requestCode); if ((requestCode == 0) && resultCode == -1) { if (data == null) { if (DEBUG) Log.d(TAG, "onActivityResult camera"); diff --git a/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsSearchFragment.java b/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsSearchFragment.java index 7641380..c9eb16a 100644 --- a/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsSearchFragment.java +++ b/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsSearchFragment.java @@ -177,13 +177,13 @@ private void fetchListings(String text) { query.whereContainedIn(ParseTables.Listings.CATEGORY, categories); if (text == null) { //if (filterPrefs.getString("sortby", "nearest").equalsIgnoreCase("recent")) - query.orderByDescending(ParseTables.Listings.CREATED_AT); + query.orderByDescending(ParseTables.Listings.CREATED_AT); //else - //query.whereNear(ParseTables.Listings.LOCATION,location); + //query.whereNear(ParseTables.Listings.LOCATION,location); query.findInBackground(new FindCallback() { @Override public void done(final List parseObjects, ParseException e) { - Log.d("Objects: ","" +parseObjects); + Log.d("Objects: ", "" + parseObjects); if (e == null) { doneFetching(parseObjects); } else { @@ -211,12 +211,12 @@ public void done(final List parseObjects, ParseException e) { ParseQuery mainQuery = ParseQuery.or(queries); mainQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE); //if (filterPrefs.getString("sortby", "nearest").compareTo("recent") == 0) - mainQuery.orderByDescending(ParseTables.Listings.CREATED_AT); + mainQuery.orderByDescending(ParseTables.Listings.CREATED_AT); //else // mainQuery.whereNear("location",location); mainQuery.findInBackground(new FindCallback() { public void done(List results, ParseException e) { - if(e==null) + if (e == null) doneFetching(results); else e.printStackTrace(); // shouldn't happen @@ -261,7 +261,7 @@ public void onBindViewHolder(final ViewHolder viewHolder, final int i) { public void done(byte[] bytes, ParseException e) { } }); - try{ + try { double distance = mDataset.get(i).getParseGeoPoint(ParseTables.Listings.LOCATION).distanceInKilometersTo(location); if (distance < 10 && distance >= 0.1) viewHolder.listing_distance.setText(String.format("%.1f", distance) + " km away"); @@ -282,7 +282,7 @@ public void onClick(View view) { } } }); - }catch(Exception e){ + } catch (Exception e) { viewHolder.listing_distance.setText("Unknown"); } } diff --git a/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsUploadFragment.java b/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsUploadFragment.java index 5818886..3a3514a 100644 --- a/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsUploadFragment.java +++ b/app/src/main/java/in/tosc/studddin/fragments/listings/ListingsUploadFragment.java @@ -130,7 +130,7 @@ public void onClick(View view) { bitmap.compress(Bitmap.CompressFormat.JPEG, 25, stream); byteArray = stream.toByteArray(); } - try{ + try { ParseFile file = new ParseFile(ParseTables.Listings.LISTING_PNG, byteArray); file.saveInBackground(); upload.put(ParseTables.Listings.IMAGE, file); @@ -138,7 +138,7 @@ public void onClick(View view) { upload.put(ParseTables.Listings.LISTING_NAME, listing.getText().toString()); upload.put(ParseTables.Listings.LISTING_DESC, listing_desc.getText().toString()); upload.put(ParseTables.Listings.MOBILE, mobile.getText().toString()); - if(point!=null) + if (point != null) upload.put(ParseTables.Listings.LOCATION, point); upload.put(ParseTables.Listings.CATEGORY, category.getSelectedItem().toString()); @@ -150,8 +150,8 @@ public void done(ParseException e) { Toast.LENGTH_SHORT).show(); } }); - }catch(Exception e){ - Toast.makeText(getActivity(),"Please connect to the Internet",Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + Toast.makeText(getActivity(), "Please connect to the Internet", Toast.LENGTH_SHORT).show(); } } break; diff --git a/app/src/main/java/in/tosc/studddin/fragments/listings/MyListingsFragment.java b/app/src/main/java/in/tosc/studddin/fragments/listings/MyListingsFragment.java index 39cb1e2..e624597 100644 --- a/app/src/main/java/in/tosc/studddin/fragments/listings/MyListingsFragment.java +++ b/app/src/main/java/in/tosc/studddin/fragments/listings/MyListingsFragment.java @@ -51,7 +51,7 @@ public MyListingsFragment() { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - rootView = inflater.inflate(R.layout.fragment_my_listings, container, false); + rootView = inflater.inflate(R.layout.fragment_my_listings, container, false); loader = (ProgressBarCircular) rootView.findViewById(R.id.progressBar); loader.setBackgroundColor(getResources().getColor(R.color.listingsColorPrimaryDark)); mEmptyView = (ScrollView) rootView.findViewById(R.id.listing_empty); @@ -65,7 +65,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, return rootView; } - private void fetchMyListings(){ + private void fetchMyListings() { ParseQuery query = new ParseQuery<>( ParseTables.Listings.LISTINGS); query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE); @@ -88,7 +88,7 @@ private void doneFetching(List parseObjects) { mAdapter.notifyDataSetChanged(); loader.setVisibility(View.GONE); mRecyclerView.setAdapter(mAdapter); - if(mAdapter.getItemCount()==0) { + if (mAdapter.getItemCount() == 0) { mEmptyView.setVisibility(View.VISIBLE); mListings.setVisibility(View.GONE); } @@ -150,14 +150,13 @@ public void onClick(View view) { object.deleteInBackground(new DeleteCallback() { @Override public void done(ParseException e) { - if(e==null){ + if (e == null) { mDataset.remove(getPosition()); notifyItemRemoved(getPosition()); notifyItemRangeChanged(getPosition(), mDataset.size()); fetchMyListings(); - } - else - Toast.makeText(getActivity(),"Please connect to the Internet",Toast.LENGTH_SHORT).show(); + } else + Toast.makeText(getActivity(), "Please connect to the Internet", Toast.LENGTH_SHORT).show(); } });