List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.androidquery.AbstractAQuery.java
/** * Set the image of an ImageView./*from w w w . j ava2 s .co m*/ * * @param resid the resource id * @return self * * @see testImage1 */ public T image(int resid) { if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setTag(AQuery.TAG_URL, null); if (resid == 0) { iv.setImageBitmap(null); } else { iv.setImageResource(resid); } } return self(); }
From source file:co.taqat.call.LinphoneActivity.java
private void displayMainAccount() { defaultAccount.setVisibility(View.VISIBLE); ImageView status = (ImageView) defaultAccount.findViewById(R.id.main_account_status); TextView address = (TextView) defaultAccount.findViewById(R.id.main_account_address); TextView displayName = (TextView) defaultAccount.findViewById(R.id.main_account_display_name); LinphoneProxyConfig proxy = LinphoneManager.getLc().getDefaultProxyConfig(); if (proxy == null) { displayName.setText(getString(R.string.no_account)); status.setVisibility(View.GONE); address.setText(""); statusFragment.resetAccountStatus(); LinphoneManager.getInstance().subscribeFriendList(false); defaultAccount.setOnClickListener(new OnClickListener() { @Override//from w ww .j a v a 2 s . com public void onClick(View view) { LinphoneActivity.instance().displayAccountSettings(0); openOrCloseSideMenu(false); } }); } else { //address.setText(proxy.getAddress().asStringUriOnly()); displayName.setText(LinphoneUtils.getAddressDisplayName(proxy.getAddress())); status.setImageResource(getStatusIconResource(proxy.getState())); status.setVisibility(View.VISIBLE); defaultAccount.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { LinphoneActivity.instance() .displayAccountSettings(LinphonePreferences.instance().getDefaultAccountIndex()); openOrCloseSideMenu(false); } }); } }
From source file:com.filemanager.free.activities.MainActivity.java
@SuppressLint("InflateParams") private void initialiseViews() { mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame); appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }/*from w w w . ja va 2 s . co m*/ if (displayImageOptions != null) { displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565).build(); } buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else { assert mDrawerLinear != null; mDrawerLinear.setBackgroundColor(Color.WHITE); } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); } View v = findViewById(R.id.fab_bg); if (theme1 == 1) { assert v != null; v.setBackgroundColor(Color.parseColor("#a6ffffff")); } assert v != null; v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) { assert divider != null; divider.setImageResource(R.color.divider); } else { assert divider != null; divider.setImageResource(R.color.divider_dark); } setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { assert settingsbutton != null; settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert settingsbutton != null; settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { assert appbutton != null; appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert appbutton != null; appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } //admob mAdView = (View) findViewById(R.id.ads); }
From source file:com.amaze.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }/*from w w w. jav a2 s. c o m*/ displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); if (theme1 == 1) v.setBackgroundColor(Color.parseColor("#a6ffffff")); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } }
From source file:com.igniva.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from w w w.jav a2 s. c o m displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); mFabBackground = findViewById(R.id.fab_bg); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); /*if (theme1 != 1) v.setBackgroundColor(Color.parseColor("#a6ffffff"));*/ v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (theme1 == 1) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(getResources().getColor(android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(getResources().getColor(android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }
From source file:android.melbournehistorymap.MapsActivity.java
/** * Manipulates the map once available./*w w w .ja v a2s.c o m*/ * This callback is triggered when the map is ready to be used. * This is where we can add markers or lines, add listeners or move the camera. In this case, * we just add a marker near Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; spinner = (ProgressBar) findViewById(R.id.prograssSpinner); //check if permission has been granted if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Permission has already been granted return; } mMap.setMyLocationEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(false); double lat; double lng; final int radius; int zoom; lat = Double.parseDouble(CurrLat); lng = Double.parseDouble(CurrLong); //build current location LatLng currentLocation = new LatLng(lat, lng); final LatLng realLocation = currentLocation; if (MELBOURNE.contains(currentLocation)) { mMap.getUiSettings().setMyLocationButtonEnabled(true); zoom = 17; } else { mMap.getUiSettings().setMyLocationButtonEnabled(false); lat = -37.81161508043379; lng = 144.9647320434451; zoom = 15; currentLocation = new LatLng(lat, lng); } mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 13)); CameraPosition cameraPosition = new CameraPosition.Builder().target(currentLocation) // Sets the center of the map to location user .zoom(zoom) // Sets the zoom .bearing(0) // Sets the orientation of the camera to east .tilt(25) // Sets the tilt of the camera to 30 degrees .build(); // Creates a CameraPosition from the builder //Animate user to map location, if in Melbourne or outside of Melbourne bounds mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), new GoogleMap.CancelableCallback() { @Override public void onFinish() { updateMap(); } @Override public void onCancel() { } }); final TextView placeTitle = (TextView) findViewById(R.id.placeTitle); final TextView placeVic = (TextView) findViewById(R.id.placeVic); final TextView expPlaceTitle = (TextView) findViewById(R.id.expPlaceTitle); final TextView expPlaceVic = (TextView) findViewById(R.id.expPlaceVic); final TextView expPlaceDescription = (TextView) findViewById(R.id.placeDescription); final TextView wikiLicense = (TextView) findViewById(R.id.wikiLicense); final TextView expPlaceDistance = (TextView) findViewById(R.id.expPlaceDistance); final RelativeLayout tile = (RelativeLayout) findViewById(R.id.tile); final TextView fab = (TextView) findViewById(R.id.fab); final RelativeLayout distanceCont = (RelativeLayout) findViewById(R.id.distanceContainer); // String license = "Text is available under the <a rel=\"license\" href=\"//en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License\">Creative Commons Attribution-ShareAlike License</a><a rel=\"license\" href=\"//creativecommons.org/licenses/by-sa/3.0/\" style=\"display:none;\"></a>;\n" + // "additional terms may apply."; // wikiLicense.setText(Html.fromHtml(license)); // wikiLicense.setMovementMethod(LinkMovementMethod.getInstance()); //Marker click mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { String title = marker.getTitle(); mMap.setPadding(0, 0, 0, 620); //set clicked marker to full opacity marker.setAlpha(1f); //set previous marker back to partial opac (if there is a prevMarker if (dirtyMarker == 1) { prevMarker.setAlpha(0.6f); } prevMarker = marker; dirtyMarker = 1; //Set DB helper DBHelper myDBHelper = new DBHelper(MapsActivity.this, WikiAPI.DB_NAME, null, WikiAPI.VERSION); //Only search for Wiki API requests if no place article returned. // ** //Open DB as readable only. SQLiteDatabase db = myDBHelper.getReadableDatabase(); //Set the query String dbFriendlyName = title.replace("\'", "\'\'"); //Limit by 1 rows Cursor cursor = db.query(DBHelper.TABLE_NAME, null, "PLACE_NAME = '" + dbFriendlyName + "'", null, null, null, null, "1"); //move through each row returned in the query results while (cursor.moveToNext()) { String place_ID = cursor.getString(cursor.getColumnIndex("PLACE_ID")); String placeName = cursor.getString(cursor.getColumnIndex("PLACE_NAME")); String placeLoc = cursor.getString(cursor.getColumnIndex("PLACE_LOCATION")); String placeArticle = cursor.getString(cursor.getColumnIndex("ARTICLE")); String placeLat = cursor.getString(cursor.getColumnIndex("LAT")); String placeLng = cursor.getString(cursor.getColumnIndex("LNG")); //Get Google Place photos //Source: https://developers.google.com/places/android-api/photos final String placeId = place_ID; Places.GeoDataApi.getPlacePhotos(mGoogleApiClient, placeId) .setResultCallback(new ResultCallback<PlacePhotoMetadataResult>() { @Override public void onResult(PlacePhotoMetadataResult photos) { if (!photos.getStatus().isSuccess()) { return; } ImageView mImageView = (ImageView) findViewById(R.id.imageView); ImageView mImageViewExpanded = (ImageView) findViewById(R.id.headerImage); TextView txtAttribute = (TextView) findViewById(R.id.photoAttribute); TextView expTxtAttribute = (TextView) findViewById(R.id.expPhotoAttribute); PlacePhotoMetadataBuffer photoMetadataBuffer = photos.getPhotoMetadata(); if (photoMetadataBuffer.getCount() > 0) { // Display the first bitmap in an ImageView in the size of the view photoMetadataBuffer.get(0).getScaledPhoto(mGoogleApiClient, 600, 200) .setResultCallback(mDisplayPhotoResultCallback); //get photo attributions PlacePhotoMetadata photo = photoMetadataBuffer.get(0); CharSequence attribution = photo.getAttributions(); if (attribution != null) { txtAttribute.setText(Html.fromHtml(String.valueOf(attribution))); expTxtAttribute.setText(Html.fromHtml(String.valueOf(attribution))); //http://stackoverflow.com/questions/4303160/how-can-i-make-links-in-fromhtml-clickable-android txtAttribute.setMovementMethod(LinkMovementMethod.getInstance()); expTxtAttribute.setMovementMethod(LinkMovementMethod.getInstance()); } else { txtAttribute.setText(" "); expTxtAttribute.setText(" "); } } else { //Reset image view as no photo was identified mImageView.setImageResource(android.R.color.transparent); mImageViewExpanded.setImageResource(android.R.color.transparent); txtAttribute.setText(R.string.no_photos); expTxtAttribute.setText(R.string.no_photos); } photoMetadataBuffer.release(); } }); LatLng destLocation = new LatLng(Double.parseDouble(placeLat), Double.parseDouble(placeLng)); //Work out distance between current location and place location //Source Library: https://github.com/googlemaps/android-maps-utils double distance = SphericalUtil.computeDistanceBetween(realLocation, destLocation); distance = Math.round(distance); distance = distance * 0.001; String strDistance = String.valueOf(distance); String[] arrDistance = strDistance.split("\\."); String unit = "km"; if (arrDistance[0] == "0") { unit = "m"; strDistance = arrDistance[1]; } else { strDistance = arrDistance[0] + "." + arrDistance[1].substring(0, 1); } placeArticle = placeArticle .replaceAll("(<div class=\"thumb t).*\\s.*\\s.*\\s.*\\s.*\\s<\\/div>\\s<\\/div>", " "); Spannable noUnderlineMessage = new SpannableString(Html.fromHtml(placeArticle)); //http://stackoverflow.com/questions/4096851/remove-underline-from-links-in-textview-android for (URLSpan u : noUnderlineMessage.getSpans(0, noUnderlineMessage.length(), URLSpan.class)) { noUnderlineMessage.setSpan(new UnderlineSpan() { public void updateDrawState(TextPaint tp) { tp.setUnderlineText(false); } }, noUnderlineMessage.getSpanStart(u), noUnderlineMessage.getSpanEnd(u), 0); } placeArticle = String.valueOf(noUnderlineMessage); placeArticle = placeArticle.replaceAll("(\\[\\d\\])", " "); placeTitle.setText(placeName); expPlaceTitle.setText(placeName); placeVic.setText(placeLoc); expPlaceVic.setText(placeLoc); expPlaceDescription.setText(placeArticle); if (MELBOURNE.contains(realLocation)) { expPlaceDistance.setText("Distance: " + strDistance + unit); distanceCont.setVisibility(View.VISIBLE); } } tile.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE); //Set to true to not show default behaviour. return false; } }); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { int viewStatus = tile.getVisibility(); if (viewStatus == View.VISIBLE) { tile.setVisibility(View.INVISIBLE); fab.setVisibility(View.INVISIBLE); //set previous marker back to partial opac (if there is a prevMarker if (dirtyMarker == 1) { prevMarker.setAlpha(0.6f); } } mMap.setPadding(0, 0, 0, 0); } }); FloatingActionButton shareIcon = (FloatingActionButton) findViewById(R.id.shareIcon); shareIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //https://www.google.com.au/maps/place/Federation+Square/@-37.8179789,144.9668635,15z //Build implicit intent by triggering a SENDTO action, which will capture applications that allow for messages //that allow for messages to be sent to a specific user with data //http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); //Build SMS String encodedPlace = "empty"; try { encodedPlace = URLEncoder.encode(String.valueOf(expPlaceTitle.getText()), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } intent.putExtra(Intent.EXTRA_TEXT, String.valueOf(expPlaceTitle.getText()) + " \n\nhttps://www.google.com.au/maps/place/" + encodedPlace); Intent sms = Intent.createChooser(intent, null); startActivity(sms); } }); TextView fullArticle = (TextView) findViewById(R.id.fullArticle); fullArticle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String wikiPlace = WikiPlace.getName(String.valueOf(expPlaceTitle.getText())); String url = "https://en.wikipedia.org/wiki/" + wikiPlace; Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browserIntent); } }); }
From source file:com.jrummyapps.android.colorpicker.ColorPickerDialog.java
void createColorShades(@ColorInt final int color) { final int[] colorShades = getColorShades(color); if (shadesLayout.getChildCount() != 0) { for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); final ColorPanelView cpv = layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = layout.findViewById(R.id.cpv_color_image_view); cpv.setColor(colorShades[i]); cpv.setTag(false);//from ww w. ja va2s .co m iv.setImageDrawable(null); } return; } final int horizontalPadding = getResources().getDimensionPixelSize(R.dimen.cpv_item_horizontal_padding); for (final int colorShade : colorShades) { int layoutResId; if (colorShape == ColorShape.SQUARE) { layoutResId = R.layout.cpv_color_item_square; } else { layoutResId = R.layout.cpv_color_item_circle; } final View view = View.inflate(getActivity(), layoutResId, null); final ColorPanelView colorPanelView = view.findViewById(R.id.cpv_color_panel_view); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) colorPanelView.getLayoutParams(); params.leftMargin = params.rightMargin = horizontalPadding; colorPanelView.setLayoutParams(params); colorPanelView.setColor(colorShade); shadesLayout.addView(view); colorPanelView.post(new Runnable() { @Override public void run() { // The color is black when rotating the dialog. This is a dirty fix. WTF!? colorPanelView.setColor(colorShade); } }); colorPanelView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v.getTag() instanceof Boolean && (Boolean) v.getTag()) { colorPickerDialogListener.onColorSelected(dialogId, ColorPickerDialog.this.color); dismiss(); return; // already selected } ColorPickerDialog.this.color = colorPanelView.getColor(); adapter.selectNone(); for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); ColorPanelView cpv = layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = layout.findViewById(R.id.cpv_color_image_view); iv.setImageResource(cpv == v ? R.drawable.cpv_preset_checked : 0); if (cpv == v && ColorUtils.calculateLuminance(cpv.getColor()) >= 0.65 || Color.alpha(cpv.getColor()) <= ALPHA_THRESHOLD) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { iv.setColorFilter(null); } cpv.setTag(cpv == v); } } }); colorPanelView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { colorPanelView.showHint(); return true; } }); } }
From source file:com.jaredrummler.android.colorpicker.ColorPickerDialog.java
void createColorShades(@ColorInt final int color) { final int[] colorShades = getColorShades(color); if (shadesLayout.getChildCount() != 0) { for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); final ColorPanelView cpv = (ColorPanelView) layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = (ImageView) layout.findViewById(R.id.cpv_color_image_view); cpv.setColor(colorShades[i]); cpv.setTag(false);//from w w w .ja va 2 s . c o m iv.setImageDrawable(null); } return; } final int horizontalPadding = getResources().getDimensionPixelSize(R.dimen.cpv_item_horizontal_padding); for (final int colorShade : colorShades) { int layoutResId; if (colorShape == ColorShape.SQUARE) { layoutResId = R.layout.cpv_color_item_square; } else { layoutResId = R.layout.cpv_color_item_circle; } final View view = View.inflate(getActivity(), layoutResId, null); final ColorPanelView colorPanelView = (ColorPanelView) view.findViewById(R.id.cpv_color_panel_view); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) colorPanelView.getLayoutParams(); params.leftMargin = params.rightMargin = horizontalPadding; colorPanelView.setLayoutParams(params); colorPanelView.setColor(colorShade); shadesLayout.addView(view); colorPanelView.post(new Runnable() { @Override public void run() { // The color is black when rotating the dialog. This is a dirty fix. WTF!? colorPanelView.setColor(colorShade); } }); colorPanelView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v.getTag() instanceof Boolean && (Boolean) v.getTag()) { colorPickerDialogListener.onColorSelected(dialogId, ColorPickerDialog.this.color); dismiss(); return; // already selected } ColorPickerDialog.this.color = colorPanelView.getColor(); adapter.selectNone(); for (int i = 0; i < shadesLayout.getChildCount(); i++) { FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i); ColorPanelView cpv = (ColorPanelView) layout.findViewById(R.id.cpv_color_panel_view); ImageView iv = (ImageView) layout.findViewById(R.id.cpv_color_image_view); iv.setImageResource(cpv == v ? R.drawable.cpv_preset_checked : 0); if (cpv == v && ColorUtils.calculateLuminance(cpv.getColor()) >= 0.65 || Color.alpha(cpv.getColor()) <= ALPHA_THRESHOLD) { iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN); } else { iv.setColorFilter(null); } cpv.setTag(cpv == v); } } }); colorPanelView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { colorPanelView.showHint(); return true; } }); } }
From source file:cm.aptoide.pt.MainActivity.java
private void loadUi() { setContentView(R.layout.activity_aptoide); TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.indicator); pager = (ViewPager) findViewById(R.id.viewpager); if (!ApplicationAptoide.MULTIPLESTORES) { depth = ListDepth.CATEGORY1;//from w w w . j a v a 2 s. c o m store_id = 1; } updateView.findViewById(R.id.update_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { updateAll(); } }); availableListView.setFastScrollEnabled(true); availableListView.addHeaderView(breadcrumbs, null, false); registerForContextMenu(updatesListView); updatesListView.setLongClickable(true); availableView.findViewById(R.id.refresh_view_layout).findViewById(R.id.refresh_view) .setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { refreshClick = true; availableView.findViewById(R.id.refresh_view_layout).setVisibility(View.GONE); refreshAvailableList(false); } }); joinStores.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { joinStores_boolean = isChecked; // if (isChecked) { // addBreadCrumb("All Stores", depth); // } else { // breadcrumbs.removeAllViews(); // } refreshAvailableList(true); } }); bindService(serviceDownloadManagerIntent, serviceManagerConnection, BIND_AUTO_CREATE); pb.setText(R.string.add_store_button_below); addStoreButton.setOnClickListener(addStoreListener); if (!ApplicationAptoide.MULTIPLESTORES) { addStoreButton.setVisibility(View.GONE); } availableListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i; View v = availableListView.getChildAt(0); scrollMemory.put(depth, new ListViewPosition((v == null) ? 0 : v.getTop(), availableListView.getFirstVisiblePosition())); switch (depth) { case STORES: depth = ListDepth.CATEGORY1; store_id = id; break; case CATEGORY1: String category = ((Cursor) parent.getItemAtPosition(position)).getString(1); if (category.equals("Top Apps")) { depth = ListDepth.TOPAPPS; } else if (category.equals("Latest Apps")) { depth = ListDepth.LATESTAPPS; } else if (id == LATEST_LIKES) { depth = ListDepth.LATEST_LIKES; } else if (id == LATEST_COMMENTS) { depth = ListDepth.LATEST_COMMENTS; } else if (id == -3) { if (!Login.isLoggedIn(mContext)) { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.you_need_to_login_toast), Toast.LENGTH_SHORT); toast.show(); return; } else { depth = ListDepth.RECOMMENDED; } } else if (id == -4) { depth = ListDepth.ALLAPPLICATIONS; } else if (id == -10) { Toast toast = Toast.makeText(mContext, mContext.getString(R.string.store_beginning_to_load), Toast.LENGTH_SHORT); toast.show(); return; } else { depth = ListDepth.CATEGORY2; } category_id = id; break; case CATEGORY2: depth = ListDepth.APPLICATIONS; category2_id = id; break; case TOPAPPS: i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", true); i.putExtra("category", Category.TOP.ordinal()); startActivity(i); return; case LATESTAPPS: i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", true); i.putExtra("category", Category.LATEST.ordinal()); startActivity(i); return; case APPLICATIONS: case ALLAPPLICATIONS: case RECOMMENDED: i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("top", false); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); return; case LATEST_COMMENTS: case LATEST_LIKES: String apkid = ((Cursor) parent.getItemAtPosition(position)).getString(1); latestClick(apkid); return; default: return; } addBreadCrumb(((Cursor) parent.getItemAtPosition(position)).getString(1), depth); refreshAvailableList(true); } }); installedView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) { Intent i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("installed", true); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); } }); ImageView brandIv = (ImageView) findViewById(R.id.brand); if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("jblow")) { brandIv.setImageResource(R.drawable.brand_jblow); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("magalhaes")) { brandIv.setImageResource(R.drawable.brand_magalhaes); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("timwe")) { brandIv.setImageResource(R.drawable.brand_timwe); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("digitallydifferent")) { brandIv.setImageResource(R.drawable.brand_digitallydifferent); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("eocean")) { brandIv.setImageResource(R.drawable.brand_eocean); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("educomp")) { brandIv.setImageResource(R.drawable.brand_educomp); } else if (ApplicationAptoide.APTOIDETHEME.equalsIgnoreCase("peoplenet")) { brandIv.setImageResource(R.drawable.brand_peoplenet); } else if (ApplicationAptoide.BRAND != null) { brandIv.setImageResource(getBrandDrawableResource()); } else { brandIv.setImageResource(R.drawable.brand_aptoide); } findViewById(R.id.btsearch).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onSearchRequested(); } }); updatesListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) { Intent i = new Intent(MainActivity.this, ApkInfo.class); i.putExtra("_id", id); i.putExtra("updates", true); i.putExtra("category", Category.INFOXML.ordinal()); startActivity(i); } }); // LoaderManager.enableDebugLogging(true); availableLoader = getSupportLoaderManager().initLoader(AVAILABLE_LOADER, null, this); ArrayList<View> views = new ArrayList<View>(); views.add(featuredView); views.add(availableView); views.add(installedView); views.add(updateView); pager.setAdapter(new ViewPagerAdapter(mContext, views)); indicator.setViewPager(pager); refreshAvailableList(true); if (!ApplicationAptoide.MULTIPLESTORES) { addBreadCrumb(getString(R.string.store), ListDepth.CATEGORY1); } else { addBreadCrumb(getString(R.string.stores), ListDepth.STORES); } if (!ApplicationAptoide.MATURECONTENTSWITCH) { featuredView.findViewById(R.id.toggleButton1).setVisibility(View.GONE); featuredView.findViewById(R.id.adultcontent_label).setVisibility(View.GONE); } }
From source file:com.android.mtkex.chips.BaseRecipientAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { /// M: add view holder to improve performance. DropDownListViewHolder viewHolder;/*from ww w . j ava2 s.c o m*/ /// M: get view holder from convert view. @{ if (convertView == null) { convertView = mInflater.inflate(getItemLayout(), parent, false); viewHolder = new DropDownListViewHolder(); if (convertView != null) { viewHolder.name = (TextView) convertView.findViewById(getDisplayNameId()); viewHolder.dest = (TextView) convertView.findViewById(getDestinationId()); viewHolder.destType = (TextView) convertView.findViewById(getDestinationTypeId()); viewHolder.img = (ImageView) convertView.findViewById(getPhotoId()); convertView.setTag(viewHolder); } } else { viewHolder = (DropDownListViewHolder) convertView.getTag(); } /// @} final RecipientEntry entry = getEntries().get(position); String displayName = entry.getDisplayName(); String destination = entry.getDestination(); if (TextUtils.isEmpty(displayName) || TextUtils.equals(displayName, destination)) { displayName = destination; // We only show the destination for secondary entries, so clear it // only for the first level. if (entry.isFirstLevel()) { destination = null; } } /// M: get properties from view holder. @{ final View itemView = convertView; final TextView displayNameView = viewHolder.name; final TextView destinationView = viewHolder.dest; final TextView destinationTypeView = viewHolder.destType; final ImageView imageView = viewHolder.img; /// @} displayNameView.setText(displayName); if (!TextUtils.isEmpty(destination)) { destinationView.setText(destination); } else { destinationView.setText(null); } if (destinationTypeView != null) { CharSequence destinationType = null; if (mShowPhoneAndEmail) { /// M: Current query is phone query, but there may exist email results as well. /// Hence, we need to get destinationType of email results by Queries.EMAIL. @{ if (entry.getDestinationKind() == RecipientEntry.ENTRY_KIND_EMAIL) { destinationType = Queries.EMAIL.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } else { destinationType = Queries.PHONE.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } /// @} } else { destinationType = mQuery.getTypeLabel(mContext.getResources(), entry.getDestinationType(), entry.getDestinationLabel()).toString().toUpperCase(); } destinationTypeView.setText(destinationType); } if (entry.isFirstLevel()) { displayNameView.setVisibility(View.VISIBLE); if (imageView != null) { imageView.setVisibility(View.VISIBLE); final byte[] photoBytes = entry.getPhotoBytes(); if (photoBytes != null) { /// M: get bitmap from recipient entry Bitmap photo = entry.getBitmap(); /// M: cache bitmap if unavailable. @{ if (photo == null) { photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length); entry.setBitmap(photo); } /// @} imageView.setImageBitmap(photo); } else { imageView.setImageResource(getDefaultPhotoResource()); } } } else { displayNameView.setVisibility(View.GONE); if (imageView != null) { imageView.setVisibility(View.INVISIBLE); } } return itemView; }