Example usage for android.support.v4.view GravityCompat START

List of usage examples for android.support.v4.view GravityCompat START

Introduction

In this page you can find the example usage for android.support.v4.view GravityCompat START.

Prototype

int START

To view the source code for android.support.v4.view GravityCompat START.

Click Source Link

Usage

From source file:chao.widget.tablayout.TabLayout.java

private void updateTabViews(final boolean requestLayout) {
    for (int i = 0; i < mTabStrip.getChildCount(); i++) {
        TabView child = (TabView) mTabStrip.getChildAt(i);
        child.setMinimumWidth(getTabMinWidth());
        child.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) child.getLayoutParams();
        updateTabViewLayoutParams(lp);// ww  w .  j  av  a 2  s. com
        if (mMode == MODE_FIXED_COMMON) {
            child.setGravity(GravityCompat.START);
            lp.width = LinearLayout.LayoutParams.WRAP_CONTENT;
            if (i == mTabStrip.getChildCount() - 1) {
                lp.weight = 0;
            }
        }
        if (requestLayout) {
            child.requestLayout();
        }
    }
}

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

@SuppressLint("ResourceAsColor")
@Override/*from ww  w . j  a v a 2  s . c o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_PROGRESS);

    if (!K9.isHideSpecialAccounts()) {
        createSpecialAccounts();
    }

    Account[] accounts = Preferences.getPreferences(this).getAccounts();
    Intent intent = getIntent();
    // onNewIntent(intent);

    // see if we should show the welcome message
    if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) {
        mAccounts.onImport();
    } else if (accounts.length < 1) {
        WelcomeMessage.showWelcomeMessage(this);
        finish();
        return;
    }

    if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) {
        finish();
        return;
    }

    Log.d(TAG, "onCreate()");

    String packageName = "com.bernard.beaconportal.activities";

    counterss = "0";

    int versionNumber = 0;

    try {
        PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(packageName,
                PackageManager.GET_META_DATA);
        versionNumber = pi.versionCode;
        String versionName = pi.versionName;

        Log.d(TAG, "K-9 is installed - " + versionNumber + " " + versionName);

    } catch (NameNotFoundException e) {
        Log.d(TAG, "K-9 not found");
    }

    if (versionNumber <= 1) {
        // Register a listener for broadcasts (needed for the older versions
        // of k9)
        Log.d(TAG, "Initialising BroadcastReceiver for old K-9 version");
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                Log.d(TAG, "receiver.onReceive()");
                doRefresh();
            }
        };

        filter = new IntentFilter();
        filter.addAction("com.bernard.beaconportal.activities.intent.action.EMAIL_RECEIVED");
        filter.addAction("com.bernard.beaconportal.activities.intent.action.EMAIL_DELETED");
        filter.addDataScheme("email");
        registerReceiver(receiver, filter);
    } else {
        // Register our own content observer, rather than using
        // addWatchContentUris()
        // since DashClock might not have permission to access the database
        Log.d(TAG, "Initialising ContentObserver for new K-9 version");
        contentObserver = new ContentObserver(null) {
            @Override
            public void onChange(boolean selfChange) {
                Log.d(TAG, "contentResolver.onChange()");
                doRefresh();
            }
        };
        getContentResolver().registerContentObserver(Uri.parse(k9UnreadUri), true, contentObserver);
    }

    doRefresh();

    if (UpgradeDatabases.actionUpgradeDatabases(this, getIntent())) {
        finish();
        return;
    }

    if (useSplitView()) {
        setContentView(R.layout.split_drawer_main);
    } else {
        setContentView(R.layout.drawermain1);
        mViewSwitcher = (ViewSwitcher) findViewById(R.id.container);
        mViewSwitcher.setFirstInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
        mViewSwitcher.setFirstOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right));
        mViewSwitcher.setSecondInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
        mViewSwitcher.setSecondOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_left));
        mViewSwitcher.setOnSwitchCompleteListener(this);
    }

    mergeadapter = new MergeAdapter();

    LayoutInflater inflater = getLayoutInflater();

    accounts_view = inflater.inflate(R.layout.accounts_list, null);

    portals_view = inflater.inflate(R.layout.portal_list, null);

    folders_view = inflater.inflate(R.layout.folders_list, null);

    header_folders = inflater.inflate(R.layout.header_folders, null);

    header_drawer = inflater.inflate(R.layout.header_drawer, null);

    initializeActionBar();

    mListView = (ListView) findViewById(android.R.id.list);
    // mListView.addHeaderView(header_folders, null, false);

    mListView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mListView.setLongClickable(true);
    mListView.setFastScrollEnabled(true);
    mListView.setScrollingCacheEnabled(false);
    // mListView.setOnItemClickListener(new OnItemClickListener() {
    // public void onItemClick(AdapterView<?> parent, View view,
    // int position, long id) {
    //
    // onOpenFolder(((FolderInfoHolder) mAdapter.getItem(position)).name);
    //
    // Log.d("Folder Click Listener", "clicked");
    //
    // }
    // });

    setResult(RESULT_CANCELED);

    // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox);
    //
    // View header_inbox = (View) inflater
    // .inflate(R.layout.header_inbox, null);
    //
    // mDrawerList_Inbox.setOnItemClickListener(this);
    //
    // mDrawerList_Inbox.setItemsCanFocus(false);
    //
    // mDrawerList_Inbox.setLongClickable(true);

    mListView.setSaveEnabled(true);

    mInflater = getLayoutInflater();

    onNewIntent(getIntent());

    context = this;

    SharedPreferences sharedpre = getSharedPreferences("show_view", Context.MODE_PRIVATE);

    Show_View = sharedpre.getString("show_view", "");

    SharedPreferences Today_Homework = getApplicationContext().getSharedPreferences("due_today",
            Context.MODE_PRIVATE);

    SharedPreferences counts = getSharedPreferences("due_today", Context.MODE_PRIVATE);

    if (counts.contains("homeworkdue")) {
        counterss = counts.getString("homeworkdue", null);
    } else {

        counterss = null;
    }

    title_Inbox = new String[] { "Inbox" };

    icon_Inbox = new int[] { R.drawable.ic_action_email };

    count_Inbox = new String[] { K9counts };

    if (Show_View.equals("Homework Due")) {

        title = new String[] { "Homework Due", "Schedule", "Resources", "Options", "Logout" };

        icon = new int[] { R.drawable.ic_action_duehomework, R.drawable.ic_action_go_to_today,
                R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout };

        if (counterss == null && counterss.isEmpty()) {

            count = new String[] { "", "", "", "", "" };

        } else {

            count = new String[] { counterss, "", "", "", "" };

        }

    } else {

        if (counterss == null && counterss.isEmpty()) {

            count = new String[] { "", "", "", "", "" };

        } else {

            count = new String[] { "", counterss, "", "", "" };

        }

        title = new String[] { "Schedule", "Homework Due", "Resources", "Options", "Logout" };

        icon = new int[] { R.drawable.ic_action_go_to_today, R.drawable.ic_action_duehomework,
                R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout };

    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);

    // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox);

    // mDrawerList = (ListView) findViewById(R.id.listview_drawer);

    // mDrawer_Scroll = (ScrollView)
    // findViewById(R.id.left_drawer_scrollview);

    // mDrawerList.addHeaderView(header_drawer, null, false);

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // mMenuAdapter_Inbox = new MenuListAdapter(MessageList.this,
    // title_Inbox,
    // icon_Inbox, count_Inbox);

    // mDrawerList_Inbox.setAdapter(mMenuAdapter_Inbox);

    // mDrawerList_Inbox
    // .setOnItemClickListener(new DrawerItemClickListener_Inbox());

    mMenuAdapter = new MenuListAdapter(MessageList.this, title, icon, count);

    // mDrawerList.setAdapter(mMenuAdapter);

    // mergeadapter.addView(header_drawer);
    //
    // mergeadapter.addAdapter(mMenuAdapter);
    //
    // mergeadapter.addadapter(AccountsAdapter);
    //
    // mDrawerList.setAdapter(mergeadapter);

    getListView().setOnItemClickListener(new DrawerItemClickListener());

    // mDrawerList_Inbox.setOnItemClickListener(new
    // DrawerItemClickListener());

    //
    // if (savedInstanceState == null) {
    // selectItem_Inbox(1);
    // }

    SharedPreferences sharedpref = getSharedPreferences("actionbar_color", Context.MODE_PRIVATE);

    final int splitBarId = getResources().getIdentifier("split_action_bar", "id", "android");
    final View splitActionBar = findViewById(splitBarId);

    if (!sharedpref.contains("actionbar_color")) {

        getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4")));

        if (splitActionBar != null) {

            splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4285f4")));

        }

    } else {

        actionbar_colors = sharedpref.getString("actionbar_color", null);

        getActionBar().setBackgroundDrawable(

                new ColorDrawable(Color.parseColor(actionbar_colors)));

        if (splitActionBar != null) {

            splitActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(actionbar_colors)));

        }

    }

    android.app.ActionBar bar = getActionBar();

    bar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    // Enable gesture detection for MessageLists
    // setupGestureDetector(this);

    if (!decodeExtras(getIntent())) {
        return;
    }

    findFragments();
    initializeDisplayMode(savedInstanceState);
    initializeLayout();
    initializeFragments();
    displayViews();
    // registerForContextMenu(mDrawerList_Inbox);
    registerForContextMenu(mListView);

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerClosed(View view) {
            // TODO Auto-generated method stub
            super.onDrawerClosed(view);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            // TODO Auto-generated method stub

            super.onDrawerOpened(drawerView);
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

}

From source file:android.support.design.widget.RaeTabLayout.java

private void applyModeAndGravity() {
    int paddingStart = 0;
    if (mMode == MODE_SCROLLABLE) {
        // If we're scrollable, or fixed at start, inset using padding
        paddingStart = Math.max(0, mContentInsetStart - mTabPaddingStart);
    }// w  ww  . ja  va2 s  .  c o  m
    ViewCompat.setPaddingRelative(mTabStrip, paddingStart, 0, 0, 0);

    switch (mMode) {
    case MODE_FIXED:
        mTabStrip.setGravity(Gravity.CENTER_HORIZONTAL);
        break;
    case MODE_SCROLLABLE:
        mTabStrip.setGravity(GravityCompat.START);
        break;
    }

    updateTabViews(true);
}

From source file:android.support.design.widget.CoordinatorLayout.java

/**
 * Return the given gravity value, but if either or both of the axes doesn't have any gravity
 * specified, the default value (start or top) is specified. This should be used for children
 * that are not anchored to another view or a keyline.
 *///from ww  w .  j  a  v  a  2  s. c  o  m
