fi.harism.anndblur.MainActivity.java Source code

Java tutorial

Introduction

Here is the source code for fi.harism.anndblur.MainActivity.java

Source

/*
   Copyright 2013 Harri Smatt
    
   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 fi.harism.anndblur;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.SeekBar;

/**
 * Simple activity for testing purposes
 */
public class MainActivity extends Activity {

    private BlurLinearLayout mFooterLayout;
    private DrawerLayout mDrawerLayout;

    @Override
    @SuppressWarnings("deprecation")
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

        findViewById(R.id.button_left).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDrawerLayout.openDrawer(Gravity.LEFT);
            }
        });

        findViewById(R.id.button_right).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDrawerLayout.openDrawer(Gravity.RIGHT);
            }
        });

        int maxBlur = getWindowManager().getDefaultDisplay().getWidth() / 8;
        mFooterLayout = (BlurLinearLayout) findViewById(R.id.footer_layout);
        mFooterLayout.setBlurRadius(maxBlur / 2);

        SeekBar seekBar = (SeekBar) mFooterLayout.findViewById(R.id.seekbar_blur);
        seekBar.setMax(maxBlur);
        seekBar.setProgress(maxBlur / 2);
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mFooterLayout.setBlurRadius(progress + 1);
            }
        });

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerLayout.setScrimColor(0x40000000);
    }

}