Android Open Source - videoMerge F B Like Activity






From Project

Back to project page videoMerge.

License

The source code is released under:

Apache License

If you think the Android project videoMerge listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.dragonplayer.merge;
/*  w w  w  .  ja va2  s . co  m*/
import com.dragonplayer.merge.utils.Constants;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class FBLikeActivity extends Activity {
//  String url = "http://m.facebook.com/intelkorea";
  //168356489891715
  
  private WebView mWebView;
  
  private boolean mLiked = false;

  /* Constants */
  private final String likeURL = "?fan&";
  private final String unlikeURL = "?unfan&";
  private final String url = Constants.Common.FB_PAGE_PREFIX + Constants.Common.FB_FOLLOW_ID;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fblike);
        
        //mLiked = getIntent().getExtras().getBoolean(Constants.Common.INTENT_FB_LIKE);
        mLiked = false;
        mWebView = (WebView)findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebViewClient(new FacebookWebViewClient());
        mWebView.loadUrl(url);
    }

  class FacebookWebViewClient extends WebViewClient {

    @Override
    public void onFormResubmission(WebView view, Message dontResend,
        Message resend) {
      super.onFormResubmission(view, dontResend, resend);
      Log.e("FacebookWebViewClient", "FacebookWebViewClient");
    }

    @Override
    public void onLoadResource(WebView view, String url) {
      super.onLoadResource(view, url);
      Log.e("onLoadResource", url);
      /* Check url to check if user clicked 'like' or 'unlike' button.*/
      boolean following = url.indexOf(likeURL) > -1;
      boolean unFollowing = url.indexOf(unlikeURL) > -1;
      /* More, check if user clicked 'like' button with our facebook page.
       * This prevents user from clicking other facebook page, not our page.*/
      boolean isOurPage = url.indexOf(Constants.Common.FB_FOLLOW_PAGE_ID) > -1;
      
      if (!isOurPage)
        return;
      if (following) {
        Log.i("like", "liked");
        mLiked = true;
//        Toast.makeText(getApplicationContext(),
//            "You have just selected 'like' ",
//            Toast.LENGTH_LONG).show();
        //you liked
      } else if (unFollowing) {
        Log.i("like", "unliked");
        mLiked = false;
//        Toast.makeText(getApplicationContext(),
//            "You have just selected 'unlike' ",
//            Toast.LENGTH_LONG).show();

      } else {
        // other operations
      }
    }

    @Override
    public void onPageFinished(WebView view, String url) {
      super.onPageFinished(view, url);
      Log.e("onPageFinished", "onPageFinished");
    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
      super.onPageStarted(view, url, favicon);
      Log.e("onPageStarted", "onPageStarted");
    }

    @Override
    public void onReceivedError(WebView view, int errorCode,
        String description, String failingUrl) {
      super.onReceivedError(view, errorCode, description, failingUrl);
      Log.e("onReceivedError", "onReceivedError");
    }

    @Override
    public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
      super.onUnhandledKeyEvent(view, event);
      Log.e("onUnhandledKeyEvent", "onUnhandledKeyEvent");
    }

    @Override
    public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
      Log.e("shouldOverrideKeyEvent", "shouldOverrideKeyEvent");
      return super.shouldOverrideKeyEvent(view, event);

    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      Log.e("shouldOverrideUrlLoading", url);
//      return super.shouldOverrideUrlLoading(view, url);
      return false;

    }

  }

  /** Allow user to navigate our facebook page.
   * If you don't override, android's back key will just lead user to go back to the main activity. */
    @Override
    public void onBackPressed(){
      if (!mWebView.canGoBack()){
          Intent intent = getIntent();
          intent.putExtra(Constants.Common.INTENT_FB_LIKE, mLiked);

        setResult(RESULT_OK, intent);
        finish();
      }
      else{
        mWebView.goBack();
      }
    }
}




Java Source Code List

com.dragonplayer.merge.FBLikeActivity.java
com.dragonplayer.merge.FacebookActivity.java
com.dragonplayer.merge.FacebookEventObserver.java
com.dragonplayer.merge.LoadingDialog.java
com.dragonplayer.merge.MainActivity.java
com.dragonplayer.merge.SplashActivity.java
com.dragonplayer.merge.TextInputActivity.java
com.dragonplayer.merge.adapter.FrameListAdapter.java
com.dragonplayer.merge.adapter.FrameSubListAdapter.java
com.dragonplayer.merge.adapter.MediaListAdapter.java
com.dragonplayer.merge.adapter.ProjectListAdapter.java
com.dragonplayer.merge.adapter.ProjectSubListAdapter.java
com.dragonplayer.merge.fragment.AboutFragment.java
com.dragonplayer.merge.fragment.AddAudioFragment.java
com.dragonplayer.merge.fragment.BaseFragment.java
com.dragonplayer.merge.fragment.FinishFragment.java
com.dragonplayer.merge.fragment.FrameFragment.java
com.dragonplayer.merge.fragment.FrameListFragment.java
com.dragonplayer.merge.fragment.GiftFragment.java
com.dragonplayer.merge.fragment.GridFragment.java
com.dragonplayer.merge.fragment.HomeFragment.java
com.dragonplayer.merge.fragment.LockConfirmFragment.java
com.dragonplayer.merge.fragment.LockFragment.java
com.dragonplayer.merge.fragment.UploadConfirmFragment.java
com.dragonplayer.merge.fragment.UploadFragment.java
com.dragonplayer.merge.fragment.UploadInfoFragment.java
com.dragonplayer.merge.fragment.UploadSelectMediaFragment.java
com.dragonplayer.merge.fragment.WorkFragment.java
com.dragonplayer.merge.frames.FrameInfo.java
com.dragonplayer.merge.frames.FramePart.java
com.dragonplayer.merge.frames.FrameView.java
com.dragonplayer.merge.frames.Frame.java
com.dragonplayer.merge.frames.FramesLayout.java
com.dragonplayer.merge.frames.Frames.java
com.dragonplayer.merge.frames.HorizontalListView.java
com.dragonplayer.merge.frames.ProjectFiles.java
com.dragonplayer.merge.frames.timeout.java
com.dragonplayer.merge.utils.AppConnectivity.java
com.dragonplayer.merge.utils.BannerData.java
com.dragonplayer.merge.utils.BitmapManager.java
com.dragonplayer.merge.utils.BitmapUtil.java
com.dragonplayer.merge.utils.Constants.java
com.dragonplayer.merge.utils.DlgWindow1.java
com.dragonplayer.merge.utils.DlgWindow2.java
com.dragonplayer.merge.utils.DlgWindow4.java
com.dragonplayer.merge.utils.DlgWindow5.java
com.dragonplayer.merge.utils.DlgWindow6.java
com.dragonplayer.merge.utils.DlgWindow7.java
com.dragonplayer.merge.utils.DlgWindow8.java
com.dragonplayer.merge.utils.FileMover.java
com.dragonplayer.merge.utils.Flag.java
com.dragonplayer.merge.utils.MLog.java
com.dragonplayer.merge.utils.SingleMediaScanner.java
com.dragonplayer.merge.utils.Utils.java
com.dragonplayer.merge.utils.WeTouch_network_interface.java
com.dragonplayer.merge.utils.WeTouch_uploadImage.java
com.dragonplayer.merge.utils.WebService.java