Pass data from 1st Activity to Fragments using Adapter - java

I'm able to pass data from 1st activity to 2nd activity but I decided to add Fragments in my 2nd activity and now it's not working. I'm completely new to Android Studio, I tried to search for solution but I can't find one.
I'm getting an error in the logcat
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.galila/com.example.galila.MainDetails}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
Here's my Main Activity (1st Activity)
RecyclerView mainRecycler, mpRecycler;
MainAdapter mainAdapter;
MpAdapter mpAdapter;
EditText searchView;
CharSequence search="";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
searchView = findViewById(R.id.search);
mainRecycler = findViewById(R.id.main_recycler);
mpRecycler = findViewById(R.id.mp_recycler);
mainRecycler();
mpRecycler();
}
private void mainRecycler() {
mainRecycler.setHasFixedSize(true);
mainRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
final ArrayList<MainHelperClass> mainLocations = new ArrayList<>();
mainLocations.add(new MainHelperClass(R.drawable.tondolbeach, R.drawable.tondol_beach1, R.drawable.tondol_beach2, R.drawable.tondol_beach3, R.drawable.tondol_beach4, "Tondol Beach", "Anda, Pangasinan", "Tondol Beach is located at the northern tip of Anda, an island municipality that used to be accessible only by boat across the narrow Catubig Channel. What makes Tondol unique is its long, shallow nature. There is a considerable amount of marine life besides starfish and crabs on the shallow beach.", "Manila - Tondol Beach", "5 hrs 19 mins (291.1 km)", "Swimming", "Sightseeing", "Boat Ride", "Eat Seafoods", "Party"));
mainLocations.add(new MainHelperClass(R.drawable.saintspeterandpaul, R.drawable.calasiao_church1, R.drawable.calasiao_church2, R.drawable.calasiao_church3, R.drawable.calasiao_church4, "Calasiao Church", "Calasiao, Pangasinan", "The Saints Peter and Paul Parish Church (Iglesia Parroquial de los Pedro y Pablo), commonly know as Calasiao Church is a baroque church located in Poblacion West, Calasiao, Pangasinan, Philippines. It was founded in 1588 by the Spaniards. It is 88.3 meter long, 25 meters wide and 27.3 meters high. It was declared as a National Treasure in 2001.", "Manila - Calasiao", "3 hrs 26 mins (211.6 km)", "Attend Mass", "Souvenirs", "Local Foods", "Sightseeing", "Fiesta"));
mainLocations.add(new MainHelperClass(R.drawable.manaoagchurch, R.drawable.manaoag_church1, R.drawable.manaoag_church2, R.drawable.manaoag_church3, R.drawable.manaoag_church4, "Manaoag Church", "Manaoag, Pangasinan", "Our Lady of Manaoag is a top-rated destination in the Philippines for Catholic travelers around the world. 'Our Lady of the Most Holy Rosary of Manaoag' or known as 'Our Lady of Manaoag' is one of the most visited church in Pangasinan. It was built in the 17th century. Thousands of people come to the province every year to experience the spiritual nature of the area and take in different historical and religious attractions.", "Manila - Manaoag Church", "3 hrs 3 mins (198.9 km)", "Attend Mass", "Souvenirs", "Local Foods", "Sightseeing", "Fiesta"));
mainLocations.add(new MainHelperClass(R.drawable.patarbeach, R.drawable.patar_beach1, R.drawable.patar_beach2, R.drawable.patar_beach3, R.drawable.patar_beach4, "Patar Beach", "Bolinao, Pangasinan", "Bolinao is known for a number of prestine beaches, the most popular one is the Patar Beach which dubbed as the Boracay of the North, located on the western coast along the South China Sea southwest of the town proper. Patar Beach is a creamy white sand beach that slopes gradually from shore making it good for swimming.", "Manila - Patar Beach", "5 hrs 25 mins (298.4 km)", "Swimming", "Sightseeing", "Boat Ride", "Eat Seafoods", "Party"));
mainLocations.add(new MainHelperClass(R.drawable.hundredisland, R.drawable.hundred_island_gallery1, R.drawable.hundred_island_gallery2, R.drawable.hundred_island_gallery3, R.drawable.hundred_island_gallery4, "Hundred Islands", "Alaminos, Pangasinan", "The Hundred Islands National Park is the first national park and a protected area located in Alaminos, Pangasinan in the Northern Philippines. The islands, totaling 124 at low tide and 123 at high tide, are scattered in Lingayen Gulf covering an area of 16.76 square kilometers (6.47 sq mi.). Only three of them have been developed for tourism: Governor Island, Quezon Island and Childrens Island.", "Manila - Hundred Islands", "3 hrs 10 mins (205 km)", "Swimming", "Island Hoping", "Snorkeling", "Kayaking", "Zipline"));
mainLocations.add(new MainHelperClass(R.drawable.bolinao_lighthouse, R.drawable.bolinao_lighthouse_1, R.drawable.bolinao_lighthouse_2, R.drawable.bolinao_lighthouse_3, R.drawable.bolinao_lighthouse_4, "Bolinao Lighthouse", "Bolinao, Pangasinan", "The Cape of Bolinao Lighthouse at Patar rises 351 ft (107 m) above sea level atop Punta Piedra Point, a towering hill of solid rock which is the sharp point of Cape Bolinao itself. It was built by the Americans in 1903. The lighthouse provides a panoramic view of a portion of the 1269 hectares Cape Bolinao Dendro Thermal Ipil-Ipil Plantation on a land area where archeological excavations have revealed relics from 14th to 15th centuries.", "Manila - Bolinao Lighthouse", "5 hrs 20 mins (284.1 km)", "Sightseeing", "Exploration", "Local Foods", "Photoshoot", "Souvenirs"));
mainLocations.add(new MainHelperClass(R.drawable.st_james_the_great, R.drawable.st_james_the_great_1, R.drawable.st_james_the_great_2, R.drawable.st_james_the_great_3, R.drawable.st_james_the_great_4, "St. James the Great Church", "Bolinao, Pangasinan", "The Saint James the Great Parish Church is a Spanish colonial church located at Brgy. Germinal in Bolinao, Pangasinan. The church was made out of black coral stones. It is one of the oldest church in Pangasinan, it was constructed in 1600s and survived multiple natural and manmade calamities like 1788 earthquake, 1819 fire and 2009 typhoon.", "Manila - St. James the Great Church", "5 hrs 6 mins (286 km)", "Attend Mass", "Souvenirs", "Local Foods", "Sightseeing", "Fiesta"));
mainLocations.add(new MainHelperClass(R.drawable.bolinao_falls, R.drawable.bolinao_falls_1, R.drawable.bolinao_falls_2, R.drawable.bolinao_falls_3, R.drawable.bolinao_falls_4, "Bolinao Falls", "Bolinao, Pangasinan", "Bolinao Falls is a short waterfall which is a result varying elevations of the Balingasay River, thus the water falls down to a pool of water located on a lower elevation. Bolinao Falls is about 19 kilometers away from Bolinao town proper. Its divided into three waterfalls, all located along the Bolinao river. Each falls has different views and features.", "Manila - Bolinao Falls", "5 hrs 3 mins (277.3 km)", "Cliff Diving", "Swimming", "Sightseeing", "Exploration", "Photoshoot"));
mainLocations.add(new MainHelperClass(R.drawable.enchanted_cave, R.drawable.enchanted_cave_1, R.drawable.enchanted_cave_2, R.drawable.enchanted_cave_3, R.drawable.enchanted_cave_4, "Enchanted Cave", "Bolinao, Pangasinan", "Enchanted Cave is one of the must visit attractions in Bolinao, Pangasinan. The name itself portrays its mystical beauty. The entire place is really enchanted since it is like a huge coral reef that emerged underwater. The water inside the cave is clear and not salty. Its depth is estimated around 3-6 ft. Enchanted Cave offers underground pool with crystal clear spring water, natural sea rock hill terrain, and etc.", "Manila - Enchanted Cave", "5 hrs 26 mins (297.6 km)", "Swimming", "Sightseeing", "Exploration", "Photoshoot", "Local Foods"));
mainLocations.add(new MainHelperClass(R.drawable.tondaligan_beach, R.drawable.tondaligan_beach_1, R.drawable.tondaligan_beach_2, R.drawable.tondaligan_beach_3, R.drawable.tondaligan_beach_4, "Tondaligan Beach", "Dagupan, Pangasinan", "One of the most visited beach in Dagupan. Its fine sands and numerous coconut trees attract people all year-round, the beach area is quite large so no need to worry about running out of good spots.", "Manila - Tondaligan Beach", "3 hrs 30 mins (219.2 km)", "Swimming", "Boat Ride", "Sightseeing", "Eat Seafoods", "Party"));
mainAdapter = new MainAdapter(mainLocations, getApplicationContext());
mainRecycler.setAdapter(mainAdapter);
searchView.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
mainAdapter.getFilter().filter(charSequence);
search = charSequence;
}
#Override
public void afterTextChanged(Editable s) {
}
});
}
private void mpRecycler() {
mpRecycler.setHasFixedSize(true);
mpRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
ArrayList<MpHelperClass> mpLocations = new ArrayList<>();
mpLocations.add(new MpHelperClass(R.drawable.hundredisland, R.drawable.hundred_island_gallery1, R.drawable.hundred_island_gallery2, R.drawable.hundred_island_gallery3, R.drawable.hundred_island_gallery4, "Hundred Islands", "Alaminos, Pangasinan", "The Hundred Islands National Park is the first national park and a protected area located in Alaminos, Pangasinan in the Northern Philippines. The islands, totaling 124 at low tide and 123 at high tide, are scattered in Lingayen Gulf covering an area of 16.76 square kilometers (6.47 sq mi.). Only three of them have been developed for tourism: Governor Island, Quezon Island and Childrens Island.", "Ratings: 4.5", "Manila - Hundred Islands", "3 hrs 10 mins (205 km)", "Swimming", "Island Hoping", "Snorkeling", "Kayaking", "Zipline"));
mpLocations.add(new MpHelperClass(R.drawable.patarbeach, R.drawable.patar_beach1, R.drawable.patar_beach2, R.drawable.patar_beach3, R.drawable.patar_beach4, "Patar Beach", "Bolinao, Pangasinan", "Bolinao is known for a number of prestine beaches, the most popular one is the Patar Beach which dubbed as the Boracay of the North, located on the western coast along the South China Sea southwest of the town proper. Patar Beach is a creamy white sand beach that slopes gradually from shore making it good for swimming.", "Ratings: 4.5", "Manila - Patar Beach", "5 hrs 25 mins (298.4 km)", "Swimming", "Sightseeing", "Boat Ride", "Eat Seafoods", "Party"));
mpLocations.add(new MpHelperClass(R.drawable.bolinao_falls, R.drawable.bolinao_falls_1, R.drawable.bolinao_falls_2, R.drawable.bolinao_falls_3, R.drawable.bolinao_falls_4, "Bolinao Falls", "Bolinao, Pangasinan", "Bolinao Falls is a short waterfall which is a result varying elevations of the Balingasay River, thus the water falls down to a pool of water located on a lower elevation. Bolinao Falls is about 19 kilometers away from Bolinao town proper. Its divided into three waterfalls, all located along the Bolinao river. Each falls has different views and features.", "Ratings: 4.5", "Manila - Bolinao Falls", "5 hrs 3 mins (277.3 km)", "Cliff Diving", "Swimming", "Sightseeing", "Exploration", "Photoshoot"));
mpLocations.add(new MpHelperClass(R.drawable.tondolbeach, R.drawable.tondol_beach1, R.drawable.tondol_beach2, R.drawable.tondol_beach3, R.drawable.tondol_beach4, "Tondol Beach", "Anda, Pangasinan", "Tondol Beach is located at the northern tip of Anda, an island municipality that used to be accessible only by boat across the narrow Catubig Channel. What makes Tondol unique is its long, shallow nature. There is a considerable amount of marine life besides starfish and crabs on the shallow beach.", "Ratings: 4", "Manila - Tondol Beach", "5 hrs 19 mins (291.1 km)", "Swimming", "Sightseeing", "Boat Ride", "Eat Seafoods", "Party"));
mpLocations.add(new MpHelperClass(R.drawable.manaoagchurch, R.drawable.manaoag_church1, R.drawable.manaoag_church2, R.drawable.manaoag_church3, R.drawable.manaoag_church4, "Manaoag Church", "Manaoag, Pangasinan", "Our Lady of Manaoag is a top-rated destination in the Philippines for Catholic travelers around the world. 'Our Lady of the Most Holy Rosary of Manaoag' or known as 'Our Lady of Manaoag' is one of the most visited church in Pangasinan. It was built in the 17th century. Thousands of people come to the province every year to experience the spiritual nature of the area and take in different historical and religious attractions.", "Ratings: 4", "Manila - Manaoag Church", "3 hrs 3 mins (198.9 km)", "Attend Mass", "Souvenirs", "Local Foods", "Sightseeing", "Fiesta"));
mpLocations.add(new MpHelperClass(R.drawable.st_james_the_great, R.drawable.st_james_the_great_1, R.drawable.st_james_the_great_2, R.drawable.st_james_the_great_3, R.drawable.st_james_the_great_4, "St. James the Great Church", "Bolinao, Pangasinan", "The Saint James the Great Parish Church is a Spanish colonial church located at Brgy. Germinal in Bolinao, Pangasinan. The church was made out of black coral stones. It is one of the oldest church in Pangasinan, it was constructed in 1600s and survived multiple natural and manmade calamities like 1788 earthquake, 1819 fire and 2009 typhoon.", "Ratings: 4", "Manila - St. James the Great Church", "5 hrs 6 mins (286 km)", "Attend Mass", "Souvenirs", "Local Foods", "Sightseeing", "Fiesta"));
mpLocations.add(new MpHelperClass(R.drawable.enchanted_cave, R.drawable.enchanted_cave_1, R.drawable.enchanted_cave_2, R.drawable.enchanted_cave_3, R.drawable.enchanted_cave_4, "Enchanted Cave", "Bolinao, Pangasinan", "Enchanted Cave is one of the must visit attractions in Bolinao, Pangasinan. The name itself portrays its mystical beauty. The entire place is really enchanted since it is like a huge coral reef that emerged underwater. The water inside the cave is clear and not salty. Its depth is estimated around 3-6 ft. Enchanted Cave offers underground pool with crystal clear spring water, natural sea rock hill terrain, and etc.", "Ratings: 4", "Manila - Enchanted Cave", "5 hrs 26 mins (297.6 km)", "Swimming", "Sightseeing", "Exploration", "Photoshoot", "Local Foods"));
mpLocations.add(new MpHelperClass(R.drawable.bolinao_lighthouse, R.drawable.bolinao_lighthouse_1, R.drawable.bolinao_lighthouse_2, R.drawable.bolinao_lighthouse_3, R.drawable.bolinao_lighthouse_4, "Bolinao Lighthouse", "Bolinao, Pangasinan", "The Cape of Bolinao Lighthouse at Patar rises 351 ft (107 m) above sea level atop Punta Piedra Point, a towering hill of solid rock which is the sharp point of Cape Bolinao itself. It was built by the Americans in 1903. The lighthouse provides a panoramic view of a portion of the 1269 hectares Cape Bolinao Dendro Thermal Ipil-Ipil Plantation on a land area where archeological excavations have revealed relics from 14th to 15th centuries.", "Ratings: 4", "Manila - Bolinao Lighthouse", "5 hrs 20 mins (284.1 km)", "Sightseeing", "Exploration", "Local Foods", "Photoshoot", "Souvenirs"));
mpLocations.add(new MpHelperClass(R.drawable.tondaligan_beach, R.drawable.tondaligan_beach_1, R.drawable.tondaligan_beach_2, R.drawable.tondaligan_beach_3, R.drawable.tondaligan_beach_4, "Tondaligan Beach", "Dagupan, Pangasinan", "One of the most visited beach in Dagupan. Its fine sands and numerous coconut trees attract people all year-round, the beach area is quite large so no need to worry about running out of good spots.", "Ratings: 3.5", "Manila - Tondaligan Beach", "3 hrs 30 mins (219.2 km)", "Swimming", "Boat Ride", "Sightseeing", "Eat Seafoods", "Party"));
mpLocations.add(new MpHelperClass(R.drawable.saintspeterandpaul, R.drawable.calasiao_church1, R.drawable.calasiao_church2, R.drawable.calasiao_church3, R.drawable.calasiao_church4, "Calasiao Church", "Calasiao, Pangasinan", "The Saints Peter and Paul Parish Church (Iglesia Parroquial de los Pedro y Pablo), commonly know as Calasiao Church is a baroque church located in Poblacion West, Calasiao, Pangasinan, Philippines. It was founded in 1588 by the Spaniards. It is 88.3 meter long, 25 meters wide and 27.3 meters high. It was declared as a National Treasure in 2001.", "Ratings: 3.5", "Manila - Calasiao", "3 hrs 26 mins (211.6 km)", "Attend Mass", "Souvenirs", "Local Foods", "Sightseeing", "Fiesta"));
mpAdapter = new MpAdapter(mpLocations, getApplicationContext());
mpRecycler.setAdapter(mpAdapter);
}
}
Here's my AdapterClass
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.MainViewHolder> implements Filterable {
ArrayList<MainHelperClass> mainLocations;
ArrayList<MainHelperClass> filteredMainLocations;
Context context;
public MainAdapter(ArrayList<MainHelperClass> mainLocations, Context context) {
this.mainLocations = mainLocations;
this.context = context;
this.filteredMainLocations = mainLocations;
}
#NonNull
#Override
public MainViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.main_card_design,parent,false);
MainViewHolder mainViewHolder = new MainViewHolder(view);
return mainViewHolder;
}
#Override
public void onBindViewHolder(#NonNull MainViewHolder holder, int position) {
final MainHelperClass mainHelperClass = filteredMainLocations.get(position);
holder.image.setImageResource(mainHelperClass.getImage());
holder.gallery1.setImageResource(mainHelperClass.getGallery1());
holder.gallery2.setImageResource(mainHelperClass.getGallery2());
holder.gallery3.setImageResource(mainHelperClass.getGallery3());
holder.gallery4.setImageResource(mainHelperClass.getGallery4());
holder.placeName.setText(mainHelperClass.getPlaceName());
holder.location.setText(mainHelperClass.getLocation());
holder.description.setText(mainHelperClass.getDescription());
holder.distance.setText(mainHelperClass.getDistance());
holder.km.setText(mainHelperClass.getKm());
holder.todo1.setText(mainHelperClass.getTodo1());
holder.todo2.setText(mainHelperClass.getTodo2());
holder.todo3.setText(mainHelperClass.getTodo3());
holder.todo4.setText(mainHelperClass.getTodo4());
holder.todo5.setText(mainHelperClass.getTodo5());
holder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(context, MainDetails.class);
intent.putExtra("image", mainHelperClass.getImage());
intent.putExtra("gallery1", mainHelperClass.getGallery1());
intent.putExtra("gallery2", mainHelperClass.getGallery2());
intent.putExtra("gallery3", mainHelperClass.getGallery3());
intent.putExtra("gallery4", mainHelperClass.getGallery4());
intent.putExtra("place name", mainHelperClass.getPlaceName());
intent.putExtra("location", mainHelperClass.getLocation());
intent.putExtra("description", mainHelperClass.getDescription());
intent.putExtra("distance", mainHelperClass.getDistance());
intent.putExtra("km", mainHelperClass.getKm());
intent.putExtra("todo1", mainHelperClass.getTodo1());
intent.putExtra("todo2", mainHelperClass.getTodo2());
intent.putExtra("todo3", mainHelperClass.getTodo3());
intent.putExtra("todo4", mainHelperClass.getTodo4());
intent.putExtra("todo5", mainHelperClass.getTodo5());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
}
#Override
public int getItemCount() {
return filteredMainLocations.size();
}
public static class MainViewHolder extends RecyclerView.ViewHolder{
ImageView image, gallery1, gallery2, gallery3, gallery4;
TextView placeName, location, description, distance, km, todo1, todo2, todo3, todo4, todo5;
public MainViewHolder(#NonNull View itemView) {
super(itemView);
image = itemView.findViewById(R.id.main_image);
gallery1 = itemView.findViewById(R.id.main_gallery_1);
gallery2 = itemView.findViewById(R.id.main_gallery_2);
gallery3 = itemView.findViewById(R.id.main_gallery_3);
gallery4 = itemView.findViewById(R.id.main_gallery_4);
placeName = itemView.findViewById(R.id.main_place_name);
location = itemView.findViewById(R.id.main_location);
description = itemView.findViewById(R.id.main_description);
distance = itemView.findViewById(R.id.main_distance);
km = itemView.findViewById(R.id.main_km);
todo1 = itemView.findViewById(R.id.main_todo1);
todo2 = itemView.findViewById(R.id.main_todo2);
todo3 = itemView.findViewById(R.id.main_todo3);
todo4 = itemView.findViewById(R.id.main_todo4);
todo5 = itemView.findViewById(R.id.main_todo5);
}
}
public Filter getFilter() {
return new Filter() {
#Override
protected FilterResults performFiltering(CharSequence charSequence) {
String key = charSequence.toString();
if (key.isEmpty()) {
filteredMainLocations = mainLocations;
}else {
ArrayList<MainHelperClass> isFiltered = new ArrayList<>();
for (MainHelperClass row : mainLocations) {
if (row.getPlaceName().toLowerCase().contains(key.toLowerCase())) {
isFiltered.add(row);
}
else if (row.getLocation().toLowerCase().contains(key.toLowerCase())) {
isFiltered.add(row);
}
}
filteredMainLocations = isFiltered;
}
FilterResults filterResults = new FilterResults();
filterResults.values = filteredMainLocations;
return filterResults;
}
#Override
protected void publishResults(CharSequence constraint, FilterResults filterResults) {
filteredMainLocations = (ArrayList<MainHelperClass>) filterResults.values;
notifyDataSetChanged();
}
};
}
}
Here's my DetailsActivity (2nd Activity), I want to create Fragments here for navigation purposes
public class MainDetails extends AppCompatActivity {
ImageView image, gallery1, gallery2, gallery3, gallery4;
TextView placeName, location, description, distance, km, todo1, todo2, todo3, todo4, todo5;
Button descriptionFragment, distanceFragment, galleryFragment, todoFragment;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_details);
descriptionFragment = (Button) findViewById(R.id.description_fragment);
distanceFragment = (Button)findViewById(R.id.distance_fragment);
galleryFragment = (Button)findViewById(R.id.gallery_fragment);
todoFragment = (Button)findViewById(R.id.todo_fragment);
descriptionFragment.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
setFragment(new DescriptionFragment());
}
});
distanceFragment.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
setFragment(new DistanceFragment());
}
});
galleryFragment.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
setFragment(new GalleryFragment());
}
});
todoFragment.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
setFragment(new TodoFragment());
}
});
image = (ImageView)findViewById(R.id.main_image_details);
gallery1 = (ImageView)findViewById(R.id.main_gallery_details_1);
gallery2 = (ImageView)findViewById(R.id.main_gallery_details_2);
gallery3 = (ImageView)findViewById(R.id.main_gallery_details_3);
gallery4 = (ImageView)findViewById(R.id.main_gallery_details_4);
placeName = (TextView)findViewById(R.id.main_place_name_details);
location = (TextView)findViewById(R.id.main_loc_details);
description = (TextView)findViewById(R.id.main_desc_details);
distance = (TextView)findViewById(R.id.main_distance_details);
km = (TextView)findViewById(R.id.main_km_details);
todo1 = (TextView)findViewById(R.id.main_todo1_details);
todo2 = (TextView)findViewById(R.id.main_todo2_details);
todo3 = (TextView)findViewById(R.id.main_todo3_details);
todo4 = (TextView)findViewById(R.id.main_todo4_details);
todo5 = (TextView)findViewById(R.id.main_todo5_details);
image.setImageResource(getIntent().getIntExtra("image", 0));
gallery1.setImageResource(getIntent().getIntExtra("gallery1", 0));
gallery2.setImageResource(getIntent().getIntExtra("gallery2", 0));
gallery3.setImageResource(getIntent().getIntExtra("gallery3", 0));
gallery4.setImageResource(getIntent().getIntExtra("gallery4", 0));
placeName.setText(getIntent().getStringExtra("place name"));
location.setText(getIntent().getStringExtra("location"));
description.setText(getIntent().getStringExtra("description"));
distance.setText(getIntent().getStringExtra("distance"));
km.setText(getIntent().getStringExtra("km"));
todo1.setText(getIntent().getStringExtra("todo1"));
todo2.setText(getIntent().getStringExtra("todo2"));
todo3.setText(getIntent().getStringExtra("todo3"));
todo4.setText(getIntent().getStringExtra("todo4"));
todo5.setText(getIntent().getStringExtra("todo5"));
final ImageView image1 = (ImageView) findViewById(R.id.main_image_details);
final ImageView gallery1 = (ImageView) findViewById(R.id.main_gallery_details_1);
gallery1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
image1.setImageResource(getIntent().getIntExtra("gallery1", 0));
}
});
final ImageView image2 = (ImageView) findViewById(R.id.main_image_details);
final ImageView gallery2 = (ImageView) findViewById(R.id.main_gallery_details_2);
gallery2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
image2.setImageResource(getIntent().getIntExtra("gallery2", 0));
}
});
final ImageView image3 = (ImageView) findViewById(R.id.main_image_details);
final ImageView gallery3 = (ImageView) findViewById(R.id.main_gallery_details_3);
gallery3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
image3.setImageResource(getIntent().getIntExtra("gallery3", 0));
}
});
final ImageView image4 = (ImageView) findViewById(R.id.main_image_details);
final ImageView gallery4 = (ImageView) findViewById(R.id.main_gallery_details_4);
gallery4.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
image4.setImageResource(getIntent().getIntExtra("gallery4", 0));
}
});
}
private void setFragment(Fragment Fragment) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.flFragment, Fragment);
fragmentTransaction.commit();
}
}

