Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

In this page you can find the example usage for android.widget FrameLayout FrameLayout.

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:com.ndn.menurandom.ImageDownloader.java

private void makeFrameLayout(ImageView imageView) {
    boolean isExist = false;
    ViewGroup vg = (ViewGroup) imageView.getParent();
    if (vg instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) vg;
        String tag = (String) frameLayout.getTag();
        if (tag != null && tag.equals("fl_imagedownloader")) {
            isExist = true;//from   w  w w  .  ja  v a2 s .c om
        }
    }

    if (!isExist) {
        int childCount = vg.getChildCount();
        int index = 0;
        while (index < childCount) {
            if (imageView == vg.getChildAt(index)) {
                break;
            }
            index++;
        }
        vg.removeViewAt(index);

        FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext());
        frameLayout.setTag("fl_imagedownloader");
        ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams();
        frameLayout.setLayoutParams(lpImageView);
        imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height));
        frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(),
                imageView.getPaddingRight(), imageView.getPaddingBottom());
        imageView.setPadding(0, 0, 0, 0);
        frameLayout.addView(imageView);
        vg.addView(frameLayout, index);

        ProgressBar progressBar = new ProgressBar(frameLayout.getContext());
        progressBar.setTag("pb_imagedownloader");
        int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2;
        int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2;
        progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
        frameLayout.addView(progressBar);

    }
}

From source file:android.support.v13.app.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();//  w ww  .  ja  va2 s  .  c  om

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:org.shaastra.helper.SuperAwesomeCardFragment2.java

@SuppressLint("NewApi")
@Override//from ww  w .j  ava 2s  .  com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    ListView lv;
    EditText inputSearch;
    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    //v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    View v1 = inflater.inflate(R.layout.contacts_list, container, false);
    lv = (ListView) v1.findViewById(R.id.list1);
    inputSearch = (EditText) v1.findViewById(R.id.inputSearch);

    ArrayList<Coord> rowItems = new ArrayList<Coord>();
    if (position == 0)
        for (int i = 0; i < con.size(); i++) {
            Coord item = new Coord(con.get(i), pon.get(i), eon.get(i), eson.get(i));
            rowItems.add(item);
        }
    else {
        for (int i = 0; i < len[position]; i++) {
            Coord item = new Coord(cString[position][i], pString[position][i], eString[position][i],
                    evString[position][i]);
            rowItems.add(item);
        }

    }

    /*final ArrayAdapter<String> files = new ArrayAdapter<String>(getActivity(), 
            R.layout.custom_list_item 
         );
    files.addAll(values);
    */
    final CoordAdapter files = new CoordAdapter(getActivity(), R.layout.cordlist, rowItems);

    v1.setBackgroundColor(0xbba0d9ea);

    lv.setAdapter(files);
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {

            b1 = new AlertDialog.Builder(getActivity());
            b1.setMessage("What do you want to do?");
            b1.setNegativeButton("Call", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    TextView t = (TextView) view.findViewById(R.id.cordphone);

                    String url = "tel:" + t.getText();
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
                    startActivity(intent);
                }
            });
            b1.setPositiveButton("Message", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    TextView t = (TextView) view.findViewById(R.id.cordphone);
                    String url = "sms:" + t.getText();
                    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(url));
                    startActivity(intent);
                }
            });
            AlertDialog a1 = b1.create();
            a1.setCanceledOnTouchOutside(true);
            a1.show();

            //Open the browser here
        }
    });

    inputSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
            // When user changed the Text
            files.getFilter().filter(cs.toString());

        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable arg0) {
            // TODO Auto-generated method stub                     
        }
    });

    //v1.setLayoutParams(params);
    return v1;

}

From source file:com.andreadec.musicplayer.MainActivity.java