private static int resolveGravity(int gravity) {
    if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.NO_GRAVITY) {
        gravity |= GravityCompat.START;
    }
    if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.NO_GRAVITY) {
        gravity |= Gravity.TOP;
    }
    return gravity;
}

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

@Override
public void onResume() {
    super.onResume();

    refresh();//from   w w w. j  a v a 2s  .  co  m
    MessagingController.getInstance(getApplication()).addListener(mListener_Accounts);
    StorageManager.getInstance(getApplication()).addListener(storageListener);
    mListener_Accounts.onResume(this);

    new LoadAccounts().execute();

    // figure out why below if statement throws null later

    // if (!mAccount.isAvailable(this)) {
    // Log.i(K9.LOG_TAG,
    // "account unavaliabale, not showing folder-list but account-list");
    // Accounts.listAccounts(this);
    // finish();
    // return;
    // }
    if (mAdapter == null)
        initializeActivityView();

    MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
    // mAccount.refresh(Preferences.getPreferences(this));
    MessagingController.getInstance(getApplication()).getAccountStats(this, mAccount, mAdapter.mListener);

    onRefresh(!REFRESH_REMOTE);

    MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount);
    mAdapter.mListener.onResume(this);

    if (!(this instanceof Search)) {
        // necessary b/c no guarantee Search.onStop will be called before
        // MessageList.onResume
        // when returning from search results
        Search.setActive(false);
    }

    if (mAccount != null && !mAccount.isAvailable(this)) {
        onAccountUnavailable();
        return;
    }
    StorageManager.getInstance(getApplication()).addListener(mStorageListener);

    // mergeadapter = new MergeAdapter();

    LayoutInflater inflater = getLayoutInflater();

    header_folders = inflater.inflate(R.layout.header_folders, null);

    header_drawer = inflater.inflate(R.layout.header_drawer, null);

    header_inbox = inflater.inflate(R.layout.header_inbox, null);

    mListView = getListView();

    mListView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mListView.setLongClickable(true);
    mListView.setFastScrollEnabled(true);
    mListView.setScrollingCacheEnabled(false);

    // mListView.addHeaderView(header_folders);

    // mListView.setOnItemClickListener(new OnItemClickListener() {
    // public void onItemClick(AdapterView<?> parent, View view,
    // int position, long id) {
    //
    // onOpenFolder(((FolderInfoHolder) mAdapter.getItem(position)).name);
    //
    // Log.d("Folder Click Listener", "clicked");
    //
    // }
    // });

    setResult(RESULT_CANCELED);

    // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox);
    //
    // mDrawerList_Inbox.setOnItemClickListener(this);
    //
    // mDrawerList_Inbox.setItemsCanFocus(false);
    //
    // mDrawerList_Inbox.setLongClickable(true);

    // mDrawerList_Inbox.addHeaderView(header_inbox);

    getListView().setSaveEnabled(true);

    mInflater = getLayoutInflater();

    context = this;

    SharedPreferences sharedpre = getSharedPreferences("show_view", Context.MODE_PRIVATE);

    Show_View = sharedpre.getString("show_view", "");

    SharedPreferences Today_Homework = getApplicationContext().getSharedPreferences("due_today",
            Context.MODE_PRIVATE);

    SharedPreferences counts = getSharedPreferences("due_today", Context.MODE_PRIVATE);

    K9counts = counts.getString("inbox", null);

    counterss = counts.getString("homeworkdue", null);

    title_Inbox = new String[] { "Inbox" };

    icon_Inbox = new int[] { R.drawable.ic_action_email };

    count_Inbox = new String[] { K9counts };

    if (Show_View.equals("Homework Due")) {

        title = new String[] { "Homework Due", "Schedule", "Resources", "Options", "Logout" };

        icon = new int[] { R.drawable.ic_action_duehomework, R.drawable.ic_action_go_to_today,
                R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout };

        if (counterss == null && counterss.isEmpty()) {

            count = new String[] { "", "", "", "", "" };

        } else {

            count = new String[] { counterss, "", "", "", "" };

        }

    } else {

        if (counterss == null && counterss.isEmpty()) {

            count = new String[] { "", "", "", "", "" };

        } else {

            count = new String[] { "", counterss, "", "", "" };

        }

        title = new String[] { "Schedule", "Homework Due", "Resources", "Options", "Logout" };

        icon = new int[] { R.drawable.ic_action_go_to_today, R.drawable.ic_action_duehomework,
                R.drawable.ic_action_resources, R.drawable.ic_action_settings, R.drawable.ic_action_logout };

    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);

    // mDrawerList_Inbox = (ListView) findViewById(R.id.listview_inbox);

    // mDrawerList = (ListView)
    // portals_view.findViewById(R.id.listview_drawer);

    // mDrawer_Scroll = (ScrollView)
    // findViewById(R.id.left_drawer_scrollview);

    // mDrawerList.addHeaderView(header_drawer);

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // mMenuAdapter_Inbox = new MenuListAdapter(MessageList.this,
    // title_Inbox,
    // icon_Inbox, count_Inbox);

    // mDrawerList_Inbox.setAdapter(mMenuAdapter_Inbox);

    // mDrawerList_Inbox
    // .setOnItemClickListener(new DrawerItemClickListener_Inbox());

    mMenuAdapter = new MenuListAdapter(MessageList.this, title, icon, count);

    // mDrawerList.setAdapter(mMenuAdapter);

    // mergeadapter.addView(header_drawer);
    //
    // mergeadapter.addAdapter(mMenuAdapter);
    //
    // mergeadapter.addadapter(AccountsAdapter);
    //
    // mDrawerList.setAdapter(mergeadapter);

    // mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

}