You need to use Bundle for passing data from activity to Fragment
Here is a sample code :
Create Bundle object and assign values like this
Bundle bundle = new Bundle();
bundle.putString("image", mainHelperClass.getImage());
bundle.putString("gallery1", mainHelperClass.getGallery1());
bundle.putString("gallery2", mainHelperClass.getGallery2());
bundle.putString("gallery3", mainHelperClass.getGallery3());
bundle.putString("gallery4", mainHelperClass.getGallery4());
bundle.putString("place name", mainHelperClass.getPlaceName());
bundle.putString("location", mainHelperClass.getLocation());
bundle.putString("description", mainHelperClass.getDescription());
bundle.putString("distance", mainHelperClass.getDistance());
bundle.putString("km", mainHelperClass.getKm());
bundle.putString("todo1", mainHelperClass.getTodo1());
bundle.putString("todo2", mainHelperClass.getTodo2());
bundle.putString("todo3", mainHelperClass.getTodo3());
bundle.putString("todo4", mainHelperClass.getTodo4());
bundle.putString("todo5", mainHelperClass.getTodo5());
Call the Fragment and pass arguments from Adapter class
YourFragment fragment = new YourFragment();
fragment.setArguments(bundle);
FragmentManager fragmentManager = ((FragmentActivity) context).getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frame_id, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();