@SuppressLint({ "InlinedApi", "NewApi" })
@Override//from ww  w .  j a va 2 s  . com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (preferences.getBoolean(Constants.PREFERENCE_DISABLELOCKSCREEN, Constants.DEFAULT_DISABLELOCKSCREEN)) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // Disable lock screen for this activity
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    if (preferences.getBoolean(Constants.PREFERENCE_SHOWHELPOVERLAYMAINACTIVITY, true)) {
        final FrameLayout frameLayout = new FrameLayout(this);
        LayoutInflater layoutInflater = getLayoutInflater();
        layoutInflater.inflate(R.layout.layout_main, frameLayout);
        layoutInflater.inflate(R.layout.layout_helpoverlay_main, frameLayout);
        final View overlayView = frameLayout.getChildAt(1);
        overlayView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                frameLayout.removeView(overlayView);
                SharedPreferences.Editor editor = preferences.edit();
                editor.putBoolean(Constants.PREFERENCE_SHOWHELPOVERLAYMAINACTIVITY, false);
                editor.commit();
            }
        });
        setContentView(frameLayout);
    } else {
        setContentView(R.layout.layout_main);
    }

    pages = new String[4];
    pages[PAGE_BROWSER] = getResources().getString(R.string.browser);
    pages[PAGE_PLAYLISTS] = getResources().getString(R.string.playlist);
    pages[PAGE_RADIOS] = getResources().getString(R.string.radio);
    pages[PAGE_PODCASTS] = getResources().getString(R.string.podcasts);
    fragmentManager = getSupportFragmentManager();
    setTitle(pages[currentPage]);

    /* NAVIGATION DRAWER */
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            setTitle(pages[currentPage]);
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            setTitle(getResources().getString(R.string.app_name));
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
    if (Build.VERSION.SDK_INT >= 11)
        getActionBar().setDisplayHomeAsUpEnabled(true);
    drawerContainer = (RelativeLayout) findViewById(R.id.navigation_container);
    drawerList = (ListView) findViewById(R.id.navigation_list);
    navigationAdapter = new NavigationDrawerArrayAdapter(this, pages);
    drawerList.setAdapter(navigationAdapter);
    drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(@SuppressWarnings("rawtypes") AdapterView parent, View view, int position,
                long id) {
            openPage(position);
            drawerLayout.closeDrawer(drawerContainer);
        }
    });
    buttonQuit = findViewById(R.id.navigation_buttonQuit);
    buttonQuit.setOnClickListener(this);

    if (Build.VERSION.SDK_INT >= 19) {
        // Android 4.4+ only
        boolean translucentStatus = preferences.getBoolean(Constants.PREFERENCE_TRANSLUCENTSTATUSBAR,
                Constants.DEFAULT_TRANSLUCENTSTATUSBAR);
        boolean translucentNavigation = preferences.getBoolean(Constants.PREFERENCE_TRANSLUCENTNAVIGATIONBAR,
                Constants.DEFAULT_TRANSLUCENTNAVIGATIONBAR);

        if (translucentStatus)
            getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (translucentNavigation)
            getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        if (translucentStatus) {
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintResource(R.color.actionBarBackground);
        }
    }

    textViewArtist = (TextView) findViewById(R.id.textViewArtist);
    textViewTitle = (TextView) findViewById(R.id.textViewTitle);
    textViewTime = (TextView) findViewById(R.id.textViewTime);
    imageViewSongImage = (ImageView) findViewById(R.id.imageViewSongImage);
    imageButtonPrevious = (ImageButton) findViewById(R.id.imageButtonPrevious);
    imageButtonPlayPause = (ImageButton) findViewById(R.id.imageButtonPlayPause);
    imageButtonNext = (ImageButton) findViewById(R.id.imageButtonNext);
    seekBar1 = (SeekBar) findViewById(R.id.seekBar1);
    seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
    imageButtonShowSeekbar2 = (ImageButton) findViewById(R.id.imageButtonShowSeekbar2);
    imageButtonShuffle = (ImageButton) findViewById(R.id.imageButtonShuffle);
    imageButtonRepeat = (ImageButton) findViewById(R.id.imageButtonRepeat);
    imageButtonRepeatAll = (ImageButton) findViewById(R.id.imageButtonRepeatAll);
    buttonBassBoost = (Button) findViewById(R.id.buttonBassBoost);
    buttonEqualizer = (Button) findViewById(R.id.buttonEqualizer);
    buttonShake = (Button) findViewById(R.id.buttonShake);

    imageButtonShuffle.setOnClickListener(this);
    imageButtonRepeat.setOnClickListener(this);
    imageButtonRepeatAll.setOnClickListener(this);
    buttonBassBoost.setOnClickListener(this);
    buttonEqualizer.setOnClickListener(this);
    buttonShake.setOnClickListener(this);

    imageButtonShowSeekbar2.setOnClickListener(this);
    imageButtonPrevious.setOnClickListener(this);
    imageButtonPlayPause.setOnClickListener(this);
    imageButtonNext.setOnClickListener(this);
    seekBar1.setOnSeekBarChangeListener(this);
    seekBar1.setClickable(false);
    seekBar2.setOnSeekBarChangeListener(this);
    textViewTime.setOnClickListener(this);

    showSongImage = preferences.getBoolean(Constants.PREFERENCE_SHOWSONGIMAGE, Constants.DEFAULT_SHOWSONGIMAGE);
    imagesCache = new LruCache<String, Bitmap>(Constants.IMAGES_CACHE_SIZE);

    serviceIntent = new Intent(this, MusicService.class);
    startService(serviceIntent); // Starts the service if it is not running

    if (preferences.getBoolean(Constants.PREFERENCE_OPENLASTPAGEONSTART,
            Constants.DEFAULT_OPENLASTPAGEONSTART)) {
        openPage(preferences.getInt(Constants.PREFERENCE_LASTPAGE, Constants.DEFAULT_LASTPAGE));
    } else {
        openPage(PAGE_BROWSER);
    }
    loadSongFromIntent();

    layoutPlaybackControls = findViewById(R.id.layoutPlaybackControls);
    if (preferences.getBoolean(Constants.PREFERENCE_ENABLEGESTURES, Constants.DEFAULT_ENABLEGESTURES)) {
        final GestureDetectorCompat gestureDetector = new GestureDetectorCompat(this,
                new PlayerGestureListener());
        View layoutTop = findViewById(R.id.layoutTop);
        layoutTop.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return gestureDetector.onTouchEvent(event);
            }
        });
        if (preferences.getBoolean(Constants.PREFERENCE_SHOWPLAYBACKCONTROLS,
                Constants.DEFAULT_SHOWPLAYBACKCONTROLS)) {
            layoutPlaybackControls.setVisibility(View.VISIBLE);
        }
    } else {
        layoutPlaybackControls.setVisibility(View.VISIBLE);
    }
}

