001/**
002 * Copyright 2013 John Ericksen
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *    http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.androidtransfuse.plugins;
017
018import org.androidtransfuse.ConfigurationRepository;
019import org.androidtransfuse.TransfusePlugin;
020import org.androidtransfuse.adapter.ASTPrimitiveType;
021import org.androidtransfuse.annotations.*;
022import org.androidtransfuse.bootstrap.Bootstrap;
023import org.androidtransfuse.gen.variableBuilder.InjectionBindingBuilder;
024import org.androidtransfuse.listeners.*;
025import org.androidtransfuse.util.AndroidLiterals;
026
027import javax.inject.Inject;
028
029/**
030 * @author John Ericksen
031 */
032@Bootstrap
033public class ActivityPlugin implements TransfusePlugin{
034
035    @Inject
036    InjectionBindingBuilder injectionBindingBuilder;
037
038    @Override
039    public void run(ConfigurationRepository repository) {
040
041        repository.component(Activity.class).method("onCreate", AndroidLiterals.BUNDLE)
042                .event(OnCreate.class)
043                .superCall()
044                .registration();
045        repository.component(Activity.class).method("onDestroy").event(OnDestroy.class).superCall();
046        repository.component(Activity.class).method("onPause").event(OnPause.class).superCall();
047        repository.component(Activity.class).method("onRestart").event(OnRestart.class).superCall();
048        repository.component(Activity.class).method("onResume").event(OnResume.class).superCall();
049        repository.component(Activity.class).method("onStart").event(OnStart.class).superCall();
050        repository.component(Activity.class).method("onStop").event(OnStop.class).superCall();
051        repository.component(Activity.class).method("onBackPressed").event(OnBackPressed.class).superCall();
052        repository.component(Activity.class).method("onPostCreate", AndroidLiterals.BUNDLE).event(OnPostCreate.class).superCall();
053        repository.component(Activity.class).method("onActivityResult", ASTPrimitiveType.INT, ASTPrimitiveType.INT, AndroidLiterals.INTENT).event(OnActivityResult.class);
054        repository.component(Activity.class).method("onNewIntent", AndroidLiterals.INTENT).event(OnNewIntent.class);
055        repository.component(Activity.class).method("onSaveInstanceState", AndroidLiterals.BUNDLE).event(OnSaveInstanceState.class).superCall();
056        repository.component(Activity.class).method("onRestoreInstanceState", AndroidLiterals.BUNDLE).event(OnRestoreInstanceState.class).superCall();
057        repository.component(Activity.class).extending(AndroidLiterals.LIST_ACTIVITY)
058                .method("onListItemClick", AndroidLiterals.LIST_VIEW, AndroidLiterals.VIEW, ASTPrimitiveType.INT, ASTPrimitiveType.LONG).event(OnListItemClick.class);
059
060        repository.component(Activity.class).callThroughEvent(ActivityMenuComponent.class);
061        repository.component(Activity.class).callThroughEvent(ActivityOnKeyDownListener.class);
062        repository.component(Activity.class).callThroughEvent(ActivityOnKeyLongPressListener.class);
063        repository.component(Activity.class).callThroughEvent(ActivityOnKeyMultipleListener.class);
064        repository.component(Activity.class).callThroughEvent(ActivityOnKeyUpListener.class);
065        repository.component(Activity.class).callThroughEvent(ActivityOnTouchEventListener.class);
066        repository.component(Activity.class).callThroughEvent(ActivityOnTrackballEventListener.class);
067
068        repository.component(Activity.class).listener(AndroidLiterals.VIEW_ON_CLICK_LISTENER, AndroidLiterals.VIEW, "setOnClickListener");
069        repository.component(Activity.class).listener(AndroidLiterals.VIEW_ON_LONG_CLICK_LISTENER, AndroidLiterals.VIEW, "setOnLongClickListener");
070        repository.component(Activity.class).listener(AndroidLiterals.VIEW_ON_CREATE_CONTEXT_MENU_LISTENER, AndroidLiterals.VIEW, "setOnCreateContextMenuListener");
071        repository.component(Activity.class).listener(AndroidLiterals.VIEW_ON_KEY_LISTENER, AndroidLiterals.VIEW, "setOnKeyListener");
072        repository.component(Activity.class).listener(AndroidLiterals.VIEW_ON_TOUCH_LISTENER, AndroidLiterals.VIEW, "setOnTouchListener");
073        repository.component(Activity.class).listener(AndroidLiterals.VIEW_ON_FOCUS_CHANGE_LISTENER, AndroidLiterals.VIEW, "setOnFocusChangeListener");
074        repository.component(Activity.class).listener(AndroidLiterals.ADAPTER_VIEW_ON_ITEM_CLICK_LISTENER, AndroidLiterals.ADAPTER_VIEW, "setOnItemClickListener");
075        repository.component(Activity.class).listener(AndroidLiterals.ADAPTER_VIEW_ON_ITEM_LONG_CLICK_LISTENER, AndroidLiterals.ADAPTER_VIEW, "setOnItemLongClickListener");
076        repository.component(Activity.class).listener(AndroidLiterals.ADAPTER_VIEW_ON_ITEM_SELECTED_LISTENER, AndroidLiterals.ADAPTER_VIEW, "setOnItemSelectedListener");
077        repository.component(Activity.class).listener(AndroidLiterals.ABS_LIST_VIEW_ON_SCROLL_LISTENER, AndroidLiterals.ABS_LIST_VIEw, "setOnScrollListener");
078        repository.component(Activity.class).listener(AndroidLiterals.ABS_LIST_VIEW_MULTI_CHOICE_MODE_LISTENER, AndroidLiterals.ABS_LIST_VIEw, "setMultiChoiceModeListener");
079        repository.component(Activity.class).listener(AndroidLiterals.ABS_LIST_VIEW_RECYCLER_LISTENER, AndroidLiterals.ABS_LIST_VIEw, "setViewRecyclerListener");
080        repository.component(Activity.class).listener(AndroidLiterals.TEXT_VIEW_ON_EDITOR_ACTION_LISTENER, AndroidLiterals.TEXT_VIEW, "setOnEditorActionListener");
081
082    }
083}