You can pass data activity to fragment via Bundle
Bundle bundle = new Bundle();
bundle.putString("edttext", "From Activity");
// set Fragmentclass Arguments
Fragmentclass fragobj = new Fragmentclass();
fragobj.setArguments(bundle);
To get those datas in fragment
String strtext = getArguments().getString("edttext");
return inflater.inflate(R.layout.fragment, container, false);

Related

How to get the method to return and print in main? Java

I've written the whole program, but I still can't get the discount to apply to the second print.
Here is my code:
public static void main(String[] args) {
// create array
Book[] bookArray = new Book[6];
// use parameterized constructor to create books
bookArray[0] = new Book("Java Programming", "Liang", 1320, 145.00);
bookArray[1] = new Book("Horton Hears a Who!", "Dr. Suess", 72, 19.99);
bookArray[2] = new Book("The Hobbit", "Tolkien", 320, 9.25);
bookArray[3] = new Book("Born a Crime", "Noah", 304, 17.33);
// use no-arg constructor to create books
bookArray[4] = new Book();
bookArray[5] = new Book();
// foreach to print
for (Book book: bookArray) {
System.out.println(book);
}
System.out.println();
finishArray(bookArray);
System.out.println("Books after completing library and 40% discount");
for (Book book: bookArray) {
System.out.println(book);
}
System.out.println("Most Expensive book after the discounts:\n" + reduceBooks(bookArray));
System.out.println("Size of Library: " + bookArray.length + " books");
}
public static void finishArray(Book bookArray[]) {
Book book;
book = bookArray[4];
book.setTitle("Dark Territory");
book.setAuthor("Kaplan");
book.setPages(352);
book.setPrice(11.24);
book = bookArray[5];
book.setTitle("Born to Run");
book.setAuthor("Springsteen");
book.setPages(508);
book.setPrice(12.17);
}
public static Book reduceBooks(Book bookArray[]) {
Book most = bookArray[0];
for (int i = 0; i < bookArray.length; i++) {
Book book = bookArray[i];
// see if this book is more expensive than current most
if(book.getPrice() > most.getPrice()) {
most = book;
}
// reduce price
book.setPrice(book.getPrice() * 0.6);
}
return most; // return most expensive
}
}
Here's my output which as you can see the discount does not apply to the second printing:
Title: Java Programming
Author: Liang
Pages: 1320
Price: 145.00
Title: Horton Hears a Who!
Author: Dr. Suess
Pages: 72
Price: 19.99
Title: The Hobbit
Author: Tolkien
Pages: 320
Price: 9.25
Title: Born a Crime
Author: Noah
Pages: 304
Price: 17.33
Title: null
Author: null
Pages: 0
Price: 0.00
Title: null
Author: null
Pages: 0
Price: 0.00
Books after completing library and 40% discount
Title: Java Programming
Author: Liang
Pages: 1320
Price: 145.00
Title: Horton Hears a Who!
Author: Dr. Suess
Pages: 72
Price: 19.99
Title: The Hobbit
Author: Tolkien
Pages: 320
Price: 9.25
Title: Born a Crime
Author: Noah
Pages: 304
Price: 17.33
Title: Dark Territory
Author: Kaplan
Pages: 352
Price: 11.24
Title: Born to Run
Author: Springsteen
Pages: 508
Price: 12.17
Most Expensive book after the discounts:
Title: Java Programming
Author: Liang
Pages: 1320
Price: 87.00
Size of Library: 6 books
Also, these are the instructions for the reduceBooks(), everything must be done in that method-
In reduceBooks():
this method returns a Book instance.
use a loop (any type) to reduce the price of every book in the array by 40%.
determine the most expensive book after the discounts and return this book to main.
You should apply discount before second print. Also, do not forget to remove reducing price code from reduceBooks or else you'll reduce price twice.
Here is an example how you can do it:
// first print
applyDiscount(bookArray);
// second print
public static void applyDiscount(Book bookArray[]) {
for (int i = 0; i < bookArray.length; i++) {
Book book = bookArray[i];
// reduce price
book.setPrice(book.getPrice() * 0.6);
}
}