From source file:org.cocos2dx.lib.Cocos2dxFragmentActivity.java

public void init() {

    View v = null;//w w w.j a  va 2s . co  m
    if (useCustomContentView) {
        // Cocos2dxGLSurfaceView
        this.mGLSurfaceView = this.onCreateView();

        // Switch to supported OpenGL (ARGB888) mode on emulator
        if (isAndroidEmulator())
            this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());

        v = initLayout(this.mGLSurfaceView);
    }

    if (v != null) {
        setContentView(v);
        return;
    }

    // FrameLayout
    ViewGroup.LayoutParams framelayout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    FrameLayout framelayout = new FrameLayout(this);
    framelayout.setLayoutParams(framelayout_params);

    // Cocos2dxEditText layout
    ViewGroup.LayoutParams edittext_layout_params = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    Cocos2dxEditText edittext = new Cocos2dxEditText(this);
    edittext.setLayoutParams(edittext_layout_params);

    // ...add to FrameLayout
    framelayout.addView(edittext);

    // Cocos2dxGLSurfaceView
    this.mGLSurfaceView = this.onCreateView();

    // ...add to FrameLayout
    framelayout.addView(this.mGLSurfaceView);

    // Switch to supported OpenGL (ARGB888) mode on emulator
    if (isAndroidEmulator())
        this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

    this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
    this.mGLSurfaceView.setCocos2dxEditText(edittext);

    // Set framelayout as the content view
    setContentView(framelayout);
}

