Search in sources :

Example 66 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Precisely by Pankaj-Baranwal.

the class BaseNavigationActivity method onCreateDrawer.

protected void onCreateDrawer() {
    toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(Constants.toolbar_title);
    setSupportActionBar(toolbar);
    mDrawerLayout = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    sp = PreferenceManager.getDefaultSharedPreferences(this);
    editor = sp.edit();
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle)

Example 67 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project FaceRecognitionApp by Lauszus.

the class FaceRecognitionAppActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_face_recognition_app);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    // Sets the Toolbar to act as the ActionBar for this Activity window
    setSupportActionBar(mToolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    final RadioButton mRadioButtonEigenfaces = (RadioButton) findViewById(R.id.eigenfaces);
    final RadioButton mRadioButtonFisherfaces = (RadioButton) findViewById(R.id.fisherfaces);
    mRadioButtonEigenfaces.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            useEigenfaces = true;
            if (!trainFaces()) {
                // Set variable back
                useEigenfaces = false;
                showToast("Still training...", Toast.LENGTH_SHORT);
                mRadioButtonEigenfaces.setChecked(useEigenfaces);
                mRadioButtonFisherfaces.setChecked(!useEigenfaces);
            }
        }
    });
    mRadioButtonFisherfaces.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            useEigenfaces = false;
            if (!trainFaces()) {
                // Set variable back
                useEigenfaces = true;
                showToast("Still training...", Toast.LENGTH_SHORT);
                mRadioButtonEigenfaces.setChecked(useEigenfaces);
                mRadioButtonFisherfaces.setChecked(!useEigenfaces);
            }
        }
    });
    // Set radio button based on value stored in shared preferences
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    useEigenfaces = prefs.getBoolean("useEigenfaces", false);
    mRadioButtonEigenfaces.setChecked(useEigenfaces);
    mRadioButtonFisherfaces.setChecked(!useEigenfaces);
    // Used to store ArrayLists in the shared preferences
    tinydb = new TinyDB(this);
    mThresholdFace = (SeekBarArrows) findViewById(R.id.threshold_face);
    mThresholdFace.setOnSeekBarArrowsChangeListener(new SeekBarArrows.OnSeekBarArrowsChangeListener() {

        @Override
        public void onProgressChanged(float progress) {
            Log.i(TAG, "Face threshold: " + mThresholdFace.progressToString(progress));
            faceThreshold = progress;
        }
    });
    // Get initial value
    faceThreshold = mThresholdFace.getProgress();
    mThresholdDistance = (SeekBarArrows) findViewById(R.id.threshold_distance);
    mThresholdDistance.setOnSeekBarArrowsChangeListener(new SeekBarArrows.OnSeekBarArrowsChangeListener() {

        @Override
        public void onProgressChanged(float progress) {
            Log.i(TAG, "Distance threshold: " + mThresholdDistance.progressToString(progress));
            distanceThreshold = progress;
        }
    });
    // Get initial value
    distanceThreshold = mThresholdDistance.getProgress();
    mMaximumImages = (SeekBarArrows) findViewById(R.id.maximum_images);
    mMaximumImages.setOnSeekBarArrowsChangeListener(new SeekBarArrows.OnSeekBarArrowsChangeListener() {

        @Override
        public void onProgressChanged(float progress) {
            Log.i(TAG, "Maximum number of images: " + mMaximumImages.progressToString(progress));
            maximumImages = (int) progress;
            if (images != null && images.size() > maximumImages) {
                int nrRemoveImages = images.size() - maximumImages;
                Log.i(TAG, "Removed " + nrRemoveImages + " images from the list");
                // Remove oldest images
                images.subList(0, nrRemoveImages).clear();
                // Remove oldest labels
                imagesLabels.subList(0, nrRemoveImages).clear();
                // Retrain faces
                trainFaces();
            }
        }
    });
    // Get initial value
    maximumImages = (int) mMaximumImages.getProgress();
    findViewById(R.id.clear_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.i(TAG, "Cleared training set");
            // Clear both arrays, when new instance is created
            images.clear();
            imagesLabels.clear();
            showToast("Training set cleared", Toast.LENGTH_SHORT);
        }
    });
    findViewById(R.id.take_picture_button).setOnClickListener(new View.OnClickListener() {

        NativeMethods.MeasureDistTask mMeasureDistTask;

        @Override
        public void onClick(View v) {
            if (mMeasureDistTask != null && mMeasureDistTask.getStatus() != AsyncTask.Status.FINISHED) {
                Log.i(TAG, "mMeasureDistTask is still running");
                showToast("Still processing old image...", Toast.LENGTH_SHORT);
                return;
            }
            if (mTrainFacesTask != null && mTrainFacesTask.getStatus() != AsyncTask.Status.FINISHED) {
                Log.i(TAG, "mTrainFacesTask is still running");
                showToast("Still training...", Toast.LENGTH_SHORT);
                return;
            }
            Log.i(TAG, "Gray height: " + mGray.height() + " Width: " + mGray.width() + " total: " + mGray.total());
            if (mGray.total() == 0)
                return;
            // Scale image in order to decrease computation time
            Size imageSize = new Size(200, 200.0f / ((float) mGray.width() / (float) mGray.height()));
            Imgproc.resize(mGray, mGray, imageSize);
            Log.i(TAG, "Small gray height: " + mGray.height() + " Width: " + mGray.width() + " total: " + mGray.total());
            // SaveImage(mGray);
            // Create column vector
            Mat image = mGray.reshape(0, (int) mGray.total());
            Log.i(TAG, "Vector height: " + image.height() + " Width: " + image.width() + " total: " + image.total());
            // Add current image to the array
            images.add(image);
            if (images.size() > maximumImages) {
                // Remove first image
                images.remove(0);
                // Remove first label
                imagesLabels.remove(0);
                Log.i(TAG, "The number of images is limited to: " + images.size());
            }
            // Calculate normalized Euclidean distance
            mMeasureDistTask = new NativeMethods.MeasureDistTask(useEigenfaces, measureDistTaskCallback);
            mMeasureDistTask.execute(image);
            showLabelsDialog();
        }
    });
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.camera_java_surface_view);
    mOpenCvCameraView.setCameraIndex(prefs.getInt("mCameraIndex", CameraBridgeViewBase.CAMERA_ID_FRONT));
    mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(this);
}
Also used : Mat(org.opencv.core.Mat) Size(org.opencv.core.Size) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) RadioButton(android.widget.RadioButton) SurfaceView(android.view.SurfaceView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 68 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Detours-Android by TeamDetours.

the class NightLife_NavDrawer_Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.attractions_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    MyScrollView = (ScrollView) findViewById(R.id.MyScroll);
    ParentLinearLayout = new LinearLayout(this);
    ParentLinearLayout.setOrientation(LinearLayout.VERTICAL);
    ParentLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    // Create some spacing
    TextView SpaceView = new TextView(this);
    String spaceViewS = "" + '\n' + "" + '\n' + "";
    SpaceView.setText(spaceViewS);
    ParentLinearLayout.addView(SpaceView);
    MyScrollView.addView(ParentLinearLayout);
    // Get lat and lon from main activity
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        m_lat = Double.parseDouble(extras.get("Lat").toString());
        m_lon = Double.parseDouble(extras.get("Lon").toString());
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    new Thread() {

        public void run() {
            GooglePlacesAPIFunction(m_lat, m_lon, 4828, "night_club");
        }
    }.start();
}
Also used : NavigationView(android.support.design.widget.NavigationView) Bundle(android.os.Bundle) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) TextView(android.widget.TextView) DrawerLayout(android.support.v4.widget.DrawerLayout) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 69 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Detours-Android by TeamDetours.

the class Reviews_Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reviews);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    // setSupportActionBar(toolbar); //uncomment this to show overflow menu
    MyScrollaleView = (ScrollView) findViewById(R.id.MyScroll);
    ParentLinearLayout = new LinearLayout(this);
    ParentLinearLayout.setOrientation(LinearLayout.VERTICAL);
    ParentLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    // Create some spacing
    TextView SpaceView = new TextView(this);
    SpaceView.setText("" + '\n' + "" + '\n' + "");
    ParentLinearLayout.addView(SpaceView);
    MyScrollaleView.addView(ParentLinearLayout);
    // Get lat and lon from main activity
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        empty_flag = false;
        String jsonArrayString = extras.getString("ReviewsList");
        try {
            ReviewsArray = new JSONArray(jsonArrayString);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    if (empty_flag) {
        NoReviewsErrorMessage();
    } else {
        ParseJsonArray();
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) Bundle(android.os.Bundle) JSONArray(org.json.JSONArray) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) JSONException(org.json.JSONException) TextView(android.widget.TextView) DrawerLayout(android.support.v4.widget.DrawerLayout) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 70 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Detours-Android by TeamDetours.

the class Minimart_NavDrawer_Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.attractions_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    MyScrollView = (ScrollView) findViewById(R.id.MyScroll);
    ParentLinearLayout = new LinearLayout(this);
    ParentLinearLayout.setOrientation(LinearLayout.VERTICAL);
    ParentLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    // Create some spacing
    TextView SpaceView = new TextView(this);
    String spaceViewS = "" + '\n' + "" + '\n' + "";
    SpaceView.setText(spaceViewS);
    ParentLinearLayout.addView(SpaceView);
    MyScrollView.addView(ParentLinearLayout);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        m_lat = Double.parseDouble(extras.get("Lat").toString());
        m_lon = Double.parseDouble(extras.get("Lon").toString());
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    new Thread() {

        public void run() {
            GooglePlacesAPIFunction(m_lat, m_lon, 4828, "convenience_store");
        }
    }.start();
}
Also used : NavigationView(android.support.design.widget.NavigationView) Bundle(android.os.Bundle) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) TextView(android.widget.TextView) DrawerLayout(android.support.v4.widget.DrawerLayout) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)218 View (android.view.View)153 NavigationView (android.support.design.widget.NavigationView)118 Toolbar (android.support.v7.widget.Toolbar)98 DrawerLayout (android.support.v4.widget.DrawerLayout)96 TextView (android.widget.TextView)85 AdapterView (android.widget.AdapterView)51 ImageView (android.widget.ImageView)48 ListView (android.widget.ListView)48 Intent (android.content.Intent)45 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)35 ActionBar (android.support.v7.app.ActionBar)31 SharedPreferences (android.content.SharedPreferences)30 RecyclerView (android.support.v7.widget.RecyclerView)23 Bundle (android.os.Bundle)20 FloatingActionButton (android.support.design.widget.FloatingActionButton)20 LinearLayout (android.widget.LinearLayout)19 MenuItem (android.view.MenuItem)17 BindView (butterknife.BindView)15 ArrayList (java.util.ArrayList)15