Why my textview deosn't show up, I can see it on the preview in my XML file but not on my app? (Android)

My textview shows up in the code preview, but not when I run the app. I have had this issue for another page and can not resolve it. I'm not really sure why this is happening. I've been playing with a lot of different things in the code and none seem to work.
Below is the code for my XML file and my activity:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/provider_title"
android:layout_width="match_parent"
android:layout_below="#id/moreInfoPicture"
android:layout_height="30dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginRight="0dp"
android:layout_marginLeft="25dp"
/>
<TextView
android:id="#+id/about_the_provider"
android:layout_width="match_parent"
android:layout_below="#id/provider_title"
android:layout_height="30dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginRight="0dp"
android:layout_marginLeft="25dp"
android:text="About the provider"
/>
<TextView
android:id="#+id/more_info_text"
android:layout_width="match_parent"
android:layout_below="#id/about_the_provider"
android:layout_height="250dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="25dp"
/>
<ImageButton
android:id="#+id/moreInfoPicture"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:padding="0dp"
/>
</RelativeLayout>
</ScrollView>
Here is the code for my activity:
package com.example.leoconnelly.connexus;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.method.ScrollingMovementMethod;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
/**
* Created by leoconnelly on 4/11/18.
*/
public class MoreInfoActivity extends AppCompatActivity {
ImageButton moreInfoImage;
TextView moreInfoText;
TextView AboutProv;
TextView ProvName;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.more_info);
Context mContext = this;
Typeface buttonFont = Typeface.createFromAsset(this.getAssets(), "fonts/Roboto-Regular.ttf");
Typeface boldFont = Typeface.createFromAsset(this.getAssets(), "fonts/Roboto-Bold.ttf");
AboutProv = findViewById(R.id.about_the_provider);
AboutProv.setTypeface(boldFont);
AboutProv.setTextColor(000000);
AboutProv.setText("About the provider:");
AboutProv.setTextSize(30);
ProvName = findViewById(R.id.provider_title);
ProvName.setTypeface(boldFont);
ProvName.setTextColor(000000);
// moreInfoImage.findViewById(R.id.moreInfoPicture);
moreInfoText = findViewById(R.id.more_info_text);
// moreInfoImage = findViewById(R.id.moreInfoPicture);
//get array
final ArrayList<HealthCenterButton> healthCentersList = HealthCenterButton.getHealthCentersFromFile("healthCenters.json", this);
final ArrayList <String> miniList = new ArrayList <String>();
for (HealthCenterButton healthCenterButton : healthCentersList) {
miniList.add(healthCenterButton.mini);
System.out.println("BEEEP BEEP BEEP BOOP BOP BEEPED BOOP BEEP");
System.out.println(miniList);
}
//set up array for mini iamges
/*
ImageView iw= (ImageView)findViewById(R.id.imageView1);
*/
//make it scrollable
moreInfoText.setMovementMethod(new ScrollingMovementMethod());
// int index = getIntent(index);
int index = getIntent().getExtras().getInt("index");
//String intentStringNumber = getIntent().getStringExtra("index");
// int index = Integer.parseInt(intentStringNumber);
// int index = 0;
System.out.println(index +" BOOOP BOP BOOP BOOP BOPP BOOP");
if (index == 7) {
//Bowdoin
moreInfoText.setText("Founded in Boston's Dorchester neighborhood in 1972 by community residents, " +
"Bowdoin Street Health Center remains focused on providing outstanding medical care while" +
" maintaining a tradition of working with residents to identify and meet their " +
"unique health needs. The mission of the health center is to provide excellent, " +
"compassionate care to our patients and support the health of the entire community.");
//Picasso.with(mContext).load(miniList.get(1)).into(moreInfoImage);
// moreInfoImage =
// Picasso.with(mContext).load(healthCenterButton.imageUrl).into(thumbnailImageView);
// ProvName.setText("Bowdoin Street Health Center");
AboutProv.setText("About the provider:");
}
else if (index == 7) {
//BIDMC Chelsea
moreInfoText.setText("In the midst of a thriving Chelsea neighborhood, " +
"we bring world-class health care to patients north of Boston. " +
"Our patients have the best of all worlds: dedicated staff, the atmosphere of a private practice, " +
"and access to the expertise, resources, and systems of Beth Israel Deaconess Medical Center.");
// ProvName.setText("BIDMC Chelsea");
}
else if (index == 2) {
//BIDMC
moreInfoText.setText("Beth Israel Deaconess Medical Center (BIDMC) in Boston, Massachusetts is a teaching hospital of Harvard Medical School. It was formed out of the 1996 merger of Beth Israel Hospital (founded in 1916) and New England Deaconess Hospital (founded in 1896). Among independent teaching hospitals, Beth Israel Deaconess Medical Center consistently ranks in the top three recipients of biomedical research funding from the National Institutes of Health. Research funding totals nearly $200 million annually. BIDMC researchers run more than 850 active sponsored projects and 200 clinical trials. " +
"The Harvard-Thorndike General Clinical Research Center, " +
"the oldest clinical research laboratory in the United States, " +
"has been located on this site since 1973");
// ProvName.setText("Beth Israel Deaconess Medical Center (BIDMC)");
}
else if (index == 1) {
//Dimock Community Health Center Complex
moreInfoText.setText("Recognized nationally as a model for the delivery of comprehensive health and human services in an urban community, The Dimock Center provides the residents of Boston with convenient access to high quality, low cost health care and human services that might not otherwise be available to the communities we serve. " +
" In 2013, Dimock handled over 76,000 visits annually with 17,000 unique patients and " +
"clients representing a wide range of socioeconomic and ethnic backgrounds.");
//ProvName.setText("Dimock Community Health Center");
}
else if (index == 4) {
//Fenway Health
moreInfoText.setText("For more than forty years, " +
"Fenway Health has been working to make life healthier for the people in our neighborhood, " +
"the LGBT community, people living with HIV/AIDS and the broader population. Fenway was " +
"founded in 1971 as part of the free clinic movement by students who believed that" +
" ''health care should be a right, not a privilege. In its early days, " +
"Fenway was a drop-in clinic providing free blood pressure checks and STD screenings. Over the years, Fenway obtained permanent space and incorporated as a freestanding health center with a staff of one volunteer doctor, one nurse and one intake worker. Today, Fenway Health has a budget of more than $90 million, a staff of 500 and a patient population of more than 28,000. " +
"Fenway Health is a Federally Qualified Community Health Center.");
// ProvName.setText("Fenway Health");
}
else if (index == 5) {
//South Cove Medical Center
moreInfoText.setText("South Cove Community Health Center ('South Cove') is the premier Asian community health center of Massachusetts. Founded in 1972, South Cove provides medical and behavioral health services and youth and family programs for approximately 32,000 clients at four locations in the greater Boston area. Our mission is to improve the health and well being of all medically underserved in Massachusetts, with a special focus on Asian Americans. " +
"This mission is accomplished by providing high quality, " +
"community-based health care and health promotion programs " +
"that are accessible and linguistically and culturally competent for these populations.");
// ProvName.setText("South Cove Medical Center");
}
else if (index == 6) {
//South Cove Chinatown
moreInfoText.setText("South Cove Community Health Center ('South Cove') is the" +
" premier Asian community health center of Massachusetts.
Founded in 1972, South Cove provides medical and" +
" behavioral health services and youth and family programs for
approximately 32,000 clients at four locations in the greater Boston area. " +
"Our mission is to improve the health and well being of all
medically underserved in Massachusetts, with a special focus on Asian
Americans. " +
" This mission is accomplished by providing high quality," +
" community-based health care and health promotion programs" +
" that are accessible and " +
"linguistically and culturally competent for these
populations");
// ProvName.setText("South Cove China Town");
}
}
}
TRY THIS
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
I havnt tried but it seems like you scroll view is overlaying the layout try this and let me know
Try below :
text.setTextColor(Color.parseColor(Color.BLACK));
or
text.setTextColor(Color.parseColor("#FFFFFF"));
instead of
ProvName.setTextColor(000000);
Try:
public ImageButton moreInfoImage;
public TextView moreInfoText;
public TextView AboutProv;
public TextView ProvName;
or
public ImageButton moreInfoImage;
public TextView moreInfoText, AboutProv, ProvName;
You define the TextViews in a protected and class specific method. This causes issues with the display of the activity outside of the onCreate method.
Also you should avoid using an uppercase letter as the first letter in your variable. That's not proper camel-casing methodologies.
For clarity I'd change:
AboutProv to aboutProv
ProvName to provName
everywhere mentioned in your code.