From source file:org.telegram.ui.ChannelUsersActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (type == 0) {
        actionBar.setTitle(LocaleController.getString("ChannelBlockedUsers", R.string.ChannelBlockedUsers));
    } else if (type == 1) {
        actionBar.setTitle(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators));
    } else if (type == 2) {
        actionBar.setTitle(LocaleController.getString("ChannelMembers", R.string.ChannelMembers));
    }/*from   ww w .  j  a  v a  2 s.  co m*/
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();

    fragmentView = new FrameLayout(context);
    fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));
    FrameLayout frameLayout = (FrameLayout) fragmentView;

    emptyView = new EmptyTextProgressView(context);
    if (type == 0) {
        if (isMegagroup) {
            emptyView.setText(LocaleController.getString("NoBlockedGroup", R.string.NoBlockedGroup));
        } else {
            emptyView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
        }
    }
    frameLayout.addView(emptyView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    final ListView listView = new ListView(context);
    listView.setEmptyView(emptyView);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setDrawSelectorOnTop(true);
    listView.setAdapter(listViewAdapter = new ListAdapter(context));
    listView.setVerticalScrollbarPosition(
            LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (type == 2) {
                if (isAdmin) {
                    if (i == 0) {
                        Bundle args = new Bundle();
                        args.putBoolean("onlyUsers", true);
                        args.putBoolean("destroyAfterSelect", true);
                        args.putBoolean("returnAsResult", true);
                        args.putBoolean("needForwardCount", false);
                        args.putBoolean("allowUsernameSearch", false);
                        args.putString("selectAlertString",
                                LocaleController.getString("ChannelAddTo", R.string.ChannelAddTo));
                        ContactsActivity fragment = new ContactsActivity(args);
                        fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
                            @Override
                            public void didSelectContact(TLRPC.User user, String param) {
                                MessagesController.getInstance().addUserToChat(chatId, user, null,
                                        param != null ? Utilities.parseInt(param) : 0, null,
                                        ChannelUsersActivity.this);
                            }
                        });
                        presentFragment(fragment);
                    } else if (!isPublic && i == 1) {
                        presentFragment(new GroupInviteActivity(chatId));
                    }
                }

            } else if (type == 1) {
                if (isAdmin) {
                    if (isMegagroup && (i == 1 || i == 2)) {
                        TLRPC.Chat chat = MessagesController.getInstance().getChat(chatId);
                        if (chat == null) {
                            return;
                        }
                        boolean changed = false;
                        if (i == 1 && !chat.democracy) {
                            chat.democracy = true;
                            changed = true;
                        } else if (i == 2 && chat.democracy) {
                            chat.democracy = false;
                            changed = true;
                        }
                        if (changed) {
                            MessagesController.getInstance().toogleChannelInvites(chatId, chat.democracy);
                            int count = listView.getChildCount();
                            for (int a = 0; a < count; a++) {
                                View child = listView.getChildAt(a);
                                if (child instanceof RadioCell) {
                                    int num = (Integer) child.getTag();
                                    ((RadioCell) child).setChecked(
                                            num == 0 && chat.democracy || num == 1 && !chat.democracy, true);
                                }
                            }
                        }
                        return;
                    }
                    if (i == participantsStartRow + participants.size()) {
                        Bundle args = new Bundle();
                        args.putBoolean("onlyUsers", true);
                        args.putBoolean("destroyAfterSelect", true);
                        args.putBoolean("returnAsResult", true);
                        args.putBoolean("needForwardCount", false);
                        args.putBoolean("allowUsernameSearch", true);
                        /*if (isMegagroup) {
                        args.putBoolean("allowBots", false);
                        }*/
                        args.putString("selectAlertString", LocaleController
                                .getString("ChannelAddUserAdminAlert", R.string.ChannelAddUserAdminAlert));
                        ContactsActivity fragment = new ContactsActivity(args);
                        fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
                            @Override
                            public void didSelectContact(TLRPC.User user, String param) {
                                setUserChannelRole(user, new TLRPC.TL_channelRoleEditor());
                            }
                        });
                        presentFragment(fragment);
                        return;
                    }
                }
            }
            TLRPC.ChannelParticipant participant = null;
            if (i >= participantsStartRow && i < participants.size() + participantsStartRow) {
                participant = participants.get(i - participantsStartRow);
            }
            if (participant != null) {
                Bundle args = new Bundle();
                args.putInt("user_id", participant.user_id);
                presentFragment(new ProfileActivity(args));
            }
        }
    });

    if (isAdmin || isMegagroup && type == 0) {
        listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                if (getParentActivity() == null) {
                    return false;
                }
                TLRPC.ChannelParticipant participant = null;
                if (i >= participantsStartRow && i < participants.size() + participantsStartRow) {
                    participant = participants.get(i - participantsStartRow);
                }
                if (participant != null) {
                    final TLRPC.ChannelParticipant finalParticipant = participant;
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    CharSequence[] items = null;
                    if (type == 0) {
                        items = new CharSequence[] { LocaleController.getString("Unblock", R.string.Unblock) };
                    } else if (type == 1) {
                        items = new CharSequence[] { LocaleController.getString("ChannelRemoveUserAdmin",
                                R.string.ChannelRemoveUserAdmin) };
                    } else if (type == 2) {
                        items = new CharSequence[] {
                                LocaleController.getString("ChannelRemoveUser", R.string.ChannelRemoveUser) };
                    }
                    builder.setItems(items, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (i == 0) {
                                if (type == 0) {
                                    participants.remove(finalParticipant);
                                    listViewAdapter.notifyDataSetChanged();
                                    TLRPC.TL_channels_kickFromChannel req = new TLRPC.TL_channels_kickFromChannel();
                                    req.kicked = false;
                                    req.user_id = MessagesController.getInputUser(finalParticipant.user_id);
                                    req.channel = MessagesController.getInputChannel(chatId);
                                    ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                        @Override
                                        public void run(TLObject response, TLRPC.TL_error error) {
                                            if (response != null) {
                                                final TLRPC.Updates updates = (TLRPC.Updates) response;
                                                MessagesController.getInstance().processUpdates(updates, false);
                                                if (!updates.chats.isEmpty()) {
                                                    AndroidUtilities.runOnUIThread(new Runnable() {
                                                        @Override
                                                        public void run() {
                                                            TLRPC.Chat chat = updates.chats.get(0);
                                                            MessagesController.getInstance()
                                                                    .loadFullChat(chat.id, 0, true);
                                                        }
                                                    }, 1000);
                                                }
                                            }
                                        }
                                    });
                                } else if (type == 1) {
                                    setUserChannelRole(
                                            MessagesController.getInstance().getUser(finalParticipant.user_id),
                                            new TLRPC.TL_channelRoleEmpty());
                                } else if (type == 2) {
                                    MessagesController.getInstance().deleteUserFromChat(chatId,
                                            MessagesController.getInstance().getUser(finalParticipant.user_id),
                                            null);
                                }
                            }
                        }
                    });
                    showDialog(builder.create());
                    return true;
                } else {
                    return false;
                }
            }
        });
    }

    if (loadingUsers) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }
    return fragmentView;
}

