Android Open Source - Gamework Help Activity






From Project

Back to project page Gamework.

License

The source code is released under:

Apache License

If you think the Android project Gamework 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 cz.robyer.gamework.app.activity;
/* ww w.j  av  a  2  s .com*/
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import cz.robyer.gamework.app.R;
import cz.robyer.gamework.app.service.JavaScriptHandler;

/**
 * Represents help with informations of how to use this application.
 * @author Robert P?sel
 */
@SuppressLint("SetJavaScriptEnabled")
public class HelpActivity extends BaseActivity {  
  //private static final String TAG = HelpActivity.class.getSimpleName();

  WebView webview;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    
    webview = (WebView)findViewById(R.id.webview);
    
    webview.getSettings().setJavaScriptEnabled(true);
    webview.addJavascriptInterface(new JavaScriptHandler(this), "Gamework");
    webview.setWebViewClient(new WebViewClient());/* {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (Uri.parse(url).getHost().equals("www.example.com")) {
                // This is my web site, so do not override; let my WebView load the page
                return false;
            }
            // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
    });*/
    
    webview.loadUrl("file:///android_asset/help/index.html");
    
    setupActionBar();
  }
  
  /**
   * Rewrite 'back' button behavior to get back in {@link WebView}.
   */
  @Override
  public void onBackPressed() {
    if (webview.canGoBack())
      webview.goBack();
    else
      super.onBackPressed();
  }
  
  /**
   * Set up the {@link android.app.ActionBar}, if the API is available.
   */
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void setupActionBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      getActionBar().setDisplayHomeAsUpEnabled(true);
    }
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
      // This ID represents the Home or Up button. In the case of this
      // activity, the Up button is shown. Use NavUtils to allow users
      // to navigate up one level in the application structure. For
      // more details, see the Navigation pattern on Android Design:
      //
      // http://developer.android.com/design/patterns/navigation.html#up-vs-back
      //
      NavUtils.navigateUpFromSameTask(this);
      return true;
    }
    return super.onOptionsItemSelected(item);
  }

}




Java Source Code List

cz.robyer.gamework.app.activity.BaseActivity.java
cz.robyer.gamework.app.activity.BaseGameActivity.java
cz.robyer.gamework.app.activity.GameInventoryActivity.java
cz.robyer.gamework.app.activity.GameMapActivity.java
cz.robyer.gamework.app.activity.GameMessagesActivity.java
cz.robyer.gamework.app.activity.GameObjectivesActivity.java
cz.robyer.gamework.app.activity.GameToolsActivity.java
cz.robyer.gamework.app.activity.HelpActivity.java
cz.robyer.gamework.app.activity.MainActivity.java
cz.robyer.gamework.app.activity.MessageActivity.java
cz.robyer.gamework.app.game.GameService.java
cz.robyer.gamework.app.service.JavaScriptHandler.java
cz.robyer.gamework.app.service.MessageAdapter.java
cz.robyer.gamework.constants.Constants.java
cz.robyer.gamework.game.GameEventBroadcaster.java
cz.robyer.gamework.game.GameEventListener.java
cz.robyer.gamework.game.GameEvent.java
cz.robyer.gamework.game.GameHandler.java
cz.robyer.gamework.game.GameService.java
cz.robyer.gamework.game.GameStatus.java
cz.robyer.gamework.scenario.BaseObject.java
cz.robyer.gamework.scenario.HookableObject.java
cz.robyer.gamework.scenario.IdentificableObject.java
cz.robyer.gamework.scenario.ScenarioInfo.java
cz.robyer.gamework.scenario.Scenario.java
cz.robyer.gamework.scenario.area.Area.java
cz.robyer.gamework.scenario.area.MultiPointArea.java
cz.robyer.gamework.scenario.area.PointArea.java
cz.robyer.gamework.scenario.area.SoundArea.java
cz.robyer.gamework.scenario.helper.EventHookable.java
cz.robyer.gamework.scenario.helper.ScannerHookable.java
cz.robyer.gamework.scenario.helper.TimeHookable.java
cz.robyer.gamework.scenario.hook.Condition.java
cz.robyer.gamework.scenario.hook.Hook.java
cz.robyer.gamework.scenario.message.Message.java
cz.robyer.gamework.scenario.parser.XmlScenarioParser.java
cz.robyer.gamework.scenario.reaction.ActivityReaction.java
cz.robyer.gamework.scenario.reaction.EventReaction.java
cz.robyer.gamework.scenario.reaction.MessageReaction.java
cz.robyer.gamework.scenario.reaction.MultiReaction.java
cz.robyer.gamework.scenario.reaction.Reaction.java
cz.robyer.gamework.scenario.reaction.ReferenceReaction.java
cz.robyer.gamework.scenario.reaction.SoundReaction.java
cz.robyer.gamework.scenario.reaction.VariableReaction.java
cz.robyer.gamework.scenario.reaction.VibrateReaction.java
cz.robyer.gamework.scenario.variable.BooleanVariable.java
cz.robyer.gamework.scenario.variable.DecimalVariable.java
cz.robyer.gamework.scenario.variable.Variable.java
cz.robyer.gamework.utils.GPoint.java
cz.robyer.gamework.utils.Log.java
cz.robyer.gamework.utils.Utils.java