Unable to get required output for simple Hadoop mapreduce program

I am trying to write this mapreduce program which has to take input from two files, one has the details of occupations and states , and the other has details of occupation and job growth percentage. I use two mappers and combine them and in my reducer try to see which jobs have growth percent more than 30. My output should ideally be the occupation followed by the list of states. I am however, only getting the occupation names and not the states. I have posted the code and the sample input files below. PLease point out what i am doing wrong. Thanks.
(Please note that the samples of the input files i have provided are just small portions of the actual files).
package com;
import java.io.IOException;
//import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.MultipleInputs;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
public class GrowthState extends Configured implements Tool {
//Parser for Mapper1
public static class StateParser{
private String State,Occupation;
public void parse(String record){
String str[] = record.split("\t");
if(str[4].length() != 0)
setOccupation(str[4]);
else
setOccupation("Default Occupation");
if(str[2].length() != 0)
setState(str[2]);
else
setState("Default State");
}
public void parse(Text record){
parse(record.toString());
}
public String getState() {
return State;
}
public void setState(String state) {
State = state;
}
public String getOccupation() {
return Occupation;
}
public void setOccupation(String occupation) {
Occupation = occupation;
}
}
//Mapper1 - Processing state.txt
public static class GrowthMap1 extends Mapper<LongWritable,Text,Text,Text>{
StateParser sp = new StateParser();
Text outkey = new Text();
Text outvalue = new Text();
public void map(LongWritable key,Text value,Context context) throws IOException, InterruptedException{
sp.parse(value);
outkey.set(sp.getOccupation());
outvalue.set("m1\t"+sp.getState());
context.write(outkey,outvalue);
//String str[] = value.toString().split("\t");
//context.write(new Text(str[2]), new Text("m1\t"+str[4]));
}
}
public static class ProjParser{
private String Occupation,percent;
public void parse(String record){
String str[] = record.split("\t");
if(str[0].length() != 0)
setOccupation(str[0]);
else
setOccupation("Default Occupation");
if(str[5].length() != 0)
setPercent(str[5]);
else
setPercent("0");
}
public void parse(Text record){
parse(record.toString());
}
public String getOccupation() {
return Occupation;
}
public void setOccupation(String occupation) {
Occupation = occupation;
}
public String getPercent() {
return percent;
}
public void setPercent(String percent) {
this.percent = percent;
}
}
//Mapper2 - processing projection.txt
public static class GrowthMap2 extends Mapper<LongWritable,Text,Text,Text> {
ProjParser pp = new ProjParser();
Text outkey = new Text();
Text outvalue = new Text();
public void map(LongWritable key,Text value,Context context) throws IOException, InterruptedException{
pp.parse(value);
outkey.set(pp.getOccupation());
outvalue.set("m2\t"+pp.getPercent());
context.write(outkey, outvalue);
//String str[] = value.toString().split("\t");
//context.write(new Text(str[0]), new Text("m2\t"+str[5]));
}
}
//Reducer
public static class GrowthReduce extends Reducer<Text,Text,Text,Text>{
Text outvalue = new Text();
public void reduce(Text key,Iterable<Text> value,Context context)throws IOException, InterruptedException{
float cent = 0;
String state = "";
for(Text values : value){
String[] str = values.toString().split("\t");
if(str[0].equals("m1")){
state = state + " " + str[1];
}else if(str[0].equals("m2")){
try{
cent = Float.parseFloat(str[1]);
}catch(Exception nf){
cent = 0;
}
}
}
if(cent>=30){
outvalue.set(state);
context.write(key,outvalue );
}
}
}
//Driver
#Override
public int run(String[] args) throws Exception {
Job job = new Job(getConf(), "States of Growth");
job.setJarByClass(GrowthState.class);
job.setReducerClass(GrowthReduce.class);
MultipleInputs.addInputPath(job, new Path(args[0]), TextInputFormat.class, GrowthMap1.class);
MultipleInputs.addInputPath(job, new Path(args[1]), TextInputFormat.class, GrowthMap2.class);
FileOutputFormat.setOutputPath(job,new Path(args[2]));
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
return job.waitForCompletion(true)?0:1;
}
public static void main(String args[]) throws Exception{
int exitcode = ToolRunner.run(new GrowthState(), args);
System.exit(exitcode);
}
}
Sample input file1:
01 AL Alabama 00-0000 All Occupations total "1,857,530" 0.4 1000.000 1.00 19.66 "40,890" 0.5 8.30 9.72 14.83 23.95 36.04 "17,260" "20,220" "30,850" "49,810" "74,950"
01 AL Alabama 11-0000 Management Occupations major "67,500" 1.1 36.338 0.73 51.48 "107,080" 0.6 24.54 33.09 44.98 62.09 88.43 "51,050" "68,830" "93,550" "129,150" "183,940"
01 AL Alabama 11-1011 Chief Executives detailed "1,080" 4.8 0.580 0.32 97.67 "203,150" 2.5 52.05 67.58 # # # "108,270" "140,570" # # #
01 AL Alabama 11-1021 General and Operations Managers detailed "26,480" 1.5 14.258 0.94 58.00 "120,640" 0.9 27.65 35.76 49.00 71.44 # "57,510" "74,390" "101,930" "148,590" #
01 AL Alabama 11-1031 Legislators detailed "1,470" 8.7 0.790 1.94 * "21,920" 3.5 * * * * * "16,120" "17,000" "18,450" "20,670" "32,820" TRUE
01 AL Alabama 11-2011 Advertising and Promotions Managers detailed 80 16.3 0.042 0.19 44.88 "93,350" 9.5 21.59 30.28 38.92 52.22 74.07 "44,900" "62,980" "80,960" "108,620" "154,060"
01 AL Alabama 11-2021 Marketing Managers detailed 610 11.5 0.329 0.24 61.28 "127,460" 7.4 31.96 37.63 53.39 73.17 # "66,480" "78,280" "111,040" "152,200" #
01 AL Alabama 11-2022 Sales Managers detailed "2,330" 5.4 1.253 0.47 54.63 "113,620" 2.2 27.28 35.42 48.92 67.62 89.42 "56,740" "73,660" "101,750" "140,640" "186,000"
05 AR Arkansas 43-4161 "Human Resources Assistants, Except Payroll and Timekeeping" detailed "1,470" 6.6 1.265 1.26 17.25 "35,870" 1.5 11.09 13.54 17.11 20.74 23.30 "23,060" "28,170" "35,590" "43,150" "48,450"
05 AR Arkansas 43-4171 Receptionists and Information Clerks detailed "7,080" 3.3 6.109 0.84 11.26 "23,420" 0.8 8.14 9.19 10.87 13.09 14.94 "16,940" "19,110" "22,600" "27,230" "31,070"
05 AR Arkansas 43-4181 Reservation and Transportation Ticket Agents and Travel Clerks detailed 590 23.6 0.510 0.50 12.61 "26,220" 6.1 8.99 9.81 10.88 14.82 20.59 "18,710" "20,400" "22,630" "30,830" "42,830"
05 AR Arkansas 43-4199 "Information and Record Clerks, All Other" detailed 920 4.7 0.795 0.61 18.45 "38,370" 1.8 13.59 15.33 18.49 21.35 23.86 "28,270" "31,880" "38,470" "44,410" "49,630"
05 AR Arkansas 43-5011 Cargo and Freight Agents detailed 480 16.5 0.418 0.73 * * * * * * * * * * * * *
05 AR Arkansas 43-5021 Couriers and Messengers detailed 510 12.4 0.444 0.84 11.92 "24,790" 2.1 8.73 9.91 11.26 13.49 16.03 "18,160" "20,620" "23,420" "28,060" "33,350"
sample input file 2:
Management occupations 11-0000 "8,861.5" "9,498.0" 636.6 7.2 22.2 "2,586.7" "$93,910" — — —
Top executives 11-1000 "2,361.5" "2,626.8" 265.2 11.2 3.3 717.4 "$99,550" — — —
Chief executives 11-1011 330.5 347.9 17.4 5.3 17.7 87.8 "$168,140" Bachelor's degree 5 years or more None
General and operations managers 11-1021 "1,972.7" "2,216.8" 244.1 12.4 1.0 613.1 "$95,440" Bachelor's degree Less than 5 years None
Legislators 11-1031 58.4 62.1 3.7 6.4 — 16.5 "$19,780" Bachelor's degree Less than 5 years None
"Advertising, marketing, promotions, public relations, and sales managers" 11-2000 637.4 700.5 63.1 9.9 3.4 203.3 "$107,950" — — —
Advertising and promotions managers 11-2011 35.5 38.0 2.4 6.9 17.8 13.4 "$88,590" Bachelor's degree Less than 5 years None
Marketing and sales managers 11-2020 539.8 592.5 52.7 9.8 2.6 168.6 "$110,340" — — —
Marketing managers 11-2021 180.5 203.4 22.9 12.7 2.6 61.7 "$119,480" Bachelor's degree 5 years or more None
Sales managers 11-2022 359.3 389.0 29.8 8.3 2.7 106.9 "$105,260" Bachelor's degree Less than 5 years None
Public relations and fundraising managers 11-2031 62.1 70.1 8.0 12.9 1.6 21.3 "$95,450" Bachelor's degree 5 years or more None
Operations specialties managers 11-3000 "1,647.5" "1,799.7" 152.1 9.2 3.3 459.1 "$100,720" — — —
Administrative services managers 11-3011 280.8 315.0 34.2 12.2 0.1 79.9 "$81,080" Bachelor's degree Less than 5 years None
Computer and information systems managers 11-3021 332.7 383.6 50.9 15.3 3.1 97.1 "$120,950" Bachelor's degree 5 years or more None
Financial managers 11-3031 532.1 579.2 47.1 8.9 5.1 146.9 "$109,740" Bachelor's degree 5 years or more None
Industrial production managers 11-3051 172.7 168.6 -4.1 -2.4 6.1 31.4 "$89,190" Bachelor's degree 5 years or more None
Purchasing managers 11-3061 71.9 73.4 1.5 2.1 0.3 17.3 "$100,170" Bachelor's degree 5 years or more None
"Transportation, storage, and distribution managers" 11-3071 105.2 110.3 5.1 4.9 4.8 29.1 "$81,830" High school diploma or equivalent 5 years or more None
Compensation and benefits managers 11-3111 20.7 21.4 0.6 3.1 — 6.1 "$95,250" Bachelor's degree 5 years or more None
Human resources managers 11-3121 102.7 116.3 13.6 13.2 1.0 40.6 "$99,720" Bachelor's degree 5 years or more None
Training and development managers 11-3131 28.6 31.8 3.2 11.2 — 10.7 "$95,400" Bachelor's degree 5 years or more None
Other management occupations 11-9000 "4,215.0" "4,371.0" 156.1 3.7 43.1 "1,207.0" "$81,940" — — —
There is a problem with your reducer.
The faulty code is shown below. The loop below gets called for all the values of a particular key (for e.g. for "Advertising and promotions managers", it gets called twice. Once with value "Alabama" and again with value "6.9"). Problem is, you have put the if(cent >= 30) statement, outside the for loop. It should be inside, for matching the key.
for(Text values : value){
String[] str = values.toString().split("\t");
if(str[0].equals("m1")){
state = state + " " + str[1];
}else if(str[0].equals("m2")){
try{
cent = Float.parseFloat(str[1]);
}catch(Exception nf){
cent = 0;
}
}
}
if(cent>=30){
outvalue.set(state);
context.write(key,outvalue );
}
Following piece of code works fine.
//Reducer
public static class GrowthReduce extends Reducer<Text,Text,Text,Text>{
Text outvalue = new Text();
HashMap<String, String> stateMap = new HashMap<String, String>();
public void reduce(Text key,Iterable<Text> value,Context context)throws IOException, InterruptedException{
float cent = 0;
for(Text values : value){
String[] str = values.toString().split("\t");
if(str[0].equals("m1")){
stateMap.put(key.toString().toLowerCase(), str[1]);
}
else if(str[0].equals("m2")){
try{
cent = Float.parseFloat(str[1]);
if(stateMap.containsKey(key.toString().toLowerCase()))
{
if(cent>30) {
outvalue.set(stateMap.get(key.toString().toLowerCase()));
context.write(key, outvalue);
}
stateMap.remove(key.toString());
}
}catch(Exception nf){
cent = 0;
}
}
}
}
}
The logic is:
As and when you encounter a state (value "m1"), you put it in state map.
Next time, when you encounter percent with same key (value "m2"), you check if the state is already in the map. If yes, then you output the key/value.