From source file:com.fvd.nimbus.BrowseActivity.java

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    drawer.closeDrawer(GravityCompat.START);
    Intent ip = new Intent();
    switch (arg2) {
    case 0:// w  w  w.ja  v a 2 s . co m
        ip.putExtra("act", "photo");
        ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity");
        startActivity(ip);
        break;
    case 1:
        ip.putExtra("act", "picture");
        ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity");
        startActivity(ip);
        break;
    case 2:
        ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.ChoosePDFActivity");
        startActivity(ip);
        break;

    default:
        break;
    }
    overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
    finish();

}

From source file:android.support.v7.widget.LinearLayoutCompat.java

/**
 * Describes how the child views are positioned. Defaults to GRAVITY_TOP. If
 * this layout has a VERTICAL orientation, this controls where all the child
 * views are placed if there is extra vertical space. If this layout has a
 * HORIZONTAL orientation, this controls the alignment of the children.
 *
 * @param gravity See {@link android.view.Gravity}
 *///from www  . j  a v a  2  s. c o m
public void setGravity(int gravity) {
    if (mGravity != gravity) {
        if ((gravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
            gravity |= GravityCompat.START;
        }

        if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
            gravity |= Gravity.TOP;
        }

        mGravity = gravity;
        requestLayout();
    }
}

