Android Open Source - webview-gm Script List






From Project

Back to project page webview-gm.

License

The source code is released under:

Apache License

If you think the Android project webview-gm 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

/*
 *    Copyright 2012 Werner Bayer//from   w w  w  .j  a va  2s  .c om
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package at.pardus.android.webview.gm.store.ui;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import at.pardus.android.webview.gm.model.Script;
import at.pardus.android.webview.gm.model.ScriptId;
import at.pardus.android.webview.gm.store.ScriptStore;
import at.pardus.webview.gm.R;

/**
 * Includes the UI to list, enable/disable and delete scripts.
 */
public class ScriptList {

  protected ScriptManagerActivity activity;

  protected ScriptStore scriptStore;

  protected ListView scriptList;

  /**
   * Returns the view listing all installed scripts.
   * 
   * @return the updated list view
   */
  public View getScriptList() {
    // TODO separate look (or list) for disabled scripts
    Script[] scripts = scriptStore.getAll();
    scriptList.setAdapter(new ArrayAdapter<Script>(activity,
        R.layout.script_list_item, scripts));
    scriptList.invalidate();
    return scriptList;
  }

  /**
   * Returns the ScriptId object for a given position in the list.
   * 
   * @param position
   *            the selected position
   * @return the ScriptId object at that position
   */
  public ScriptId getScriptId(int position) {
    return (ScriptId) scriptList.getItemAtPosition(position);
  }

  /**
   * Inflates the ListView from XML and registers its OnItemClickListener and
   * context menu.
   */
  private void init() {
    scriptList = (ListView) activity.getLayoutInflater().inflate(
        R.layout.script_list, null);
    scriptList.setTextFilterEnabled(true);
    scriptList.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {
        activity.openScriptEditor(getScriptId(position));
      }
    });
    activity.registerForContextMenu(scriptList);
  }

  /**
   * Constructor.
   * 
   * @param activity
   *            the application's activity
   * @param scriptStore
   *            the database to use
   */
  public ScriptList(ScriptManagerActivity activity, ScriptStore scriptStore) {
    this.activity = activity;
    this.scriptStore = scriptStore;
    init();
  }

}




Java Source Code List

at.pardus.android.webview.gm.WebViewGmImpl.java
at.pardus.android.webview.gm.model.ScriptCriteria.java
at.pardus.android.webview.gm.model.ScriptId.java
at.pardus.android.webview.gm.model.ScriptMetadata.java
at.pardus.android.webview.gm.model.Script.java
at.pardus.android.webview.gm.run.WebViewClientGm.java
at.pardus.android.webview.gm.run.WebViewGmApi.java
at.pardus.android.webview.gm.run.WebViewGm.java
at.pardus.android.webview.gm.store.ScriptStoreSQLite.java
at.pardus.android.webview.gm.store.ScriptStore.java
at.pardus.android.webview.gm.store.ui.ScriptBrowser.java
at.pardus.android.webview.gm.store.ui.ScriptEditor.java
at.pardus.android.webview.gm.store.ui.ScriptList.java
at.pardus.android.webview.gm.store.ui.ScriptManagerActivity.java
at.pardus.android.webview.gm.util.CriterionMatcher.java
at.pardus.android.webview.gm.util.UnicodeReader.java