Android Open Source - LimeLight Model Helper






From Project

Back to project page LimeLight.

License

The source code is released under:

GNU General Public License

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

/**
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0, as well as to the Additional Term regarding proper
 attribution. The latter is located in Term 11 of the License.
 If a copy of the MPL with the Additional Term was not distributed
 with this file, You can obtain one at http://static.fuzzhq.com/licenses/MPL
 *///from  www  .  j  a  v a 2s.  c  om

package com.fuzz.android.limelight.model;

import android.graphics.Rect;
import android.util.Log;
import android.view.View;
import android.widget.ListView;

import com.fuzz.android.limelight.LimeLight;

/**
 * @author Leonard Collins (Fuzz)
 *         <p>Helper for model package</p>
 */
class ModelHelper {

    public static void performIdentifierAction(int id) {
        LimeLight.getMenu().performIdentifierAction(id, 0);
    }

    public static int getScreenHeight() {
        int screenHeight = LimeLight.getActivity().getResources().getDisplayMetrics().heightPixels;
        return screenHeight;
    }

    public static void openDrawer() {
        if (LimeLight.getDrawerAutomator() != null) {
            LimeLight.getDrawerAutomator().openDrawer();
        }
    }

    public static void closeDrawer() {
        if (LimeLight.getDrawerAutomator() != null) {
            LimeLight.getDrawerAutomator().closeDrawer();
        }
    }

    public static void clickDrawerItem(int position) {
        if (LimeLight.getDrawerAutomator() != null) {
            LimeLight.getDrawerAutomator().clickItem(position);
        }
    }

    public static Rect getAbsolutePositionOnScreen(View v) {
        Rect rect = new Rect();
        v.getHitRect(rect);
        if (v.getClass().getName().contains("ActionMenuItemView")) {
            //TODO Actionbar items will have to be offset to the right, but this is not the right
            //implementation, however, it should work for the first element
            int left = getScreenWidth() - rect.width();
            rect.offsetTo(left, 0);
        }
        return rect;
    }

    public static int getScreenWidth() {
        int screenWidth = LimeLight.getActivity().getResources().getDisplayMetrics().widthPixels;
        return screenWidth;
    }

    public static void scrollViewToPosition(View view, int position) {
        if (view instanceof ListView) {
            ListView listView = ((ListView) view);
            listView.smoothScrollToPosition(position);
        } else {
            Log.w("LimeLight | scrollViewToPosition()", "This view is not a list view. Cannot be scrolled.");
        }
    }

    public static void scrollViewUntilChildIsVisible(View view, View child) {
        float value = child.getY();
        view.scrollTo(0, (int) value);
    }

    public static int getID(String id) {
        String defPackageName = LimeLight.getActivity().getPackageName();
        return LimeLight.getActivity().getResources().getIdentifier(id, "id", defPackageName);
    }

    public static int getResourceIntValue(String id) {
        return LimeLight.getActivity().getResources().getIdentifier(id, null, null);
    }

}




Java Source Code List

com.fuzz.android.limelight.LimeLight.java
com.fuzz.android.limelight.animation.AnimationHolder.java
com.fuzz.android.limelight.animation.LeftRightAnimation.java
com.fuzz.android.limelight.animation.UpDownAnimation.java
com.fuzz.android.limelight.automate.DrawerAutomator.java
com.fuzz.android.limelight.automate.ViewAutomator.java
com.fuzz.android.limelight.model.ActToViewHelper.java
com.fuzz.android.limelight.model.Act.java
com.fuzz.android.limelight.model.BaseChapter.java
com.fuzz.android.limelight.model.Book.java
com.fuzz.android.limelight.model.ChapterTransition.java
com.fuzz.android.limelight.model.Chapter.java
com.fuzz.android.limelight.model.ModelHelper.java
com.fuzz.android.limelight.model.Text.java
com.fuzz.android.limelight.model.Transition.java
com.fuzz.android.limelight.recorder.FontListAdapter.java
com.fuzz.android.limelight.recorder.RecorderClickListener.java
com.fuzz.android.limelight.recorder.RecorderWindow.java
com.fuzz.android.limelight.recorder.Recorder.java
com.fuzz.android.limelight.recorder.widget.color.ColorHueSlider.java
com.fuzz.android.limelight.recorder.widget.color.ColorPickDialog.java
com.fuzz.android.limelight.recorder.widget.color.ColorSquareView.java
com.fuzz.android.limelight.recorder.widget.color.OnColorChangedListener.java
com.fuzz.android.limelight.recorder.widget.drag.DragAndEditView.java
com.fuzz.android.limelight.recorder.widget.drag.EditorFrameLayout.java
com.fuzz.android.limelight.recorder.widget.drag.OffSetChangeListener.java
com.fuzz.android.limelight.recorder.widget.editor.ActEditor.java
com.fuzz.android.limelight.recorder.widget.editor.ActIconAdapter.java
com.fuzz.android.limelight.recorder.widget.editor.operations.BaseOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeAnimationOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeBackgroundColorOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeIconOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.SetTextColorOperation.java
com.fuzz.android.limelight.recorder.widget.filedialog.FileDirectoryDialog.java
com.fuzz.android.limelight.recorder.widget.filedialog.OnDirectorySelectListener.java
com.fuzz.android.limelight.recorder.widget.snap.SnapHelper.java
com.fuzz.android.limelight.recorder.widget.snap.SnapInfo.java
com.fuzz.android.limelight.text.PrimeTextWatcher.java
com.fuzz.android.limelight.util.FontUtils.java
com.fuzz.android.limelight.util.IOUtils.java
com.fuzz.android.limelight.util.JSONTool.java
com.fuzz.android.limelight.util.LimeLightLog.java
com.fuzz.android.limelight.util.ViewUtils.java
com.fuzz.android.limelight.view.PrimeClickListener.java
com.fuzz.android.limelight.widget.ManualPositionFrameLayout.java