Skip to content

Commit

Permalink
fix #20,search detaiils
Browse files Browse the repository at this point in the history
  • Loading branch information
prprhyt committed May 24, 2019
1 parent 7521a3a commit 4ba3009
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void onClick(View v) {
public void onClick(View v) {
if(fragmentManager != null) {
Bundle bundle = new Bundle();
bundle.putInt("position", position);
bundle.putString("itemID", itemList.getItemID());
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
// BackStackを設定
fragmentTransaction.addToBackStack(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@
import androidx.recyclerview.widget.RecyclerView;

public class DetailFragment extends Fragment {
private int position;
private String itemID;


private TimelineDataBean.TimelineData getTimelineDataFromItemID(String itemID){
for(TimelineDataBean.TimelineData d:MainActivity.timelineData.getData()){
if(null==d || null==d.getItemID()){
continue;
}
if(d.getItemID().equals(itemID)){
return d;
}
}
return null;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -28,11 +41,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

Bundle bundle = getArguments();
if (bundle != null) {
position = bundle.getInt("position");
itemID = bundle.getString("itemID");
}

if (MainActivity.timelineData != null) {
final TimelineDataBean.TimelineData timelineData = MainActivity.timelineData.getData().get(position);
final TimelineDataBean.TimelineData timelineData = getTimelineDataFromItemID(itemID);
if(null==timelineData){
return v;
}
RecyclerView detailRecyclerView = v.findViewById(R.id.presenterRecyclerView);
DetailAdapter detailAdapter = new DetailAdapter(timelineData, getFragmentManager(), this);

Expand Down

0 comments on commit 4ba3009

Please sign in to comment.