List of usage examples for android.widget RelativeLayout BELOW
int BELOW
To view the source code for android.widget RelativeLayout BELOW.
Click Source Link
From source file:com.trk.aboutme.facebook.widget.PickerFragment.java
private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); }/* w ww . j a v a 2s. c o m*/ doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this); } } }); if (getDoneButtonText() != null) { doneButton.setText(getDoneButtonText()); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (getTitleText() != null) { titleTextView.setText(getTitleText()); } } } }
From source file:com.eutectoid.dosomething.picker.PickerFragment.java
private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); }//from w w w . j av a2 s . co m doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { logAppEvents(true); appEventsLogged = true; if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this); } } }); if (getDoneButtonText() != null) { doneButton.setText(getDoneButtonText()); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (getTitleText() != null) { titleTextView.setText(getTitleText()); } } } }
From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); dialog = new ProgressDialog(this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentViewLayout = new RelativeLayout(ResourcePlayer.this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); token = prefsPrivate.getString("token", ""); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); Bundle extra = getIntent().getExtras(); if (extra != null) { value = extra.getInt("key"); gooruOID1 = extra.getStringArrayList("goor"); searchkeyword = extra.getString("searchkey"); limit = gooruOID1.size();//from w w w. ja v a 2 s .c om gooruOID = gooruOID1.get(value); resourceGooruId = gooruOID; if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) { if (checkInternetConnection()) { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("Please wait while loading..."); dialog.setCancelable(false); dialog.show(); new getResourcesInfo().execute(); } else { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("No internet connection"); dialog.show(); } } } Editor prefsPrivateEditor = prefsPrivate.edit(); // Authentication details prefsPrivateEditor.putString("searchkeyword", searchkeyword); prefsPrivateEditor.commit(); wvPlayer = new WebView(ResourcePlayer.this); wvPlayer.resumeTimers(); wvPlayer.getSettings().setJavaScriptEnabled(true); wvPlayer.getSettings().setPluginState(PluginState.ON); wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); wvPlayer.setWebViewClient(new HelloWebViewClient()); wvPlayer.setWebChromeClient(new MyWebChromeClient() { }); wvPlayer.getSettings().setPluginsEnabled(true); new getResourcesInfo().execute(); RelativeLayout temp = new RelativeLayout(ResourcePlayer.this); temp.setId(668); temp.setBackgroundColor(getResources().getColor(android.R.color.transparent)); header = new RelativeLayout(ResourcePlayer.this); header.setId(1); header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, 53); headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1); ivCloseIcon = new ImageView(ResourcePlayer.this); ivCloseIcon.setId(130); ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50); ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); ivCloseIcon.setPadding(0, 0, 0, 0); ivCloseIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner)); header.addView(ivCloseIcon, ivCloseIconIconParams); ivmoveforward = new ImageView(ResourcePlayer.this); ivmoveforward.setId(222); if (value == limit - 1) { ivmoveforward.setVisibility(View.GONE); } ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0); imageshare = new ImageView(ResourcePlayer.this); imageshare.setId(440); imageshare.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50); imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); imageshareIconParams.setMargins(0, 10, 100, 0); tvDescriptionn = new TextView(ResourcePlayer.this); tvDescriptionn1 = new TextView(ResourcePlayer.this); edittext_copyurl = new EditText(ResourcePlayer.this); imageshare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (desc == 0) { new getShortUrl().execute(); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected)); subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); tvDescriptionn.setVisibility(View.VISIBLE); tvDescriptionn1.setVisibility(View.VISIBLE); edittext_copyurl.setVisibility(View.VISIBLE); tvDescriptionn.setText("Share this with other by copying and pasting these links"); tvDescriptionn.setId(221); tvDescriptionn.setTextSize(18); tvDescriptionn.setTypeface(null, Typeface.BOLD); tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); subheader.addView(tvDescriptionn, tvDescriptionParams); tvDescriptionn1.setText("Collections"); tvDescriptionn1.setId(226); tvDescriptionn1.setTextSize(18); tvDescriptionn1.setTypeface(null, Typeface.BOLD); tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams1.setMargins(20, 42, 0, 20); subheader.addView(tvDescriptionn1, tvDescriptionParams1); edittext_copyurl.setId(266); edittext_copyurl.setTextSize(18); edittext_copyurl.setTypeface(null, Typeface.BOLD); edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams11.setMargins(130, 35, 0, 20); subheader.addView(edittext_copyurl, tvDescriptionParams11); desc = 1; flag = 0; } else { imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); subheader.removeAllViews(); subheader.setVisibility(View.GONE); desc = 0; } } }); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); ivmoveforward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (value < limit - 1) { Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); // extras.putString("gooruOId",s); extras.putStringArrayList("goor", gooruOID1); value++; extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright)); ivmoveback = new ImageView(ResourcePlayer.this); ivmoveback.setId(220); if (value == 0) { ivmoveback.setVisibility(View.GONE); } ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmovebackIconIconParams.setMargins(55, 0, 0, 0); ivmoveback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!(value <= 0)) { value--; Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); extras.putStringArrayList("goor", gooruOID1); extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left)); webViewBack = new ImageView(ResourcePlayer.this); webViewBack.setId(323); webViewBack.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26); webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewBackIconParams.setMargins(175, 0, 0, 0); webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive)); webViewBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoBack()) { wvPlayer.goBack(); } } }); webViewRefresh = new ImageView(ResourcePlayer.this); webViewRefresh.setId(322); webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30); webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewRefreshIconParams.setMargins(305, 0, 0, 0); webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh)); webViewRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wvPlayer.reload(); } }); webViewForward = new ImageView(ResourcePlayer.this); webViewForward.setId(321); webViewForward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26); webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParams.setMargins(245, 0, 0, 0); webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive)); webViewForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoForward()) { wvPlayer.goForward(); } } }); ivResourceIcon = new ImageView(ResourcePlayer.this); ivResourceIcon.setId(30); ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25); ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130); ivResourceIcon.setPadding(50, 0, 0, 0); ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts)); header.addView(ivResourceIcon, ivResourceIconParams); tvLearn = new TextView(this); tvLearn.setText("Learn More"); tvLearn.setId(20); tvLearn.setPadding(100, 0, 0, 0); tvLearn.setTextSize(20); tvLearn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); tvAbout = new ImageView(ResourcePlayer.this); tvAbout.setId(21); tvAbout.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32); webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParamsa.setMargins(0, 0, 200, 0); tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info)); header.addView(tvAbout, webViewForwardIconParamsa); RelativeLayout fortvtitle = new RelativeLayout(this); RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322); tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21); header.addView(fortvtitle, tvTitleParams); tvTitle = new TextView(this); tvTitle.setText(""); tvTitle.setId(22); tvTitle.setPadding(0, 0, 0, 0); tvTitle.setTextSize(25); tvTitle.setSingleLine(true); tvTitle.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1); fortvtitle.addView(tvTitle, tvTitleParamstv); tvViewsNLikes = new TextView(this); tvViewsNLikes.setText(""); tvViewsNLikes.setId(23); tvViewsNLikes.setPadding(0, 0, 5, 5); tvViewsNLikes.setTextSize(18); tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); subheader = new RelativeLayout(ResourcePlayer.this); subheader.setId(100); subheader.setVisibility(View.GONE); subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, 100); subheaderParams.addRule(RelativeLayout.BELOW, 1); subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); wvPlayerParams.addRule(RelativeLayout.BELOW, 100); wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100); LinearLayout videoLayout = new LinearLayout(this); videoLayout.setVisibility(View.GONE); header.addView(webViewBack, webViewBackIconParams); header.addView(webViewRefresh, webViewRefreshIconParams); header.addView(webViewForward, webViewForwardIconParams); header.addView(ivmoveforward, ivmoveforwardIconIconParams); header.addView(imageshare, imageshareIconParams); header.addView(ivmoveback, ivmovebackIconIconParams); temp.addView(header, headerParams); temp.addView(subheader, subheaderParams); temp.addView(wvPlayer, wvPlayerParams); temp.addView(videoLayout, wvPlayerParams); setContentViewLayout.addView(temp, layoutParams); setContentView(setContentViewLayout); tvDescription = new TextView(ResourcePlayer.this); tvDescription1 = new TextView(ResourcePlayer.this); tvAbout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (flag == 0) { subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); // tvDescriptionn.setVisibility(View.INVISIBLE); tvDescription1.setVisibility(View.VISIBLE); tvDescription.setVisibility(View.VISIBLE); tvDescription.setText("Description"); tvDescription.setId(221); tvDescription.setTextSize(18); tvDescription.setTypeface(null, Typeface.BOLD); tvDescription.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); tvDescriptionParams.addRule(RelativeLayout.BELOW, 220); tvDescription1.setText(description); tvDescription1.setLines(3); tvDescription1.setId(321); tvDescription1.setTextSize(15); tvDescription1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100); tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1); tvDescription1.setPadding(100, 20, 100, 0); subheader.addView(tvDescription1, tvDescription1Params); desc = 0; flag = 1; flag1 = 0; } else { subheader.removeAllViews(); subheader.setVisibility(View.GONE); flag = 0; } } }); }
From source file:com.wwtv.player.mediaplayer.LocalPlayerActivity.java
private void updateMetadata(boolean visible) { Point displaySize;// ww w .j a v a 2 s. c om if (!visible) { mDescriptionView.setVisibility(View.GONE); mTitleView.setVisibility(View.GONE); mAuthorView.setVisibility(View.GONE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, displaySize.y + getSupportActionBar().getHeight()); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } else { MediaMetadata mm = mSelectedMedia.getMetadata(); // mDescriptionView.setText(mSelectedMedia.getCustomData().optString(VideoProvider.KEY_DESCRIPTION)); mTitleView.setText(mm.getString(MediaMetadata.KEY_TITLE)); // mAuthorView.setText(mm.getString(MediaMetadata.KEY_SUBTITLE)); mDescriptionView.setVisibility(View.VISIBLE); mTitleView.setVisibility(View.VISIBLE); mAuthorView.setVisibility(View.VISIBLE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, (int) (displaySize.x * mAspectRatio)); lp.addRule(RelativeLayout.BELOW, R.id.toolbar); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } }
From source file:com.google.sample.cast.refplayer.mediaplayer.LocalPlayerActivity.java
private void updateMetadata(boolean visible) { Point displaySize;//w w w . j a v a 2s. com if (!visible) { mDescriptionView.setVisibility(View.GONE); mTitleView.setVisibility(View.GONE); mAuthorView.setVisibility(View.GONE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, displaySize.y + getSupportActionBar().getHeight()); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } else { MediaMetadata mm = mSelectedMedia.getMetadata(); mDescriptionView.setText(mSelectedMedia.getCustomData().optString(VideoProvider.KEY_DESCRIPTION)); mTitleView.setText(mm.getString(MediaMetadata.KEY_TITLE)); mAuthorView.setText(mm.getString(MediaMetadata.KEY_SUBTITLE)); mDescriptionView.setVisibility(View.VISIBLE); mTitleView.setVisibility(View.VISIBLE); mAuthorView.setVisibility(View.VISIBLE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, (int) (displaySize.x * mAspectRatio)); lp.addRule(RelativeLayout.BELOW, R.id.toolbar); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
/** * Aligns the Twitter icon the parent bottom right. Aligns the G+ icon to the left of the * Twitter icon if it is present. Otherwise, aligns the G+ icon to the parent bottom right. *///ww w .j a v a 2 s .c o m private void determineSocialIconPlacement(ImageView plusOneIcon, ImageView twitterIcon) { if (plusOneIcon.getVisibility() == View.VISIBLE) { // Set the dimensions of the G+ button. int socialIconDimension = getResources().getDimensionPixelSize(R.dimen.social_icon_box_size); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(socialIconDimension, socialIconDimension); params.addRule(RelativeLayout.BELOW, R.id.speaker_abstract); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); if (twitterIcon.getVisibility() == View.VISIBLE) { params.addRule(RelativeLayout.LEFT_OF, R.id.twitter_icon_box); } else { params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } plusOneIcon.setLayoutParams(params); } }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Attaches the alarmIcon to all Finds in ListView that currently have an * associated Reminder, which is indicated by the Find's * is_adhoc field being set to REMINDER_SET or REMINDER_NOTIFIED. * //from w ww.j a v a 2s .co m * @param context -- the context from which this method is called * @param find -- the current Find * @param view -- the calling activity's contentView, which is needed * to access the UI's sub-views. * */ public void listFindCallback(Context context, Find find, View view) { Log.i(TAG, "listFindCallback"); if (find.getIs_adhoc() == REMINDER_SET || find.getIs_adhoc() == this.REMINDER_NOTIFIED) { ImageView alarmIcon = new ImageView(context); alarmIcon.setImageResource(R.drawable.reminder_alarm); RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.list_row_rl); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(25, 25); lp.addRule(RelativeLayout.BELOW, R.id.status); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); lp.setMargins(0, 6, 0, 0); rl.addView(alarmIcon, lp); alarmIcon.setVisibility(ImageView.VISIBLE); } }
From source file:busradar.madison.StopDialog.java
@Override public void show() { new Thread() { @Override/* w w w . j a va2 s .c o m*/ public void run() { for (final RouteURL r : routes) { G.activity.runOnUiThread(new Runnable() { public void run() { cur_loading_text .setText(String.format("Loading route %s...", G.route_points[r.route].name)); } }); final ArrayList<RouteTime> curtimes = new ArrayList<RouteTime>(); try { System.err.printf("BusRadar URL %s\n", TRANSITTRACKER_URL + r.url); URL url = new URL(TRANSITTRACKER_URL + r.url); URLConnection url_conn = url.openConnection(); if (url_conn instanceof HttpsURLConnection) { ((HttpsURLConnection) url_conn).setHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); } InputStream is = url_conn.getInputStream(); Scanner scan = new Scanner(is, "UTF-8"); //String outstr_cur = "Route " + r.route + "\n"; if (scan.findWithinHorizon(num_vehicles_re, 0) != null) { while (scan.findWithinHorizon(time_re, 0) != null) { RouteTime time = new RouteTime(); time.route = r.route; time.time = scan.match().group(1).replace(".", ""); time.dir = scan.match().group(2); //time.date = DateFormat.getTimeInstance(DateFormat.SHORT).parse(time.time); SimpleDateFormat f = new SimpleDateFormat("h:mm aa", Locale.US); time.date = f.parse(time.time); r.status = RouteURL.DONE; //outstr_cur += String.format("%s to %s\n", time.time, time.dir); curtimes.add(time); } while (scan.findWithinHorizon(time_re_backup, 0) != null) { RouteTime time = new RouteTime(); time.route = r.route; time.time = scan.match().group(1).replace(".", ""); //time.dir = scan.match().group(2); //time.date = DateFormat.getTimeInstance(DateFormat.SHORT).parse(time.time); SimpleDateFormat f = new SimpleDateFormat("h:mm aa", Locale.US); time.date = f.parse(time.time); r.status = RouteURL.DONE; //outstr_cur += String.format("%s to %s\n", time.time, time.dir); curtimes.add(time); } } // else if (scan.findWithinHorizon(no_busses_re, 0) != null) { // r.status = RouteURL.NO_MORE_TODAY; // } // else if (scan.findWithinHorizon(no_timepoints_re, 0) != null) { // r.status = RouteURL.NO_TIMEPOINTS; // } // else { // r.status = RouteURL.ERROR; // System.out.printf("BusRadar: Could not get stop info for %s\n", r.url); // // throw new Exception("Error parsing TransitTracker webpage."); // } else { r.status = RouteURL.NO_STOPS_UNKONWN; } //r.text = outstr_cur; G.activity.runOnUiThread(new Runnable() { public void run() { times.addAll(curtimes); StopDialog.this.update_times(); } }); } // catch (final IOException ioe) { // log_problem(ioe); // G.activity.runOnUiThread(new Runnable() { // public void run() { // final Context ctx = StopDialog.this.getContext(); // // StopDialog.this.setContentView(new RelativeLayout(ctx) {{ // addView(new TextView(ctx) {{ // setText(Html.fromHtml("Error downloading data. Is the data connection enabled?"+ // "<p>Report problems to <a href='mailto:support@busradarapp.com'>support@busradarapp.com</a><p>"+ioe)); // setPadding(5, 5, 5, 5); // this.setMovementMethod(LinkMovementMethod.getInstance()); // }}, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); // }}); // } // }); // return; // } catch (Exception e) { log_problem(e); String custom_msg = ""; final String turl = TRANSITTRACKER_URL + r.url; if ((e instanceof SocketException) || (e instanceof UnknownHostException)) { // data connection doesn't work custom_msg = "Error downloading data. Is the data connection enabled?" + "<p>Report problems to <a href='mailto:support@busradarapp.com'>support@busradarapp.com</a><p>" + TextUtils.htmlEncode(e.toString()); } else { String rurl = String.format( "http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf", stopid); custom_msg = "Trouble retrieving real-time arrival estimates from <a href='" + turl + "'>this</a> TransitTracker webpage, which is displayed below. " + "Meanwhile, try PDF timetable <a href='" + rurl + "'>here</a>. " + "Contact us at <a href='mailto:support@busradarapp.com'>support@busradarapp.com</a> to report the problem.<p>" + TextUtils.htmlEncode(e.toString()); } final String msg = custom_msg; G.activity.runOnUiThread(new Runnable() { public void run() { final Context ctx = StopDialog.this.getContext(); StopDialog.this.setContentView(new RelativeLayout(ctx) { { addView(new TextView(ctx) { { setId(1); setText(Html.fromHtml(msg)); setPadding(5, 5, 5, 5); this.setMovementMethod(LinkMovementMethod.getInstance()); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); addView(new WebView(ctx) { { setWebViewClient(new WebViewClient()); loadUrl(turl); } }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) { { addRule(RelativeLayout.BELOW, 1); } }); } }); } }); return; } } G.activity.runOnUiThread(new Runnable() { public void run() { cur_loading_text.setText(""); } }); } }.start(); super.show(); }
From source file:kr.wdream.ui.DialogsActivity.java
public void initView() { RelativeLayout relativeLayout = new RelativeLayout(context); fragmentView = relativeLayout;/*from w w w . j a va 2s . c o m*/ LinearLayout lytTab = new LinearLayout(context); lytTab.setId(kr.wdream.storyshop.R.id.lytTab); tabParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1); tabParams.setMargins(0, 0, 0, 5); tab1 = new LinearLayout(context); tab1.setGravity(Gravity.CENTER); imgTab1 = new ImageView(context); imgTab1.setImageResource(R.drawable.m_i_main_flist_n); tab1.addView(imgTab1, LayoutHelper.createLinear(21, 20)); tab1.setOnClickListener(this); tab2 = new LinearLayout(context); tab2.setGravity(Gravity.CENTER); imgTab2 = new ImageView(context); imgTab2.setImageResource(R.drawable.m_i_main_clist_n); tab2.addView(imgTab2, LayoutHelper.createLinear(21, 20)); tab2.setOnClickListener(this); tab3 = new LinearLayout(context); tab3.setGravity(Gravity.CENTER); imgTab3 = new ImageView(context); imgTab3.setImageResource(R.drawable.m_i_main_content_n); tab3.addView(imgTab3, LayoutHelper.createLinear(21, 20)); tab3.setOnClickListener(this); tab4 = new LinearLayout(context); tab4.setGravity(Gravity.CENTER); imgTab4 = new ImageView(context); imgTab4.setImageResource(R.drawable.m_i_main_setting_n); tab4.addView(imgTab4, LayoutHelper.createLinear(21, 20)); tab4.setOnClickListener(this); lytDialogs = new RelativeLayout(context); RelativeLayout.LayoutParams lytDialogsParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); lytDialogsParams.addRule(RelativeLayout.BELOW, lytTab.getId()); lytDialogs.setLayoutParams(lytDialogsParams); lytDialogs.setVisibility(View.GONE); listView = new RecyclerListView(context); listView.setVerticalScrollBarEnabled(true); listView.setItemAnimator(null); listView.setInstantClick(true); listView.setLayoutAnimation(null); listView.setTag(4); listView.setVisibility(View.GONE); layoutManager = new LinearLayoutManager(context) { @Override public boolean supportsPredictiveItemAnimations() { return false; } }; layoutManager.setOrientation(LinearLayoutManager.VERTICAL); listView.setLayoutManager(layoutManager); listView.setVerticalScrollbarPosition( LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT); listView.setVerticalScrollBarEnabled(false); listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); listView.setVerticalScrollbarPosition( LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT); listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (listView == null || listView.getAdapter() == null) { return; } long dialog_id = 0; int message_id = 0; RecyclerView.Adapter adapter = listView.getAdapter(); if (adapter == dialogsAdapter) { TLRPC.TL_dialog dialog = dialogsAdapter.getItem(position); if (dialog == null) { return; } dialog_id = dialog.id; } else if (adapter == dialogsSearchAdapter) { Object obj = dialogsSearchAdapter.getItem(position); if (obj instanceof TLRPC.User) { dialog_id = ((TLRPC.User) obj).id; if (dialogsSearchAdapter.isGlobalSearch(position)) { ArrayList<TLRPC.User> users = new ArrayList<>(); users.add((TLRPC.User) obj); MessagesController.getInstance().putUsers(users, false); MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); } if (!onlySelect) { dialogsSearchAdapter.putRecentSearch(dialog_id, (TLRPC.User) obj); } } else if (obj instanceof TLRPC.Chat) { if (dialogsSearchAdapter.isGlobalSearch(position)) { ArrayList<TLRPC.Chat> chats = new ArrayList<>(); chats.add((TLRPC.Chat) obj); MessagesController.getInstance().putChats(chats, false); MessagesStorage.getInstance().putUsersAndChats(null, chats, false, true); } if (((TLRPC.Chat) obj).id > 0) { dialog_id = -((TLRPC.Chat) obj).id; } else { dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id); } if (!onlySelect) { dialogsSearchAdapter.putRecentSearch(dialog_id, (TLRPC.Chat) obj); } } else if (obj instanceof TLRPC.EncryptedChat) { dialog_id = ((long) ((TLRPC.EncryptedChat) obj).id) << 32; if (!onlySelect) { dialogsSearchAdapter.putRecentSearch(dialog_id, (TLRPC.EncryptedChat) obj); } } else if (obj instanceof MessageObject) { MessageObject messageObject = (MessageObject) obj; dialog_id = messageObject.getDialogId(); message_id = messageObject.getId(); dialogsSearchAdapter.addHashtagsFromMessage(dialogsSearchAdapter.getLastSearchString()); } else if (obj instanceof String) { Log.d(LOG_TAG, "obj String : openSearchField"); actionBar.openSearchField((String) obj); } } if (dialog_id == 0) { return; } if (onlySelect) { didSelectResult(dialog_id, true, false); } else { Bundle args = new Bundle(); int lower_part = (int) dialog_id; int high_id = (int) (dialog_id >> 32); if (lower_part != 0) { if (high_id == 1) { args.putInt("chat_id", lower_part); } else { if (lower_part > 0) { args.putInt("user_id", lower_part); } else if (lower_part < 0) { if (message_id != 0) { TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_part); if (chat != null && chat.migrated_to != null) { args.putInt("migrated_to", lower_part); lower_part = -chat.migrated_to.channel_id; } } args.putInt("chat_id", -lower_part); } } } else { args.putInt("enc_id", high_id); } if (message_id != 0) { args.putInt("message_id", message_id); } else { if (actionBar != null) { actionBar.closeSearchField(); } } if (AndroidUtilities.isTablet()) { if (openedDialogId == dialog_id && adapter != dialogsSearchAdapter) { return; } if (dialogsAdapter != null) { dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id); updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } } if (searchString != null) { if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); presentFragment(new ChatActivity(args)); } } else { if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) { presentFragment(new ChatActivity(args)); } } } } }); listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() { @Override public boolean onItemClick(View view, int position) { if (onlySelect || searching && searchWas || getParentActivity() == null) { if (searchWas && searching || dialogsSearchAdapter.isRecentSearchDisplayed()) { RecyclerView.Adapter adapter = listView.getAdapter(); if (adapter == dialogsSearchAdapter) { Object item = dialogsSearchAdapter.getItem(position); if (item instanceof String || dialogsSearchAdapter.isRecentSearchDisplayed()) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); builder.setMessage(LocaleController.getString("ClearSearch", kr.wdream.storyshop.R.string.ClearSearch)); builder.setPositiveButton(LocaleController .getString("ClearButton", kr.wdream.storyshop.R.string.ClearButton) .toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (dialogsSearchAdapter.isRecentSearchDisplayed()) { dialogsSearchAdapter.clearRecentSearch(); } else { dialogsSearchAdapter.clearRecentHashtags(); } } }); builder.setNegativeButton( LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); showDialog(builder.create()); return true; } } } return false; } TLRPC.TL_dialog dialog; ArrayList<TLRPC.TL_dialog> dialogs = getDialogsArray(); if (position < 0 || position >= dialogs.size()) { return false; } dialog = dialogs.get(position); selectedDialog = dialog.id; BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); int lower_id = (int) selectedDialog; int high_id = (int) (selectedDialog >> 32); if (DialogObject.isChannel(dialog)) { final TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_id); CharSequence items[]; if (chat != null && chat.megagroup) { items = new CharSequence[] { LocaleController.getString("ClearHistoryCache", kr.wdream.storyshop.R.string.ClearHistoryCache), chat == null || !chat.creator ? LocaleController.getString("LeaveMegaMenu", kr.wdream.storyshop.R.string.LeaveMegaMenu) : LocaleController.getString("DeleteMegaMenu", kr.wdream.storyshop.R.string.DeleteMegaMenu) }; } else { items = new CharSequence[] { LocaleController.getString("ClearHistoryCache", kr.wdream.storyshop.R.string.ClearHistoryCache), chat == null || !chat.creator ? LocaleController.getString("LeaveChannelMenu", kr.wdream.storyshop.R.string.LeaveChannelMenu) : LocaleController.getString("ChannelDeleteMenu", kr.wdream.storyshop.R.string.ChannelDeleteMenu) }; } builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle( LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); if (which == 0) { if (chat != null && chat.megagroup) { builder.setMessage(LocaleController.getString("AreYouSureClearHistorySuper", kr.wdream.storyshop.R.string.AreYouSureClearHistorySuper)); } else { builder.setMessage(LocaleController.getString("AreYouSureClearHistoryChannel", kr.wdream.storyshop.R.string.AreYouSureClearHistoryChannel)); } builder.setPositiveButton( LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { MessagesController.getInstance().deleteDialog(selectedDialog, 2); } }); } else { if (chat != null && chat.megagroup) { if (!chat.creator) { builder.setMessage(LocaleController.getString("MegaLeaveAlert", kr.wdream.storyshop.R.string.MegaLeaveAlert)); } else { builder.setMessage(LocaleController.getString("MegaDeleteAlert", kr.wdream.storyshop.R.string.MegaDeleteAlert)); } } else { if (chat == null || !chat.creator) { builder.setMessage(LocaleController.getString("ChannelLeaveAlert", kr.wdream.storyshop.R.string.ChannelLeaveAlert)); } else { builder.setMessage(LocaleController.getString("ChannelDeleteAlert", kr.wdream.storyshop.R.string.ChannelDeleteAlert)); } } builder.setPositiveButton( LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { MessagesController.getInstance().deleteUserFromChat( (int) -selectedDialog, UserConfig.getCurrentUser(), null); if (AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName( NotificationCenter.closeChats, selectedDialog); } } }); } builder.setNegativeButton( LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); showDialog(builder.create()); } }); showDialog(builder.create()); } else { final boolean isChat = lower_id < 0 && high_id != 1; TLRPC.User user = null; if (!isChat && lower_id > 0 && high_id != 1) { user = MessagesController.getInstance().getUser(lower_id); } final boolean isBot = user != null && user.bot; builder.setItems( new CharSequence[] { LocaleController.getString("ClearHistory", kr.wdream.storyshop.R.string.ClearHistory), isChat ? LocaleController.getString("DeleteChat", kr.wdream.storyshop.R.string.DeleteChat) : isBot ? LocaleController.getString("DeleteAndStop", kr.wdream.storyshop.R.string.DeleteAndStop) : LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); if (which == 0) { builder.setMessage(LocaleController.getString("AreYouSureClearHistory", kr.wdream.storyshop.R.string.AreYouSureClearHistory)); } else { if (isChat) { builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", kr.wdream.storyshop.R.string.AreYouSureDeleteAndExit)); } else { builder.setMessage( LocaleController.getString("AreYouSureDeleteThisChat", kr.wdream.storyshop.R.string.AreYouSureDeleteThisChat)); } } builder.setPositiveButton( LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (which != 0) { if (isChat) { TLRPC.Chat currentChat = MessagesController .getInstance().getChat((int) -selectedDialog); if (currentChat != null && ChatObject.isNotInChat(currentChat)) { MessagesController.getInstance() .deleteDialog(selectedDialog, 0); } else { MessagesController.getInstance().deleteUserFromChat( (int) -selectedDialog, MessagesController.getInstance().getUser( UserConfig.getClientUserId()), null); } } else { MessagesController.getInstance() .deleteDialog(selectedDialog, 0); } if (isBot) { MessagesController.getInstance() .blockUser((int) selectedDialog); } if (AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName( NotificationCenter.closeChats, selectedDialog); } } else { MessagesController.getInstance() .deleteDialog(selectedDialog, 1); } } }); builder.setNegativeButton(LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); showDialog(builder.create()); } }); showDialog(builder.create()); } return true; } }); listContacts = new LetterSectionsListView(context); RelativeLayout.LayoutParams contactParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); contactParams.addRule(RelativeLayout.BELOW, lytTab.getId()); listContacts.setLayoutParams(contactParams); Log.d(LOG_TAG, "contactsAdapter : " + LaunchActivity.contactsAdapter.getItem(0)); listContacts.setAdapter(LaunchActivity.contactsAdapter); handler.postDelayed(new Runnable() { @Override public void run() { Log.d(LOG_TAG, "postDelayed Start"); handler.sendEmptyMessage(0); } }, 1500); listContacts.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int section = LaunchActivity.contactsAdapter.getSectionForPosition(position); int row = LaunchActivity.contactsAdapter.getPositionInSectionForPosition(position); Object item = LaunchActivity.contactsAdapter.getItem(section, row); if (0 == position) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText()); getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController .getString("InviteFriends", kr.wdream.storyshop.R.string.InviteFriends)), 500); } else if (item instanceof ContactsController.Contact) { ContactsController.Contact contact = (ContactsController.Contact) item; String usePhone = null; if (!contact.phones.isEmpty()) { usePhone = contact.phones.get(0); } if (usePhone == null || getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage( LocaleController.getString("InviteUser", kr.wdream.storyshop.R.string.InviteUser)); builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); final String arg1 = usePhone; builder.setPositiveButton(LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", arg1, null)); intent.putExtra("sms_body", LocaleController.getString("InviteText", kr.wdream.storyshop.R.string.InviteText)); getParentActivity().startActivityForResult(intent, 500); } catch (Exception e) { FileLog.e("tmessages", e); } } }); builder.setNegativeButton( LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); showDialog(builder.create()); } else { TLRPC.User user = (TLRPC.User) LaunchActivity.contactsAdapter.getItem(position); if (user == null) return; Bundle args = new Bundle(); args.putInt("user_id", user.id); if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) { presentFragment(new ChatActivity(args), false); } } } }); contentLayout = new LinearLayout(context); contentLayout.setOrientation(LinearLayout.VERTICAL); contentLayout.setVisibility(View.GONE); RelativeLayout.LayoutParams contentParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); contentParams.addRule(RelativeLayout.BELOW, lytTab.getId()); // Contents Layout ? GridView gridContents = new GridView(context); gridContents.setNumColumns(GridView.AUTO_FIT); gridContents.setGravity(Gravity.CENTER); ContentsAdapter contentsAdapter = new ContentsAdapter(context); gridContents.setAdapter(contentsAdapter); contentLayout.addView(gridContents, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); gridContents.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: Log.d("??", "grid0"); Intent intent = new Intent(context, ShoppingMainActivity.class); context.startActivity(intent); break; case 1: Log.d("??", "grid1"); break; case 2: Log.d("??", "grid2"); break; case 3: Log.d("??", "grid3"); break; } } }); // Setting Layout ? settingLayout = new LinearLayout(context); settingLayout.setOrientation(LinearLayout.VERTICAL); settingLayout.setVisibility(View.GONE); settingLayout.setBackgroundColor(Color.parseColor("#EEEEEE")); createSettingLayout(); // TabBar lytTab.addView(tab1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1)); lytTab.addView(tab2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1)); lytTab.addView(tab3, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1)); lytTab.addView(tab4, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1)); relativeLayout.addView(lytTab, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50)); RelativeLayout.LayoutParams listParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); lytDialogs.addView(listView, listParams); relativeLayout.addView(lytDialogs, lytDialogsParams); relativeLayout.addView(listContacts, contactParams); relativeLayout.addView(contentLayout, contentParams); relativeLayout.addView(settingLayout, contentParams); searchEmptyView = new EmptyTextProgressView(context); searchEmptyView.setVisibility(View.GONE); searchEmptyView.setShowAtCenter(true); searchEmptyView.setText(LocaleController.getString("NoResult", kr.wdream.storyshop.R.string.NoResult)); relativeLayout.addView(searchEmptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); emptyView = new LinearLayout(context); emptyView.setOrientation(LinearLayout.VERTICAL); emptyView.setVisibility(View.GONE); emptyView.setGravity(Gravity.CENTER); // relativeLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); emptyView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoChats", kr.wdream.storyshop.R.string.NoChats)); textView.setTextColor(0xff959595); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); emptyView.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); textView = new TextView(context); String help = LocaleController.getString("NoChatsHelp", kr.wdream.storyshop.R.string.NoChatsHelp); if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) { help = help.replace('\n', ' '); } textView.setText(help); textView.setTextColor(0xff959595); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setGravity(Gravity.CENTER); textView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(6), AndroidUtilities.dp(8), 0); textView.setLineSpacing(AndroidUtilities.dp(2), 1); emptyView.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); progressView = new ProgressBar(context); progressView.setVisibility(View.GONE); RelativeLayout.LayoutParams progParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); progParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); progressView.setLayoutParams(progParams); // relativeLayout.addView(progressView); // relativeLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); floatingButton = new ImageView(context); floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE); floatingButton.setScaleType(ImageView.ScaleType.CENTER); floatingButton.setBackgroundResource(kr.wdream.storyshop.R.drawable.floating_states); floatingButton.setImageResource(kr.wdream.storyshop.R.drawable.floating_pencil); Log.d(LOG_TAG, "setVisibility.VISIBLE_floating : " + floatingButton.getVisibility()); floatingButton.setVisibility(View.GONE); Log.d(LOG_TAG, "setVisibility.GONE_floating : " + floatingButton.getVisibility()); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); floatingButton.setStateListAnimator(animator); floatingButton.setOutlineProvider(new ViewOutlineProvider() { @SuppressLint("NewApi") @Override public void getOutline(View view, Outline outline) { outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56)); } }); } RelativeLayout.LayoutParams floatingParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); floatingParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); floatingParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // relativeLayout.addView(floatingButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14)); relativeLayout.addView(floatingButton, floatingParams); floatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Bundle args = new Bundle(); args.putBoolean("destroyAfterSelect", true); presentFragment(new ContactsActivity(args)); } }); listView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) { AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int firstVisibleItem = layoutManager.findFirstVisibleItemPosition(); int visibleItemCount = Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1; int totalItemCount = recyclerView.getAdapter().getItemCount(); if (searching && searchWas) { if (visibleItemCount > 0 && layoutManager.findLastVisibleItemPosition() == totalItemCount - 1 && !dialogsSearchAdapter.isMessagesSearchEndReached()) { dialogsSearchAdapter.loadMoreSearchMessages(); } return; } if (visibleItemCount > 0) { if (layoutManager.findLastVisibleItemPosition() >= getDialogsArray().size() - 10) { MessagesController.getInstance().loadDialogs(-1, 100, !MessagesController.getInstance().dialogsEndReached); } } if (floatingButton.getVisibility() != View.GONE) { final View topChild = recyclerView.getChildAt(0); int firstViewTop = 0; if (topChild != null) { firstViewTop = topChild.getTop(); } boolean goingDown; boolean changed = true; if (prevPosition == firstVisibleItem) { final int topDelta = prevTop - firstViewTop; goingDown = firstViewTop < prevTop; changed = Math.abs(topDelta) > 1; } else { goingDown = firstVisibleItem > prevPosition; } if (changed && scrollUpdated) { hideFloatingButton(goingDown); } prevPosition = firstVisibleItem; prevTop = firstViewTop; scrollUpdated = true; } } }); if (searchString == null) { dialogsAdapter = new DialogsAdapter(context, dialogsType); Log.d("Dialog", "dialogsSize : " + dialogsAdapter.getItemCount()); if (AndroidUtilities.isTablet() && openedDialogId != 0) { dialogsAdapter.setOpenedDialogId(openedDialogId); } listView.setAdapter(dialogsAdapter); } int type = 0; if (searchString != null) { type = 2; } else if (!onlySelect) { type = 1; } dialogsSearchAdapter = new DialogsSearchAdapter(context, type, dialogsType); dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() { @Override public void searchStateChanged(boolean search) { if (searching && searchWas && searchEmptyView != null) { if (search) { searchEmptyView.showProgress(); } else { searchEmptyView.showTextView(); } } } @Override public void didPressedOnSubDialog(int did) { if (onlySelect) { didSelectResult(did, true, false); } else { Bundle args = new Bundle(); if (did > 0) { args.putInt("user_id", did); } else { args.putInt("chat_id", -did); } if (actionBar != null) { actionBar.closeSearchField(); } if (AndroidUtilities.isTablet()) { if (dialogsAdapter != null) { dialogsAdapter.setOpenedDialogId(openedDialogId = did); updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } } if (searchString != null) { if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); presentFragment(new ChatActivity(args)); } } else { if (MessagesController.checkCanOpenChat(args, DialogsActivity.this)) { presentFragment(new ChatActivity(args)); } } } } @Override public void needRemoveHint(final int did) { if (getParentActivity() == null) { return; } TLRPC.User user = MessagesController.getInstance().getUser(did); if (user == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", kr.wdream.storyshop.R.string.AppName)); builder.setMessage(LocaleController.formatString("ChatHintsDelete", kr.wdream.storyshop.R.string.ChatHintsDelete, ContactsController.formatName(user.first_name, user.last_name))); builder.setPositiveButton(LocaleController.getString("OK", kr.wdream.storyshop.R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { SearchQuery.removePeer(did); } }); builder.setNegativeButton(LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel), null); showDialog(builder.create()); } }); if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) { searchEmptyView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); listView.setEmptyView(progressView); } else { searchEmptyView.setVisibility(View.GONE); progressView.setVisibility(View.GONE); listView.setEmptyView(emptyView); } if (searchString != null) { actionBar.openSearchField(searchString); } if (!onlySelect && dialogsType == 0) { relativeLayout.addView(new PlayerView(context, this), LayoutHelper .createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); } tab1.performClick(); }
From source file:com.hectorosorio.hosocast.mediaplayer.LocalPlayerActivity.java
private void updateMetadata(boolean visible) { Point displaySize;//from w w w .j av a 2s .co m if (!visible) { mDescriptionView.setVisibility(View.GONE); mTitleView.setVisibility(View.GONE); mAuthorView.setVisibility(View.GONE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, displaySize.y + getSupportActionBar().getHeight()); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } else { MediaMetadata mm = mSelectedMedia.getMetadata(); mDescriptionView.setText(mSelectedMedia.getCustomData().optString("description")); //VideoProvider.KEY_DESCRIPTION mTitleView.setText(mm.getString(MediaMetadata.KEY_TITLE)); mAuthorView.setText(mm.getString(MediaMetadata.KEY_SUBTITLE)); mDescriptionView.setVisibility(View.VISIBLE); mTitleView.setVisibility(View.VISIBLE); mAuthorView.setVisibility(View.VISIBLE); displaySize = Utils.getDisplaySize(this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(displaySize.x, (int) (displaySize.x * mAspectRatio)); lp.addRule(RelativeLayout.BELOW, R.id.toolbar); //lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); mVideoView.setLayoutParams(lp); mVideoView.invalidate(); } }