From source file:org.loon.framework.android.game.LGameActivity.java

public void initialization(Bundle icicle, final boolean landscape, final boolean openAD, final LAD lad,
        final String publisherId, final String keywords, final int requestInterval) {
    LSystem.gc();//from  w  ww  .j  av  a 2  s.  c om
    this.androidSelect = -2;
    frameLayout = new FrameLayout(LGameActivity.this);
    super.onCreate(icicle);
    if (openAD) {
        // setVolumeControlStream(AudioManager.STREAM_MUSIC);
        AdManager.setPublisherId(publisherId);
        AdManager.setTestDevices(new String[] { "" });
        AdManager.setAllowUseOfLocation(true);
        view = new LGameView(LGameActivity.this, landscape);
        adview = new AdView(LGameActivity.this);
        adview.setKeywords(keywords);
        adview.setRequestInterval(requestInterval);
        adview.setGravity(Gravity.NO_GRAVITY);
        RelativeLayout rl = new RelativeLayout(LGameActivity.this);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        if (lad == LAD.LEFT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
        } else if (lad == LAD.RIGHT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else if (lad == LAD.TOP) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else {
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
        }
        visible = true;
        adview.requestFreshAd();
        frameLayout.addView(view);
        rl.addView(adview, lp);
        frameLayout.addView(rl);
    } else {
        view = new LGameView(LGameActivity.this, landscape);
        frameLayout.addView(view);
    }
    if (view != null) {
        gameHandler = view.getGameHandler();
    }

}

From source file:com.flipkart.android.proteus.demo.performance.ProteusActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    gson = new Gson();
    styles = gson.fromJson(getJsonFromFile(R.raw.styles).getAsJsonObject(), Styles.class);
    Map<String, JsonObject> layoutProvider = getProviderFromFile(R.raw.layout_provider);
    pageLayout = getJsonFromFile(R.raw.page_layout).getAsJsonObject();

    data = getJsonFromFile(R.raw.data_init).getAsJsonObject();

    builder = new LayoutBuilderFactory().getDataAndViewParsingLayoutBuilder(layoutProvider);
    builder.setListener(callback);/* w ww . j  a v  a  2s.  c  om*/
    builder.setBitmapLoader(bitmapLoader);

    container = new FrameLayout(ProteusActivity.this);
    layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    super.onCreate(savedInstanceState);
}