From source file:com.dycody.android.idealnote.ListFragment.java

private boolean isFabAllowed(boolean actionModeFinishing) {

    boolean isAllowed = true;

    // Actionmode check
    isAllowed = isAllowed && (getActionMode() == null || actionModeFinishing);
    // Navigation check
    int navigation = Navigation.getNavigation();
    isAllowed = isAllowed && navigation != Navigation.ARCHIVE && navigation != Navigation.REMINDERS
            && navigation != Navigation.TRASH;
    // Navigation drawer check
    isAllowed = isAllowed && mainActivity.getDrawerLayout() != null
            && !mainActivity.getDrawerLayout().isDrawerOpen(GravityCompat.START);

    return isAllowed;
}

From source file:com.fvd.nimbus.PaintActivity.java

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub
    Intent ip;/*from  ww  w .ja  v  a  2s.c  o m*/
    drawer.closeDrawer(GravityCompat.START);
    switch (arg2) {
    case 0:
        getPhoto();
        break;
    case 1:
        getPicture();
        break;
    case 2:
        ip = new Intent();
        ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.BrowseActivity");
        startActivity(ip);
        finish();
        break;
    case 3:
        ip = new Intent();
        ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.ChoosePDFActivity");
        startActivity(ip);
        finish();
        break;
    default:
        break;
    }
}