How to read the contents of (.bib) file format using Java

I need to read .bib file and insert it tags into an objects of bib-entries
the file is big (almost 4000 lines) , so my first question is what to use (bufferrReader or FileReader)
the general format is
#ARTICLE{orleans01DJ,
author = {Doug Orleans and Karl Lieberherr},
title = {{{DJ}: {Dynamic} Adaptive Programming in {Java}}},
journal = {Metalevel Architectures and Separation of Crosscutting Concerns 3rd
Int'l Conf. (Reflection 2001), {LNCS} 2192},
year = {2001},
pages = {73--80},
month = sep,
editor = {A. Yonezawa and S. Matsuoka},
owner = {Administrator},
publisher = {Springer-Verlag},
timestamp = {2009.03.09}
}
#ARTICLE{Ossher:1995:SOCR,
author = {Harold Ossher and Matthew Kaplan and William Harrison and Alexander
Katz},
title = {{Subject-Oriented Composition Rules}},
journal = {ACM SIG{\-}PLAN Notices},
year = {1995},
volume = {30},
pages = {235--250},
number = {10},
month = oct,
acknowledgement = {Nelson H. F. Beebe, University of Utah, Department of Mathematics,
110 LCB, 155 S 1400 E RM 233, Salt Lake City, UT 84112-0090, USA,
Tel: +1 801 581 5254, FAX: +1 801 581 4148, e-mail: \path|beebe#math.utah.edu|,
\path|beebe#acm.org|, \path|beebe#computer.org| (Internet), URL:
\path|http://www.math.utah.edu/~beebe/|},
bibdate = {Fri Apr 30 12:33:10 MDT 1999},
coden = {SINODQ},
issn = {0362-1340},
keywords = {ACM; object-oriented programming systems; OOPSLA; programming languages;
SIGPLAN},
owner = {Administrator},
timestamp = {2009.02.26}
}
As you can see , there are some entries that have more than line, entries that end with }
entries that end with }, or }},
Also , some entries have {..},{..}.. in the middle
so , i am a little bit confused on how to start reading this file and how to get these entries and manipulate them.
Any help will be highly appreciated.
We currently discuss different options at JabRef.
These are the current options:
JBibTeX
ANTLRv3 Grammar
JabRef's BibtexParser.java

