3rd Party Library Kullanimi(FoldableLayout)
Merhabalar,
Gelistirdigim uygulamada FoldableLayout(https://github.com/alexvasilkov/FoldableLayout/) adli kutuphaneyi kullanmaktayim.Uygulama Navigation Drawer uzerine kurulu ve buradaki Fragmentlarin Acitivity uzerinden tetiklenmesine dayali bir sisteme sahip.Kullandigim kutuphaneyle Sliding Menu uzerindeki item'a tiklandigi zaman yeni bir Fragment aciyorum ve ardindan oradaki her bir item uzerine tiklandiginda acilmasini bekledigim bir senaryo var fakat 2.adimda tikaniyorum.
Adapter ve Fragment classlarini paylasiyorum
PaintingAdapter:
public class PaintingsAdapter extends ItemsAdapter<Painting> implements View.OnClickListener {
public PaintingsAdapter(Context context) {
super(context);
setItemsList(Arrays.asList(Painting.getAllPaintings(context.getResources())));
}
@Override
protected View createView(Painting item, int pos, ViewGroup parent, LayoutInflater inflater) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
ViewHolder vh = new ViewHolder();
vh.image = Views.find(view, R.id.list_item_image);
vh.image.setOnClickListener(this);
vh.title = Views.find(view, R.id.list_item_title);
view.setTag(vh);
return view;
}
@Override
protected void bindView(Painting item, int pos, View convertView) {
ViewHolder vh = (ViewHolder) convertView.getTag();
vh.image.setTag(item);
Picasso.with(convertView.getContext()).load(item.getImageId()).noFade().into(vh.image);
vh.title.setText(item.getTitle());
}
@Override
public void onClick(View view) {
//Log.i("bilgi", "basildi");
UnfoldableDetailsFragment fm = new UnfoldableDetailsFragment();
fm.openDetails(view, (Painting)view.getTag());
Log.i("bilgi", "basildi");
}
private static class ViewHolder {
ImageView image;
TextView title;
}
}
UnfoldableDetailsFragment:
public class UnfoldableDetailsFragment extends Fragment {
private ListView mListView;
private View mListTouchInterceptor;
private View mDetailsLayout;
private UnfoldableView mUnfoldableView;
private Painting pa;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setDisplayHomeAsUpEnabled(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_unfoldable_details, container, false);
mListView = (ListView) rootView.findViewById(R.id.list_view);
mListView.setAdapter(new PaintingsAdapter(getActivity()));
mListTouchInterceptor = rootView.findViewById(R.id.touch_interceptor_view);
mListTouchInterceptor.setClickable(false);
mDetailsLayout = rootView.findViewById(R.id.details_layout);
mDetailsLayout.setVisibility(View.INVISIBLE);
mUnfoldableView = (UnfoldableView) rootView.findViewById(R.id.unfoldable_view);
Bitmap glance = ((BitmapDrawable) getResources().getDrawable(R.drawable.unfold_glance)).getBitmap();
mUnfoldableView.setFoldShading(new GlanceFoldShading(getActivity(), glance));
mUnfoldableView.setOnFoldingListener(new UnfoldableView.SimpleFoldingListener() {
@Override
public void onUnfolding(UnfoldableView unfoldableView) {
mListTouchInterceptor.setClickable(true);
mDetailsLayout.setVisibility(View.VISIBLE);
}
@Override
public void onUnfolded(UnfoldableView unfoldableView) {
mListTouchInterceptor.setClickable(false);
}
@Override
public void onFoldingBack(UnfoldableView unfoldableView) {
mListTouchInterceptor.setClickable(true);
}
@Override
public void onFoldedBack(UnfoldableView unfoldableView) {
mListTouchInterceptor.setClickable(false);
mDetailsLayout.setVisibility(View.INVISIBLE);
}
});
return rootView;
}
public void openDetails(View coverView, Painting painting) {
ImageView image = (ImageView) coverView.findViewById(R.id.details_image);
TextView title = (TextView) coverView.findViewById(R.id.details_title);
TextView description = (TextView) coverView.findViewById(R.id.details_text);
Picasso.with(getActivity()).load(painting.getImageId()).into(image);
Log.i("bilgi", "basildi");
title.setText(painting.getTitle());
SpannableBuilder builder = new SpannableBuilder(getActivity());
builder
.createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
.append(R.string.year).append(": ")
.clearStyle()
.append(painting.getYear()).append("\n")
.createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
.append(R.string.location).append(": ")
.clearStyle()
.append(painting.getLocation());
description.setText(builder.build());
mUnfoldableView.unfold(coverView, mDetailsLayout);
}
LOGCAT:
java.lang.IllegalArgumentException: Target must not be null.
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:340)
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:326)
at com.zafer.celaloglu.FragmentsandActivities.UnfoldableDetailsFragment.openDetails(UnfoldableDetailsFragment.java:89)
at com.zafer.celaloglu.model.PaintingsAdapter.onClick(PaintingsAdapter.java:52)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)