List of usage examples for android.view View.OnClickListener View.OnClickListener
View.OnClickListener
From source file:org.ale.openwatch.feeds.RemoteRecordingsListFragment.java
private void addListViewHeader() { if (feed.compareTo(Constants.OWFeedType.MISSION.toString().toLowerCase()) == 0) { if (getActivity() == null) return; LayoutInflater inflater = (LayoutInflater) parentActivity .getSystemService(parentActivity.LAYOUT_INFLATER_SERVICE); View missionHeader = inflater.inflate(R.layout.mission_header, (ViewGroup) getListView(), false); if (missionHeader != null) { missionHeader.setOnClickListener(new View.OnClickListener() { @Override/* w w w . j a v a2 s . com*/ public void onClick(View v) { final View missionHeader = v; SharedPreferences.Editor profile = getActivity() .getSharedPreferences(Constants.PROFILE_PREFS, 0).edit(); profile.putBoolean(Constants.MISSION_TIP, true); profile.commit(); Animation fadeOut = AnimationUtils.loadAnimation(v.getContext(), R.anim.fadeout); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { missionHeader.findViewById(R.id.missionBadge).setVisibility(View.GONE); missionHeader.findViewById(R.id.missionButton).setVisibility(View.GONE); missionHeader.findViewById(R.id.tapToDismiss).setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); v.startAnimation(fadeOut); } }); } this.getListView().addHeaderView(missionHeader); } }
From source file:com.egoclean.testpregnancy.util.ActivityHelper.java
/** * Adds an action button to the compatibility action bar, using menu information from a * {@link android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state * can be changed to show a loading spinner using * {@link ActivityHelper#setRefreshActionButtonCompatState(boolean)}. *//* w w w . j a va 2s. c om*/ private View addActionButtonCompatFromMenuItem(final MenuItem item) { final ViewGroup actionBar = getActionBarCompat(); if (actionBar == null) { return null; } // Create the separator ImageView separator = new ImageView(mActivity, null, R.attr.actionbarCompatSeparatorStyle); separator.setLayoutParams(new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.FILL_PARENT)); // Create the button ImageButton actionButton = new ImageButton(mActivity, null, R.attr.actionbarCompatButtonStyle); actionButton.setId(item.getItemId()); actionButton.setLayoutParams(new ViewGroup.LayoutParams( (int) mActivity.getResources().getDimension(R.dimen.actionbar_compat_height), ViewGroup.LayoutParams.FILL_PARENT)); actionButton.setImageDrawable(item.getIcon()); actionButton.setScaleType(ImageView.ScaleType.CENTER); actionButton.setContentDescription(item.getTitle()); actionButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item); } }); actionBar.addView(separator); actionBar.addView(actionButton); if (item.getItemId() == R.id.menu_refresh) { // Refresh buttons should be stateful, and allow for indeterminate progress indicators, // so add those. int buttonWidth = mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height); int buttonWidthDiv3 = buttonWidth / 3; ProgressBar indicator = new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle); LinearLayout.LayoutParams indicatorLayoutParams = new LinearLayout.LayoutParams(buttonWidthDiv3, buttonWidthDiv3); indicatorLayoutParams.setMargins(buttonWidthDiv3, buttonWidthDiv3, buttonWidth - 2 * buttonWidthDiv3, 0); indicator.setLayoutParams(indicatorLayoutParams); indicator.setVisibility(View.GONE); indicator.setId(R.id.menu_refresh_progress); actionBar.addView(indicator); } return actionButton; }
From source file:org.jitsi.android.gui.call.VideoCallActivity.java
/** * Initializes the microphone button view. *///from w w w . j a va 2s . c om private void initMicrophoneView() { final ImageView microphoneButton = (ImageView) findViewById(R.id.callMicrophoneButton); microphoneButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CallManager.setMute(call, !isMuted()); } }); microphoneButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { DialogFragment newFragment = VolumeControlDialog.createInputVolCtrlDialog(); newFragment.show(getSupportFragmentManager(), "vol_ctrl_dialog"); return true; } }); }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { getActivity().finish();/* ww w. j av a 2s.c o m*/ return true; } case R.id.AddLog: { try { addMessageDialog = new Dialog(getActivity()); addMessageDialog.setContentView(R.layout.add_message); addMessageDialog.setTitle("Add Message to Event Log"); ((Button) addMessageDialog.findViewById(R.id.SaveButton)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AddLogMessage(((EditText) addMessageDialog.findViewById(R.id.LogMessage)).getText() .toString()); addMessageDialog.dismiss(); } }); addMessageDialog.show(); return true; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventFragmentUpdate", "AddLog", e); return false; } } case R.id.escalate: { try { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Add data to the intent, the receiving app will decide what to do with it. intent.putExtra(Intent.EXTRA_SUBJECT, "Escalation of Zenoss Event on " + Title.getText()); String EventDetails = Summary.getText() + "\r\r\n" + LastTime.getText() + "\r\r\n" + "Count: " + EventCount.getText(); intent.putExtra(Intent.EXTRA_TEXT, EventDetails); startActivity(Intent.createChooser(intent, "How would you like to escalate this event?")); return true; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventFragmentUpdate", "escalate", e); return false; } } default: { return false; } } }
From source file:uk.ac.hutton.ics.buntata.adapter.NodeAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final BuntataNodeAdvanced item = dataset.get(position); boolean foundImage = false; /* Try to find an image */ File imagePath = null;// w ww . j a v a 2 s.c om BuntataMediaAdvanced medium = null; if (item.getMediaAdvanced().size() > 0) { /* First, check if we've got the same image as our parent. If so, show this one preferably */ for (BuntataMediaAdvanced m : item.getMediaAdvanced()) { if (m.getId() == parentMediaId) { medium = m; foundImage = true; imagePath = FileUtils.getFileForDatasource(context, datasource.getId(), m.getInternalLink()); break; } } /* If we don't, check all our media and pick the first "Image" */ if (!foundImage) { BuntataMediaAdvanced m = item.getFirstImage(); if (m != null) { medium = m; foundImage = true; imagePath = FileUtils.getFileForDatasource(context, datasource.getId(), m.getInternalLink()); } } } /* Get the width of the view */ int viewWidth = (parent.getWidth() - left - right - (columnCount - 1) * padding) / columnCount; if (context instanceof MainActivity && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { holder.image.setTransitionName(context.getString(R.string.transition_node_view)); } /* If this is within the NodeDetailsActivity, then restrict the size of the items */ if (context instanceof NodeDetailsActivity) { viewWidth = context.getResources().getDimensionPixelSize(R.dimen.node_image_height) / 2; holder.image.setMaxHeight(viewWidth); holder.image.setMaxWidth(viewWidth); holder.layout.getLayoutParams().width = viewWidth; } holder.image.setMinimumHeight(viewWidth); /* If no image is found */ if (!foundImage) { Picasso.get().load(R.drawable.missing_image).error(R.drawable.missing_image) .resize(viewWidth, viewWidth) // Resize to fit .centerInside().into(holder.image); } /* If an image is found */ else { /* Load the image */ PaletteTransformation paletteTransformation; RequestCreator c = Picasso.get().load(imagePath); /* Load from file */ final boolean showKeys = datasource.isShowKeyName(); if (showKeys) { paletteTransformation = PaletteTransformation.instance(); c.transform(paletteTransformation); /* Generate the palette based on the image */ } c.resize(viewWidth, viewWidth) /* Resize to fit */ .onlyScaleDown() /* But only scale down */ .centerCrop() /* And respect the aspect ratio */ .into(holder.image, new Callback.EmptyCallback() /* When done, use the palette */ { @Override public void onError(Exception e) { /* Set the placeholder */ holder.image.setImageResource(R.drawable.missing_image); holder.image.setScaleType(ImageView.ScaleType.CENTER_INSIDE); } @Override public void onSuccess() { holder.image.setScaleType(ImageView.ScaleType.CENTER_CROP); if (showKeys) { /* Get back the bitmap */ Bitmap bitmap = ((BitmapDrawable) holder.image.getDrawable()).getBitmap(); /* Ew! */ /* Get the generated palette */ Palette palette = PaletteTransformation.getPalette(bitmap); /* Get the vibrant color and a high-contrast text color */ /* Try a couple of fallback colors. Hopefully one of them is present. */ int vibrantColor = palette.getVibrantColor(defaultBackgroundColor); if (vibrantColor == defaultBackgroundColor) vibrantColor = palette.getDarkVibrantColor(defaultBackgroundColor); if (vibrantColor == defaultBackgroundColor) vibrantColor = palette.getLightVibrantColor(defaultBackgroundColor); if (vibrantColor == defaultBackgroundColor) vibrantColor = palette.getMutedColor(defaultBackgroundColor); if (vibrantColor == defaultBackgroundColor) vibrantColor = palette.getDarkMutedColor(defaultBackgroundColor); if (vibrantColor == defaultBackgroundColor) vibrantColor = palette.getLightMutedColor(defaultBackgroundColor); if (vibrantColor == defaultBackgroundColor) vibrantColor = palette.getDominantColor(defaultBackgroundColor); int textColor = ColorUtils.isColorDark(vibrantColor) ? textColorLight : textColorDark; holder.title.setBackgroundColor(vibrantColor); holder.title.setTextColor(textColor); } } }); } holder.title.setText(item.getName()); if (datasource.isShowKeyName() || !item.hasChildren()) holder.title.setVisibility(View.VISIBLE); else holder.title.setVisibility(View.GONE); final BuntataMediaAdvanced m = medium; /* Listen to click events */ holder.view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int top = v.getTop(); if (top < 0 && USE_DIRTY_HACK_TO_FIX_SHARED_ELEMENT_TRANSITION) { /* * This is a very dirty hack to fix an issue where shared elements will overlap the toolbar and status bar * when the node is hidden behind them on click. Solutions on Stackoverflow suggested to include the toolbar * and status bar in the shared elements transition. This, however, didn't seem to work, thus this solution. * The view is then scrolled "into view" and the shared elements transition is postponed until the scroll * event finishes. */ parent.smoothScrollToPosition(holder.getAdapterPosition()); parent.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE) { parent.removeOnScrollListener(this); onNodeClicked(holder.image, holder.title, m, dataset.get(holder.getAdapterPosition())); } } }); } else { onNodeClicked(holder.image, holder.title, m, dataset.get(holder.getAdapterPosition())); } } }); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
/** * Refreshes funds table with fetched data * * @param response JSONObject with funds data *///www . j a va 2s. co m private void refreshFunds(JSONObject response) { try { if (response == null) { Toast.makeText(getActivity(), getResources().getString(R.string.GeneralErrorText), Toast.LENGTH_LONG).show(); return; } String notificationText; if (response.getInt("success") == 1) { View.OnClickListener fillAmount = new View.OnClickListener() { @Override public void onClick(View v) { ScrollView scrollView = (ScrollView) getView(); if (scrollView != null) { EditText tradeAmount = (EditText) scrollView.findViewById(R.id.TradeAmount); tradeAmount.setText(((TextView) v).getText()); scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom()); } } }; notificationText = getResources().getString(R.string.FundsInfoUpdatedtext); TableLayout fundsContainer = (TableLayout) getView().findViewById(R.id.FundsContainer); fundsContainer.removeAllViews(); JSONObject funds = response.getJSONObject("return").getJSONObject("funds"); JSONArray fundsNames = response.getJSONObject("return").getJSONObject("funds").names(); List<String> arrayList = new ArrayList<>(); for (int i = 0; i < fundsNames.length(); i++) { arrayList.add(fundsNames.getString(i)); } Collections.sort(arrayList); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); for (String anArrayList : arrayList) { TableRow row = new TableRow(getActivity()); TextView currency = new TextView(getActivity()); TextView amount = new TextView(getActivity()); currency.setText(anArrayList.toUpperCase(Locale.US)); amount.setText(funds.getString(anArrayList)); currency.setLayoutParams(layoutParams); currency.setTypeface(Typeface.DEFAULT, Typeface.BOLD); currency.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); currency.setGravity(Gravity.CENTER); amount.setLayoutParams(layoutParams); amount.setGravity(Gravity.CENTER); amount.setOnClickListener(fillAmount); row.addView(currency); row.addView(amount); fundsContainer.addView(row); } } else { notificationText = response.getString("error"); } mCallback.makeNotification(ConstantHolder.ACCOUNT_INFO_NOTIF_ID, notificationText); } catch (JSONException e) { e.printStackTrace(); } }
From source file:org.mitre.svmp.activities.AppRTCVideoActivity.java
private void createTopPanel() { // TODO Auto-generated method stub ll.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2 s. co m*/ public void onClick(View v) { // TODO Auto-generated method stub } }); ImageView homeStreamingBtn = (ImageView) findViewById(R.id.homeStreamingBtn); homeStreamingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(AppRTCVideoActivity.this, OvalDrawerActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); disconnectAndExit(); } }); ImageView stopStreamingBtn = (ImageView) findViewById(R.id.stopStreamingBtn); stopStreamingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub disconnectAndExit(); } }); scrollUpImgVw.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // TODO Auto-generated method stub if (scrollClicked == false) { scrollClicked = true; Vibrator vb = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(50); // vsv.onPause(); vsvProgrssBar.setVisibility(View.VISIBLE); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { vsvProgrssBar.setVisibility(View.INVISIBLE); // vsv.onResume(); scrollClicked = false; } }, 2000); SVMPProtocol.Request.Builder msg = SVMPProtocol.Request.newBuilder(); SVMPProtocol.TouchEvent.Builder eventmsg = SVMPProtocol.TouchEvent.newBuilder(); eventmsg.setAction(51); msg.setType(RequestType.TOUCHEVENT); msg.addTouch(eventmsg); // TODO: batch touch events // Send touch event to VM sendMessage(msg.build()); } } }); scrolldownImgVw.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // TODO Auto-generated method stub if (scrollClicked == false) { scrollClicked = true; Vibrator vb = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(50); // vsv.onPause(); vsvProgrssBar.setVisibility(View.VISIBLE); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { vsvProgrssBar.setVisibility(View.INVISIBLE); //vsv.onResume(); scrollClicked = false; } }, 2000); SVMPProtocol.Request.Builder msg = SVMPProtocol.Request.newBuilder(); SVMPProtocol.TouchEvent.Builder eventmsg = SVMPProtocol.TouchEvent.newBuilder(); eventmsg.setAction(50); msg.setType(RequestType.TOUCHEVENT); msg.addTouch(eventmsg); // TODO: batch touch events // Send touch event to VM sendMessage(msg.build()); } } }); ((ViewGroup) scrollBtnsRLayout.getParent()).removeView(scrollBtnsRLayout); ((ViewGroup) ll.getParent()).removeView(ll); }
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { try {/*w w w . java2s .c o m*/ DataFramework.getInstance().open(this, Utils.packageName); } catch (Exception e) { e.printStackTrace(); } super.onCreate(savedInstanceState); CacheData.getInstance().fillHide(); ConnectionManager.getInstance().open(this); ConnectionManager.getInstance().loadUsers(); OnAlarmReceiver.callAlarm(this); if (PreferenceUtils.getFinishForceClose(this)) { PreferenceUtils.setFinishForceClose(this, false); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.title_crash); builder.setMessage(R.string.msg_crash); builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Utils.sendLastCrash(TweetTopicsActivity.this); } }); builder.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); builder.create(); builder.show(); } Thread.UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler(); if (currentHandler != null) { Thread.setDefaultUncaughtExceptionHandler(new ErrorReporter(currentHandler, getApplication())); } if (PreferenceManager.getDefaultSharedPreferences(this).getString("prf_orientation", "2").equals("2")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } // borrar notificaciones if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("prf_notif_delete_notifications_inside", true)) { ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll(); } long goToColumnPosition = -1; int goToColumnType = -1; long goToColumnUser = -1; long goToColumnSearch = -1; long selectedTweetId = -1; Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_POSITION)) { goToColumnPosition = extras.getLong(KEY_EXTRAS_GOTO_COLUMN_POSITION); } if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_TYPE)) { goToColumnType = extras.getInt(KEY_EXTRAS_GOTO_COLUMN_TYPE); } if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_USER)) { goToColumnUser = extras.getLong(KEY_EXTRAS_GOTO_COLUMN_USER); } if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_SEARCH)) { goToColumnSearch = extras.getLong(KEY_EXTRAS_GOTO_COLUMN_SEARCH); } if (extras.containsKey(KEY_EXTRAS_GOTO_TWEET_ID)) { selectedTweetId = extras.getLong(KEY_EXTRAS_GOTO_TWEET_ID); } } int positionFromSensor = -1; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SAVE_STATE_COLUMN_POS)) { positionFromSensor = savedInstanceState.getInt(KEY_SAVE_STATE_COLUMN_POS); } Utils.createDirectoriesIfIsNecessary(); Display display = getWindowManager().getDefaultDisplay(); widthScreen = display.getWidth(); heightScreen = display.getHeight(); themeManager = new ThemeManager(this); themeManager.setTheme(); setContentView(R.layout.tweettopics_activity); fragmentAdapter = new TweetTopicsFragmentAdapter(this, getSupportFragmentManager()); pager = (ViewPager) findViewById(R.id.tweet_pager); pager.setAdapter(fragmentAdapter); indicator = (TitlePageIndicator) findViewById(R.id.tweettopics_bar_indicator); indicator.setFooterIndicatorStyle(TitlePageIndicator.IndicatorStyle.Triangle); indicator.setFooterLineHeight(0); indicator.setFooterColor(Color.WHITE); indicator.setClipPadding(-getWindowManager().getDefaultDisplay().getWidth()); indicator.setViewPager(pager); indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i1) { } @Override public void onPageSelected(int i) { reloadBarAvatar(); if (i == 0) { refreshMyActivity(); } } @Override public void onPageScrollStateChanged(int i) { } }); indicator.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showActionBarColumns(); } }); findViewById(R.id.tweettopics_bar_my_activity).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showActionBarIndicatorAndMovePager(0); } }); findViewById(R.id.tweettopics_bar_options).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showMenuColumnsOptions(view); } }); layoutOptionsColumns = (LinearLayout) findViewById(R.id.tweettopics_ll_options_columns); layoutMainOptionsColumns = (LinearLayout) findViewById(R.id.tweettopics_ll_main_options_columns); layoutMainOptionsColumns.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideOptionsColumns(); } }); btnOptionsColumnsMain = (Button) findViewById(R.id.tweettopics_ll_options_columns_btn_main); btnOptionsColumnsMain.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int pos = Integer.valueOf(view.getTag().toString()); Toast.makeText(TweetTopicsActivity.this, getString(R.string.column_main_message, fragmentAdapter.setColumnActive(pos)), Toast.LENGTH_LONG).show(); hideOptionsColumns(); } }); btnOptionsColumnsEdit = (Button) findViewById(R.id.tweettopics_ll_options_columns_btn_edit); btnOptionsColumnsEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int pos = Integer.valueOf(view.getTag().toString()); EditColumnDialogFragment frag = new EditColumnDialogFragment( fragmentAdapter.getFragmentList().get(pos), new Callable() { @Override public Object call() throws Exception { refreshActionBarColumns(); return null; } }); frag.show(getSupportFragmentManager(), "dialog"); hideOptionsColumns(); } }); // cargar el popup de enlaces FrameLayout root = ((FrameLayout) findViewById(R.id.tweettopics_root)); popupLinks = new PopupLinks(this); popupLinks.loadPopup(root); splitActionBarMenu = new SplitActionBarMenu(this); splitActionBarMenu.loadSplitActionBarMenu(root); layoutBackgroundApp = (RelativeLayout) findViewById(R.id.tweettopics_layout_background_app); layoutBackgroundBar = (RelativeLayout) findViewById(R.id.tweettopics_bar_background); horizontalScrollViewColumns = (HorizontalScrollView) findViewById(R.id.tweettopics_bar_horizontal_scroll); layoutBackgroundColumnsBarContainer = (LinearLayout) findViewById(R.id.tweettopics_bar_columns_container); layoutBackgroundColumnsBar = (LinearLayout) findViewById(R.id.tweettopics_bar_columns); // layoutBackgroundColumnsBar.setCols(4); // // layoutBackgroundColumnsBar.setOnRearrangeListener(new OnRearrangeListener() { // public void onRearrange(int oldIndex, int newIndex) { // reorganizeColumns(oldIndex, newIndex); // } // // @Override // public void onStartDrag(int x, int index) { // showOptionsColumns(x, index, true); // } // // @Override // public void onMoveDragged(int index) { // hideOptionsColumns(); // } // // }); // layoutBackgroundColumnsBar.setOnItemClickListener(new AdapterView.OnItemClickListener() { // @Override // public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // showActionBarIndicatorAndMovePager(position); // } // }); imgBarAvatar = (ImageView) findViewById(R.id.tweettopics_bar_avatar); imgBarAvatarBg = (ImageView) findViewById(R.id.tweettopics_bar_avatar_bg); imgBarCounter = (TextView) findViewById(R.id.tweettopics_bar_counter); imgNewStatus = (ImageView) findViewById(R.id.tweettopics_bar_new_status); imgNewStatus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { newStatus(); } }); imgBarAvatarGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { if (fragmentAdapter.instantiateItem(pager, pager.getCurrentItem()) instanceof BaseListFragment) { ((BaseListFragment) fragmentAdapter.instantiateItem(pager, pager.getCurrentItem())).goToTop(); } } @Override public boolean onDoubleTap(MotionEvent e) { if (fragmentAdapter.instantiateItem(pager, pager.getCurrentItem()) instanceof BaseListFragment) { ((BaseListFragment) fragmentAdapter.instantiateItem(pager, pager.getCurrentItem())).goToTop(); } return true; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { animateDragged(); return true; } @Override public boolean onDown(MotionEvent e) { return true; } }); imgBarAvatarBg.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { return imgBarAvatarGestureDetector.onTouchEvent(motionEvent); } }); refreshTheme(); reloadBarAvatar(); refreshActionBarColumns(); if (goToColumnType >= 0) { if ((goToColumnType == TweetTopicsUtils.COLUMN_TIMELINE || goToColumnType == TweetTopicsUtils.COLUMN_MENTIONS || goToColumnType == TweetTopicsUtils.COLUMN_DIRECT_MESSAGES) && goToColumnUser >= 0) { openUserColumn(goToColumnUser, goToColumnType); } if (goToColumnType == TweetTopicsUtils.COLUMN_SEARCH && goToColumnSearch > 0) { openSearchColumn(new Entity("search", goToColumnSearch)); } } else if (goToColumnType == TweetTopicsUtils.COLUMN_MY_ACTIVITY) { } else if (goToColumnPosition > 0) { goToColumn((int) goToColumnPosition, false, selectedTweetId); } else if (positionFromSensor >= 0) { goToColumn(positionFromSensor, false, selectedTweetId); } else { int col = fragmentAdapter.getPositionColumnActive(); if (col > 0) goToColumn(col, false, selectedTweetId); } // comprobar si hay que proponer ir al market int access_count = PreferenceUtils.getApplicationAccessCount(this); if (access_count <= 20) { if (access_count == 20) { try { AlertDialog dialog = DialogUtils.RateAppDialogBuilder.create(this); dialog.show(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } PreferenceUtils.setApplicationAccessCount(this, access_count + 1); } PreferenceUtils.showChangeLog(this, true); }
From source file:com.juick.android.UserCenterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { JuickAdvancedApplication.setupTheme(this); handler = new Handler(); super.onCreate(savedInstanceState); setContentView(R.layout.user_center); final ListView list = (ListView) findViewById(R.id.list); final View listWait = findViewById(R.id.list_wait); final TextView userRealName = (TextView) findViewById(R.id.user_realname); final ImageView userPic = (ImageView) findViewById(R.id.userpic); final TextView userName = (TextView) findViewById(R.id.username); search = findViewById(R.id.search);//from w w w. j a v a2 s. c o m final View stats = findViewById(R.id.stats); userRealName.setText("..."); Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } uname = extras.getString("uname"); final int uid = extras.getInt("uid"); final MessageID mid = (MessageID) extras.getSerializable("mid"); final MessagesSource messagesSource = (MessagesSource) extras.getSerializable("messagesSource"); if (uname == null || mid == null) { finish(); return; } int height = getWindow().getWindowManager().getDefaultDisplay().getHeight(); final int userpicSize = height <= 320 ? 32 : 96; float scaledDensity = getResources().getDisplayMetrics().scaledDensity; userPic.setMinimumHeight((int) (scaledDensity * userpicSize)); userPic.setMinimumWidth((int) (scaledDensity * userpicSize)); stats.setEnabled(false); userName.setText("@" + uname); final boolean russian = Locale.getDefault().getLanguage().equals("ru"); new Thread() { @Override public void run() { final Utils.RESTResponse json = Utils.getJSON(UserCenterActivity.this, "http://" + Utils.JA_ADDRESS + "/api/userinfo?uname=" + Uri.encode(uname), null); runOnUiThread(new Runnable() { @Override public void run() { stats.setEnabled(true); if (json.getErrorText() != null) { Toast.makeText(UserCenterActivity.this, "JA server: " + json.getErrorText(), Toast.LENGTH_LONG).show(); listWait.setVisibility(View.GONE); } else { final UserInfo userInfo = new Gson().fromJson(json.getResult(), UserInfo.class); if (userInfo == null) { Toast.makeText(UserCenterActivity.this, "Unable to parse JSON", Toast.LENGTH_LONG) .show(); listWait.setVisibility(View.GONE); } else { userRealName.setText(userInfo.fullName); listWait.setVisibility(View.GONE); list.setVisibility(View.VISIBLE); list.setAdapter(new BaseAdapter() { @Override public int getCount() { return userInfo.getExtraInfo().size(); } @Override public Object getItem(int position) { return userInfo.getExtraInfo().get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = getLayoutInflater().inflate(R.layout.listitem_userinfo, null); } TextView text = (TextView) convertView.findViewById(R.id.text); TextView text2 = (TextView) convertView.findViewById(R.id.text2); String info = userInfo.getExtraInfo().get(position); int ix = info.indexOf("|"); if (ix == -1) { text.setText(info); if (russian && UserInfo.translations.containsKey(info)) { info = UserInfo.translations.get(info); } text2.setText(""); } else { String theInfo = info.substring(0, ix); if (russian && UserInfo.translations.containsKey(theInfo)) { theInfo = UserInfo.translations.get(theInfo); } text.setText(theInfo); String value = info.substring(ix + 1); if (value.startsWith("Date:")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); value = value.substring(5); value = sdf.format(new Date(Long.parseLong(value))); } text2.setText(value); } return convertView; } }); } } } }); } }.start(); View subscribe_user = findViewById(R.id.subscribe_user); View unsubscribe_user = findViewById(R.id.unsubscribe_user); View subscribe_comments = findViewById(R.id.subscribe_comments); View unsubscribe_comments = findViewById(R.id.unsubscribe_comments); View filter_user = findViewById(R.id.filter_user); View blacklist_user = findViewById(R.id.blacklist_user); View show_blog = findViewById(R.id.show_blog); MicroBlog microBlog = MainActivity.getMicroBlog(mid.getMicroBlogCode()); final MessageMenu mm = microBlog.getMessageMenu(this, messagesSource, null, null); JuickMessage message = microBlog.createMessage(); mm.listSelectedItem = message; message.User = new JuickUser(); message.User.UName = uname; message.User.UID = uid; message.setMID(mid); final UserpicStorage.AvatarID avatarID = microBlog.getAvatarID(message); final UserpicStorage.Listener userpicListener = new UserpicStorage.Listener() { @Override public void onUserpicReady(UserpicStorage.AvatarID id, int size) { final UserpicStorage.Listener thiz = this; runOnUiThread(new Runnable() { @Override public void run() { UserpicStorage.instance.removeListener(avatarID, userpicSize, thiz); final Bitmap userpic = UserpicStorage.instance.getUserpic(UserCenterActivity.this, avatarID, userpicSize, thiz); userPic.setImageBitmap(userpic); // can be null } }); } }; Bitmap userpic = UserpicStorage.instance.getUserpic(this, avatarID, userpicSize, userpicListener); userPic.setImageBitmap(userpic); // can be null subscribe_user.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mm.actionSubscribeUser(); } }); show_blog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mm.listSelectedItem.User.UID == 0) { JuickMicroBlog.obtainProperUserIdByName(UserCenterActivity.this, mm.listSelectedItem.User.UName, "Getting Juick User Id", new Utils.Function<Void, Pair<String, String>>() { @Override public Void apply(Pair<String, String> cred) { mm.listSelectedItem.User.UID = Integer.parseInt(cred.first); mm.actionUserBlog(); return null; } }); } else { mm.actionUserBlog(); } } }); search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { search.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(0, SEARCH_PAST_CONVERSATIONS, 0, "My dialogs with user"); menu.add(0, SEARCH_MORE, 1, "More"); } }); search.showContextMenu(); } }); stats.setOnClickListener(new View.OnClickListener() { NewJuickPreferenceActivity.MenuItem[] items = new NewJuickPreferenceActivity.MenuItem[] { new NewJuickPreferenceActivity.MenuItem(R.string.UserAllTimeActivityReport, R.string.UserAllTimeActivityReport2, new Runnable() { @Override public void run() { NewJuickPreferenceActivity.showChart(UserCenterActivity.this, "USER_ACTIVITY_VOLUME", "uid=" + uid); } }), new NewJuickPreferenceActivity.MenuItem(R.string.UserHoursReport, R.string.UserHoursReport2, new Runnable() { @Override public void run() { NewJuickPreferenceActivity.showChart(UserCenterActivity.this, "USER_HOURS_ACTIVITY", "uid=" + uid + "&tzoffset=" + TimeZone.getDefault().getRawOffset() / 1000 / 60 / 60); } }) }; @Override public void onClick(View v) { list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { items[position].action.run(); } }); list.setAdapter(new BaseAdapter() { @Override public int getCount() { return items.length; } @Override public Object getItem(int position) { return items[position]; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater layoutInflater = getLayoutInflater(); View listItem = layoutInflater.inflate(android.R.layout.simple_list_item_2, null); TextView text = (TextView) listItem.findViewById(android.R.id.text1); text.setText(items[position].labelId); TextView text2 = (TextView) listItem.findViewById(android.R.id.text2); text2.setText(items[position].label2Id); return listItem; } }); } }); blacklist_user.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mm.actionBlacklistUser(); } }); filter_user.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mm.actionFilterUser(uname); } }); unsubscribe_user.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mm.actionUnsubscribeUser(); } }); subscribe_comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enableJAM(new Runnable() { @Override public void run() { JAMService.instance.client.subscribeToComments(uname); } }); } }); unsubscribe_comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enableJAM(new Runnable() { @Override public void run() { JAMService.instance.client.unsubscribeFromComments(uname); } }); } }); }
From source file:th.in.ffc.person.visit.VisitAncPregnancyActivity.java
private void doInitializeView(Bundle savedInstanceState) { PregNo = (EditText) findViewById(R.id.code); Hint = (TextView) findViewById(R.id.hint); FpBefore = (ArrayFormatSpinner) findViewById(R.id.contracep); FpBefore.setArray(R.array.contracep); FirstAbNormal = (ArrayFormatSpinner) findViewById(R.id.abnormal); FirstAbNormal.setArray(R.array.abnormal); RiskLayout = (LinearLayout) findViewById(R.id.risk); lmp = (ThaiDatePicker) findViewById(R.id.lmp); edc = (ThaiDatePicker) findViewById(R.id.edc); refresh = (ImageView) findViewById(R.id.refresh); refresh.setOnClickListener(new View.OnClickListener() { @Override//from ww w. java 2 s . c o m public void onClick(View v) { Date l = lmp.getDate(); edc.updateDate(l.year + 1, (l.month - 3 - 1) % 11, l.day); } }); if (savedInstanceState == null) { Date date = Date.newInstance(DateTime.getCurrentDate()); lmp.updateDate(date.year, date.month - 1, date.day); edc.updateDate(date.year + 1, (date.month - 3 - 1) % 11, date.day); } }