List of usage examples for android.widget FrameLayout addView
public void addView(View child, int index)
From source file:com.sunho.nating.fragments.DetailUnivFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { FrameLayout root = (FrameLayout) view; context = view.getContext();//from w w w .j av a 2 s. c o m assert context != null; // This is how the fragment looks at first. Since the transition is one-way, we don't need to make // this a Scene. View item = LayoutInflater.from(context).inflate(R.layout.item_gridview, root, false); assert item != null; bind(item); // We adjust the position of the initial image with LayoutParams using the values supplied // as the fragment arguments. Bundle args = getArguments(); FrameLayout.LayoutParams params = null; if (args != null) { params = new FrameLayout.LayoutParams(args.getInt(ARG_WIDTH), args.getInt(ARG_HEIGHT)); params.topMargin = args.getInt(ARG_Y); params.leftMargin = args.getInt(ARG_X); } root.addView(item, params); }
From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java
/** * Copy all the visible views in the mAbsListView into a new FrameLayout and return it. * * @return a FrameLayout with all the visible views inside. *///w w w . ja va 2 s. co m private FrameLayout copyVisibleViews() { // This is the FrameLayout we return afterwards. FrameLayout layout = new FrameLayout(getActivity()); // The transition framework requires to set ID for all views to be animated. layout.setId(ROOT_ID); // We only copy visible views. int first = mAbsListView.getFirstVisiblePosition(); int index = 0; while (true) { // This is one of the views that we copy. Note that the argument for getChildAt is a // zero-oriented index, and it doesn't usually match with its position in the list. View source = mAbsListView.getChildAt(index); if (null == source) { break; } // This is the copy of the original view. View destination = mAdapter.getView(first + index, null, layout); assert destination != null; destination.setId(ROOT_ID + first + index); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight()); params.leftMargin = (int) source.getX(); params.topMargin = (int) source.getY(); layout.addView(destination, params); ++index; } return layout; }
From source file:org.telegram.ui.CacheControlActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("CacheSettings", R.string.CacheSettings)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/*w w w . ja va2 s . c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ListView listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) { if (getParentActivity() == null) { return; } if (i == keepMediaRow) { BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); builder.setItems( new CharSequence[] { LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { SharedPreferences.Editor editor = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit(); editor.putInt("keep_media", which).commit(); if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } PendingIntent pintent = PendingIntent.getService( ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, ClearCacheService.class), 0); AlarmManager alarmManager = (AlarmManager) ApplicationLoader.applicationContext .getSystemService(Context.ALARM_SERVICE); if (which == 2) { alarmManager.cancel(pintent); } else { alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_DAY, AlarmManager.INTERVAL_DAY, pintent); } } }); showDialog(builder.create()); } else if (i == databaseRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setMessage( LocaleController.getString("LocalDatabaseClear", R.string.LocalDatabaseClear)); builder.setPositiveButton(LocaleController.getString("CacheClear", R.string.CacheClear), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); progressDialog .setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @Override public void run() { try { SQLiteDatabase database = MessagesStorage.getInstance() .getDatabase(); ArrayList<Long> dialogsToCleanup = new ArrayList<>(); SQLiteCursor cursor = database .queryFinalized("SELECT did FROM dialogs WHERE 1"); StringBuilder ids = new StringBuilder(); while (cursor.next()) { long did = cursor.longValue(0); int lower_id = (int) did; int high_id = (int) (did >> 32); if (lower_id != 0 && high_id != 1) { dialogsToCleanup.add(did); } } cursor.dispose(); SQLitePreparedStatement state5 = database .executeFast("REPLACE INTO messages_holes VALUES(?, ?, ?)"); SQLitePreparedStatement state6 = database.executeFast( "REPLACE INTO media_holes_v2 VALUES(?, ?, ?, ?)"); database.beginTransaction(); for (int a = 0; a < dialogsToCleanup.size(); a++) { Long did = dialogsToCleanup.get(a); int messagesCount = 0; cursor = database.queryFinalized( "SELECT COUNT(mid) FROM messages WHERE uid = " + did); if (cursor.next()) { messagesCount = cursor.intValue(0); } cursor.dispose(); if (messagesCount <= 2) { continue; } cursor = database.queryFinalized( "SELECT last_mid_i, last_mid FROM dialogs WHERE did = " + did); int messageId = -1; if (cursor.next()) { long last_mid_i = cursor.longValue(0); long last_mid = cursor.longValue(1); SQLiteCursor cursor2 = database.queryFinalized( "SELECT data FROM messages WHERE uid = " + did + " AND mid IN (" + last_mid_i + "," + last_mid + ")"); try { while (cursor2.next()) { NativeByteBuffer data = cursor2.byteBufferValue(0); if (data != null) { TLRPC.Message message = TLRPC.Message .TLdeserialize(data, data.readInt32(false), false); data.reuse(); if (message != null) { messageId = message.id; } } } } catch (Exception e) { FileLog.e("tmessages", e); } cursor2.dispose(); database.executeFast("DELETE FROM messages WHERE uid = " + did + " AND mid != " + last_mid_i + " AND mid != " + last_mid).stepThis().dispose(); database.executeFast( "DELETE FROM messages_holes WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM bot_keyboard WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM media_counts_v2 WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM media_v2 WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM media_holes_v2 WHERE uid = " + did) .stepThis().dispose(); BotQuery.clearBotKeyboard(did, null); if (messageId != -1) { MessagesStorage.createFirstHoles(did, state5, state6, messageId); } } cursor.dispose(); } state5.dispose(); state6.dispose(); database.commitTransaction(); database.executeFast("VACUUM").stepThis().dispose(); } catch (Exception e) { FileLog.e("tmessages", e); } finally { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } if (listAdapter != null) { File file = new File( ApplicationLoader.getFilesDirFixed(), "cache4.db"); databaseSize = file.length(); listAdapter.notifyDataSetChanged(); } } }); } } }); } }); showDialog(builder.create()); } else if (i == cacheRow) { if (totalSize <= 0 || getParentActivity() == null) { return; } BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); builder.setApplyTopPadding(false); builder.setApplyBottomPadding(false); LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < 6; a++) { long size = 0; String name = null; if (a == 0) { size = photoSize; name = LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache); } else if (a == 1) { size = videoSize; name = LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache); } else if (a == 2) { size = documentsSize; name = LocaleController.getString("LocalDocumentCache", R.string.LocalDocumentCache); } else if (a == 3) { size = musicSize; name = LocaleController.getString("LocalMusicCache", R.string.LocalMusicCache); } else if (a == 4) { size = audioSize; name = LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache); } else if (a == 5) { size = cacheSize; name = LocaleController.getString("LocalCache", R.string.LocalCache); } if (size > 0) { clear[a] = true; CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity()); checkBoxCell.setTag(a); checkBoxCell.setBackgroundResource(R.drawable.list_selector); linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); checkBoxCell.setText(name, AndroidUtilities.formatFileSize(size), true, true); checkBoxCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CheckBoxCell cell = (CheckBoxCell) v; int num = (Integer) cell.getTag(); clear[num] = !clear[num]; cell.setChecked(clear[num], true); } }); } else { clear[a] = false; } } BottomSheet.BottomSheetCell cell = new BottomSheet.BottomSheetCell(getParentActivity(), 1); cell.setBackgroundResource(R.drawable.list_selector); cell.setTextAndIcon( LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache).toUpperCase(), 0); cell.setTextColor(Theme.STICKERS_SHEET_REMOVE_TEXT_COLOR); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (visibleDialog != null) { visibleDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } cleanupFolders(); } }); linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); builder.setCustomView(linearLayout); showDialog(builder.create()); } } }); return fragmentView; }
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)); }//w w w .j a va 2s .c om 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:com.example.kent_zheng.sdk_adaptertransition.AdapterTransitionFragment.java
/** * Copy all the visible views in the mAbsListView into a new FrameLayout and return it. * * @return a FrameLayout with all the visible views inside. *//*from www. j a va 2s .co m*/ private FrameLayout copyVisibleViews() { // This is the FrameLayout we return afterwards. FrameLayout layout = new FrameLayout(getActivity()); // The transition framework requires to set ID for all views to be animated. layout.setId(ROOT_ID); // We only copy visible views. int first = mAbsListView.getFirstVisiblePosition(); int index = 0; while (true) { // This is one of the views that we copy. Note that the argument for getChildAt is a // zero-oriented index, and it doesn't usually match with its position in the list. View source = mAbsListView.getChildAt(index); if (null == source) { // break; } // This is the copy of the original view. View destination = mAdapter.getView(first + index, null, layout); assert destination != null; destination.setId(ROOT_ID + first + index); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight()); params.leftMargin = (int) source.getX(); params.topMargin = (int) source.getY(); layout.addView(destination, params); ++index; } return layout; }
From source file:org.telegram.ui.ChannelEditActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from www . ja v a 2 s .c om public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (donePressed) { return; } if (nameTextView.length() == 0) { Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } AndroidUtilities.shakeView(nameTextView, 2, 0); return; } donePressed = true; if (avatarUpdater.uploadingAvatar != null) { createAfterUpload = true; progressDialog = new ProgressDialog(getParentActivity()); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createAfterUpload = false; progressDialog = null; donePressed = false; try { dialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); progressDialog.show(); return; } if (!currentChat.title.equals(nameTextView.getText().toString())) { MessagesController.getInstance().changeChatTitle(chatId, nameTextView.getText().toString()); } if (info != null && !info.about.equals(descriptionTextView.getText().toString())) { MessagesController.getInstance().updateChannelAbout(chatId, descriptionTextView.getText().toString(), info); } if (signMessages != currentChat.signatures) { currentChat.signatures = true; MessagesController.getInstance().toogleChannelSignatures(chatId, signMessages); } if (uploadedAvatar != null) { MessagesController.getInstance().changeChatAvatar(chatId, uploadedAvatar); } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) { MessagesController.getInstance().changeChatAvatar(chatId, null); } finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); LinearLayout linearLayout; fragmentView = new ScrollView(context); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ScrollView scrollView = (ScrollView) fragmentView; scrollView.setFillViewport(true); linearLayout = new LinearLayout(context); scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); actionBar.setTitle(LocaleController.getString("ChannelEdit", R.string.ChannelEdit)); LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setElevation(AndroidUtilities.dp(2)); linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); FrameLayout frameLayout = new FrameLayout(context); linearLayout2.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); avatarImage = new BackupImageView(context); avatarImage.setRoundRadius(AndroidUtilities.dp(32)); avatarDrawable.setInfo(5, null, null, false); avatarDrawable.setDrawPhoto(true); frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12)); avatarImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); CharSequence[] items; if (avatar != null) { items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto) }; } else { items = new CharSequence[] { LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley) }; } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (i == 0) { avatarUpdater.openCamera(); } else if (i == 1) { avatarUpdater.openGallery(); } else if (i == 2) { avatar = null; uploadedAvatar = null; avatarImage.setImage(avatar, "50_50", avatarDrawable); } } }); showDialog(builder.create()); } }); nameTextView = new EditText(context); if (currentChat.megagroup) { nameTextView.setHint(LocaleController.getString("GroupName", R.string.GroupName)); } else { nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName)); } nameTextView.setMaxLines(4); nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); //nameTextView.setHintTextColor(0xff979797); nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8)); InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(100); nameTextView.setFilters(inputFilters); AndroidUtilities.clearCursorDrawable(nameTextView); nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 16 : 96, 0, LocaleController.isRTL ? 96 : 16, 0)); nameTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null, null, false); avatarImage.invalidate(); } }); View lineView = new View(context); lineView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_divider)); linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1)); linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); linearLayout2.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout2.setElevation(AndroidUtilities.dp(2)); linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); descriptionTextView = new EditText(context); descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); //descriptionTextView.setHintTextColor(0xff979797); descriptionTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text)); descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6)); descriptionTextView.setBackgroundDrawable(null); descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE); inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(255); descriptionTextView.setFilters(inputFilters); descriptionTextView.setHint(LocaleController.getString("DescriptionOptionalPlaceholder", R.string.DescriptionOptionalPlaceholder)); AndroidUtilities.clearCursorDrawable(descriptionTextView); linearLayout2.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 17, 12, 17, 6)); descriptionTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) { doneButton.performClick(); return true; } return false; } }); descriptionTextView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { } }); ShadowSectionCell sectionCell = new ShadowSectionCell(context); sectionCell.setSize(20); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); if (currentChat.megagroup || !currentChat.megagroup) { frameLayout = new FrameLayout(context); frameLayout.setElevation(AndroidUtilities.dp(2)); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); typeCell = new TextSettingsCell(context); updateTypeCell(); typeCell.setForeground(R.drawable.list_selector); frameLayout.addView(typeCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); lineView = new View(context); lineView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_divider)); linearLayout.addView(lineView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1)); frameLayout = new FrameLayout(context); frameLayout.setElevation(AndroidUtilities.dp(2)); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); if (!currentChat.megagroup) { TextCheckCell textCheckCell = new TextCheckCell(context); textCheckCell.setForeground(R.drawable.list_selector); textCheckCell.setTextAndCheck( LocaleController.getString("ChannelSignMessages", R.string.ChannelSignMessages), signMessages, false); frameLayout.addView(textCheckCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); textCheckCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { signMessages = !signMessages; ((TextCheckCell) v).setChecked(signMessages); } }); TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context); //infoCell.setBackgroundResource(R.drawable.greydivider); infoCell.setText( LocaleController.getString("ChannelSignMessagesInfo", R.string.ChannelSignMessagesInfo)); linearLayout.addView(infoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } else { adminCell = new TextSettingsCell(context); updateAdminCell(); adminCell.setForeground(R.drawable.list_selector); frameLayout.addView(adminCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); adminCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Bundle args = new Bundle(); args.putInt("chat_id", chatId); args.putInt("type", 1); presentFragment(new ChannelUsersActivity(args)); } }); sectionCell = new ShadowSectionCell(context); sectionCell.setSize(20); linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); /*if (!currentChat.creator) { sectionCell.setBackgroundResource(R.drawable.greydivider_bottom); }*/ } } if (currentChat.creator) { frameLayout = new FrameLayout(context); frameLayout.setElevation(AndroidUtilities.dp(2)); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); TextSettingsCell textCell = new TextSettingsCell(context); textCell.setTextColor(0xffed3d39); textCell.setBackgroundResource(R.drawable.list_selector); if (currentChat.megagroup) { textCell.setText(LocaleController.getString("DeleteMega", R.string.DeleteMega), false); } else { textCell.setText(LocaleController.getString("ChannelDelete", R.string.ChannelDelete), false); } frameLayout.addView(textCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); textCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (currentChat.megagroup) { builder.setMessage(LocaleController.getString("MegaDeleteAlert", R.string.MegaDeleteAlert)); } else { builder.setMessage( LocaleController.getString("ChannelDeleteAlert", R.string.ChannelDeleteAlert)); } builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); if (AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName( NotificationCenter.closeChats, -(long) chatId); } else { NotificationCenter.getInstance() .postNotificationName(NotificationCenter.closeChats); } MessagesController.getInstance().deleteUserFromChat(chatId, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info); finishFragment(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } }); TextInfoPrivacyCell infoCell = new TextInfoPrivacyCell(context); //infoCell.setBackgroundResource(R.drawable.greydivider_bottom); if (currentChat.megagroup) { infoCell.setText(LocaleController.getString("MegaDeleteInfo", R.string.MegaDeleteInfo)); } else { infoCell.setText(LocaleController.getString("ChannelDeleteInfo", R.string.ChannelDeleteInfo)); } linearLayout.addView(infoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); } nameTextView.setText(currentChat.title); nameTextView.setSelection(nameTextView.length()); if (info != null) { descriptionTextView.setText(info.about); } if (currentChat.photo != null) { avatar = currentChat.photo.photo_small; avatarImage.setImage(avatar, "50_50", avatarDrawable); } else { avatarImage.setImageDrawable(avatarDrawable); } return fragmentView; }
From source file:com.example.angelina.travelapp.map.MapFragment.java
@Override public void showRouteDetail(final int position) { // Remove the route header view, ///*from w w w.j a v a 2s. c om*/ //since we're replacing it with a different header removeRouteHeaderView(); // State and stage flags mCurrentPosition = position; mShowingRouteDetail = true; // Hide action bar final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (ab != null) { ab.hide(); } // Display route detail header final LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LinearLayout.LayoutParams routeDetailLayout = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); if (mRouteHeaderDetail == null) { mRouteHeaderDetail = (LinearLayout) inflater.inflate(R.layout.route_detail_header, null); TextView title = (TextView) mRouteHeaderDetail.findViewById(R.id.route_txt_detail); title.setText("Route Detail"); mRouteHeaderDetail.setBackgroundColor(Color.WHITE); mMapView.addView(mRouteHeaderDetail, routeDetailLayout); mMapView.requestLayout(); // Attach a listener to the back arrow ImageView imageBtn = (ImageView) mRouteHeaderDetail.findViewById(R.id.btnDetailHeaderClose); imageBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Navigate back to directions list mShowingRouteDetail = false; ((MapActivity) getActivity()).showDirections(mRouteDirections); } }); } // Display arrows to scroll through directions if (mSegmentNavigator == null) { mSegmentNavigator = (LinearLayout) inflater.inflate(R.layout.navigation_arrows, null); final FrameLayout navigatorLayout = (FrameLayout) getActivity() .findViewById(R.id.map_fragment_container); FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.END); frameLayoutParams.setMargins(0, 0, 0, 80); navigatorLayout.addView(mSegmentNavigator, frameLayoutParams); navigatorLayout.requestLayout(); // Add button click listeners Button btnPrev = (Button) getActivity().findViewById(R.id.btnBack); btnPrev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mCurrentPosition > 0) { populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition - 1)); mCurrentPosition = mCurrentPosition - 1; } } }); Button btnNext = (Button) getActivity().findViewById(R.id.btnNext); btnNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mCurrentPosition < mRouteDirections.size() - 1) { populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition + 1)); mCurrentPosition = mCurrentPosition + 1; } } }); } // Populate with directions DirectionManeuver maneuver = mRouteDirections.get(position); populateViewWithRouteDetail(maneuver); }
From source file:android.support.v17.leanback.app.GuidedStepFragment.java
/** * {@inheritDoc}//from w ww .ja v a2 s.c om */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we dont need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }
From source file:android.support.v17.leanback.app.GuidedStepSupportFragment.java
/** * {@inheritDoc}/*from ww w . j ava2 s .c o m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepSupportFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepSupportFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we dont need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }
From source file:com.rbware.github.androidcouchpotato.app.GuidedStepFragment.java
/** * {@inheritDoc}/*from w ww . j av a 2 s.c om*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we don't need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }