List of usage examples for android.graphics Color parseColor
@ColorInt public static int parseColor(@Size(min = 1) String colorString)
From source file:com.dsdar.thosearoundme.TeamViewActivity.java
/** * Method to initialize the components used in team activity *///from w ww.j a va 2 s.c o m @SuppressLint("NewApi") private void initializeComponents() { itsActionBar = getActionBar(); itsActionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); // itsActionBar.setDisplayShowTitleEnabled(false); itsActionBar.setDisplayShowTitleEnabled(true); itsActionBar.setTitle("Those Around Me"); // itsActionBar.setCustomView(R.layout.invitation_count); // itsInvitationcount = (TextView) findViewById(R.id.text2); itsActionBar.setDisplayShowCustomEnabled(true); itsActionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor(ACTION_BAR_COLOR))); // LayoutInflater inflator = (LayoutInflater) this // .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // // View v = inflator.inflate(R.layout.invitation_count, null); itsActionBar.setCustomView(R.layout.invitation_count); itsInvitationcount = (TextView) findViewById(R.id.text2); itsActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); startRefreshTimer(); // if (invite_count != null || invite_count != "") { // itsInvitationcount.setText(invite_count); // } else { // itsInvitationcount.setText(""); // } itsNormalMapView = (TextView) findViewById(R.id.tvMainPageMapMap); itsSatelliteMapView = (TextView) findViewById(R.id.tvMainPageMapSatellite); itsHybridMapView = (TextView) findViewById(R.id.tvMainPageMapHybrid); itsTeamView = (TextView) findViewById(R.id.tvTeamActTeam); itsTeamView.setText("Team"); itsHomeView = (TextView) findViewById(R.id.tvTeamActHome); itsFollowersView = (TextView) findViewById(R.id.tvTeamActFollowers); itsHomeImgBlack = getResources().getDrawable(R.drawable.home_icon_black); itsHomeImgBlack.setBounds(0, 0, imgBounds, imgBounds); itsHomeImgGreen = getResources().getDrawable(R.drawable.home_icon_green); itsHomeImgGreen.setBounds(0, 0, imgBounds, imgBounds); itsTeamImgGreen = getResources().getDrawable(R.drawable.team_icon_green); itsTeamImgGreen.setBounds(0, 0, imgBounds, imgBounds); itsTeamImgBlack = getResources().getDrawable(R.drawable.team_icon_black); itsTeamImgBlack.setBounds(0, 0, imgBounds, imgBounds); itsFollowerImgGreen = getResources().getDrawable(R.drawable.followers_icon_green); itsFollowerImgGreen.setBounds(0, 0, imgBounds, imgBounds); itsFollowerImgBlack = getResources().getDrawable(R.drawable.followers_icon_black); itsFollowerImgBlack.setBounds(0, 0, imgBounds, imgBounds); itsShowAllButton = (Button) findViewById(R.id.tvMainPageShowAllMembers); itsAddTeam = (Button) findViewById(R.id.tvAddTeam); itsAddTeamMember = (Button) findViewById(R.id.tvAddMember); itsTvMan = (Button) findViewById(R.id.tvMan); itsMyLoc = (Button) findViewById(R.id.btnMyLoc); itsStickyMarker = (Button) findViewById(R.id.btnStickyMarker); itsTvMan.setBackgroundResource(R.drawable.map_follow_me_no); itsGPSAlert = (TextView) findViewById(R.id.tvGpsAlert); SupportMapFragment aSupportMapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.TeamViewMap); itsGoogleMap = aSupportMapFragment.getMap(); enableMapsPreference(); // itsGoogleMap.setMyLocationEnabled(true); itsGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); itsGoogleMap.setOnMarkerClickListener(this); itsGoogleMap.setOnMarkerDragListener(this); // itsGoogleMap.setOnMapClickListener(this); itsGoogleMap.setOnMapLongClickListener(this); itsGoogleMap.clear(); }
From source file:com.androguide.apkreator.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override/*www . j ava 2 s.c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_main); /** * Before anything we need to check if the config files exist to avoid * FC is they don't * * @see #checkIfConfigExists() */ checkIfConfigExists(); /** * Now it's all good because if no configuration was found we have * copied a default one over. * * @see #checkIfConfigExists() */ setAppConfigInPrefs(); headers = getPluginTabs(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); /* * set a custom shadow that overlays the main content when the drawer * opens */ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); /* set up the drawer's list view with items and click listener */ ArrayAdapter<String> pimpAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item, mDrawerHeaders); mDrawerList.setAdapter(pimpAdapter); Log.e("FIRST POS", mDrawerList.getFirstVisiblePosition() + ""); Log.e("LAST POS", mDrawerList.getLastVisiblePosition() + ""); View child = mDrawerList.getChildAt(mDrawerList.getFirstVisiblePosition()); if (child != null && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) child.setBackground(getColouredTouchFeedback()); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); /** Set the user-defined ActionBar icon */ File file = new File(getFilesDir() + "/.APKreator/icon.png"); if (file.exists()) { try { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); Uri iconUri = Uri.fromFile(new File(getFilesDir() + "/.APKreator/icon.png")); Bitmap icon = BitmapFactory.decodeFile(iconUri.getPath()); Drawable ic = new BitmapDrawable(icon); getSupportActionBar().setIcon(ic); } catch (NullPointerException e) { Log.e("NPE", e.getMessage()); } } /* * ActionBarDrawerToggle ties together the proper interactions between * the sliding drawer and the action bar app icon */ mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.app_name, /* "open drawer" description for accessibility */ R.string.app_name /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); /* * creates call to * onPrepareOptionsMenu() */ } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); /* * creates call to * onPrepareOptionsMenu() */ } }; mDrawerLayout.setDrawerListener(mDrawerToggle); /** Tabs adapter using the PagerSlidingStrip library */ tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); ViewPager pager = (ViewPager) findViewById(R.id.pager); MyPagerAdapter adapter = new MyPagerAdapter(this.getSupportFragmentManager()); pager.setAdapter(adapter); pager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); tabs.setOnPageChangeListener(this); changeColor(Color.parseColor(getPluginColor())); pager.setOffscreenPageLimit(5); }
From source file:org.sirimangalo.meditationplus.AdapterCommit.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.list_item_commit, parent, false); final View shell = rowView.findViewById(R.id.detail_shell); rowView.setOnClickListener(new View.OnClickListener() { @Override//from w w w .j a va 2 s. co m public void onClick(View view) { boolean visible = shell.getVisibility() == View.VISIBLE; shell.setVisibility(visible ? View.GONE : View.VISIBLE); context.setCommitVisible(position, !visible); } }); final JSONObject p = values.get(position); TextView title = (TextView) rowView.findViewById(R.id.title); TextView descV = (TextView) rowView.findViewById(R.id.desc); TextView defV = (TextView) rowView.findViewById(R.id.def); TextView usersV = (TextView) rowView.findViewById(R.id.users); TextView youV = (TextView) rowView.findViewById(R.id.you); try { if (p.getBoolean("open")) shell.setVisibility(View.VISIBLE); title.setText(p.getString("title")); descV.setText(p.getString("description")); String length = p.getString("length"); String time = p.getString("time"); final String cid = p.getString("cid"); String def = ""; boolean repeat = false; if (length.indexOf(":") > 0) { repeat = true; String[] lengtha = length.split(":"); def += lengtha[0] + " minutes walking and " + lengtha[1] + " minutes sitting"; } else def += length + " minutes total meditation"; String period = p.getString("period"); String day = p.getString("day"); if (period.equals("daily")) { if (repeat) def += " every day"; else def += " per day"; } else if (period.equals("weekly")) { if (repeat) def += " every " + dow[Integer.parseInt(day)]; else def += " per week"; } else if (period.equals("monthly")) { if (repeat) def += " on the " + day + (day.substring(day.length() - 1).equals("1") ? "st" : (day.substring(day.length() - 1).equals("2") ? "nd" : (day.substring(day.length() - 1).equals("3") ? "rd" : "th"))) + " day of the month"; else def += " per month"; } else if (period.equals("yearly")) { if (repeat) def += " on the " + day + (day.substring(day.length() - 1).equals("1") ? "st" : (day.substring(day.length() - 1).equals("2") ? "nd" : (day.substring(day.length() - 1).equals("3") ? "rd" : "th"))) + " day of the year"; else def += " per year"; } if (!time.equals("any")) { Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); utc.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time.split(":")[0])); utc.set(Calendar.MINUTE, Integer.parseInt(time.split(":")[1])); Calendar here = Calendar.getInstance(); here.setTimeInMillis(utc.getTimeInMillis()); int hours = here.get(Calendar.HOUR_OF_DAY); int minutes = here.get(Calendar.MINUTE); def += " at " + (time.length() == 4 ? "0" : "") + time.replace(":", "") + "h UTC <i>(" + (hours > 12 ? hours - 12 : hours) + ":" + ((minutes < 10 ? "0" : "") + minutes) + " " + (hours > 11 && hours < 24 ? "PM" : "AM") + " your time)</i>"; } defV.setText(Html.fromHtml(def)); JSONObject usersJ = p.getJSONObject("users"); ArrayList<String> committedArray = new ArrayList<String>(); // collect into array for (int i = 0; i < usersJ.names().length(); i++) { try { String j = usersJ.names().getString(i); String k = j; // if(j.equals(p.getString("creator"))) // k = "["+j+"]"; committedArray.add(k); } catch (JSONException e) { e.printStackTrace(); } } String text = context.getString(R.string.committed) + " "; // add spans int committed = -1; int pos = text.length(); // start after "Committed: " text += TextUtils.join(", ", committedArray); Spannable span = new SpannableString(text); span.setSpan(new StyleSpan(Typeface.BOLD), 0, pos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // bold the "Online: " for (int i = 0; i < committedArray.size(); i++) { try { final String oneCom = committedArray.get(i); String userCom = usersJ.getString(oneCom); //String userCom = usersJ.getString(oneCom.replace("[", "").replace("]", "")); //if(oneCom.replace("[","").replace("]","").equals(loggedUser)) if (oneCom.equals(loggedUser)) committed = Integer.parseInt(userCom); int end = pos + oneCom.length(); ClickableSpan clickable = new ClickableSpan() { @Override public void onClick(View widget) { context.showProfile(oneCom); } }; span.setSpan(clickable, pos, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new UnderlineSpan() { public void updateDrawState(TextPaint tp) { tp.setUnderlineText(false); } }, pos, end, 0); String color = Utils.makeRedGreen(Integer.parseInt(userCom), true); span.setSpan(new ForegroundColorSpan(Color.parseColor("#FF" + color)), pos, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); pos += oneCom.length() + 2; } catch (JSONException e) { e.printStackTrace(); } } usersV.setText(span); usersV.setMovementMethod(new LinkMovementMethod()); if (loggedUser != null && loggedUser.length() > 0) { LinearLayout bl = (LinearLayout) rowView.findViewById(R.id.commit_buttons); if (!usersJ.has(loggedUser)) { Button commitB = new Button(context); commitB.setId(R.id.commit_button); commitB.setText(R.string.commit); commitB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); context.doSubmit("commitform_" + cid, nvp, true); } }); bl.addView(commitB); } else { Button commitB = new Button(context); commitB.setId(R.id.uncommit_button); commitB.setText(R.string.uncommit); commitB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); context.doSubmit("uncommitform_" + cid, nvp, true); } }); bl.addView(commitB); } if (loggedUser.equals(p.getString("creator")) || context.isAdmin) { Button commitB2 = new Button(context); commitB2.setId(R.id.edit_commit_button); commitB2.setText(R.string.edit); commitB2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(context, ActivityCommit.class); i.putExtra("commitment", p.toString()); context.startActivity(i); } }); bl.addView(commitB2); Button commitB3 = new Button(context); commitB3.setId(R.id.uncommit_button); commitB3.setText(R.string.delete); commitB3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); context.doSubmit("delcommitform_" + cid, nvp, true); } }); bl.addView(commitB3); } } if (committed > -1) { int color = Color.parseColor("#FF" + Utils.makeRedGreen(committed, false)); rowView.setBackgroundColor(color); } if (committed != -1) { youV.setText(String.format(context.getString(R.string.you_commit_x), committed)); youV.setVisibility(View.VISIBLE); } } catch (Exception e) { e.printStackTrace(); } return rowView; }
From source file:com.insthub.O2OMobile.View.A0_RequestListView.java
private void changeTextColor(View view) { if (view == mFilterPriceDesc) { mFilterPriceDesc.setTextColor(Color.parseColor("#39BCED")); mFilterPriceAsc.setTextColor(Color.parseColor("#333333")); mFilterTime.setTextColor(Color.parseColor("#333333")); mFilterLocation.setTextColor(Color.parseColor("#333333")); mFilterPriceDescIcon.setVisibility(View.VISIBLE); mFilterPriceAscIcon.setVisibility(View.GONE); mFilterTimeIcon.setVisibility(View.GONE); mFilterLocationIcon.setVisibility(View.GONE); } else if (view == mFilterPriceAsc) { mFilterPriceDesc.setTextColor(Color.parseColor("#333333")); mFilterPriceAsc.setTextColor(Color.parseColor("#39BCED")); mFilterTime.setTextColor(Color.parseColor("#333333")); mFilterLocation.setTextColor(Color.parseColor("#333333")); mFilterPriceDescIcon.setVisibility(View.GONE); mFilterPriceAscIcon.setVisibility(View.VISIBLE); mFilterTimeIcon.setVisibility(View.GONE); mFilterLocationIcon.setVisibility(View.GONE); } else if (view == mFilterTime) { mFilterPriceDesc.setTextColor(Color.parseColor("#333333")); mFilterPriceAsc.setTextColor(Color.parseColor("#333333")); mFilterTime.setTextColor(Color.parseColor("#39BCED")); mFilterLocation.setTextColor(Color.parseColor("#333333")); mFilterPriceDescIcon.setVisibility(View.GONE); mFilterPriceAscIcon.setVisibility(View.GONE); mFilterTimeIcon.setVisibility(View.VISIBLE); mFilterLocationIcon.setVisibility(View.GONE); } else if (view == mFilterLocation) { mFilterPriceDesc.setTextColor(Color.parseColor("#333333")); mFilterPriceAsc.setTextColor(Color.parseColor("#333333")); mFilterTime.setTextColor(Color.parseColor("#333333")); mFilterLocation.setTextColor(Color.parseColor("#39BCED")); mFilterPriceDescIcon.setVisibility(View.GONE); mFilterPriceAscIcon.setVisibility(View.GONE); mFilterTimeIcon.setVisibility(View.GONE); mFilterLocationIcon.setVisibility(View.VISIBLE); }/* w w w. ja va2s. c om*/ }
From source file:app.jorge.mobile.com.transportalert.ScrollingActivity.java
private void addCard(LinearLayout item, CardFactory.TUBE_LINE line) { CardTube card = CardFactory.getCard(line); View child = getLayoutInflater().inflate(R.layout.tube_line, null); ImageView imageView = (ImageView) child.findViewById(R.id.iconTube); //imageView.setImageResource(card.getIcon()); imageView.setImageBitmap(decodeSampledBitmapFromResource(getResources(), card.getIcon(), 100, 100)); TextView lineName = (TextView) child.findViewById(R.id.tubeName); lineName.setText(card.getName());//from ww w .ja va2 s.co m lineName.setTextColor(Color.parseColor(card.getColour())); TextView text = (TextView) child.findViewById(R.id.tubeStatus); text.setText(card.getStatus()); item.addView(child); child.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View imageView = v.findViewById(R.id.iconTube); imageView.setTransitionName(getString(R.string.activity_image_trans)); View textTubeNameView = v.findViewById(R.id.tubeName); textTubeNameView.setTransitionName(getString(R.string.activity_text_tube_name)); View textStatusView = v.findViewById(R.id.tubeStatus); textStatusView.setTransitionName(getString(R.string.activity_text_tube_status)); Intent intent = new Intent(ScrollingActivity.this, DetailActivity.class); Pair<View, String> pair1 = Pair.create(imageView, imageView.getTransitionName()); Pair<View, String> pair2 = Pair.create(textTubeNameView, textTubeNameView.getTransitionName()); Pair<View, String> pair3 = Pair.create(textStatusView, textStatusView.getTransitionName()); ActivityOptionsCompat options = ActivityOptionsCompat .makeSceneTransitionAnimation(ScrollingActivity.this, pair1, pair2, pair3); String line = ((TextView) textTubeNameView).getText().toString(); String status = ((TextView) textStatusView).getText().toString(); LineStatuses ls = tubeStatus.get(line); if ((ls != null) && (ls.getDisruption() != null)) { intent.putExtra(getString(R.string.activity_info_category), ls.getDisruption().getCategory()); intent.putExtra(getString(R.string.activity_info_description), ls.getDisruption().getDescription()); intent.putExtra(getString(R.string.activity_info_additional), ls.getDisruption().getAdditionalInfo()); intent.putExtra(getString(R.string.activity_info_icon), line); intent.putExtra(getString(R.string.activity_info_status), status); startActivity(intent, options.toBundle()); } } }); }
From source file:com.openerp.addons.messages.Message.java
public void setupListView(List<OEListViewRows> message_list) { // Destroying pre-loaded instance and going to create new one lstview = null;/* w w w . java 2s . co m*/ // Fetching required messages for listview by filtering of requrement if (list != null && list.size() <= 0) { list = message_list;// getMessages(message_list); } else { rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE); rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE); } // Handling List View controls and keys String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date", "model|type" }; int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred, R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db, true, new int[] { R.drawable.message_listview_bg_toread_selector, R.drawable.message_listview_bg_tonotread_selector }, "to_read"); // Telling adapter to clean HTML text for key value listAdapter.cleanHtmlToTextOn("body"); listAdapter.cleanDate("date", scope.User().getTimezone()); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) { String model_name = row_data.getRow_data().get("model").toString(); String model = model_name; String res_id = row_data.getRow_data().get("res_id").toString(); if (model_name.equals("false")) { model_name = capitalizeString(row_data.getRow_data().get("type").toString()); } else { String[] model_parts = TextUtils.split(model_name, "\\."); HashSet unique_parts = new HashSet(Arrays.asList(model_parts)); model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray())); } TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag); int tag_color = 0; if (message_model_colors.containsKey(model_name)) { tag_color = message_model_colors.get(model_name); } else { tag_color = Color.parseColor(tag_colors[tag_color_count]); message_model_colors.put(model_name, tag_color); tag_color_count++; if (tag_color_count > tag_colors.length) { tag_color_count = 0; } } if (model.equals("mail.group")) { if (UserGroups.group_names.containsKey("group_" + res_id)) { model_name = UserGroups.group_names.get("group_" + res_id); tag_color = UserGroups.menu_color.get("group_" + res_id); } } msgTag.setBackgroundColor(tag_color); msgTag.setText(model_name); TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject); TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom); if (row_data.getRow_data().get("to_read").toString().equals("false")) { txvSubject.setTypeface(null, Typeface.NORMAL); txvSubject.setTextColor(Color.BLACK); txvAuthor.setTypeface(null, Typeface.NORMAL); txvAuthor.setTextColor(Color.BLACK); } else { txvSubject.setTypeface(null, Typeface.BOLD); txvSubject.setTextColor(Color.parseColor("#414141")); txvAuthor.setTypeface(null, Typeface.BOLD); txvAuthor.setTextColor(Color.parseColor("#414141")); } return row_view; } }); // Creating instance for listview control lstview = (ListView) rootView.findViewById(R.id.lstMessages); // Providing adapter to listview scope.context().runOnUiThread(new Runnable() { @Override public void run() { lstview.setAdapter(listAdapter); } }); // Setting listview choice mode to multiple model lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); // Seeting item long click listern to activate action mode. lstview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) { // TODO Auto-generated method stub OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index); Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show(); view.setSelected(true); if (mActionMode != null) { return false; } // Start the CAB using the ActionMode.Callback defined above mActionMode = scope.context().startActionMode(mActionModeCallback); selectedCounter++; view.setBackgroundResource(R.drawable.listitem_pressed); // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); return true; } }); // Setting multi choice selection listener lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() { HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>(); @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are // selected/de-selected, // such as update the title in the CAB selectedList.put(position, checked); if (checked) { selectedCounter++; } else { selectedCounter--; } if (selectedCounter != 0) { mode.setTitle(selectedCounter + ""); } } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>(); OEDialog dialog = null; switch (item.getItemId()) { case R.id.menu_message_mark_unread_selected: Log.e("menu_message_context", "Mark as Unread"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_mark_read_selected: Log.e("menu_message_context", "Mark as Read"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_move_to_archive_selected: Log.e("menu_message_context", "Archive"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_add_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, true); markasTodoTask.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_remove_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, false); markasTodoTask.execute((Void) null); mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_fragment_message_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are // deselected/unchecked. /* * Perform Operation on Selected Ids. * * row_ids are list of selected message Ids. */ selectedList.clear(); selectedCounter = 0; lstview.clearChoices(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } }); lstview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int index, long id) { // TODO Auto-generated method stub MessageDetail messageDetail = new MessageDetail(); Bundle bundle = new Bundle(); bundle.putInt("message_id", list.get(index).getRow_id()); bundle.putInt("position", index); messageDetail.setArguments(bundle); scope.context().fragmentHandler.setBackStack(true, null); scope.context().fragmentHandler.replaceFragmnet(messageDetail); if (!type.equals("archive")) { list.remove(index); } listAdapter.refresh(list); } }); // Getting Pull To Refresh Attacher from Main Activity mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher(); // Set the Refreshable View to be the ListView and the refresh listener // to be this. if (mPullToRefreshAttacher != null & lstview != null) { mPullToRefreshAttacher.setRefreshableView(lstview, this); } }
From source file:com.github.hobbe.android.openkarotz.karotz.OpenKarotz.java
@Override public void led(int color, boolean pulse) throws IOException { int rgb = color & 0x00FFFFFF; if (pulse == state.isPulsing() && rgb == state.getLedColor()) { // No change return;//from ww w . ja v a 2 s .c om } String c = toColorCode(rgb); URL url = new URL(api, CGI_BIN + "/leds?color=" + c + (pulse ? "&pulse=1" : "")); Log.d(LOG_TAG, url.toString()); String result = NetUtils.downloadUrl(url); Log.d(LOG_TAG, result); // Answer: {"color":"0000FF","secondary_color":"000000","pulse":"0","no_memory":"0","speed":"700","return":"0"} // Answer: {"return":"1","msg":"Unable to perform action, rabbit is sleeping."} try { JSONObject json = new JSONObject(result); boolean ok = "0".equals(json.getString("return")); if (ok) { state.setLedColor(Color.parseColor("#" + json.getString("color"))); state.setPulsing("1".equals(json.getString("pulse"))); return; } } catch (JSONException e) { Log.e(LOG_TAG, "Cannot change LED on Karotz: " + e.getMessage(), e); } // Not OK, set back to previous values state.setLedColor(rgb); state.setPulsing(pulse); }
From source file:com.cflp.zwl.view.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from w w w . ja va2 s. c om mSelectedTabIndex = item; mViewPager.setCurrentItem(item); TabView view = (TabView) mTabLayout.getChildAt(item); PagerAdapter adapter = mViewPager.getAdapter(); view.setTextColor(Color.parseColor(((IconPagerAdapter) mViewPager.getAdapter()).getIconResId(0))); if (((IconPagerAdapter) mViewPager.getAdapter()).getIconResId(0).equals("#CC0000")) { view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_meeting); } else if (((IconPagerAdapter) mViewPager.getAdapter()).getIconResId(0).equals("#3366ff")) { switch (view.getWidth()) { case 408: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_408); break; case 205: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_205); break; case 164: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_164); break; case 105: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_105); break; case 82: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_82); break; default: view.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.tab_line_164); } } final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } } }
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of * the barcode.//from w w w.ja v a 2 s . c om * * @param barcode * A bitmap of the captured image. * @param scaleFactor * amount by which thumbnail was scaled * @param rawResult * The decoded results which contains the points to draw. */ private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(Color.parseColor("#c099cc00")); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1], scaleFactor); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and // metadata drawLine(canvas, paint, points[0], points[1], scaleFactor); drawLine(canvas, paint, points[2], points[3], scaleFactor); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint); } } } }
From source file:com.filemanager.free.utils.MainActivityHelper.java
public void guideDialogForLEXA(String path) { final MaterialDialog.Builder x = new MaterialDialog.Builder(mainActivity); if (mainActivity.theme1 == 1) x.theme(Theme.DARK);//from w ww. jav a2 s . com x.title(R.string.needsaccess); LayoutInflater layoutInflater = (LayoutInflater) mainActivity .getSystemService(mainActivity.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.lexadrawer, null); x.customView(view, true); // textView TextView textView = (TextView) view.findViewById(R.id.description); textView.setText(utils.getString(mainActivity, R.string.needsaccesssummary) + path + utils.getString(mainActivity, R.string.needsaccesssummary1)); ((ImageView) view.findViewById(R.id.icon)).setImageResource(R.drawable.sd_operate_step); x.positiveText(R.string.open); x.negativeText(R.string.cancel); x.positiveColor(Color.parseColor(mainActivity.fabskin)); x.negativeColor(Color.parseColor(mainActivity.fabskin)); x.callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog materialDialog) { triggerStorageAccessFramework(); } @Override public void onNegative(MaterialDialog materialDialog) { Toast.makeText(mainActivity, R.string.error, Toast.LENGTH_SHORT).show(); } }); final MaterialDialog y = x.build(); y.show(); }