Android Open Source - iPhoroidUI Activity Util






From Project

Back to project page iPhoroidUI.

License

The source code is released under:

Apache License

If you think the Android project iPhoroidUI 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 (c) 2011 by KLab Inc., All rights reserved.
 */*from ww w .jav a  2s .  co m*/
 * Programmed by Naohide Sano
 */

package org.klab.iphoroid.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import android.app.Activity;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.util.Log;
import android.view.Display;


/**
 * ActivityUtil.
 * 
 * @author <a href="mailto:sano-n@klab.jp">Naohide Sano</a> (sano-n)
 * @version 0.00 2011/07/06 sano-n initial version <br>
 */
public abstract class ActivityUtil {

    private static final String TAG = "ActivityUtil";

    /**
     * ???????????????????????????????
     * 
     * @see "http://stackoverflow.com/questions/2795833/check-orientation-on-android-phone"
     */
    public static int getScreenOrientation(Activity activity) {
        Display getOrient = activity.getWindowManager().getDefaultDisplay();
        int orientation = Configuration.ORIENTATION_UNDEFINED;
        if (getOrient.getWidth() == getOrient.getHeight()) {
            orientation = Configuration.ORIENTATION_SQUARE;
        } else {
            if (getOrient.getWidth() < getOrient.getHeight()) {
                orientation = Configuration.ORIENTATION_PORTRAIT;
            } else {
                orientation = Configuration.ORIENTATION_LANDSCAPE;
            }
        }
        return orientation;
    }

    /**
     * ?????????????????????????????????????????.
     * 
     * @param activity
     * @param fileName ???????
     * @param charset ???????????????
     * @return ?????????
     */
    public static String loadAssetsText(Activity activity, String fileName, String charset) {
        return loadAssetsText(activity.getResources().getAssets(), fileName, charset);
    }

    /**
     * ?????????????????????????????????????????.
     * 
     * @param assetManager
     * @param fileName ???????
     * @param charset ???????????????
     * @return ?????????
     */
    public static String loadAssetsText(AssetManager assetManager, String fileName, String charset) {
        String text = null;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(assetManager.open(fileName), charset));
            StringBuilder sb = new StringBuilder();
            while ((text = br.readLine()) != null) {
                sb.append(text);
            }
            text = sb.toString();
        } catch (IOException e) {
            Log.e(TAG, e.getMessage(), e);
        }
        return text;
    }
}

/* */




Java Source Code List

org.klab.iphoroid.util.ActivityUtil.java
org.klab.iphoroid.util.Cache.java
org.klab.iphoroid.widget.adpterview.OnScrollListener.java
org.klab.iphoroid.widget.coverflow.CoverFlowGallery.java
org.klab.iphoroid.widget.coverflow.CoverFlowImageAdapterBase.java
org.klab.iphoroid.widget.flowview.CircleFlowIndicator.java
org.klab.iphoroid.widget.flowview.FlowIndicator.java
org.klab.iphoroid.widget.flowview.FlowView.java
org.klab.iphoroid.widget.flowview.TitleFlowIndicator.java
org.klab.iphoroid.widget.flowview.TitleProvider.java
org.klab.iphoroid.widget.gallery.ScrollDetectableGallery.java
org.klab.iphoroid.widget.listview.AdapterWrapper.java
org.klab.iphoroid.widget.listview.EndlessAdapter.java
org.klab.iphoroid.widget.listview.PullToRefreshEndlessListView.java
org.klab.iphoroid.widget.listview.PullToRefreshListView.java
org.klab.iphoroid.widget.listview.RefreshableArrayAdapter.java
org.klab.iphoroid.widget.support.DownloadTask.java
org.klab.iphoroid.widget.support.HasImage.java
org.klab.iphoroid.widget.support.ImageCache.java
org.klab.iphoroid.widget.support.ImageDownloadTask.java
org.klab.iphoroid.widget.support.SimpleImageDownloadTask.java