List of usage examples for android.view View.OnClickListener View.OnClickListener
View.OnClickListener
From source file:org.sufficientlysecure.donations.DonationsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* Flattr *///from w w w . j a va2 s . c o m if (mFlattrEnabled) { // inflate flattr view into stub ViewStub flattrViewStub = (ViewStub) getActivity().findViewById(R.id.donations__flattr_stub); flattrViewStub.inflate(); buildFlattrView(); } /* Google */ if (mGoogleEnabled) { // inflate google view into stub ViewStub googleViewStub = (ViewStub) getActivity().findViewById(R.id.donations__google_stub); googleViewStub.inflate(); // choose donation amount mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner); ArrayAdapter<CharSequence> adapter; if (mDebug) { adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, CATALOG_DEBUG); } else { adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, mGoogleCatalogValues); } adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mGoogleSpinner.setAdapter(adapter); Button btGoogle = (Button) getActivity() .findViewById(R.id.donations__google_android_market_donate_button); btGoogle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { donateGoogleOnClick(v); } }); // Create the helper, passing it our context and the public key to verify signatures with if (mDebug) Log.d(TAG, "Creating IAB helper."); mHelper = new IabHelper(getActivity(), mGooglePubkey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(mDebug); // Start setup. This is asynchronous and the specified listener // will be called once setup completes. if (mDebug) Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (mDebug) Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__google_android_market_not_supported_title, getString(R.string.donations__google_android_market_not_supported)); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; } }); } /* PayPal */ if (mPaypalEnabled) { // inflate paypal view into stub ViewStub paypalViewStub = (ViewStub) getActivity().findViewById(R.id.donations__paypal_stub); paypalViewStub.inflate(); Button btPayPal = (Button) getActivity().findViewById(R.id.donations__paypal_donate_button); btPayPal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { donatePayPalOnClick(v); } }); } /* Bitcoin */ if (mBitcoinEnabled) { // inflate bitcoin view into stub ViewStub bitcoinViewStub = (ViewStub) getActivity().findViewById(R.id.donations__bitcoin_stub); bitcoinViewStub.inflate(); Button btBitcoin = (Button) getActivity().findViewById(R.id.donations__bitcoin_button); btBitcoin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { donateBitcoinOnClick(v); } }); btBitcoin.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(getActivity(), R.string.donations__bitcoin_toast_copy, Toast.LENGTH_SHORT) .show(); // http://stackoverflow.com/a/11012443/832776 if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity() .getSystemService(getActivity().CLIPBOARD_SERVICE); clipboard.setText(mBitcoinAddress); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity() .getSystemService(getActivity().CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText(mBitcoinAddress, mBitcoinAddress); clipboard.setPrimaryClip(clip); } return true; } }); } }
From source file:com.google.android.apps.iosched.ui.SessionLivestreamActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override// w w w . jav a2 s. c o m protected void onCreate(Bundle savedInstanceState) { if (UIUtils.hasICS()) { // We can't use this mode on HC as compatible ActionBar doesn't work well with the YT // player in full screen mode (no overlays allowed). requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_session_livestream); mIsTablet = UIUtils.isHoneycombTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerSupportFragment) getSupportFragmentManager() .findFragmentById(R.id.livestream_player); mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this); // Views that are common over all layouts mMainLayout = (LinearLayout) findViewById(R.id.livestream_mainlayout); mPresentationControls = (FrameLayout) findViewById(R.id.presentation_controls); adjustMainLayoutForActionBar(); mPlayerContainer = (LinearLayout) findViewById(R.id.livestream_player_container); mFullscreenCaptions = (FrameLayout) findViewById(R.id.fullscreen_captions); final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams(); params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx()); mFullscreenCaptions.setLayoutParams(params); ViewPager viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setOffscreenPageLimit(2); if (!mIsTablet) { viewPager.setPageMarginDrawable(R.drawable.grey_border_inset_lr); } viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width)); // Set up tabs w/ViewPager mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mTabsAdapter = new TabsAdapter(this, mTabHost, viewPager); if (mIsTablet) { // Tablet UI specific views getSupportFragmentManager().beginTransaction() .add(R.id.livestream_summary, new SessionSummaryFragment(), TAG_SESSION_SUMMARY).commit(); mVideoLayout = (LinearLayout) findViewById(R.id.livestream_videolayout); mExtraLayout = (LinearLayout) findViewById(R.id.livestream_extralayout); mSummaryLayout = (FrameLayout) findViewById(R.id.livestream_summary); } else { // Handset UI specific views mTabsAdapter.addTab(getString(R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); } mTabsAdapter.addTab(getString(R.string.title_stream), new SocialStreamFragment(), TABNUM_SOCIAL_STREAM); mTabsAdapter.addTab(getString(R.string.session_livestream_captions), new SessionLiveCaptionsFragment(), TABNUM_LIVE_CAPTIONS); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString(EXTRA_TAB_STATE)); } // Reload all other data in this activity reloadFromIntent(getIntent()); // Update layout based on current configuration updateLayout(getResources().getConfiguration()); // Set up action bar if (!mLoadFromExtras) { // Start sessions query to populate action bar navigation spinner getSupportLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); // Set up action bar mLivestreamAdapter = new LivestreamAdapter(getSupportActionBar().getThemedContext()); final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mLivestreamAdapter, this); actionBar.setDisplayShowTitleEnabled(false); } // Media Router and Presentation set up if (UIUtils.hasJellyBeanMR1()) { mMediaRouterCallback = new MediaRouter.SimpleCallback() { @Override public void onRouteSelected(MediaRouter router, int type, MediaRouter.RouteInfo info) { LOGD(TAG, "onRouteSelected: type=" + type + ", info=" + info); updatePresentation(); } @Override public void onRouteUnselected(MediaRouter router, int type, MediaRouter.RouteInfo info) { LOGD(TAG, "onRouteUnselected: type=" + type + ", info=" + info); updatePresentation(); } @Override public void onRoutePresentationDisplayChanged(MediaRouter router, MediaRouter.RouteInfo info) { LOGD(TAG, "onRoutePresentationDisplayChanged: info=" + info); updatePresentation(); } }; mMediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE); final ImageButton playPauseButton = (ImageButton) findViewById(R.id.play_pause_button); playPauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mYouTubePlayer != null) { if (mYouTubePlayer.isPlaying()) { mYouTubePlayer.pause(); playPauseButton.setImageResource(R.drawable.ic_livestream_play); } else { mYouTubePlayer.play(); playPauseButton.setImageResource(R.drawable.ic_livestream_pause); } } } }); updatePresentation(); } }
From source file:com.ibuildapp.romanblack.NewsPlugin.NewsPlugin.java
@Override public void create() { try {//from w ww . j a va 2s . c o m setContentView(R.layout.news_feed_main); setTitle(R.string.news_feed); setTopbarTitleTypeface(Typeface.NORMAL); mainLayout = findViewById(R.id.news_feed_main_layout); listView = (RecyclerView) findViewById(R.id.news_feed_main_list); listView.setLayoutManager(new LinearLayoutManager(this)); progressLayout = findViewById(R.id.news_feed_main_progress_layout); refreshLayout = (SwipeRefreshLayout) findViewById(R.id.news_feed_main_refresh); refreshLayout.setEnabled(false); refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { loadRSS(); } }); currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } if (!TextUtils.isEmpty(widget.getTitle())) { setTopBarTitle(widget.getTitle()); } setTopBarTitleColor(Color.parseColor("#000000")); setTopBarLeftButtonTextAndColor(getResources().getString(R.string.news_home_button), Color.parseColor("#000000"), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); try { if (widget.getPluginXmlData().length() == 0) { if (currentIntent.getStringExtra("WidgetFile").length() == 0) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 3000); return; } } } catch (Exception e) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 3000); return; } cachePath = widget.getCachePath() + "/feed-" + widget.getOrder(); File cache = new File(this.cachePath); if (!cache.exists()) { cache.mkdirs(); } // 3 seconds String widgetMD5 = Utils.md5(widget.getPluginXmlData()); File cacheData = new File(cachePath + "/cache.data"); if (cacheData.exists() && cacheData.length() > 0) { String cacheMD5 = readFileToString(cachePath + "/cache.md5").replace("\n", ""); if (cacheMD5.equals(widgetMD5)) { useCache = true; } else { File[] files = cache.listFiles(); for (File file : files) { file.delete(); } try { BufferedWriter bw = new BufferedWriter(new FileWriter(new File(cachePath + "/cache.md5"))); bw.write(widgetMD5); bw.close(); Log.d("IMAGES PLUGIN CACHE MD5", "SUCCESS"); } catch (Exception e) { Log.w("IMAGES PLUGIN CACHE MD5", e); } } } isOnline = NetworkUtils.isOnline(this); if (!isOnline && !useCache) { handler.sendEmptyMessage(NEED_INTERNET_CONNECTION); return; } new Thread() { @Override public void run() { timer = new Timer("EventsTimer", true); EntityParser parser; if (widget.getPluginXmlData().length() > 0) { parser = new EntityParser(widget.getPluginXmlData()); } else { String xmlData = readXmlFromFile(currentIntent.getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } parser.parse(); Statics.color1 = parser.getColor1(); Statics.color2 = parser.getColor2(); Statics.color3 = parser.getColor3(); Statics.color4 = parser.getColor4(); Statics.color5 = parser.getColor5(); handler.sendEmptyMessage(COLORS_RECEIVED); title = (widget.getTitle().length() > 0) ? widget.getTitle() : parser.getFuncName(); items = parser.getItems(); if ("rss".equals(parser.getFeedType())) { Statics.isRSS = true; AndroidSchedulers.mainThread().createWorker().schedule(new Action0() { @Override public void call() { refreshLayout.setColorSchemeColors(Statics.color3); } }); feedURL = parser.getFeedUrl(); if (isOnline) { FeedParser reader = new FeedParser(parser.getFeedUrl()); items = reader.parseFeed(); encoding = reader.getEncoding(); if (items.size() > 0) { try { ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream(cachePath + "/cache.data")); oos.writeObject(items); oos.flush(); oos.close(); } catch (Exception e) { e.printStackTrace(); } } Statics.isRSS = true; AndroidSchedulers.mainThread().createWorker().schedule(new Action0() { @Override public void call() { refreshLayout.setEnabled(true); } }); } else { try { ObjectInputStream ois = new ObjectInputStream( new FileInputStream(cachePath + "/cache.data")); items = (ArrayList<FeedItem>) ois.readObject(); ois.close(); } catch (Exception e) { e.printStackTrace(); } } } else { Statics.isRSS = false; AndroidSchedulers.mainThread().createWorker().schedule(new Action0() { @Override public void call() { refreshLayout.setEnabled(false); } }); } for (int i = 0; i < items.size(); i++) { items.get(i).setTextColor(widget.getTextColor()); items.get(i).setDateFormat(widget.getDateFormat()); } funcName = parser.getFuncName(); selectShowType(); } }.start(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:ua.org.gdg.devfest.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//*from ww w . j a va2 s. c o m*/ private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); // Add session feedback link if (getResources().getBoolean(R.bool.has_feedback_enabled)) { links.add(new Pair<Integer, Intent>(R.string.session_feedback_submitlink, new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class))); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeBlockUI(context, mSessionBlockStart, mSessionBlockEnd, null, mSubtitle, subtitle); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.ibuildapp.romanblack.FanWallPlugin.FanWallPlugin.java
private void initializeUI() { setContentView(R.layout.romanblack_fanwall_main); mainlLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_main); mainlLayout.setBackgroundColor(Statics.color1); // less then android L if (android.os.Build.VERSION.SDK_INT <= 20) { InputMethodManager im = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE); SoftKeyboard softKeyboard;/*from www . ja v a 2 s .c o m*/ softKeyboard = new SoftKeyboard(mainlLayout, im); softKeyboard.setSoftKeyboardCallback(new SoftKeyboard.SoftKeyboardChanged() { @Override public void onSoftKeyboardHide() { Message msg = handler.obtainMessage(HANDLE_TAP_BAR, 1, 0); handler.sendMessage(msg); } @Override public void onSoftKeyboardShow() { Message msg = handler.obtainMessage(HANDLE_TAP_BAR, 0, 0); handler.sendMessage(msg); } }); } bottomBarHodler = (LinearLayout) findViewById(R.id.romanblack_fanwall_main_bottom_bar); TextView noMsgText = (TextView) findViewById(R.id.romanblack_fanwall_nomessages_text); // top bar setTopBarLeftButtonText(getResources().getString(R.string.common_home_upper), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); // set title if (TextUtils.isEmpty(widget.getTitle())) setTopBarTitle(getString(R.string.fanwall_talks)); else setTopBarTitle(widget.getTitle()); imageHolder = (LinearLayout) findViewById(R.id.fanwall_image_holder); userImage = (ImageView) findViewById(R.id.fanwall_user_image); closeBtn = (ImageView) findViewById(R.id.fanwall_close_image); closeBtn.setOnClickListener(this); chooserHolder = (LinearLayout) findViewById(R.id.fanwall_chooser_holder); openBottom = (LinearLayout) findViewById(R.id.romanblack_fanwall_open_bottom); openBottom.setOnClickListener(this); enableGpsCheckbox = (CheckBox) findViewById(R.id.romanblack_fanwall_enable_gps_checkbox); enableGpsCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { final AlertDialog.Builder builder = new AlertDialog.Builder(FanWallPlugin.this); builder.setMessage(getString(R.string.enable_gps_msg)).setCancelable(false) .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { startActivityForResult( new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), GPS_SETTINGS_ACTIVITY); } }).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) { enableGpsCheckbox.setChecked(false); dialog.dismiss(); } }); final AlertDialog alert = builder.create(); alert.show(); } else { Prefs.with(FanWallPlugin.this).save(Prefs.KEY_GPS, true); } } else Prefs.with(FanWallPlugin.this).save(Prefs.KEY_GPS, false); } }); enableGpsCheckbox.setChecked(Prefs.with(FanWallPlugin.this).getBoolean(Prefs.KEY_GPS, false)); galleryChooser = (LinearLayout) findViewById(R.id.romanblack_fanwall_gallery); galleryChooser.setOnClickListener(this); photoChooser = (LinearLayout) findViewById(R.id.romanblack_fanwall_make_photo); photoChooser.setOnClickListener(this); postMsg = (LinearLayout) findViewById(R.id.romanblack_fanwall_send_post); postMsg.setOnClickListener(this); editMsg = (EditText) findViewById(R.id.romanblack_fanwall_edit_msg); editMsg.addTextChangedListener(FanWallPlugin.this); tabHolder = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder); tabHolder.setBackgroundColor(res.getColor(R.color.black_50_trans)); LinearLayout separator = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder_separator); separator.setBackgroundColor(res.getColor(R.color.white_30_trans)); LinearLayout separatorUp = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder_up); LinearLayout separatorDown = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder_down); tabMapLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_map_layout); tabMapLayout.setOnClickListener(this); tabPhotosLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_photos_layout); tabPhotosLayout.setOnClickListener(this); if (Statics.isSchemaDark) { separatorUp.setBackgroundColor(res.getColor(R.color.white_20_trans)); separatorDown.setBackgroundColor(res.getColor(R.color.white_20_trans)); int temp = Color.WHITE & 0x00ffffff; int result = temp | 0x80000000; noMsgText.setTextColor(result); } else { separatorUp.setBackgroundColor(res.getColor(R.color.black_20_trans)); separatorDown.setBackgroundColor(res.getColor(R.color.black_20_trans)); int temp = Color.BLACK & 0x00ffffff; int result = temp | 0x80000000; noMsgText.setTextColor(result); } noMessagesLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_main_nomessages_layout); messageListLayoutRoot = (FrameLayout) findViewById(R.id.romanblack_fanwall_messagelist_list_layout); messageList = (PullToRefreshListView) findViewById(R.id.romanblack_fanwall_messagelist_pulltorefresh); messageList.setDivider(null); messageList.setBackgroundColor(Color.TRANSPARENT); messageList.setDrawingCacheBackgroundColor(Color.TRANSPARENT); ILoadingLayout loadingLayout = messageList.getLoadingLayoutProxy(); if (Statics.isSchemaDark) { loadingLayout.setHeaderColor(Color.WHITE); } else { loadingLayout.setHeaderColor(Color.BLACK); } //messageList.set adapter = new MainLayoutMessagesAdapter(FanWallPlugin.this, messageList, messages, widget); adapter.setInnerInterface(new MainLayoutMessagesAdapter.onEndReached() { @Override public void endReached() { if (!refreshingBottom) refreshBottom(); } }); messageList.setAdapter(adapter); messageList.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() { @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { refreshTop(); } }); if (Statics.canEdit.compareToIgnoreCase("all") == 0) { bottomBarHodler.setVisibility(View.VISIBLE); } else { bottomBarHodler.setVisibility(View.GONE); } // start downloading messages // exactly in create() method!!! handler.sendEmptyMessage(SHOW_PROGRESS_DIALOG); refreshMessages(); }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//* w w w. j a v a 2s . co m*/ private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mType = cursor.getString(SessionsQuery.TYPE); mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); // Add session feedback link if (getResources().getBoolean(R.bool.has_session_feedback_enabled)) { links.add(new Pair<Integer, Intent>(R.string.session_feedback_submitlink, new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class))); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeBlockUI(context, mSessionBlockStart, mSessionBlockEnd, null, mSubtitle, subtitle); LOGD("Tracker", "Session: " + mTitleString); }
From source file:org.mitre.svmp.activities.SvmpActivity.java
protected void passwordChangePrompt(final ConnectionInfo connectionInfo) { // if this connection uses password authentication, proceed if ((connectionInfo.getAuthType() & PasswordModule.AUTH_MODULE_ID) == PasswordModule.AUTH_MODULE_ID) { // the service is running for this connection, stop it so we can re-authenticate if (SessionService.isRunningForConn(connectionInfo.getConnectionID())) stopService(new Intent(SvmpActivity.this, SessionService.class)); // create the input container final LinearLayout inputContainer = (LinearLayout) getLayoutInflater().inflate(R.layout.auth_prompt, null);//from w w w . j a va 2s.com // set the message TextView message = (TextView) inputContainer.findViewById(R.id.authPrompt_textView_message); message.setText(connectionInfo.getUsername()); final HashMap<IAuthModule, View> moduleViewMap = new HashMap<IAuthModule, View>(); // populate module view map, add input views for each required auth module // (we know at least password input is required) addAuthModuleViews(connectionInfo, moduleViewMap, inputContainer); // loop through the Auth module(s) to find the View for the old password input (needed for validation) View oldPasswordView = null; for (Map.Entry<IAuthModule, View> entry : moduleViewMap.entrySet()) { if (entry.getKey().getID() == PasswordModule.AUTH_MODULE_ID) { oldPasswordView = entry.getValue(); break; } } // add "new password" and "confirm new password" views final PasswordChangeModule module = new PasswordChangeModule(oldPasswordView); View moduleView = module.generateUI(this); moduleViewMap.put(module, moduleView); inputContainer.addView(moduleView); // create a dialog final AlertDialog dialog = new AlertDialog.Builder(SvmpActivity.this).setCancelable(false) .setTitle(R.string.authPrompt_title_passwordChange).setView(inputContainer) .setPositiveButton(R.string.authPrompt_button_positive_text, null).setNegativeButton( R.string.authPrompt_button_negative_text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { busy = false; } }) .create(); // override positive button dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface d) { Button positive = dialog.getButton(AlertDialog.BUTTON_POSITIVE); if (positive != null) { positive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // before continuing, validate the new password inputs int resId = module.areInputsValid(); if (resId == 0) { dialog.dismiss(); // inputs are valid, dismiss the dialog startAppRTCWithAuth(connectionInfo, moduleViewMap); } else { // tell the user that the new password is not valid toastShort(resId); } } }); } } }); // show the dialog dialog.show(); // request keyboard dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } }
From source file:org.ale.openwatch.feeds.RemoteRecordingsListFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { Log.i(TAG, "Item clicked: " + id); try {// w ww .ja va 2 s . co m final int model_id = (Integer) v.getTag(R.id.list_item_model); final OWServerObject server_object = OWServerObject .objects(getActivity().getApplicationContext(), OWServerObject.class).get(model_id); if (v.getTag(R.id.subView) != null && v.getTag(R.id.subView).toString().compareTo("menu") == 0) { Log.i(TAG, "menu click!"); final Context c = getActivity(); LayoutInflater inflater = (LayoutInflater) parentActivity .getSystemService(parentActivity.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.media_menu_popup, (ViewGroup) getActivity().findViewById(R.id.content_frame), false); final AlertDialog dialog = new AlertDialog.Builder(getActivity()).setView(layout).create(); layout.findViewById(R.id.shareButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Share.showShareDialogWithInfo(c, getString(R.string.share_video), server_object.getTitle(c), OWUtils.urlForOWServerObject(server_object, c)); OWServiceRequests.increaseHitCount(c, server_object.getServerId(c), model_id, server_object.getContentType(c), Constants.HIT_TYPE.CLICK); } }); if (((OWServerObjectInterface) server_object.getChildObject(c)).getLat(c) != 0.0) { layout.findViewById(R.id.mapButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Intent i = new Intent(getActivity(), MapActivity.class); i.putExtra(Constants.INTERNAL_DB_ID, model_id); startActivity(i); } }); } else layout.findViewById(R.id.mapButton).setVisibility(View.GONE); layout.findViewById(R.id.reportButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); OWServiceRequests.flagOWServerObjet(getActivity().getApplicationContext(), server_object); } }); dialog.show(); return; } else Log.i(TAG, "non menu click!"); Intent i = null; switch (server_object.getContentType(getActivity().getApplicationContext())) { case INVESTIGATION: //TODO: InvestigationViewActivity i = new Intent(this.getActivity(), OWInvestigationViewActivity.class); break; case VIDEO: // play video inline v.findViewById(R.id.playButton).setVisibility(View.GONE); parentActivity.removeVideoView(); // remove prior VideoView if it exists LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(parentActivity.LAYOUT_INFLATER_SERVICE); //videoViewParent = (ViewGroup) v; parentActivity.videoViewHostCell = (ViewGroup) v; parentActivity.videoViewParent = (ViewGroup) layoutInflater.inflate(R.layout.feed_video_view, (ViewGroup) v, true); parentActivity.videoView = (VideoView) parentActivity.videoViewParent.findViewById(R.id.videoView); if (Build.VERSION.SDK_INT >= 11) parentActivity.videoView.setAlpha(0); parentActivity.progressBar = (ProgressBar) parentActivity.videoViewParent .findViewById(R.id.videoProgress); parentActivity.progressBar.setVisibility(View.VISIBLE); //Log.i(TAG, progressBar.toString()); //RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)videoView.getLayoutParams(); String url = ((OWVideoRecording) server_object .getChildObject(getActivity().getApplicationContext())) .getMediaFilepath(getActivity().getApplicationContext()); OWUtils.setupVideoView(getActivity(), parentActivity.videoView, url, videoViewCallback, parentActivity.progressBar); Log.i(TAG, "created VideoView"); parentActivity.videoViewListIndex = position; break; case AUDIO: case PHOTO: i = new Intent(this.getActivity(), OWMediaObjectViewActivity.class); break; case MISSION: i = new Intent(this.getActivity(), OWMissionViewActivity.class); } if (i != null) { i.putExtra(Constants.INTERNAL_DB_ID, (Integer) v.getTag(R.id.list_item_model)); startActivity(i); } } catch (Exception e) { Log.e(TAG, "failed to load list item model tag"); e.printStackTrace(); return; } }
From source file:org.ozonecity.gpslogger2.GpsMainActivity.java
public void SetUpNavigationDrawer() { final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); final DrawerView drawer = (DrawerView) findViewById(R.id.drawer); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, GetToolbar(), R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { invalidateOptionsMenu();//from w w w.ja v a 2s . c om } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); } }; drawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.primaryColorDark)); drawerLayout.setDrawerListener(drawerToggle); drawerLayout.closeDrawer(drawer); drawer.addDivider(); drawer.addItem(new DrawerItem().setId(1000).setImage(getResources().getDrawable(R.drawable.settings)) .setTextPrimary(getString(R.string.pref_general_title)) .setTextSecondary(getString(R.string.pref_general_summary))); drawer.addItem(new DrawerItem().setId(1).setImage(getResources().getDrawable(R.drawable.loggingsettings)) .setTextPrimary(getString(R.string.pref_logging_title)) .setTextSecondary(getString(R.string.pref_logging_summary))); drawer.addItem(new DrawerItem().setId(2).setImage(getResources().getDrawable(R.drawable.performance)) .setTextPrimary(getString(R.string.pref_performance_title)) .setTextSecondary(getString(R.string.pref_performance_summary))); drawer.addDivider(); drawer.addItem(new DrawerItem().setId(3).setImage(getResources().getDrawable(R.drawable.autosend)) .setTextPrimary(getString(R.string.pref_autosend_title)) .setTextSecondary(getString(R.string.pref_autosend_summary))); drawer.addItem(new DrawerItem().setId(4).setImage(getResources().getDrawable(R.drawable.googledrive)) .setTextPrimary(getString(R.string.gdocs_setup_title))); drawer.addItem(new DrawerItem().setId(5).setImage(getResources().getDrawable(R.drawable.dropbox)) .setTextPrimary(getString(R.string.dropbox_setup_title))); drawer.addItem(new DrawerItem().setId(6).setImage(getResources().getDrawable(R.drawable.email)) .setTextPrimary(getString(R.string.autoemail_title))); drawer.addItem(new DrawerItem().setId(7).setImage(getResources().getDrawable(R.drawable.ftp)) .setTextPrimary(getString(R.string.autoftp_setup_title))); drawer.addItem(new DrawerItem().setId(8).setImage(getResources().getDrawable(R.drawable.opengts)) .setTextPrimary(getString(R.string.opengts_setup_title))); drawer.addItem(new DrawerItem().setId(9).setImage(getResources().getDrawable(R.drawable.openstreetmap)) .setTextPrimary(getString(R.string.osm_setup_title))); drawer.addDivider(); drawer.addItem(new DrawerItem().setId(10).setImage(getResources().getDrawable(R.drawable.helpfaq)) .setTextPrimary(getString(R.string.menu_faq))); drawer.addItem(new DrawerItem().setId(11).setImage(getResources().getDrawable(R.drawable.exit)) .setTextPrimary(getString(R.string.menu_exit))); //drawer.selectItem(3); drawer.setOnItemClickListener(new DrawerItem.OnItemClickListener() { @Override public void onClick(DrawerItem drawerItem, long id, int position) { //drawer.selectItem(3); drawerLayout.closeDrawer(drawer); switch ((int) id) { case 1000: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.GENERAL); break; case 1: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.LOGGING); break; case 2: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.PERFORMANCE); break; case 3: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.UPLOAD); break; case 4: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.GDOCS); break; case 5: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.DROPBOX); break; case 6: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.EMAIL); break; case 7: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.FTP); break; case 8: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.OPENGTS); break; case 9: LaunchPreferenceScreen(MainPreferenceActivity.PreferenceConstants.OSM); break; case 10: Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class); startActivity(faqtivity); break; case 11: EventBus.getDefault().post(new CommandEvents.RequestStartStop(false)); finish(); break; } } }); ImageButton helpButton = (ImageButton) findViewById(R.id.imgHelp); helpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class); startActivity(faqtivity); } }); }
From source file:cx.ring.fragments.CallFragment.java
private void updateSecurityDisplay() { //First we check if all participants use a security layer. boolean secure_call = !getConference().getParticipants().isEmpty(); for (SipCall c : getConference().getParticipants()) secure_call &= c instanceof SecureSipCall && ((SecureSipCall) c).isSecure(); securityIndicator.setVisibility(secure_call ? View.VISIBLE : View.GONE); if (!secure_call) return;/*from w w w .j a va2 s .c o m*/ Log.i(TAG, "Enable security display"); if (getConference().hasMultipleParticipants()) { //TODO What layout should we put? } else { final SecureSipCall secured = (SecureSipCall) getConference().getParticipants().get(0); switch (secured.displayModule()) { case SecureSipCall.DISPLAY_GREEN_LOCK: Log.i(TAG, "DISPLAY_GREEN_LOCK"); showLock(R.drawable.green_lock); break; case SecureSipCall.DISPLAY_RED_LOCK: Log.i(TAG, "DISPLAY_RED_LOCK"); showLock(R.drawable.red_lock); break; case SecureSipCall.DISPLAY_CONFIRM_SAS: final Button sas = (Button) mSecuritySwitch.findViewById(R.id.confirm_sas); sas.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { mCallbacks.getRemoteService().confirmSAS(secured.getCallId()); showLock(R.drawable.green_lock); } catch (RemoteException e) { e.printStackTrace(); } } }); mSecuritySwitch.setDisplayedChild(0); mSecuritySwitch.setVisibility(View.VISIBLE); break; case SecureSipCall.DISPLAY_NONE: break; } } }