diff --git a/Simple Facebook Sample/res/layout/fragment_like_view.xml b/Simple Facebook Sample/res/layout/fragment_like_view.xml new file mode 100644 index 0000000..cdd825c --- /dev/null +++ b/Simple Facebook Sample/res/layout/fragment_like_view.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/MainFragment.java b/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/MainFragment.java index 8ccd5f9..d6514e0 100644 --- a/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/MainFragment.java +++ b/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/MainFragment.java @@ -96,6 +96,8 @@ public void onCreate(Bundle savedInstanceState) { mExamples.add(new Example("Permissions", null, false)); mExamples.add(new Example("Show granted permissions", GrantedPermissionsFragment.class, true)); mExamples.add(new Example("Request new permissions", RequestPermissionsFragment.class, true)); + mExamples.add(new Example("Misc", null, false)); + mExamples.add(new Example("LikeView button", PublishLikeButtonFragment.class, true)); } @Override diff --git a/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/PublishLikeButtonFragment.java b/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/PublishLikeButtonFragment.java new file mode 100644 index 0000000..f037616 --- /dev/null +++ b/Simple Facebook Sample/src/com/sromku/simple/fb/example/fragments/PublishLikeButtonFragment.java @@ -0,0 +1,41 @@ +package com.sromku.simple.fb.example.fragments; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.facebook.widget.LikeView; +import com.facebook.widget.LikeView.OnErrorListener; +import com.sromku.simple.fb.example.R; + +public class PublishLikeButtonFragment extends BaseFragment { + + private final static String EXAMPLE = "Like button"; + + private TextView mResult; + private LikeView mLikeView; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getActivity().setTitle(EXAMPLE); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_like_view, container, false); + mResult = (TextView) view.findViewById(R.id.result); + mLikeView = (LikeView) view.findViewById(R.id.like_view); + mLikeView.setObjectId("1501124800143936"); + mLikeView.setOnErrorListener(new OnErrorListener() { + @Override + public void onError(Bundle errorBundle) { + mResult.setText("Some error happened"); + } + }); + return view; + } + +}