Skip to content
This repository has been archived by the owner on Aug 3, 2019. It is now read-only.

Commit

Permalink
Added LikeView example
Browse files Browse the repository at this point in the history
  • Loading branch information
sromku committed Oct 29, 2014
1 parent 6121b25 commit 1834e1c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Simple Facebook Sample/res/layout/fragment_like_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="1" >

<TextView
android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="***"
tools:ignore="HardcodedText" />

<com.facebook.widget.LikeView
android:id="@+id/like_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.facebook.widget.LikeView>

<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@drawable/result_frame" >

<TextView
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="5dp"
android:textSize="10sp"
tools:ignore="SmallSp" />
</ScrollView>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}

0 comments on commit 1834e1c

Please sign in to comment.