Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
championswimmer committed Apr 26, 2015
1 parent 6927b55 commit 7421da5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParseObject>() {
@Override
public void done(final List<ParseObject> parseObjects, ParseException e) {
Log.d("Objects: ","" +parseObjects);
Log.d("Objects: ", "" + parseObjects);
if (e == null) {
doneFetching(parseObjects);
} else {
Expand Down Expand Up @@ -211,12 +211,12 @@ public void done(final List<ParseObject> parseObjects, ParseException e) {
ParseQuery<ParseObject> 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<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
if(e==null)
if (e == null)
doneFetching(results);
else
e.printStackTrace(); // shouldn't happen
Expand Down Expand Up @@ -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");
Expand All @@ -282,7 +282,7 @@ public void onClick(View view) {
}
}
});
}catch(Exception e){
} catch (Exception e) {
viewHolder.listing_distance.setText("Unknown");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ 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);
upload.put(ParseTables.Listings.OWNER_NAME, ParseUser.getCurrentUser().getString(ParseTables.Users.NAME));
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());

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -65,7 +65,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
return rootView;
}

private void fetchMyListings(){
private void fetchMyListings() {
ParseQuery<ParseObject> query = new ParseQuery<>(
ParseTables.Listings.LISTINGS);
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
Expand All @@ -88,7 +88,7 @@ private void doneFetching(List<ParseObject> 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);
}
Expand Down Expand Up @@ -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();
}
});

Expand Down

0 comments on commit 7421da5

Please sign in to comment.