From source file:org.telegramsecureplus.ui.Components.EmojiView.java

public EmojiView(boolean needStickers, Context context) {
    super(context);

    showStickers = needStickers;//from   www.j  a va 2 s.  c  om

    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(context);
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(emojiGridAdapter);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);
        adapters.add(emojiGridAdapter);
    }

    if (showStickers) {
        StickersQuery.checkStickers();
        GridView gridView = new GridView(context);
        gridView.setColumnWidth(AndroidUtilities.dp(72));
        gridView.setNumColumns(-1);
        gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0);
        gridView.setClipToPadding(false);
        views.add(gridView);
        stickersGridAdapter = new StickersGridAdapter(context);
        gridView.setAdapter(stickersGridAdapter);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);

        stickersWrap = new FrameLayout(context);
        stickersWrap.addView(gridView);

        TextView textView = new TextView(context);
        textView.setText(LocaleController.getString("NoStickers", R.string.NoStickers));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        textView.setTextColor(0xff888888);
        stickersWrap.addView(textView,
                LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
        gridView.setEmptyView(textView);

        scrollSlidingTabStrip = new ScrollSlidingTabStrip(context) {

            boolean startedScroll;
            float lastX;
            float lastTranslateX;
            boolean first = true;

            @Override
            public boolean onInterceptTouchEvent(MotionEvent ev) {
                if (getParent() != null) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                return super.onInterceptTouchEvent(ev);
            }

            @Override
            public boolean onTouchEvent(MotionEvent ev) {
                if (Build.VERSION.SDK_INT >= 11) {
                    if (first) {
                        first = false;
                        lastX = ev.getX();
                    }
                    float newTranslationX = ViewProxy.getTranslationX(scrollSlidingTabStrip);
                    if (scrollSlidingTabStrip.getScrollX() == 0 && newTranslationX == 0) {
                        if (!startedScroll && lastX - ev.getX() < 0) {
                            if (pager.beginFakeDrag()) {
                                startedScroll = true;
                                lastTranslateX = ViewProxy.getTranslationX(scrollSlidingTabStrip);
                            }
                        } else if (startedScroll && lastX - ev.getX() > 0) {
                            if (pager.isFakeDragging()) {
                                pager.endFakeDrag();
                                startedScroll = false;
                            }
                        }
                    }
                    if (startedScroll) {
                        int dx = (int) (ev.getX() - lastX + newTranslationX - lastTranslateX);
                        try {
                            pager.fakeDragBy(dx);
                            lastTranslateX = newTranslationX;
                        } catch (Exception e) {
                            try {
                                pager.endFakeDrag();
                            } catch (Exception e2) {
                                //don't promt
                            }
                            startedScroll = false;
                            FileLog.e("tmessages", e);
                        }
                    }
                    lastX = ev.getX();
                    if (ev.getAction() == MotionEvent.ACTION_CANCEL
                            || ev.getAction() == MotionEvent.ACTION_UP) {
                        first = true;
                        if (startedScroll) {
                            pager.endFakeDrag();
                            startedScroll = false;
                        }
                    }
                    return startedScroll || super.onTouchEvent(ev);
                }
                return super.onTouchEvent(ev);
            }
        };
        scrollSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1));
        scrollSlidingTabStrip.setIndicatorColor(0xffe2e5e7);
        scrollSlidingTabStrip.setUnderlineColor(0xffe2e5e7);
        addView(scrollSlidingTabStrip,
                LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP));
        ViewProxy.setTranslationX(scrollSlidingTabStrip, AndroidUtilities.displaySize.x);
        updateStickerTabs();
        scrollSlidingTabStrip.setDelegate(new ScrollSlidingTabStrip.ScrollSlidingTabStripDelegate() {
            @Override
            public void onPageSelected(int page) {
                if (page == 0) {
                    pager.setCurrentItem(0);
                    return;
                } else if (page == 1 && !recentStickers.isEmpty()) {
                    views.get(6).setSelection(0);
                    return;
                }
                int index = page - (recentStickers.isEmpty() ? 1 : 2);
                if (index >= stickerSets.size()) {
                    index = stickerSets.size() - 1;
                }
                views.get(6).setSelection(stickersGridAdapter.getPositionForPack(stickerSets.get(index)));
            }
        });

        gridView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                int count = view.getChildCount();
                for (int a = 0; a < count; a++) {
                    View child = view.getChildAt(a);
                    if (child.getHeight() + child.getTop() < AndroidUtilities.dp(5)) {
                        firstVisibleItem++;
                    } else {
                        break;
                    }
                }
                scrollSlidingTabStrip
                        .onPageScrolled(stickersGridAdapter.getTabForPosition(firstVisibleItem) + 1, 0);
            }
        });
    }

    setBackgroundColor(0xfff5f6f7);

    pager = new ViewPager(context) {
        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            if (getParent() != null) {
                getParent().requestDisallowInterceptTouchEvent(true);
            }
            return super.onInterceptTouchEvent(ev);
        }
    };
    pager.setAdapter(new EmojiPagesAdapter());

    pagerSlidingTabStripContainer = new LinearLayout(context) {
        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            if (getParent() != null) {
                getParent().requestDisallowInterceptTouchEvent(true);
            }
            return super.onInterceptTouchEvent(ev);
        }
    };
    pagerSlidingTabStripContainer.setOrientation(LinearLayout.HORIZONTAL);
    pagerSlidingTabStripContainer.setBackgroundColor(0xfff5f6f7);
    addView(pagerSlidingTabStripContainer, LayoutHelper.createFrame(LayoutParams.MATCH_PARENT, 48));

    PagerSlidingTabStrip pagerSlidingTabStrip = new PagerSlidingTabStrip(context);
    pagerSlidingTabStrip.setViewPager(pager);
    pagerSlidingTabStrip.setShouldExpand(true);
    pagerSlidingTabStrip.setIndicatorHeight(AndroidUtilities.dp(2));
    pagerSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1));
    pagerSlidingTabStrip.setIndicatorColor(0xff2b96e2);
    pagerSlidingTabStrip.setUnderlineColor(0xffe2e5e7);
    pagerSlidingTabStripContainer.addView(pagerSlidingTabStrip, LayoutHelper.createLinear(0, 48, 1.0f));
    pagerSlidingTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            EmojiView.this.onPageScrolled(position, getMeasuredWidth(), positionOffsetPixels);
        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    FrameLayout frameLayout = new FrameLayout(context);
    pagerSlidingTabStripContainer.addView(frameLayout, LayoutHelper.createLinear(52, 48));

    backspaceButton = new ImageView(context) {
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                backspacePressed = true;
                backspaceOnce = false;
                postBackspaceRunnable(350);
            } else if (event.getAction() == MotionEvent.ACTION_CANCEL
                    || event.getAction() == MotionEvent.ACTION_UP) {
                backspacePressed = false;
                if (!backspaceOnce) {
                    if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) {
                        backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
                    }
                }
            }
            super.onTouchEvent(event);
            return true;
        }
    };
    backspaceButton.setImageResource(R.drawable.ic_smiles_backspace);
    backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace);
    backspaceButton.setScaleType(ImageView.ScaleType.CENTER);
    frameLayout.addView(backspaceButton, LayoutHelper.createFrame(52, 48));

    View view = new View(context);
    view.setBackgroundColor(0xffe2e5e7);
    frameLayout.addView(view, LayoutHelper.createFrame(52, 1, Gravity.LEFT | Gravity.BOTTOM));

    recentsWrap = new FrameLayout(context);
    recentsWrap.addView(views.get(0));

    TextView textView = new TextView(context);
    textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    textView.setTextSize(18);
    textView.setTextColor(0xff888888);
    textView.setGravity(Gravity.CENTER);
    recentsWrap.addView(textView);
    views.get(0).setEmptyView(textView);

    addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT,
            Gravity.LEFT | Gravity.TOP, 0, 48, 0, 0));

    loadRecents();

    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:de.elanev.studip.android.app.frontend.courses.CourseDocumentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final FrameLayout wrapperLayout = new FrameLayout(getActivity());
    wrapperLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    wrapperLayout.setId(R.id.document_list_wrapper);

    return wrapperLayout;
}