Android Open Source - android-tools Resizing View






From Project

Back to project page android-tools.

License

The source code is released under:

MIT License

If you think the Android project android-tools 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 net.comfreeze.lib.views;
/*from  w w w . j a v a 2  s . c o m*/
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

public class ResizingView extends LinearLayout {
    OnResizeListener resizeListener = null;

    public ResizingView(Context context) {
        super(context);
    }

    public ResizingView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setOnResizeListener(OnResizeListener onResizeListener) {
        resizeListener = onResizeListener;
    }

    private void onResizeEvent(int oldWidth, int oldHeight, int newWidth, int newHeight) {
        if (resizeListener != null) {
            resizeListener.onResize(oldWidth, oldHeight, newWidth, newHeight);
        }
    }

    public void toggleElement(int id, int visibility) {
        View v = (View) getRootView().findViewById(id);
        if (v != null) {
            Log.d("ResizingView", "Element toggled successfully!");
            v.setVisibility(visibility);
        } else {
            Log.d("ResizingView", "Element toggling failed, element not found!");
        }
    }

    public void onSizeChanged(int w, int h, int oldw, int oldh) {
        Log.d("ResizingView", String.format("Resizing from %1$dx%2$d to %3$dx%4$d", oldw, oldh, w, h));
        super.onSizeChanged(w, h, oldw, oldh);
        new Handler().post(new Runnable() {
            public void run() {
                requestLayout();
            }
        });
        onResizeEvent(oldw, oldh, w, h);

    }

    public interface OnResizeListener {
        public abstract void onResize(int oldWidth, int oldHeight, int newWidth, int newHeight);
    }
}




Java Source Code List

net.comfreeze.lib.BundleBuilder.java
net.comfreeze.lib.CFZApplication.java
net.comfreeze.lib.ContentValueBuilder.java
net.comfreeze.lib.FragmentMap.java
net.comfreeze.lib.adapter.HeaderListAdapter.java
net.comfreeze.lib.adapter.IHeaderListAdapter.java
net.comfreeze.lib.adapter.SeparatedListAdapter.java
net.comfreeze.lib.api.BaseAPI.java
net.comfreeze.lib.api.RestAPI.java
net.comfreeze.lib.api.XMLAPI.java
net.comfreeze.lib.api.helper.CursorHelper.java
net.comfreeze.lib.api.helper.JSONHelper.java
net.comfreeze.lib.api.helper.ModelHelper.java
net.comfreeze.lib.api.xml.WordpressAPI.java
net.comfreeze.lib.audio.SoundManager.java
net.comfreeze.lib.db.DatabaseHelper.java
net.comfreeze.lib.db.DatabaseTable.java
net.comfreeze.lib.db.helper.HelperCursor.java
net.comfreeze.lib.db.model.CFZModel.java
net.comfreeze.lib.db.model.FieldColumnMap.java
net.comfreeze.lib.fragments.CFZListFragment.java
net.comfreeze.lib.provider.CFZSimpleProvider.java
net.comfreeze.lib.service.CFZService.java
net.comfreeze.lib.ui.SupportFragmentActivity.java
net.comfreeze.lib.ui.dialog.CFZDialogProgress.java
net.comfreeze.lib.ui.fragment.CFZFragmentBase.java
net.comfreeze.lib.views.BiScrollView.java
net.comfreeze.lib.views.CFZViewHelper.java
net.comfreeze.lib.views.FlowLayout.java
net.comfreeze.lib.views.GestureHelper.java
net.comfreeze.lib.views.HeaderListView.java
net.comfreeze.lib.views.ResizingView.java
net.comfreeze.lib.views.ViewCollection.java
net.comfreeze.lib.views.ViewUtils.java
net.comfreeze.lib.xml.XMLParser.java
net.comfreeze.lib.xml.wordpress.FeedXmlParser.java