JsonParser ArrayIndexOutOfBoundsException when parsing json

The following code should work as a JsonParser but it is returning an ArrayIndexOutOfBoundsException even though I check that there are still elements to parse.
public void parseJson(String url) {
try {
InputStream is = new URL(url).openStream();
JsonParser parser = Json.createParser(is);
while (parser.hasNext()) {
Event e = parser.next();
if (e == Event.KEY_NAME) {
if (parser.getString().equals("name") && parser.hasNext()) {
parser.next();
writer = new BufferedWriter(new FileWriter("names.txt"));
writer.write(parser.getString());
}
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
The error produced is such:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4096
at org.glassfish.json.JsonTokenizer.readChar(JsonTokenizer.java:388)
at org.glassfish.json.JsonTokenizer.read(JsonTokenizer.java:98)
at org.glassfish.json.JsonTokenizer.readString(JsonTokenizer.java:124)
at org.glassfish.json.JsonTokenizer.nextToken(JsonTokenizer.java:310)
at org.glassfish.json.JsonParserImpl$StateIterator.nextToken(JsonParserImpl.java:157)
at org.glassfish.json.JsonParserImpl$StateIterator.next(JsonParserImpl.java:182)
at org.glassfish.json.JsonParserImpl.next(JsonParserImpl.java:150)
at proj.Proj2.parseJson(Proj2.java:43)
at proj.Proj1.main(Proj1.java:78)
It parses everything up to when the error is thrown.
Sample JSON that produces error:
[{"id":774,"na":"Hungry Leaf","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1200,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Sandwiches"],"addr":"2608 Erwin Rd, Durham, NC","full_addr":{"addr":"2608 Erwin Rd","addr2":"","city":"Durham","state":"NC","postal_code":"27705-3843"},"city":"Durham","latitude":36.008621,"longitude":-78.94474,"del":1200,"mino":100,"is_delivering":0},{"id":780,"na":"Armadillo Grill","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1080,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["Mexican","Tex-Mex"],"addr":"439 Glenwood Ave, Raleigh, NC","full_addr":{"addr":"439 Glenwood Ave","addr2":"","city":"Raleigh","state":"NC","postal_code":"27603-1219"},"city":"Raleigh","latitude":35.785754,"longitude":-78.647293,"del":1080,"mino":100,"is_delivering":0},{"id":783,"na":"Chef Mario's Bistro","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":2880,"mino":150,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Sandwiches"],"addr":"2610 Wycliff Rd, Raleigh, NC","full_addr":{"addr":"2610 Wycliff Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27607-3060"},"city":"Raleigh","latitude":35.818683,"longitude":-78.692145,"del":2880,"mino":150,"is_delivering":0},{"id":784,"na":"Chef Mario's Catering","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":4320,"mino":150,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Catering","Italian","Sandwiches"],"addr":"2610 Wycliff Rd, Raleigh, NC","full_addr":{"addr":"2610 Wycliff Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27607-3060"},"city":"Raleigh","latitude":35.818683,"longitude":-78.692145,"del":4320,"mino":150,"is_delivering":0},{"id":786,"na":"D'Nardys Caterers","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1320,"mino":6.55,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Catering","Italian","Sandwiches"],"addr":"314 Madison Grove Pl, Cary, NC","full_addr":{"addr":"314 Madison Grove Pl","addr2":"","city":"Cary","state":"NC","postal_code":"27519-8161"},"city":"Cary","latitude":35.82135,"longitude":-78.854469,"del":1320,"mino":6.55,"is_delivering":0},{"id":787,"na":"Danny's Bar-B-Que","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":2640,"mino":100,"can":1}},"allow_tip":1,"allow_asap":1,"cu":["American","Barbecue"],"addr":"9561 Chapel Hill Rd, Morrisville, NC","full_addr":{"addr":"9561 Chapel Hill Rd","addr2":"","city":"Morrisville","state":"NC","postal_code":"27560-7359"},"city":"Morrisville","latitude":35.805972,"longitude":-78.809315,"del":2640,"mino":100,"is_delivering":1},{"id":792,"na":"Flying Biscuit","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1440,"mino":150,"can":1}},"allow_tip":1,"allow_asap":1,"cu":["Breakfast","Sandwiches"],"addr":"2016 Clark Ave, Raleigh, NC","full_addr":{"addr":"2016 Clark Ave","addr2":"","city":"Raleigh","state":"NC","postal_code":"27605-1604"},"city":"Raleigh","latitude":35.788996,"longitude":-78.659642,"del":1440,"mino":150,"is_delivering":1},{"id":793,"na":"Gateway Restaurant","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1320,"mino":50,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast"],"addr":"2411 Crabtree Blvd, Raleigh, NC","full_addr":{"addr":"2411 Crabtree Blvd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27604-2232"},"city":"Raleigh","latitude":35.805222,"longitude":-78.611873,"del":1320,"mino":50,"is_delivering":0},{"id":796,"na":"Hibachi Xpress","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":720,"mino":150,"can":0}},"allow_tip":1,"allow_asap":1,"addr":"2470 Walnut St, Cary, NC","full_addr":{"addr":"2470 Walnut St","addr2":"","city":"Cary","state":"NC","postal_code":"27518-9212"},"city":"Cary","latitude":35.75113,"longitude":-78.741205,"del":720,"mino":150,"is_delivering":0},{"id":798,"na":"HoneyBaked Ham","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1080,"mino":60,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Sandwiches"],"addr":"5275 Six Forks Rd, Raleigh, NC","full_addr":{"addr":"5275 Six Forks Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27609-4431"},"city":"Raleigh","latitude":35.85326,"longitude":-78.642593,"del":1080,"mino":60,"is_delivering":0},{"id":804,"na":"Moe's Southwest Grill","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1080,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["Mexican","Tex-Mex"],"addr":"506 Daniels St, Raleigh, NC","full_addr":{"addr":"506 Daniels St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27605-1317"},"city":"Raleigh","latitude":35.791061,"longitude":-78.66118,"del":1080,"mino":100,"is_delivering":0},{"id":806,"na":"Ole Time Barbecue","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1080,"mino":75,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["Barbecue"],"addr":"6309 Hillsborough St, Raleigh, NC","full_addr":{"addr":"6309 Hillsborough St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27606-1148"},"city":"Raleigh","latitude":35.787922,"longitude":-78.73851,"del":1080,"mino":75,"is_delivering":0},{"id":811,"na":"The Q Shack","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":180,"mino":40,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Barbecue"],"addr":"North Hills, Raleigh, NC","full_addr":{"addr":"North Hills","addr2":"","city":"Raleigh","state":"NC","postal_code":"27609"},"city":"Raleigh","latitude":35.837521,"longitude":-78.64312,"del":180,"mino":40,"is_delivering":0},{"id":812,"na":"We Cook For You","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":720,"mino":125,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Caribbean","Catering","Sandwiches"],"addr":"1125 Fuller St, Raleigh, NC","full_addr":{"addr":"1125 Fuller St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27603-2217"},"city":"Raleigh","latitude":35.765381,"longitude":-78.650581,"del":720,"mino":125,"is_delivering":0},{"id":813,"na":"WhichWich Superior Sandwiches","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1080,"mino":75,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Sandwiches"],"addr":"4025 Lake Boone Trl, Raleigh, NC","full_addr":{"addr":"4025 Lake Boone Trl","addr2":"","city":"Raleigh","state":"NC","postal_code":"27607-2928"},"city":"Raleigh","latitude":35.815604,"longitude":-78.696541,"del":1080,"mino":75,"is_delivering":0},{"id":820,"na":"Greens","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1080,"mino":6.55,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Italian","Seafood"],"addr":"4120 Main at North Hills St, Raleigh, NC","full_addr":{"addr":"4120 Main at North Hills St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27609-5754"},"city":"Raleigh","latitude":35.837546,"longitude":-78.642515,"del":1080,"mino":6.55,"is_delivering":0},{"id":861,"na":"Catering By Design","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":240,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Catering","Italian","Pizza","Sandwiches"],"addr":"132 Kilmayne Dr, Cary, NC","full_addr":{"addr":"132 Kilmayne Dr","addr2":"","city":"Cary","state":"NC","postal_code":"27511-4465"},"city":"Cary","latitude":35.769451,"longitude":-78.783912,"del":240,"mino":100,"is_delivering":0},{"id":3498,"na":"Z Pizza","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":900,"mino":75,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Pizza","Sandwiches"],"addr":"421 Fayetteville St, Raleigh, NC","full_addr":{"addr":"421 Fayetteville St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27601-1778"},"city":"Raleigh","latitude":35.77467,"longitude":-78.639389,"del":900,"mino":75,"is_delivering":0},{"id":3500,"na":"Artisan Sandwiches & Salads","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":900,"mino":50,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Sandwiches"],"addr":"421 Fayetteville St, Raleigh, NC","full_addr":{"addr":"421 Fayetteville St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27601-1778"},"city":"Raleigh","latitude":35.77467,"longitude":-78.639389,"del":900,"mino":50,"is_delivering":0},{"id":3795,"na":"Chef Mario's Catering Dinner","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":4320,"mino":150,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Asian","Barbecue","Breakfast","Catering","Italian","Jamaican","Mediterranean","Sandwiches","Seafood","Thai"],"addr":"2610 Wycliff Rd, Raleigh, NC","full_addr":{"addr":"2610 Wycliff Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27607-3060"},"city":"Raleigh","latitude":35.818683,"longitude":-78.692145,"del":4320,"mino":150,"is_delivering":0},{"id":3895,"na":"A Catered Affair","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":720,"mino":125,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Asian","Breakfast","Catering","Italian","Jamaican","Sandwiches"],"addr":"1125 Fuller St, Raleigh, NC","full_addr":{"addr":"1125 Fuller St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27603-2217"},"city":"Raleigh","latitude":35.765381,"longitude":-78.650581,"del":720,"mino":125,"is_delivering":0},{"id":4011,"na":"Neomonde Mediterranean","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1260,"mino":125,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["Breakfast","Mediterranean","Sandwiches"],"addr":"9650 Strickland Rd, Raleigh, NC","full_addr":{"addr":"9650 Strickland Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27615-1937"},"city":"Raleigh","del":1260,"mino":125,"is_delivering":0},{"id":4425,"na":"Dorry's Downtown Deli","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1320,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Sandwiches"],"addr":"211 E Chatham St, Cary, NC","full_addr":{"addr":"211 E Chatham St","addr2":"","city":"Cary","state":"NC","postal_code":"27511-3427"},"city":"Cary","latitude":35.787534,"longitude":-78.777666,"del":1320,"mino":100,"is_delivering":0},{"id":4427,"na":"Pogo","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":180,"mino":40,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Sandwiches"],"addr":"201 E Hargett St, Raleigh, NC","full_addr":{"addr":"201 E Hargett St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27601-1437"},"city":"Raleigh","latitude":35.778141,"longitude":-78.635834,"del":180,"mino":40,"is_delivering":0},{"id":4428,"na":"Chick-fil-A","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1200,"mino":200,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Sandwiches"],"addr":"1803 N Harrison Ave, Cary, NC","full_addr":{"addr":"1803 N Harrison Ave","addr2":"","city":"Cary","state":"NC","postal_code":"27513-2408"},"city":"Cary","latitude":35.828831,"longitude":-78.769402,"del":1200,"mino":200,"is_delivering":0},{"id":6142,"na":"Spartacus Restaurant","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1200,"mino":300,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["Mediterranean","Sandwiches"],"addr":"4139 Old Chapel Hill Rd, Durham, NC","full_addr":{"addr":"4139 Old Chapel Hill Rd","addr2":"","city":"Durham","state":"NC","postal_code":"27707-5057"},"city":"Durham","del":1200,"mino":300,"is_delivering":0},{"id":7776,"na":"Firehouse Subs","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":120,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Sandwiches"],"addr":"1539 Us Highway 70 E, Garner, NC","full_addr":{"addr":"1539 Us Highway 70 E","addr2":"","city":"Garner","state":"NC","postal_code":"27529"},"city":"Garner","del":120,"mino":100,"is_delivering":0},{"id":7985,"na":"Ben & Jerry's Ice Cream","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":2880,"mino":200,"can":1}},"allow_tip":1,"allow_asap":1,"cu":["American","Bakery","Ice Cream"],"addr":"102 W Franklin St, Chapel Hill, NC","full_addr":{"addr":"102 W Franklin St","addr2":"","city":"Chapel Hill","state":"NC","postal_code":"27516-2516"},"city":"Chapel Hill","latitude":35.91304,"longitude":-79.056091,"del":2880,"mino":200,"is_delivering":1},{"id":10509,"na":"Catering By Design - Dinner","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":240,"mino":6.55,"can":1}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Catering","Italian","Sandwiches","Seafood"],"addr":"132 Kilmayne Dr, Cary, NC","full_addr":{"addr":"132 Kilmayne Dr","addr2":"","city":"Cary","state":"NC","postal_code":"27511-4465"},"city":"Cary","latitude":35.769451,"longitude":-78.783912,"del":240,"mino":6.55,"is_delivering":1},{"id":12715,"na":"Top This Cafe # The Atrium","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":45,"mino":0,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Breakfast","Sandwiches"],"addr":"2501 Blue Ridge Rd, Raleigh, NC","full_addr":{"addr":"2501 Blue Ridge Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27607-6436"},"city":"Raleigh","latitude":35.814449,"longitude":-78.705399,"del":45,"mino":0,"is_delivering":0},{"id":12724,"na":"Donovan's Dish","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1200,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Catering","Sandwiches"],"addr":"1040 Buck Jones Rd, Raleigh, NC","full_addr":{"addr":"1040 Buck Jones Rd","addr2":"","city":"Raleigh","state":"NC","postal_code":"27606-3323"},"city":"Raleigh","latitude":35.770224,"longitude":-78.739941,"del":1200,"mino":100,"is_delivering":0},{"id":12739,"na":"Lubrano's Ristorante Italiano","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1200,"mino":125,"can":1}},"allow_tip":1,"allow_asap":1,"cu":["Italian"],"addr":"101 Keybridge Dr, Morrisville, NC","full_addr":{"addr":"101 Keybridge Dr","addr2":"","city":"Morrisville","state":"NC","postal_code":"27560-5911"},"city":"Morrisville","latitude":35.819771,"longitude":-78.822189,"del":1200,"mino":125,"is_delivering":1},{"id":23709,"na":"DeMarco's Restaurant & Bar","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":1260,"mino":125,"can":1}},"allow_tip":1,"allow_asap":1,"cu":["Italian"],"addr":"3607 Falls River Ave, Raleigh, NC","full_addr":{"addr":"3607 Falls River Ave","addr2":"","city":"Raleigh","state":"NC","postal_code":"27614-7359"},"city":"Raleigh","latitude":35.930141,"longitude":-78.564522,"del":1260,"mino":125,"is_delivering":1},{"id":23710,"na":"Green Planet Catering","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":4200,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Catering","Sandwiches"],"addr":"218 S Blount St, Raleigh, NC","full_addr":{"addr":"218 S Blount St","addr2":"","city":"Raleigh","state":"NC","postal_code":"27601-1408"},"city":"Raleigh","latitude":35.777495,"longitude":-78.63662,"del":4200,"mino":100,"is_delivering":0},{"id":23815,"na":"Capital Center Catering","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":960,"mino":150,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Bakery","Catering","Italian","Sandwiches"],"addr":"217 E Main St, Clayton, NC","full_addr":{"addr":"217 E Main St","addr2":"","city":"Clayton","state":"NC","postal_code":"27520-2449"},"city":"Clayton","latitude":35.652088,"longitude":-78.458515,"del":960,"mino":150,"is_delivering":0},{"id":23817,"na":"Firewurst","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":960,"mino":100,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["American","Sandwiches"],"addr":"8531 Brier Creek Pky, Raleigh, NC","full_addr":{"addr":"8531 Brier Creek Pky","addr2":"","city":"Raleigh","state":"NC","postal_code":"27617-7333"},"city":"Raleigh","latitude":35.905433,"longitude":-78.786068,"del":960,"mino":100,"is_delivering":0},{"id":32244,"na":"Don Rio's Southwest Catering","cs_phone":"919-234-7755","rds_info":{"id":125,"name":"Triangle Food Guy","logo":""},"services":{"deliver":{"time":720,"mino":125,"can":0}},"allow_tip":1,"allow_asap":1,"cu":["Mexican","Tex-Mex"],"addr":"3607 Falls River Ave, Raleigh, NC","full_addr":{"addr":"3607 Falls River Ave","addr2":"","city":"Raleigh","state":"NC","postal_code":"27614-7359"},"city":"Raleigh","latitude":35.930141,"longitude":-78.564522,"del":720,"mino":125,"is_delivering":0}]
It seems this was a bug in version 1.0.1. Here's another thread that talks about it. The JsonTokenizer class has changed pretty dramatically since then. Upgrade to 1.0.2 and you will be fine.

Categories

Resources