List of usage examples for android.widget RelativeLayout setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.mobicage.rogerthat.GroupDetailActivity.java
private void updateGroupForEdit() { T.UI();//w w w.j ava2s. c o m final Button saveBtn = (Button) findViewById(R.id.save_group); final ImageView editBtn = (ImageView) findViewById(R.id.edit_group); final RelativeLayout updateGroupName = ((RelativeLayout) findViewById(R.id.update_group_name)); final LinearLayout updateGroupAvatar = ((LinearLayout) findViewById(R.id.update_group_avatar)); final ImageView newGroupAvatar = ((ImageView) findViewById(R.id.update_group_avatar_img)); final Button updateAvatarBtn = (Button) findViewById(R.id.update_avatar); final Button cancelBtn = (Button) findViewById(R.id.cancel); final ImageView friendAvatar = (ImageView) findViewById(R.id.friend_avatar); final TextView friendName = (TextView) findViewById(R.id.friend_name); if (mEditing) { updateGroupName.setVisibility(View.VISIBLE); updateGroupAvatar.setVisibility(View.VISIBLE); updateGroupName.setBackgroundResource(android.R.drawable.edit_text); cancelBtn.setVisibility(View.VISIBLE); saveBtn.setVisibility(View.VISIBLE); editBtn.setVisibility(View.GONE); friendAvatar.setVisibility(View.GONE); friendName.setVisibility(View.GONE); updateGroupName.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mUpdateGroupName.requestFocus()) { int pos = mUpdateGroupName.getText().length(); mUpdateGroupName.setSelection(pos); UIUtils.showKeyboard(getApplicationContext()); } } }); OnClickListener newAvatarListener = new View.OnClickListener() { @Override public void onClick(View v) { getNewAvatar(true); UIUtils.hideKeyboard(getApplicationContext(), mUpdateGroupName); } }; updateAvatarBtn.setOnClickListener(newAvatarListener); newGroupAvatar.setOnClickListener(newAvatarListener); } else { updateGroupName.setVisibility(View.GONE); updateGroupAvatar.setVisibility(View.GONE); updateGroupName.setBackgroundResource(0); cancelBtn.setVisibility(View.GONE); saveBtn.setVisibility(View.GONE); editBtn.setVisibility(View.VISIBLE); friendAvatar.setVisibility(View.VISIBLE); friendName.setVisibility(View.VISIBLE); final byte[] byteArray; if (mPhotoSelected) { Bitmap bm = BitmapFactory.decodeFile(mUriSavedImage.getPath(), null); bm = ImageHelper.rotateBitmap(bm, mPhoneExifRotation); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, stream); byteArray = stream.toByteArray(); File image; try { image = getTmpUploadPhotoLocation(); } catch (IOException e) { L.d(e.getMessage()); UIUtils.showLongToast(getApplicationContext(), e.getMessage()); return; } image.delete(); mPhotoSelected = false; mGroup.avatar = byteArray; } mGroup.name = mUpdateGroupName.getText().toString(); mFriendsPlugin.getStore().updateGroup(mGroup.guid, mGroup.name, mGroup.avatar, null); mFriendsPlugin.putGroup(mGroup); mBackupMembers = new ArrayList<String>(mGroup.members); Intent intent = new Intent(mIsNewGroup ? FriendsPlugin.GROUP_ADDED : FriendsPlugin.GROUP_MODIFIED); intent.putExtra("guid", mGroup.guid); mService.sendBroadcast(intent); } }
From source file:com.VVTeam.ManHood.Fragment.HistogramFragment.java
private void initViews(View view) { parentLayout = (RelativeLayout) view.findViewById(R.id.fragment_histogram_parent_relative_layout); /*BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2;//w w w.j a v a 2 s . co m parentLayout.setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.histogram_bg, options)));*/ settingsRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_settings_relative_layout); markRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_mark_relative_layout); worldRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_world_relative); // worldRelative.setSelected(true); worldRelative.setBackgroundResource(R.drawable.cell_p); areaRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_area_relative); hoodRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_hood_relative); yourResultButton = (Button) view.findViewById(R.id.fragment_histogram_your_result_button); contentRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_content_relative); RelativeLayout shareRelative = (RelativeLayout) view .findViewById(R.id.fragment_histogram_share_button_relative); shareRelative.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub GoogleTracker.StarSendEvent(getActivity(), "ui_action", "user_action", "histogram_share"); Bitmap image = makeSnapshot(); File pictureFile = getOutputMediaFile(); try { FileOutputStream fos = new FileOutputStream(pictureFile); image.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close(); } catch (Exception e) { } // String pathofBmp = Images.Media.insertImage(getActivity().getContentResolver(), makeSnapshot(), "Man Hood App", null); // Uri bmpUri = Uri.parse(pathofBmp); Uri bmpUri = Uri.fromFile(pictureFile); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); emailIntent.setType("image/png"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Man Hood App"); getActivity().startActivity(emailIntent); } }); polarPlot = (PolarPlot) view.findViewById(R.id.polarPlot); thicknessHisto = (Histogram) view.findViewById(R.id.thicknessHisto); thicknessHisto.setOrientation(ORIENT.LEFT); thicknessHisto.setBackgroundColor(Color.TRANSPARENT); lengthHisto = (Histogram) view.findViewById(R.id.lengthHistogram); lengthHisto.setOrientation(ORIENT.RIGHT); lengthHisto.setBackgroundColor(Color.TRANSPARENT); girthHisto = (Histogram) view.findViewById(R.id.girthHistogram); girthHisto.setOrientation(ORIENT.BOTTOM); girthHisto.setBackgroundColor(Color.TRANSPARENT); lengthHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestLength(value)); setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID)); setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID)); // setSelection(false, lengthHisto, 0.0f); setSelection(true, lengthHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); girthHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestGirth(value)); setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID)); setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID)); // setSelection(false, girthHisto, 0.0f); setSelection(true, girthHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); thicknessHisto.setCallBackListener(new HistogramCallBack() { @Override public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState, float value, HistogramBin bin) { // TODO Auto-generated method stub if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) { histogramSelected = true; setNearestUserID(usersData.userIDWithNearestThickness(value)); setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID)); setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID)); // setSelection(false, thicknessHisto, 0.0f); setSelection(true, thicknessHisto, value); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) { histogramSelected = false; setNearestUserID(null); setSelectionForAverage(); setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData); } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) { } } }); textBoxTitleLabel = (TextView) view.findViewById(R.id.txtBoxTitle); textBoxTitleLabel.setText("AVERAGE"); layoutSubTitle = (LinearLayout) view.findViewById(R.id.layoutSubTitle); layoutSubTitle.setVisibility(View.INVISIBLE); textBoxSubtitleLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleLabel); textBoxSubtitleValueLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleValue); lengthSelectedLabel = (TextView) view.findViewById(R.id.txtlengthselected); lengthSelectedLabel.setText("50%"); lengthTOPLabel = (TextView) view.findViewById(R.id.lengthTOPLabel); girthSelectedLabel = (TextView) view.findViewById(R.id.txtgirthselected); girthSelectedLabel.setText("50%"); girthTOPLabel = (TextView) view.findViewById(R.id.girthTOPLabel); thicknessSelectedLabel = (TextView) view.findViewById(R.id.txtthicknessselected); thicknessSelectedLabel.setText("50%"); thinkestAtTOPLabel = (TextView) view.findViewById(R.id.thinkestAtTOPLabel); curvedSelectedLabel = (TextView) view.findViewById(R.id.txtcurvedselected); curvedSelectedLabel.setText("0"); girthTopLB = (TextView) view.findViewById(R.id.girthTop); girthMiddleLB = (TextView) view.findViewById(R.id.girthMiddle); girthBottomLB = (TextView) view.findViewById(R.id.girthBottom); thicknessTopLB = (TextView) view.findViewById(R.id.thicknessTop); thicknessMiddleLB = (TextView) view.findViewById(R.id.thicknessMiddle); thicknessBottomLB = (TextView) view.findViewById(R.id.thicknessBottom); lengthTopLB = (TextView) view.findViewById(R.id.lengthTop); lengthMiddleLB = (TextView) view.findViewById(R.id.lengthMiddle); lengthBottomLB = (TextView) view.findViewById(R.id.lengthBottom); settingsRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).openSettingsActivity(); } }); markRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()).openCertificateActivity(); } }); worldRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRangeAll); updateRangeSwitch(); } }); areaRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRange200); updateRangeSwitch(); } }); hoodRelative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setSelectedRange(SliceRange.SliceRange20); updateRangeSwitch(); } }); yourResultButton.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { youTouchDown(); } else if (event.getAction() == MotionEvent.ACTION_UP) { youTouchUp(); // final Handler handler = new Handler(); // handler.postDelayed(new Runnable() { // @Override // public void run() { // youTouchUp(); // } // }, 2000); } return true; } }); RequestManager.getInstance().checkUser(); /* in-app billing */ String base64EncodedPublicKey = LICENSE_KEY; // Create the helper, passing it our context and the public key to verify signatures with Log.d(TAG, "Creating IAB helper."); mHelper = new IabHelper(getActivity(), base64EncodedPublicKey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(true); // Start setup. This is asynchronous and the specified listener // will be called once setup completes. Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. Log.d(TAG, "Problem setting up in-app billing: " + result); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; // IAB is fully set up. Now, let's get an inventory of stuff we own. Log.d(TAG, "Setup successful. Querying inventory."); mHelper.queryInventoryAsync(mGotInventoryListener); } }); }
From source file:fr.gotorennes.AbstractMapActivity.java
protected void populateItineraireDetails(Itineraire itineraire) { LinearLayout details = (LinearLayout) findViewById(R.id.details); for (final Etape etape : itineraire.etapes) { addEtapeOverlay(etape);//w w w.j a v a 2 s .co m RelativeLayout view = (RelativeLayout) getLayoutInflater().inflate(R.layout.itineraire_listitem, null); ImageView lineIcon = (ImageView) view.findViewById(R.id.icon); if (etape.bitmapIcon != null) { lineIcon.setImageBitmap(etape.bitmapIcon); } else { lineIcon.setImageResource(etape.type.icon); } TextView name = (TextView) view.findViewById(R.id.name); name.setText(Html.fromHtml(Arret.getTime(etape.depart) + " : " + etape.adresseDepart + "<br />" + Arret.getTime(etape.arrivee) + " : " + etape.adresseArrivee)); TextView duree = (TextView) view.findViewById(R.id.duree); duree.setText(etape.getDuree() + "min"); TextView distance = (TextView) view.findViewById(R.id.distance); distance.setText(getFormattedDistance(etape.locationDepart, etape.locationArrivee)); distance.setVisibility( etape.type == TypeEtape.PIETON || etape.type == TypeEtape.VELO ? View.VISIBLE : View.GONE); view.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Location depart = etape.locationDepart; centerMap(depart.latitude, depart.longitude); } }); details.addView(view); } Location first = itineraire.etapes.get(0).locationDepart; centerMap(first.latitude, first.longitude); }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
protected void updateMessageDetail(final boolean isUpdate) { T.UI();/*from ww w . ja va2s . c om*/ // Set sender avatar ImageView avatarImage = (ImageView) findViewById(R.id.avatar); String sender = mCurrentMessage.sender; setAvatar(avatarImage, sender); // Set sender name TextView senderView = (TextView) findViewById(R.id.sender); final String senderName = mFriendsPlugin.getName(sender); senderView.setText(senderName == null ? sender : senderName); // Set timestamp TextView timestampView = (TextView) findViewById(R.id.timestamp); timestampView.setText(TimeUtils.getDayTimeStr(this, mCurrentMessage.timestamp * 1000)); // Set clickable region on top to go to friends detail final RelativeLayout messageHeader = (RelativeLayout) findViewById(R.id.message_header); messageHeader.setOnClickListener(getFriendDetailOnClickListener(mCurrentMessage.sender)); messageHeader.setVisibility(View.VISIBLE); // Set message TextView messageView = (TextView) findViewById(R.id.message); WebView web = (WebView) findViewById(R.id.webview); FrameLayout flay = (FrameLayout) findViewById(R.id.message_details); Resources resources = getResources(); flay.setBackgroundColor(resources.getColor(R.color.mc_background)); boolean showBranded = false; int darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark); int lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light); senderView.setTextColor(lightSchemeTextColor); timestampView.setTextColor(lightSchemeTextColor); BrandingResult br = null; if (!TextUtils.isEmptyOrWhitespace(mCurrentMessage.branding)) { boolean brandingAvailable = false; try { brandingAvailable = mMessagingPlugin.getBrandingMgr().isBrandingAvailable(mCurrentMessage.branding); } catch (BrandingFailureException e1) { L.d(e1); } try { if (brandingAvailable) { br = mMessagingPlugin.getBrandingMgr().prepareBranding(mCurrentMessage); WebSettings settings = web.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); web.loadUrl("file://" + br.file.getAbsolutePath()); web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (br.color != null) { flay.setBackgroundColor(br.color); } if (!br.showHeader) { messageHeader.setVisibility(View.GONE); MarginLayoutParams mlp = (MarginLayoutParams) web.getLayoutParams(); mlp.setMargins(0, 0, 0, mlp.bottomMargin); } else if (br.scheme == ColorScheme.dark) { senderView.setTextColor(darkSchemeTextColor); timestampView.setTextColor(darkSchemeTextColor); } showBranded = true; } else { mMessagingPlugin.getBrandingMgr().queueGenericBranding(mCurrentMessage.branding); } } catch (BrandingFailureException e) { L.bug("Could not display message with branding: branding is available, but prepareBranding failed", e); } } if (showBranded) { web.setVisibility(View.VISIBLE); messageView.setVisibility(View.GONE); } else { web.setVisibility(View.GONE); messageView.setVisibility(View.VISIBLE); messageView.setText(mCurrentMessage.message); } // Add list of members who did not ack yet FlowLayout memberSummary = (FlowLayout) findViewById(R.id.member_summary); memberSummary.removeAllViews(); SortedSet<MemberStatusTO> memberSummarySet = new TreeSet<MemberStatusTO>(getMemberstatusComparator()); for (MemberStatusTO ms : mCurrentMessage.members) { if ((ms.status & MessagingPlugin.STATUS_ACKED) != MessagingPlugin.STATUS_ACKED && !ms.member.equals(mCurrentMessage.sender)) { memberSummarySet.add(ms); } } FlowLayout.LayoutParams flowLP = new FlowLayout.LayoutParams(2, 0); for (MemberStatusTO ms : memberSummarySet) { FrameLayout fl = new FrameLayout(this); fl.setLayoutParams(flowLP); memberSummary.addView(fl); fl.addView(createParticipantView(ms)); } memberSummary.setVisibility(memberSummarySet.size() < 2 ? View.GONE : View.VISIBLE); // Add members statuses final LinearLayout members = (LinearLayout) findViewById(R.id.members); members.removeAllViews(); final String myEmail = mService.getIdentityStore().getIdentity().getEmail(); boolean isMember = false; mSomebodyAnswered = false; for (MemberStatusTO ms : mCurrentMessage.members) { boolean showMember = true; View view = getLayoutInflater().inflate(R.layout.message_member_detail, null); // Set receiver avatar RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.avatar); rl.addView(createParticipantView(ms)); // Set receiver name TextView receiverView = (TextView) view.findViewById(R.id.receiver); final String memberName = mFriendsPlugin.getName(ms.member); receiverView.setText(memberName == null ? sender : memberName); // Set received timestamp TextView receivedView = (TextView) view.findViewById(R.id.received_timestamp); if ((ms.status & MessagingPlugin.STATUS_RECEIVED) == MessagingPlugin.STATUS_RECEIVED) { final String humanTime = TimeUtils.getDayTimeStr(this, ms.received_timestamp * 1000); if (ms.member.equals(mCurrentMessage.sender)) receivedView.setText(getString(R.string.sent_at, humanTime)); else receivedView.setText(getString(R.string.received_at, humanTime)); } else { receivedView.setText(R.string.not_yet_received); } // Set replied timestamp TextView repliedView = (TextView) view.findViewById(R.id.acked_timestamp); if ((ms.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED) { mSomebodyAnswered = true; String acked_timestamp = TimeUtils.getDayTimeStr(this, ms.acked_timestamp * 1000); if (ms.button_id != null) { ButtonTO button = null; for (ButtonTO b : mCurrentMessage.buttons) { if (b.id.equals(ms.button_id)) { button = b; break; } } if (button == null) { repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); } else { repliedView.setText(getString(R.string.replied_at, button.caption, acked_timestamp)); } } else { if (ms.custom_reply == null) { // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); } else repliedView.setText(getString(R.string.replied_at, ms.custom_reply, acked_timestamp)); } } else { repliedView.setText(R.string.not_yet_replied); showMember = !ms.member.equals(mCurrentMessage.sender); } if (br != null && br.scheme == ColorScheme.dark) { receiverView.setTextColor(darkSchemeTextColor); receivedView.setTextColor(darkSchemeTextColor); repliedView.setTextColor(darkSchemeTextColor); } else { receiverView.setTextColor(lightSchemeTextColor); receivedView.setTextColor(lightSchemeTextColor); repliedView.setTextColor(lightSchemeTextColor); } if (showMember) members.addView(view); isMember |= ms.member.equals(myEmail); } boolean isLocked = (mCurrentMessage.flags & MessagingPlugin.FLAG_LOCKED) == MessagingPlugin.FLAG_LOCKED; boolean canEdit = isMember && !isLocked; // Add attachments LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachment_layout); attachmentLayout.removeAllViews(); if (mCurrentMessage.attachments.length > 0) { attachmentLayout.setVisibility(View.VISIBLE); for (final AttachmentTO attachment : mCurrentMessage.attachments) { View v = getLayoutInflater().inflate(R.layout.attachment_item, null); ImageView attachment_image = (ImageView) v.findViewById(R.id.attachment_image); if (AttachmentViewerActivity.CONTENT_TYPE_JPEG.equalsIgnoreCase(attachment.content_type) || AttachmentViewerActivity.CONTENT_TYPE_PNG.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_img); } else if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_pdf); } else if (AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4 .equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_video); } else { attachment_image.setImageResource(R.drawable.attachment_unknown); L.d("attachment.content_type not known: " + attachment.content_type); } TextView attachment_text = (TextView) v.findViewById(R.id.attachment_text); attachment_text.setText(attachment.name); v.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { String downloadUrlHash = mMessagingPlugin .attachmentDownloadUrlHash(attachment.download_url); File attachmentsDir; try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), null); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } boolean attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); if (!attachmentAvailable) { try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), mCurrentMessage.key); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); } if (!mService.getNetworkConnectivityManager().isConnected() && !attachmentAvailable) { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(R.string.no_internet_connection_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } if (IOUtils.shouldCheckExternalStorageAvailable()) { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // Its all oke } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { if (!attachmentAvailable) { L.d("Unable to write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } else { L.d("Unable to read or write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } L.d("attachment.content_type: " + attachment.content_type); L.d("attachment.download_url: " + attachment.download_url); L.d("attachment.name: " + attachment.name); L.d("attachment.size: " + attachment.size); if (AttachmentViewerActivity.supportsContentType(attachment.content_type)) { Intent i = new Intent(ServiceMessageDetailActivity.this, AttachmentViewerActivity.class); i.putExtra("thread_key", mCurrentMessage.getThreadKey()); i.putExtra("message", mCurrentMessage.key); i.putExtra("content_type", attachment.content_type); i.putExtra("download_url", attachment.download_url); i.putExtra("name", attachment.name); i.putExtra("download_url_hash", downloadUrlHash); startActivity(i); } else { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(getString(R.string.attachment_can_not_be_displayed_in_your_version, getString(R.string.app_name))); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } }); attachmentLayout.addView(v); } } else { attachmentLayout.setVisibility(View.GONE); } LinearLayout widgetLayout = (LinearLayout) findViewById(R.id.widget_layout); if (mCurrentMessage.form == null) { widgetLayout.setVisibility(View.GONE); } else { widgetLayout.setVisibility(View.VISIBLE); widgetLayout.setEnabled(canEdit); displayWidget(widgetLayout, br); } // Add buttons TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons); tableLayout.removeAllViews(); for (final ButtonTO button : mCurrentMessage.buttons) { addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.form == null && (mCurrentMessage.flags & MessagingPlugin.FLAG_ALLOW_DISMISS) == MessagingPlugin.FLAG_ALLOW_DISMISS) { ButtonTO button = new ButtonTO(); button.caption = "Roger that!"; addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.broadcast_type != null) { L.d("Show broadcast spam control"); final RelativeLayout broadcastSpamControl = (RelativeLayout) findViewById(R.id.broadcast_spam_control); View broadcastSpamControlBorder = findViewById(R.id.broadcast_spam_control_border); final View broadcastSpamControlDivider = findViewById(R.id.broadcast_spam_control_divider); final LinearLayout broadcastSpamControlTextContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_text_container); TextView broadcastSpamControlText = (TextView) findViewById(R.id.broadcast_spam_control_text); final LinearLayout broadcastSpamControlSettingsContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_settings_container); TextView broadcastSpamControlSettingsText = (TextView) findViewById( R.id.broadcast_spam_control_settings_text); TextView broadcastSpamControlIcon = (TextView) findViewById(R.id.broadcast_spam_control_icon); broadcastSpamControlIcon.setTypeface(mFontAwesomeTypeFace); broadcastSpamControlIcon.setText(R.string.fa_bell); final FriendBroadcastInfo fbi = mFriendsPlugin.getFriendBroadcastFlowForMfr(mCurrentMessage.sender); if (fbi == null) { L.bug("BroadcastData was null for: " + mCurrentMessage.sender); collapseDetails(DETAIL_SECTIONS); return; } broadcastSpamControl.setVisibility(View.VISIBLE); broadcastSpamControlSettingsContainer.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { L.d("goto broadcast settings"); PressMenuIconRequestTO request = new PressMenuIconRequestTO(); request.coords = fbi.coords; request.static_flow_hash = fbi.staticFlowHash; request.hashed_tag = fbi.hashedTag; request.generation = fbi.generation; request.service = mCurrentMessage.sender; mContext = "MENU_" + UUID.randomUUID().toString(); request.context = mContext; request.timestamp = System.currentTimeMillis() / 1000; showTransmitting(null); Map<String, Object> userInput = new HashMap<String, Object>(); userInput.put("request", request.toJSONMap()); userInput.put("func", "com.mobicage.api.services.pressMenuItem"); MessageFlowRun mfr = new MessageFlowRun(); mfr.staticFlowHash = fbi.staticFlowHash; try { JsMfr.executeMfr(mfr, userInput, mService, true); } catch (EmptyStaticFlowException ex) { completeTransmit(null); AlertDialog.Builder builder = new AlertDialog.Builder(ServiceMessageDetailActivity.this); builder.setMessage(ex.getMessage()); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } } }); UIUtils.showHint(this, mService, HINT_BROADCAST, R.string.hint_broadcast, mCurrentMessage.broadcast_type, mFriendsPlugin.getName(mCurrentMessage.sender)); broadcastSpamControlText .setText(getString(R.string.broadcast_subscribed_to, mCurrentMessage.broadcast_type)); broadcastSpamControlSettingsText.setText(fbi.label); int ligthAlpha = 180; int darkAlpha = 70; int alpha = ligthAlpha; if (br != null && br.scheme == ColorScheme.dark) { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.black)); broadcastSpamControlBorder.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(darkSchemeTextColor); activity.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlText.setTextColor(lightSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(lightSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(lightSchemeTextColor), Color.green(lightSchemeTextColor), Color.blue(lightSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); alpha = darkAlpha; } else { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.white)); broadcastSpamControlBorder.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(lightSchemeTextColor); activity.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlText.setTextColor(darkSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(darkSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(darkSchemeTextColor), Color.green(darkSchemeTextColor), Color.blue(darkSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); } if (br != null && br.color != null) { int alphaColor = Color.argb(alpha, Color.red(br.color), Color.green(br.color), Color.blue(br.color)); broadcastSpamControl.setBackgroundColor(alphaColor); } mService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { int maxHeight = broadcastSpamControl.getHeight(); broadcastSpamControlDivider.getLayoutParams().height = maxHeight; broadcastSpamControlDivider.requestLayout(); broadcastSpamControlSettingsContainer.getLayoutParams().height = maxHeight; broadcastSpamControlSettingsContainer.requestLayout(); broadcastSpamControlTextContainer.getLayoutParams().height = maxHeight; broadcastSpamControlTextContainer.requestLayout(); int broadcastSpamControlWidth = broadcastSpamControl.getWidth(); android.view.ViewGroup.LayoutParams lp = broadcastSpamControlSettingsContainer .getLayoutParams(); lp.width = broadcastSpamControlWidth / 4; broadcastSpamControlSettingsContainer.setLayoutParams(lp); } }); } if (!isUpdate) collapseDetails(DETAIL_SECTIONS); }
From source file:com.wewow.MainActivity.java
private void showCover() { toolbar.setBackgroundColor(getResources().getColor(R.color.cover)); if (isAppBarFolded) { imageViewLine.setBackgroundColor(getResources().getColor(R.color.cover)); mTabLayout.setBackgroundColor(getResources().getColor(R.color.cover)); layoutCoverTab.setVisibility(View.VISIBLE); layoutCoverTab.setOnClickListener(new View.OnClickListener() { @Override//from www . j ava 2 s.com public void onClick(View v) { removeCover(true); } }); } RelativeLayout layoutCover = (RelativeLayout) findViewById(R.id.layoutCover); layoutCover.setVisibility(View.VISIBLE); layoutCover.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // searchView.setVisibility(View.INVISIBLE); // if(isAppBarFolded) // { // textTitle.setVisibility(View.VISIBLE); // } removeCover(true); new Handler().postDelayed(new Runnable() { public void run() { //execute the task searchView.setVisibility(View.INVISIBLE); imageViewUnderLine.setVisibility(View.INVISIBLE); RemoveUnderLine(); searchView.setText(""); resetDropdownOffset = true; imageViewHome.setImageResource(R.drawable.menu); isSearchViewShown = false; if (isAppBarFolded) { textTitle.setVisibility(View.VISIBLE); imageViewHome.setImageResource(R.drawable.menu_b); } } }, 200); } }); ImageView imageViewBack = (ImageView) findViewById(R.id.layoutMenuCover); imageViewBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isSearchViewShown) { drawerLayout.openDrawer(GravityCompat.START); } else { removeCover(true); new Handler().postDelayed(new Runnable() { public void run() { //execute the task if (isAppBarFolded) { textTitle.setVisibility(View.VISIBLE); imageViewHome.setImageResource(R.drawable.menu_b); imageViewUnderLine.setVisibility(View.INVISIBLE); } searchView.setVisibility(View.INVISIBLE); imageViewUnderLine.setVisibility(View.INVISIBLE); RemoveUnderLine(); searchView.setText(""); resetDropdownOffset = true; imageViewHome.setImageResource(R.drawable.menu); isSearchViewShown = false; } }, 200); } } }); ImageView imageViewSearchBottom = (ImageView) findViewById(R.id.layoutSearchCover); imageViewSearchBottom.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String queryText = searchView.getText().toString().trim(); if (!isSearchViewShown) { if (isAppBarFolded) { imageViewHome.setImageResource(R.drawable.back_b); } else { imageViewHome.setImageResource(R.drawable.back); } ListSearchAdapter adapter = new ListSearchAdapter(hotWords, MainActivity.this); // // ArrayAdapter<String> adapter = new ArrayAdapter<>(MainActivity.this, R.layout.list_item_search, R.id.text, hotWords); searchView.setAdapter(adapter); searchView.setHint(getResources().getString(R.string.search_hint)); searchView.setThreshold(0); if (resetDropdownOffset) { // searchView.setDropDownVerticalOffset(40); // resetDropdownOffset = false; } showUnderLine(); showCover(); new Handler().postDelayed(new Runnable() { public void run() { //execute the task searchView.setVisibility(View.VISIBLE); textTitle.setVisibility(View.GONE); searchView.requestFocus(); InputMethodManager inputManager = (InputMethodManager) searchView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(searchView, 0); } }, 100); new Handler().postDelayed(new Runnable() { public void run() { //execute the task searchView.showDropDown(); } }, 200); searchView.addTextChangedListener(MainActivity.this); searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position != 0) { searchView.setText(hotWords.get(position), true); removeCover(true); layoutSearch.performClick(); } else { searchView.setText(""); } // } }); searchView.setThreshold(0); isSearchViewShown = true; } else { if (!queryText.equals("")) { searchView.setText(""); searchView.setVisibility(View.INVISIBLE); imageViewUnderLine.setVisibility(View.INVISIBLE); Intent intentSearch = new Intent(MainActivity.this, SearchResultActivity.class); intentSearch.putExtra("key_word", queryText); startActivity(intentSearch); if (isAppBarFolded) { imageViewHome.setImageResource(R.drawable.menu_b); } else { imageViewHome.setImageResource(R.drawable.menu); } isSearchViewShown = false; if (isAppBarFolded) { textTitle.setVisibility(View.VISIBLE); } } else { if (isAppBarFolded) { imageViewHome.setImageResource(R.drawable.back_b); } else { imageViewHome.setImageResource(R.drawable.back); } searchView.setHint(getResources().getString(R.string.search_hint)); final String[] testStrings = getResources().getStringArray(R.array.test_array); // ArrayAdapter<String> adapter = new ArrayAdapter<>(MainActivity.this, R.layout.list_item_search, R.id.text, hotWords); ListSearchAdapter adapter = new ListSearchAdapter(hotWords, MainActivity.this); searchView.setAdapter(adapter); searchView.requestFocus(); if (resetDropdownOffset) { // resetDropdownOffset = false; // searchView.setDropDownVerticalOffset(-40); } // searchView.setDropDownVerticalOffset(-40); showUnderLine(); showCover(); new Handler().postDelayed(new Runnable() { public void run() { //execute the task searchView.setVisibility(View.VISIBLE); textTitle.setVisibility(View.GONE); searchView.requestFocus(); InputMethodManager inputManager = (InputMethodManager) searchView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(searchView, 0); } }, 100); new Handler().postDelayed(new Runnable() { public void run() { //execute the task searchView.showDropDown(); } }, 200); searchView.addTextChangedListener(MainActivity.this); searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position != 0) { searchView.setText(hotWords.get(position), true); removeCover(true); imageViewSearch.performClick(); } // } }); searchView.setThreshold(0); isSearchViewShown = true; } } } }); }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
private void refreshLayout() { gDataPreferences = new GDataPreferences(getActivity()); boolean isMyProfile = (GUtil.numberToLong(gDataPreferences.getE164Number() + "") + "") .contains(GUtil.numberToLong(profileId) + ""); layout_status = (RelativeLayout) getView().findViewById(R.id.layout_status); layout_phone = (RelativeLayout) getView().findViewById(R.id.layout_phone); layout_group = (RelativeLayout) getView().findViewById(R.id.layout_member); statusDate = (TextView) getView().findViewById(R.id.profile__date); leaveGroup = (Button) getView().findViewById(R.id.buttonLeaveGroup); profileHeader = (TextView) getView().findViewById(R.id.profile_header); profileStatus = (AutoCompleteTextView) getView().findViewById(R.id.profile_status); xCloseButton = (ImageView) getView().findViewById(R.id.profile_close); imageText = (TextView) getView().findViewById(R.id.image_text); profilePhone = (TextView) getView().findViewById(R.id.profile_phone); groupMember = (ListView) getView().findViewById(R.id.selected_contacts_list); historyLayout = (LinearLayout) getView().findViewById(R.id.historylayout); historyContentTextView = (TextView) getView().findViewById(R.id.history_content); historyScrollView = (HorizontalScrollView) getView().findViewById(R.id.horizontal_scroll); recipientsPanel = (PushRecipientsPanel) getView().findViewById(R.id.recipients); profilePhone.setText(phonenumber);// ww w .jav a 2 s .c o m profilePicture = (ThumbnailView) getView().findViewById(R.id.profile_picture); phoneCall = (ImageView) getView().findViewById(R.id.phone_call); (getView().findViewById(R.id.contacts_button)).setOnClickListener(new AddRecipientButtonListener()); historyLine = (RelativeLayout) getView().findViewById(R.id.layout_history); recipient = recipients.getPrimaryRecipient(); attachmentAdapter = new ProfileImageTypeSelectorAdapter(getActivity()); scrollView = (ScrollView) getView().findViewById(R.id.scrollView); seekBarFont = (SeekBar) getView().findViewById(R.id.seekbar_font); chatPartnersColor = (CheckBox) getView().findViewById(R.id.enabled_chat_partners_color); colorDefault = (CheckBox) getView().findViewById(R.id.color_default); layoutColor = (RelativeLayout) getView().findViewById(R.id.layout_color); floatingActionColorButton = (FloatingActionButton) getView().findViewById(R.id.fab_new_color); final ImageView profileStatusEdit = (ImageView) getView().findViewById(R.id.profile_status_edit); if (!isGroup) { ImageSlide slide = ProfileAccessor.getProfileAsImageSlide(getActivity(), masterSecret, profileId); if (slide != null && !isMyProfile) { if (masterSecret != null) { try { profilePicture.setImageResource(slide, masterSecret); } catch (IllegalStateException e) { Log.w("GDATA", "Unable to load profile image"); } profileStatus.setText(ProfileAccessor.getProfileStatusForRecepient(getActivity(), profileId), TextView.BufferType.EDITABLE); profileStatus.setEnabled(false); layout_status.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { profileStatusEdit.performClick(); return false; } }); statusDate.setText(GUtil.getLocalDate( ProfileAccessor.getProfileUpdateTimeForRecepient(getActivity(), profileId), getActivity().getApplicationContext())); imageText.setText(recipient.getName()); } profilePicture.setThumbnailClickListener(new ThumbnailClickListener()); } else if (ProfileAccessor.getMyProfilePicture(getActivity()).hasImage() && isMyProfile) { profileStatus.setText(ProfileAccessor.getProfileStatus(getActivity()), TextView.BufferType.EDITABLE); imageText.setText(getString(R.string.MediaPreviewActivity_you)); initColorSeekbar(); profilePicture.setThumbnailClickListener(new ThumbnailClickListener()); if ((ProfileAccessor.getMyProfilePicture(getActivity()).getUri() + "").equals("")) { profilePicture.setImageBitmap(ContactPhotoFactory.getDefaultContactPhoto(getActivity())); } else { profilePicture.setImageResource(ProfileAccessor.getMyProfilePicture(getActivity())); } historyLine.setVisibility(View.GONE); } else { imageText.setText(recipient.getName()); profilePicture.setImageBitmap(recipient.getContactPhoto()); } layout_group.setVisibility(View.GONE); } else { String groupName = recipient.getName(); Bitmap avatar = recipient.getContactPhoto(); String encodedGroupId = recipient.getNumber(); if (encodedGroupId != null) { try { groupId = GroupUtil.getDecodedId(encodedGroupId); } catch (IOException ioe) { groupId = null; } } GroupDatabase db = DatabaseFactory.getGroupDatabase(getActivity()); Recipients recipients = db.getGroupMembers(groupId, false); recipientsPanel.setPanelChangeListener(new PushRecipientsPanel.RecipientsPanelChangedListener() { @Override public void onRecipientsPanelUpdate(Recipients recipients) { Log.w("GDATA", "onRecipientsPanelUpdate received."); if (recipients != null) { addAllSelectedContacts(recipients.getRecipientsList()); syncAdapterWithSelectedContacts(); } } }); if (recipients != null) { final List<Recipient> recipientList = recipients.getRecipientsList(); if (recipientList != null) { if (existingContacts == null) existingContacts = new HashSet<>(recipientList.size()); existingContacts.addAll(recipientList); } if (recipientList != null) { if (existingContacts == null) existingContacts = new HashSet<>(recipientList.size()); existingContacts.addAll(recipientList); } SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(getActivity(), android.R.id.text1, new ArrayList<SelectedRecipientsAdapter.RecipientWrapper>()); adapter.clear(); if (existingContacts != null) { for (Recipient contact : existingContacts) { adapter.add(new SelectedRecipientsAdapter.RecipientWrapper(contact, false)); } } adapter.setMasterSecret(masterSecret); adapter.setThreadId(threadId); adapter.setOnRecipientDeletedListener(new SelectedRecipientsAdapter.OnRecipientDeletedListener() { @Override public void onRecipientDeleted(Recipient recipient) { removeSelectedContact(recipient); } }); groupMember.setAdapter(adapter); adapter.notifyDataSetChanged(); } if (avatar != null) { profilePicture.setVisibility(View.GONE); getView().findViewById(R.id.profile_picture_group).setVisibility(View.VISIBLE); scaleImage((ImageView) getView().findViewById(R.id.profile_picture_group), avatar); } imageText.setText(groupName); if (profileStatusString.equals("")) { profileStatus.setText(groupName); } layout_phone.setVisibility(View.GONE); leaveGroup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (isActiveGroup()) { handleLeavePushGroup(); } else { handleDeleteThread(); } } }); if (!isActiveGroup()) { leaveGroup.setText(getString(R.string.conversation__menu_delete_thread)); } heightMemberList = GUtil.setListViewHeightBasedOnChildren(groupMember); } ImageView profileImageEdit = (ImageView) getView().findViewById(R.id.profile_picture_edit); ImageView profileImageDelete = (ImageView) getView().findViewById(R.id.profile_picture_delete); if (!isMyProfile && !isGroup) { profileStatusEdit.setVisibility(View.GONE); profileImageDelete.setVisibility(View.GONE); profileImageEdit.setVisibility(View.GONE); } else { if (isGroup) { profileImageDelete.setVisibility(View.GONE); profileHeader.setText(getString(R.string.group_title)); } else { profileImageDelete.setVisibility(View.VISIBLE); } profileStatusEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { profileStatus.setEnabled(!profileStatus.isEnabled()); if (!profileStatus.isEnabled()) { hasChanged = true; hasLeft = false; profileStatusEdit.setImageDrawable(getResources().getDrawable(R.drawable.ic_content_edit)); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(profileStatus.getWindowToken(), 0); if (isGroup) { new UpdateWhisperGroupAsyncTask().execute(); } else { ProfileAccessor.setProfileStatus(getActivity(), profileStatus.getText() + ""); } } else { profileStatusEdit .setImageDrawable(getResources().getDrawable(R.drawable.ic_send_sms_gdata)); profileStatus.showDropDown(); profileStatus.requestFocus(); } } }); profileImageDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hasChanged = true; hasLeft = false; ProfileAccessor.deleteMyProfilePicture(getActivity()); refreshLayout(); profileStatus.dismissDropDown(); gDataPreferences.hasProfileImageChanged(true); } }); profileImageEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { gDataPreferences.hasProfileImageChanged(true); hasChanged = true; hasLeft = false; handleAddAttachment(); } }); } if (isMyProfile) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.status_suggestions)); profileStatus.setAdapter(adapter); profileStatus.setCompletionHint(getString(R.string.status_hint)); profileStatus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { profileStatus.dismissDropDown(); } }); profileStatus.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { profileStatus.setEnabled(!profileStatus.isEnabled()); if (!profileStatus.isEnabled()) { hasChanged = true; hasLeft = false; profileStatusEdit.setImageDrawable(getResources().getDrawable(R.drawable.ic_content_edit)); InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(profileStatus.getWindowToken(), 0); if (isGroup) { new UpdateWhisperGroupAsyncTask().execute(); } else { ProfileAccessor.setProfileStatus(getActivity(), profileStatus.getText() + ""); } } } }); } else { // if(!isMyProfile) { setMediaHistoryImages(); } xCloseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finishAndSave(); } }); phoneCall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handleDial(recipient); } }); final RelativeLayout scrollContainer = (RelativeLayout) getView().findViewById(R.id.scrollContainer); final LinearLayout mainLayout = (LinearLayout) getView().findViewById(R.id.mainlayout); scrollView.setSmoothScrollingEnabled(true); ViewTreeObserver vto = scrollView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { scrollView.scrollTo(0, mainLayout.getTop() - PADDING_TOP); } }); scrollContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // getActivity().finish(); } }); onScrollChangeListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (BuildConfig.VERSION_CODE >= 11) { scrollContainer.setBackgroundColor(Color.WHITE); scrollContainer .setAlpha((float) ((1000.0 / scrollContainer.getHeight()) * scrollView.getHeight())); } int keyboardHeight = 150; int paddingBottom = 250; int scrollViewHeight = scrollView.getHeight(); if (getActivity().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { scrollViewHeight = 2 * scrollViewHeight; } int heightDiff = scrollView.getRootView().getHeight() - scrollView.getHeight(); if (pxToDp(heightDiff) > keyboardHeight) { keyboardIsVisible = true; } else { keyboardIsVisible = false; } if (!keyboardIsVisible) { if ((mainLayout.getTop() - scrollViewHeight) > scrollView.getScrollY() - pxToDp(paddingBottom)) { finishAndSave(); } if ((scrollViewHeight + (heightMemberList)) < (scrollView.getScrollY() - mainLayout.getTop())) { finishAndSave(); } } } }; scrollView.getViewTreeObserver().addOnScrollChangedListener(onScrollChangeListener); scrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ViewTreeObserver observer = scrollView.getViewTreeObserver(); observer.addOnScrollChangedListener(onScrollChangeListener); return false; } }); }
From source file:com.near.chimerarevo.fragments.PostFragment.java
private void addYoutubeVideo(String url) { final String yturl; if (url.contains("embed")) { String temp = url.split("embed/")[1]; if (url.contains("feature")) { temp = temp.split("feature=")[0]; yturl = temp.substring(0, temp.length() - 1); } else//from w ww.j a va 2s.c om yturl = temp; } else if (url.contains("youtu.be")) { yturl = url.split("youtu.be/")[1]; } else return; final RelativeLayout rl = new RelativeLayout(getActivity()); YouTubeThumbnailView yt = new YouTubeThumbnailView(getActivity()); ImageView icon = new ImageView(getActivity()); try { yt.setTag(yturl); yt.initialize(Constants.YOUTUBE_API_TOKEN, new OnInitializedListener() { @Override public void onInitializationFailure(YouTubeThumbnailView thumbView, YouTubeInitializationResult error) { rl.setVisibility(View.GONE); } @Override public void onInitializationSuccess(YouTubeThumbnailView thumbView, YouTubeThumbnailLoader thumbLoader) { thumbLoader.setVideo(yturl); } }); } catch (Exception e) { e.printStackTrace(); } RelativeLayout.LayoutParams obj_params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); obj_params.addRule(RelativeLayout.CENTER_HORIZONTAL); obj_params.addRule(RelativeLayout.CENTER_VERTICAL); yt.setLayoutParams(obj_params); icon.setImageResource(R.drawable.yt_play_button); icon.setLayoutParams(obj_params); RelativeLayout.LayoutParams rl_params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rl_params.setMargins(0, 10, 0, 0); rl.setLayoutParams(rl_params); rl.setGravity(Gravity.CENTER_HORIZONTAL); rl.setClickable(true); rl.addView(yt); rl.addView(icon); rl.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getActivity(), YoutubeActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra(Constants.KEY_VIDEO_URL, yturl); startActivity(i); } }); lay.addView(rl); }
From source file:org.egov.android.view.activity.CreateComplaintActivity.java
/** * Function used to show the image added to complaint in image view. A close icon is shown at * the top right corner of the image to delete it * /* ww w. ja v a 2s . c om*/ * @param imagePath */ @SuppressLint("InflateParams") private void _addImageView(String imagePath) { final ImageView image_container = (ImageView) findViewById(R.id.image_container); LinearLayout container = (LinearLayout) findViewById(R.id.container); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.add_photo, null); RelativeLayout inner_container = (RelativeLayout) view.findViewById(R.id.inner_container); LinearLayout.LayoutParams inner_container_params = new LinearLayout.LayoutParams(_dpToPix(100), _dpToPix(100)); inner_container.setLayoutParams(inner_container_params); ImageView image = (ImageView) view.findViewById(R.id.image); image.setImageBitmap(_getBitmapImage(imagePath)); image.setTag(imagePath); container.addView(inner_container); imageUrl.add(imagePath); image_container.setImageBitmap(_getBitmapImage(imagePath)); ImageView delete_icon = (ImageView) view.findViewById(R.id.delete_photo); delete_icon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { file_upload_limit--; RelativeLayout deleteView = (RelativeLayout) v.getParent(); ((LinearLayout) findViewById(R.id.container)).removeView(deleteView); ImageView image = (ImageView) deleteView.findViewById(R.id.image); _deleteFile(image.getTag().toString()); _reorderFiles(); } }); inner_container.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ImageView image = (ImageView) v.findViewById(R.id.image); ((ImageView) findViewById(R.id.image_container)) .setImageBitmap(_getBitmapImage(image.getTag().toString())); } }); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.hr_scroll); hsv.scrollTo(hsv.getWidth() + 600, 0); } }, 500); }
From source file:com.dish.browser.activity.BrowserActivity.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") private synchronized void initialize() { setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* w w w . j ava 2 s . co m*/ ActionBar actionBar = getSupportActionBar(); mPreferences = PreferenceManager.getInstance(); mDarkTheme = mPreferences.getUseDarkTheme() || isIncognito(); mActivity = this; mWebViews.clear(); mClickHandler = new ClickHandler(this); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout); // initialize background ColorDrawable mBackground.setColor(((ColorDrawable) mToolbarLayout.getBackground()).getColor()); mUiLayout = (LinearLayout) findViewById(R.id.ui_layout); mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view); RelativeLayout newTab = (RelativeLayout) findViewById(R.id.new_tab_button); mDrawerLeft = (LinearLayout) findViewById(R.id.left_drawer); // Drawer stutters otherwise mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list); setNavigationDrawerWidth(); mWebpageBitmap = Utils.getWebpageBitmap(getResources(), mDarkTheme); mHomepage = mPreferences.getHomepage(); mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews); mDrawerListLeft.setAdapter(mTitleAdapter); mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext()); // set display options of the ActionBar actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.toolbar_content); View v = actionBar.getCustomView(); LayoutParams lp = v.getLayoutParams(); lp.width = LayoutParams.MATCH_PARENT; v.setLayoutParams(lp); mArrowDrawable = new DrawerArrowDrawable(this); mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow); // Use hardware acceleration for the animation mArrowImage.setLayerType(View.LAYER_TYPE_HARDWARE, null); mArrowImage.setImageDrawable(mArrowDrawable); LinearLayout arrowButton = (LinearLayout) actionBar.getCustomView().findViewById(R.id.arrow_button); arrowButton.setOnClickListener(this); mI2PHelper = new I2PAndroidHelper(this); RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back); back.setOnClickListener(this); RelativeLayout forward = (RelativeLayout) findViewById(R.id.action_forward); forward.setOnClickListener(this); // create the search EditText in the ToolBar mSearch = (AutoCompleteTextView) actionBar.getCustomView().findViewById(R.id.search); mUntitledTitle = getString(R.string.untitled); mBackgroundColor = getResources().getColor(R.color.primary_color); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete); mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh); mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy); } else { Theme theme = getTheme(); mDeleteIcon = getResources().getDrawable(R.drawable.ic_action_delete, theme); mRefreshIcon = getResources().getDrawable(R.drawable.ic_action_refresh, theme); mCopyIcon = getResources().getDrawable(R.drawable.ic_action_copy, theme); } int iconBounds = Utils.convertDpToPixels(24); mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds); mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds); mCopyIcon.setBounds(0, 0, iconBounds, iconBounds); mIcon = mRefreshIcon; SearchClass search = new SearchClass(); mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); mSearch.setOnKeyListener(search.new KeyListener()); mSearch.setOnFocusChangeListener(search.new FocusChangeListener()); mSearch.setOnEditorActionListener(search.new EditorActionListener()); mSearch.setOnTouchListener(search.new TouchListener()); mSystemBrowser = getSystemBrowser(); Thread initialize = new Thread(new Runnable() { @Override public void run() { initializeSearchSuggestions(mSearch); } }); initialize.run(); newTab.setOnClickListener(this); newTab.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { String url = mPreferences.getSavedUrl(); if (url != null) { newTab(url, true); Toast.makeText(mActivity, R.string.deleted_tab, Toast.LENGTH_SHORT).show(); } mPreferences.setSavedUrl(null); return true; } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END); mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START); initializeTabs(); if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } checkForProxy(); }
From source file:com.daiv.android.twitter.ui.drawer_activities.DrawerActivity.java
public void setUpDrawer(int number, final String actName) { int currentAccount = sharedPrefs.getInt("current_account", 1); for (int i = 0; i < TimelinePagerAdapter.MAX_EXTRA_PAGES; i++) { String pageIdentifier = "account_" + currentAccount + "_page_" + (i + 1); int type = sharedPrefs.getInt(pageIdentifier, AppSettings.PAGE_TYPE_NONE); if (type != AppSettings.PAGE_TYPE_NONE) { number++;/* w w w .j a v a 2 s . co m*/ } } try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } actionBar = getActionBar(); adapter = new MainDrawerArrayAdapter(context); MainDrawerArrayAdapter.setCurrent(context, number); TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon }); int resource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button }); openMailResource = a.getResourceId(0, 0); a.recycle(); a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button }); closedMailResource = a.getResourceId(0, 0); a.recycle(); mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name); HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name); backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image); profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact); final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options); final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout); final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton); drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list); notificationList = (EnhancedListView) findViewById(R.id.notificationList); try { mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ resource, /* nav drawer icon to replace 'Up' caret */ R.string.app_name, /* "open drawer" description */ R.string.app_name /* "close drawer" description */ ) { public void onDrawerClosed(View view) { actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); if (logoutVisible) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); logoutLayout.setVisibility(View.GONE); drawerList.setVisibility(View.VISIBLE); logoutVisible = false; } if (MainDrawerArrayAdapter.current > adapter.pageTypes.size()) { actionBar.setTitle(actName); } else { int position = mViewPager.getCurrentItem(); String title = ""; try { title = "" + mSectionsPagerAdapter.getPageTitle(position); } catch (NullPointerException e) { title = ""; } actionBar.setTitle(title); } try { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.new_interactions))) { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); } } catch (Exception e) { // don't have Test pull on } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { actionBar.setTitle(getResources().getString(R.string.app_name)); actionBar.setIcon(R.mipmap.ic_launcher); try { notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(settings.currentAccount)); notificationList.setAdapter(notificationAdapter); notificationList.enableSwipeToDismiss(); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); sharedPrefs.edit().putBoolean("new_notification", false).commit(); } catch (Exception e) { // don't have Test pull on } invalidateOptionsMenu(); } public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (!actionBar.isShowing()) { actionBar.show(); } if (translucent) { statusBar.setVisibility(View.VISIBLE); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); } catch (Exception e) { // landscape mode } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); showMoreDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (logoutLayout.getVisibility() == View.GONE) { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = true; } else { Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back); ranim.setFillAfter(true); showMoreDrawer.startAnimation(ranim); Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { drawerList.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim.setDuration(300); drawerList.startAnimation(anim); Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out); anim2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { logoutLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); anim2.setDuration(300); logoutLayout.startAnimation(anim2); logoutVisible = false; } } }); logoutDrawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoutFromTwitter(); } }); final String sName = settings.myName; final String sScreenName = settings.myScreenName; final String backgroundUrl = settings.myBackgroundUrl; final String profilePicUrl = settings.myProfilePicUrl; final BitmapLruCache mCache = App.getInstance(context).getProfileCache(); if (!backgroundUrl.equals("")) { backgroundPic.loadImage(backgroundUrl, false, null); //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache); } else { backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background)); } backgroundPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } new Handler().postDelayed(new Runnable() { @Override public void run() { } }, 400); } }); backgroundPic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { try { mDrawerLayout.closeDrawer(Gravity.START); } catch (Exception e) { } return false; } }); try { name.setText(sName); screenName.setText("@" + sScreenName); name.setTextSize(15); screenName.setTextSize(15); } catch (Exception e) { // 7 inch tablet in portrait } try { if (settings.roundContactImages) { //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache); } else { profilePic.loadImage(profilePicUrl, false, null); ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache); } } catch (Exception e) { // empty path again } drawerList.setAdapter(adapter); drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager)); // set up for the second account int count = 0; // number of accounts logged in if (sharedPrefs.getBoolean("is_logged_in_1", false)) { count++; } if (sharedPrefs.getBoolean("is_logged_in_2", false)) { count++; } RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile); HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2); HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2); NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2); name2.setTextSize(15); screenname2.setTextSize(15); final int current = sharedPrefs.getInt("current_account", 1); // make a second account if (count == 1) { name2.setText(getResources().getString(R.string.new_account)); screenname2.setText(getResources().getString(R.string.tap_to_setup)); secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { if (current == 1) { sharedPrefs.edit().putInt("current_account", 2).commit(); } else { sharedPrefs.edit().putInt("current_account", 1).commit(); } context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION")); Intent login = new Intent(context, LoginActivity.class); AppSettings.invalidate(); finish(); startActivity(login); } } }); } else { // switch accounts if (current == 1) { name2.setText(sharedPrefs.getString("twitter_users_name_2", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); // we want to wait a second so that the mark position broadcast will work new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 2).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } else { name2.setText(sharedPrefs.getString("twitter_users_name_1", "")); screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", "")); try { if (settings.roundContactImages) { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE); ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } else { //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null); ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache); } } catch (Exception e) { } secondAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (canSwitch) { context.sendBroadcast(new Intent("com.daiv.android.twitter.STOP_PUSH_SERVICE")); context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION") .putExtra("current_account", current)); Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show(); new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); } catch (Exception e) { } sharedPrefs.edit().putInt("current_account", 1).commit(); sharedPrefs.edit().remove("new_notifications").remove("new_retweets") .remove("new_favorites").remove("new_follows").commit(); AppSettings.invalidate(); finish(); Intent next = new Intent(context, MainActivity.class); startActivity(next); } }).start(); } } }); } } statusBar = findViewById(R.id.activity_status_bar); statusBarHeight = Utils.getStatusBarHeight(context); navBarHeight = Utils.getNavBarHeight(context); try { RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception e) { try { LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams(); statusParams.height = statusBarHeight; statusBar.setLayoutParams(statusParams); } catch (Exception x) { // in the trends } } View navBarSeperater = findViewById(R.id.nav_bar_seperator); if (translucent && Utils.hasNavBar(context)) { try { RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception e) { try { LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater .getLayoutParams(); navParams.height = navBarHeight; navBarSeperater.setLayoutParams(navParams); } catch (Exception x) { // in the trends } } } if (translucent) { if (Utils.hasNavBar(context)) { View footer = new View(context); footer.setOnClickListener(null); footer.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); footer.setLayoutParams(params); drawerList.addFooterView(footer); drawerList.setFooterDividersEnabled(false); } View drawerStatusBar = findViewById(R.id.drawer_status_bar); LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); statusBar.setVisibility(View.VISIBLE); drawerStatusBar = findViewById(R.id.drawer_status_bar_2); status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams(); status2Params.height = statusBarHeight; drawerStatusBar.setLayoutParams(status2Params); drawerStatusBar.setVisibility(View.VISIBLE); } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) { actionBar.setDisplayHomeAsUpEnabled(false); } if (!settings.pushNotifications || !settings.useInteractionDrawer) { try { mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END); } catch (Exception e) { // no drawer? } } else { mDrawerLayout.setDrawerRightEdgeSize(this, .1f); try { if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) { View viewHeader2 = context.getLayoutInflater().inflate(R.layout.ab_header, null); notificationList.addHeaderView(viewHeader2, null, false); notificationList.setHeaderDividersEnabled(false); } } catch (Exception e) { // i don't know why it does this to be honest... } notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context) .getUnreadCursor(DrawerActivity.settings.currentAccount)); try { notificationList.setAdapter(notificationAdapter); } catch (Exception e) { } View viewHeader = context.getLayoutInflater().inflate(R.layout.interactions_footer_1, null); notificationList.addFooterView(viewHeader, null, false); oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text); readButton = (ImageView) findViewById(R.id.read_button); LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer); footer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (oldInteractions.getText().toString() .equals(getResources().getString(R.string.old_interactions))) { oldInteractions.setText(getResources().getString(R.string.new_interactions)); readButton.setImageResource(closedMailResource); notificationList.disableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getCursor(DrawerActivity.settings.currentAccount)); } else { oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); notificationList.enableSwipeToDismiss(); notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource .getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount)); } notificationList.setAdapter(notificationAdapter); } }); if (DrawerActivity.translucent) { if (Utils.hasNavBar(context)) { View nav = new View(context); nav.setOnClickListener(null); nav.setOnLongClickListener(null); ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context)); nav.setLayoutParams(params); notificationList.addFooterView(nav); notificationList.setFooterDividersEnabled(false); } } notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() { @Override public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) { Log.v("Test_interactions_delete", "position to delete: " + position); InteractionsDataSource data = InteractionsDataSource.getInstance(context); data.markRead(settings.currentAccount, position); notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount)); notificationList.setAdapter(notificationAdapter); oldInteractions.setText(getResources().getString(R.string.old_interactions)); readButton.setImageResource(openMailResource); if (notificationAdapter.getCount() == 0) { setNotificationFilled(false); } return null; } }); notificationList.enableSwipeToDismiss(); notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START); notificationList .setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager)); } }