List of usage examples for android.widget FrameLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java
private void addTab(final int position, View tab, View tab2) { tab.setPadding(tabPadding, 0, tabPadding, 0); tab2.setPadding(tabPadding, 0, tabPadding, 0); FrameLayout framelayout = new FrameLayout(context); framelayout.addView(tab, 0, matchparentTabLayoutParams); framelayout.addView(tab2, 1, matchparentTabLayoutParams); tabsContainer.addView(framelayout, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); framelayout.setOnClickListener(new OnClickListener() { @Override//from w w w . j av a2 s.c o m public void onClick(View v) { //? pager.setCurrentItem(position, true); currentPosition = position; scrollToChild(position, 0);//HorizontalScrollView invalidate();//? } }); Map<String, View> map = new HashMap<>(); ViewHelper.setAlpha(tab, 1); map.put("normal", tab); ViewHelper.setAlpha(tab2, 0); map.put("selected", tab2); tabViews.add(position, map); }
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final SRThemeAttributes attr = new SRThemeAttributes(context); mPost = post;/* ww w .ja v a 2s . c o m*/ isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, SRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:com.boko.vimusic.ui.activities.AudioPlayerActivity.java
/** * Initializes the items in the now playing screen *//*from w w w . j a va 2s .c o m*/ @SuppressWarnings("deprecation") private void initPlaybackControls() { // ViewPager container mPageContainer = (FrameLayout) findViewById(R.id.audio_player_pager_container); // Theme the pager container background mPageContainer.setBackgroundDrawable(mResources.getDrawable("audio_player_pager_container")); // Now playing header mAudioPlayerHeader = (LinearLayout) findViewById(R.id.audio_player_header); // Opens the currently playing album profile mAudioPlayerHeader.setOnClickListener(mOpenAlbumProfile); // Used to hide the artwork and show the queue final FrameLayout mSwitch = (FrameLayout) findViewById(R.id.audio_player_switch); mSwitch.setOnClickListener(mToggleHiddenPanel); // Initialize the pager adapter mPagerAdapter = new PagerAdapter(this); // Queue mPagerAdapter.add(QueueFragment.class, null); // Initialize the ViewPager mViewPager = (ViewPager) findViewById(R.id.audio_player_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Play and pause button mPlayPauseButton = (PlayPauseButton) findViewById(R.id.action_button_play); // Shuffle button mShuffleButton = (ShuffleButton) findViewById(R.id.action_button_shuffle); // Repeat button mRepeatButton = (RepeatButton) findViewById(R.id.action_button_repeat); // Previous button mPreviousButton = (RepeatingImageButton) findViewById(R.id.action_button_previous); // Next button mNextButton = (RepeatingImageButton) findViewById(R.id.action_button_next); // Track name mTrackName = (TextView) findViewById(R.id.audio_player_track_name); // Artist name mArtistName = (TextView) findViewById(R.id.audio_player_artist_name); // Album art mAlbumArt = (ImageView) findViewById(R.id.audio_player_album_art); // Small album art mAlbumArtSmall = (ImageView) findViewById(R.id.audio_player_switch_album_art); // Current time mCurrentTime = (TextView) findViewById(R.id.audio_player_current_time); // Total time mTotalTime = (TextView) findViewById(R.id.audio_player_total_time); // Used to show and hide the queue fragment mQueueSwitch = (ImageView) findViewById(R.id.audio_player_switch_queue); // Theme the queue switch icon mQueueSwitch.setImageDrawable(mResources.getDrawable("btn_switch_queue")); // Progress mProgress = (SeekBar) findViewById(android.R.id.progress); // Set the repeat listner for the previous button mPreviousButton.setRepeatListener(mRewindListener); // Set the repeat listner for the next button mNextButton.setRepeatListener(mFastForwardListener); // Update the progress mProgress.setOnSeekBarChangeListener(this); }
From source file:com.giovanniterlingen.windesheim.view.Adapters.NatschoolContentAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, final int position) { final TextView contentName = holder.contentName; final ImageView icon = holder.icon; final FrameLayout menuButton = holder.menuButton; final ImageView menuButtonImage = holder.menuButtonImage; contentName.setText(content.get(position).name); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override//from w w w . ja v a 2 s .c o m public void onClick(View v) { onContentClick(content.get(holder.getAdapterPosition()), holder.getAdapterPosition()); } }); if (content.get(position).type == -1) { icon.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(), getDrawableByName(content.get(position).name), null)); menuButton.setVisibility(View.VISIBLE); menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { menuButtonImage.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_open, null)); PopupMenu popupMenu = new PopupMenu(activity, menuButton); popupMenu.inflate(R.menu.menu_file); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.delete_file) { showPromptDialog(holder.getAdapterPosition()); return true; } return true; } }); popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { menuButtonImage.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_normal, null)); } }); popupMenu.show(); } }); } else if (content.get(position).url == null || (content.get(position).url.length() == 0)) { if (content.get(position).imageUrl != null) { icon.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_work, null)); } else { icon.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_folder, null)); } } else { if (content.get(position).type == 1 || content.get(position).type == 3 || content.get(position).type == 11) { icon.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_link, null)); } else if (content.get(position).type == 10) { icon.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(), getDrawableByName(content.get(position).url), null)); final TextView progressTextView = holder.progressTextView; final ProgressBar progressBar = holder.progressBar; final FrameLayout cancelButton = holder.cancelButton; if (content.get(position).downloading) { contentName.setVisibility(View.GONE); progressTextView.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE); if (content.get(position).progress == -1 && content.get(position).progressString == null) { progressTextView.setText(activity.getResources().getString(R.string.downloading)); progressBar.setIndeterminate(true); } else { progressTextView.setText(content.get(position).progressString); progressBar.setIndeterminate(false); progressBar.setMax(100); progressBar.setProgress(content.get(position).progress); } cancelButton.setVisibility(View.VISIBLE); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NotificationCenter.getInstance().postNotificationName( NotificationCenter.downloadCancelled, content.get(holder.getAdapterPosition()).id); contentName.setVisibility(View.VISIBLE); progressTextView.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); cancelButton.setVisibility(View.GONE); } }); } else { contentName.setVisibility(View.VISIBLE); progressTextView.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); cancelButton.setVisibility(View.GONE); } } } }
From source file:com.spollo.player.ui.activities.AudioPlayerActivity.java
/** * Initializes the items in the now playing screen */// www.jav a 2 s .co m @SuppressWarnings("deprecation") private void initPlaybackControls() { // ViewPager container mPageContainer = (FrameLayout) findViewById(R.id.audio_player_pager_container); // Theme the pager container background mPageContainer.setBackgroundDrawable(mResources.getDrawable("audio_player_pager_container")); // Now playing header mAudioPlayerHeader = (LinearLayout) findViewById(R.id.audio_player_header); // Opens the currently playing album profile mAudioPlayerHeader.setOnClickListener(mOpenAlbumProfile); // Used to hide the artwork and show the queue final FrameLayout mSwitch = (FrameLayout) findViewById(R.id.audio_player_switch); mSwitch.setOnClickListener(mToggleHiddenPanel); // Initialize the pager adapter mPagerAdapter = new PagerAdapter(this); // Queue mPagerAdapter.add(QueueFragment.class, null); // Lyrics mPagerAdapter.add(LyricsFragment.class, null); // Initialize the ViewPager mViewPager = (ViewPager) findViewById(R.id.audio_player_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Play and pause button mPlayPauseButton = (PlayPauseButton) findViewById(R.id.action_button_play); // Shuffle button mShuffleButton = (ShuffleButton) findViewById(R.id.action_button_shuffle); // Repeat button mRepeatButton = (RepeatButton) findViewById(R.id.action_button_repeat); // Previous button mPreviousButton = (RepeatingImageButton) findViewById(R.id.action_button_previous); // Next button mNextButton = (RepeatingImageButton) findViewById(R.id.action_button_next); // Track name mTrackName = (TextView) findViewById(R.id.audio_player_track_name); // Artist name mArtistName = (TextView) findViewById(R.id.audio_player_artist_name); // Album art mAlbumArt = (ImageView) findViewById(R.id.audio_player_album_art); // Small album art mAlbumArtSmall = (ImageView) findViewById(R.id.audio_player_switch_album_art); // Current time mCurrentTime = (TextView) findViewById(R.id.audio_player_current_time); // Total time mTotalTime = (TextView) findViewById(R.id.audio_player_total_time); // Used to show and hide the queue fragment mQueueSwitch = (ImageView) findViewById(R.id.audio_player_switch_queue); // Theme the queue switch icon mQueueSwitch.setImageDrawable(mResources.getDrawable("btn_switch_queue")); // Progress mProgress = (SeekBar) findViewById(android.R.id.progress); // Set the repeat listner for the previous button mPreviousButton.setRepeatListener(mRewindListener); // Set the repeat listner for the next button mNextButton.setRepeatListener(mFastForwardListener); // Update the progress mProgress.setOnSeekBarChangeListener(this); }
From source file:com.bt.download.android.gui.activities.AudioPlayerActivity.java
/** * Initializes the items in the now playing screen *//*from w w w . j a v a 2s .c o m*/ private void initPlaybackControls() { // ViewPager container mPageContainer = (FrameLayout) findViewById(R.id.audio_player_pager_container); // Theme the pager container background mPageContainer.setBackgroundResource(R.drawable.audio_player_pager_container); // Now playing header mAudioPlayerHeader = (LinearLayout) findViewById(R.id.audio_player_header); // Opens the currently playing album profile mAudioPlayerHeader.setOnClickListener(mOpenAlbumProfile); // Used to hide the artwork and show the queue final FrameLayout mSwitch = (FrameLayout) findViewById(R.id.audio_player_switch); mSwitch.setOnClickListener(mToggleHiddenPanel); // Initialize the pager adapter mPagerAdapter = new PagerAdapter(this); // Queue mPagerAdapter.add(QueueFragment.class, null); // Initialize the ViewPager mViewPager = (ViewPager) findViewById(R.id.audio_player_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Play and pause button mPlayPauseButton = (PlayPauseButton) findViewById(R.id.action_button_play); // Shuffle button mShuffleButton = (ShuffleButton) findViewById(R.id.action_button_shuffle); // Repeat button mRepeatButton = (RepeatButton) findViewById(R.id.action_button_repeat); // Previous button mPreviousButton = (RepeatingImageButton) findViewById(R.id.action_button_previous); // Next button mNextButton = (RepeatingImageButton) findViewById(R.id.action_button_next); // Track name mTrackName = (TextView) findViewById(R.id.audio_player_track_name); // Artist name mArtistName = (TextView) findViewById(R.id.audio_player_artist_name); // Album art mAlbumArt = (ImageView) findViewById(R.id.audio_player_album_art); // Small album art mAlbumArtSmall = (ImageView) findViewById(R.id.audio_player_switch_album_art); // Current time mCurrentTime = (TextView) findViewById(R.id.audio_player_current_time); // Total time mTotalTime = (TextView) findViewById(R.id.audio_player_total_time); // Used to show and hide the queue fragment mQueueSwitch = (ImageView) findViewById(R.id.audio_player_switch_queue); // Progress mProgress = (SeekBar) findViewById(R.id.activity_audio_player_progress); // Set the repeat listner for the previous button mPreviousButton.setRepeatListener(mRewindListener); // Set the repeat listner for the next button mNextButton.setRepeatListener(mFastForwardListener); // Update the progress mProgress.setOnSeekBarChangeListener(this); }
From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final RRThemeAttributes attr = new RRThemeAttributes(context); mPost = post;//from w w w.j a va 2 s . c o m isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.rrMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && RRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, RRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:com.farmerbb.taskbar.service.TaskbarService.java
private View getView(List<AppEntry> list, int position) { View convertView = View.inflate(this, R.layout.icon, null); final AppEntry entry = list.get(position); final SharedPreferences pref = U.getSharedPreferences(this); ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); ImageView imageView2 = (ImageView) convertView.findViewById(R.id.shortcut_icon); imageView.setImageDrawable(entry.getIcon(this)); imageView2.setBackgroundColor(/*ww w .ja v a 2 s. c o m*/ pref.getInt("accent_color", getResources().getInteger(R.integer.translucent_white))); String taskbarPosition = U.getTaskbarPosition(this); if (pref.getBoolean("shortcut_icon", true)) { boolean shouldShowShortcutIcon; if (taskbarPosition.contains("vertical")) shouldShowShortcutIcon = position >= list.size() - numOfPinnedApps; else shouldShowShortcutIcon = position < numOfPinnedApps; if (shouldShowShortcutIcon) imageView2.setVisibility(View.VISIBLE); } if (taskbarPosition.equals("bottom_right") || taskbarPosition.equals("top_right")) { imageView.setRotationY(180); imageView2.setRotationY(180); } FrameLayout layout = (FrameLayout) convertView.findViewById(R.id.entry); layout.setOnClickListener(view -> U.launchApp(TaskbarService.this, entry.getPackageName(), entry.getComponentName(), entry.getUserId(TaskbarService.this), null, true, false)); layout.setOnLongClickListener(view -> { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); return true; }); layout.setOnGenericMotionListener((view, motionEvent) -> { int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_BUTTON_PRESS && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) { int[] location = new int[2]; view.getLocationOnScreen(location); openContextMenu(entry, location); } if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true)) view.setBackgroundColor(0); return false; }); if (pref.getBoolean("visual_feedback", true)) { layout.setOnHoverListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) { int accentColor = U.getAccentColor(TaskbarService.this); accentColor = ColorUtils.setAlphaComponent(accentColor, Color.alpha(accentColor) / 2); v.setBackgroundColor(accentColor); } if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) v.setBackgroundColor(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) v.setPointerIcon(PointerIcon.getSystemIcon(TaskbarService.this, PointerIcon.TYPE_DEFAULT)); return false; }); layout.setOnTouchListener((v, event) -> { v.setAlpha( event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE ? 0.5f : 1); return false; }); } return convertView; }
From source file:com.ksharkapps.musicnow.ui.activities.AudioPlayerActivity.java
/** * Initializes the items in the now playing screen */// w w w. j a v a 2 s.c o m @SuppressWarnings("deprecation") private void initPlaybackControls() { // ViewPager container mPageContainer = (FrameLayout) findViewById(R.id.audio_player_pager_container); // Theme the pager container background mPageContainer.setBackgroundResource(R.drawable.audio_player_pager_container); // Now playing header mAudioPlayerHeader = (LinearLayout) findViewById(R.id.audio_player_header); // Opens the currently playing album profile mAudioPlayerHeader.setOnClickListener(mOpenAlbumProfile); mControlsLayout = (RelativeLayout) findViewById(R.id.controls_layout); // Used to hide the artwork and show the queue final FrameLayout mSwitch = (FrameLayout) findViewById(R.id.audio_player_switch); mSwitch.setOnClickListener(mToggleHiddenPanel); // Initialize the pager adapter mPagerAdapter = new PagerAdapter(this); // Queue mPagerAdapter.add(QueueFragment.class, null); // Initialize the ViewPager mViewPager = (ViewPager) findViewById(R.id.audio_player_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Play and pause button mPlayPauseButton = (PlayPauseButton) findViewById(R.id.action_button_play); // Shuffle button mShuffleButton = (ShuffleButton) findViewById(R.id.action_button_shuffle); // Repeat button mRepeatButton = (RepeatButton) findViewById(R.id.action_button_repeat); // Previous button mPreviousButton = (RepeatingImageButton) findViewById(R.id.action_button_previous); // Next button mNextButton = (RepeatingImageButton) findViewById(R.id.action_button_next); // Track name mTrackName = (TextView) findViewById(R.id.audio_player_track_name); // Artist name mArtistName = (TextView) findViewById(R.id.audio_player_artist_name); // Album art mAlbumArt = (ImageView) findViewById(R.id.audio_player_album_art); // Small album art mAlbumArtSmall = (ImageView) findViewById(R.id.audio_player_switch_album_art); // Current time mCurrentTime = (TextView) findViewById(R.id.audio_player_current_time); // Seek time mSeekTime = (TextView) findViewById(R.id.seek_time); // Total time mTotalTime = (TextView) findViewById(R.id.audio_player_total_time); // Used to show and hide the queue fragment mQueueSwitch = (ImageView) findViewById(R.id.audio_player_switch_queue); // Theme the queue switch icon mQueueSwitch.setImageResource(R.drawable.btn_switch_queue); // Progress mProgress = (SeekBar) findViewById(android.R.id.progress); // Set the repeat listner for the previous button mPreviousButton.setRepeatListener(mRewindListener); // Set the repeat listner for the next button mNextButton.setRepeatListener(mFastForwardListener); // Update the progress mProgress.setOnSeekBarChangeListener(this); }
From source file:com.b44t.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);//from w w w . j a v a2 s .c o m setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.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) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: appendCharacter("0"); break; case 1: appendCharacter("1"); break; case 2: appendCharacter("2"); break; case 3: appendCharacter("3"); break; case 4: appendCharacter("4"); break; case 5: appendCharacter("5"); break; case 6: appendCharacter("6"); break; case 7: appendCharacter("7"); break; case 8: appendCharacter("8"); break; case 9: appendCharacter("9"); break; case 10: String text = passwordEditText.getText().toString(); if (text.length() > 0) { passwordEditText.setText(text.substring(0, text.length() - 1)); } break; } if (passwordEditText.getText().toString().length() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }