app.android.box.waveprotocol.org.androidwave.activities.InboxActivity.java Source code

Java tutorial

Introduction

Here is the source code for app.android.box.waveprotocol.org.androidwave.activities.InboxActivity.java

Source

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 app.android.box.waveprotocol.org.androidwave.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import app.android.box.waveprotocol.org.androidwave.R;

/**
 * Created by roshan on 6/25/15.
 */
public class InboxActivity extends AppCompatActivity implements FragmentDrawer.FragmentDrawerListener {

    private static String TAG = MainActivity.class.getSimpleName();

    private Toolbar mToolbar;
    private FragmentDrawer drawerFragment;

    private Toolbar toolbar;
    ImageButton FAB;
    Button singOut;
    ImageButton search;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.inbox_activity);

        mToolbar = (Toolbar) findViewById(R.id.toolbar);

        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayShowHomeEnabled(true);

        drawerFragment = (FragmentDrawer) getSupportFragmentManager()
                .findFragmentById(R.id.fragment_navigation_drawer);
        drawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout),
                mToolbar);
        drawerFragment.setDrawerListener(this);

        // display the first navigation drawer view on app launch
        displayView(0);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        if (id == R.id.action_search) {
            //Toast.makeText(getApplicationContext(), "Search action is selected!", Toast.LENGTH_SHORT).show();
            Intent openNewWavectivity = new Intent("app.android.box.waveprotocol.org.androidwave.SEARCHACTIVITY");
            startActivity(openNewWavectivity);
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onDrawerItemSelected(View view, int position) {
        displayView(position);
    }

    private void displayView(int position) {
        Fragment fragment = null;
        String title = getString(R.string.app_name);
        switch (position) {
        case 0:
            fragment = new InboxFragment();
            title = getString(R.string.title_home);
            break;
        case 1:
            //                fragment = new FriendsFragment();
            //                title = getString(R.string.title_friends);
            //                break;
        case 2:
            //                fragment = new MessagesFragment();
            //                title = getString(R.string.title_messages);
            //                break;
        case 3:
            //                Sign out
        default:
            break;
        }

        if (fragment != null) {
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.container_body, fragment);
            fragmentTransaction.commit();

            // set the toolbar title
            getSupportActionBar().setTitle(title);
        }
        /*
        toolbar = (Toolbar) findViewById(R.id.tool_bar); // Attaching the layout to the toolbar object
        setSupportActionBar(toolbar);
            
            
        FAB = (ImageButton) findViewById(R.id.imageButton);
        search = (ImageButton) findViewById(R.id.ic_search);
        //singOut = (Button) findViewById(R.id.singOut);
            
        FAB.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent openNewWavectivity = new Intent("app.android.box.waveprotocol.org.androidwave.NEWWAVEACTIVITY");
            startActivity(openNewWavectivity);
            //new wave
            //setContentView(R.layout.activity_new_wave);
        }
        });
            
        search.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent openNewWavectivity = new Intent("app.android.box.waveprotocol.org.androidwave.SEARCHACTIVITY");
            startActivity(openNewWavectivity);
            //test3
            //setC//testontentView(R.layout.activity_new_wave);
        }
        });
        */

    }

    //    @Override
    ////    public boolean onCreateOptionsMenu(Menu menu) {
    ////        // Inflate the menu; this adds items to the action bar if it is present.
    ////        getMenuInflater().inflate(R.menu.menu_main, menu);
    ////        return true;
    ////    }
    //
    //    @Override
    //    public boolean onOptionsItemSelected(MenuItem item) {
    //        // Handle action bar item clicks here. The action bar will
    //        // automatically handle clicks on the Home/Up button, so long
    //        // as you specify a parent activity in AndroidManifest.xml.
    //        int id = item.getItemId();
    //
    //        //noinspection SimplifiableIfStatement
    ////        if (id == R.id.action_search) {
    ////            Intent openSearchActivity = new Intent("app.android.box.waveprotocol.org.androidwave.SEARCHACTIVITY");
    ////            startActivity(openSearchActivity);
    ////        }
    //
    //        return super.onOptionsItemSelected(item);
}