List of usage examples for android.app Activity getResources
@Override
public Resources getResources()
From source file:org.typhonrt.android.java6.data.option.control.OptionModelDrawerControl.java
public OptionModelDrawerControl(Activity activity) { optionModelList = new ArrayList<IOptionModel>(); updateNotify = new AtomicBoolean(); DrawerLayout drawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); drawerListView = (ListView) activity.findViewById(R.id.left_drawer); Resources resources = activity.getResources(); drawerLayout.setScrimColor(resources.getColor(R.color.drawer_scrim_color)); // Handle ActionBarDrawerToggle ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(activity, drawerLayout, (Toolbar) activity.findViewById(R.id.toolbar), R.string.drawer_open, R.string.drawer_close); actionBarDrawerToggle.syncState();/*from w w w. j a v a 2 s .co m*/ // Handle different Drawer States :D drawerLayout.setDrawerListener(actionBarDrawerToggle); // Setup header views LayoutInflater inflater = activity.getLayoutInflater(); headerView = inflater.inflate(R.layout.drawer_headerview, null); // Set the adapter for the list view drawerListView .setAdapter(optionListAdapter = new OptionModelAdapter(activity, optionModelList, updateNotify)); }
From source file:com.lambdasoup.watchlater.test.AddActivityTest.java
private String fillChannelTitle(int msgId, Activity activity) { return String.format(Locale.US, activity.getResources().getString(msgId), CHANNEL_TITLE); }
From source file:dev.drsoran.moloko.fragments.dialogs.RecurrencePickerDialogFragment.java
private void initFreqWheel(Map<Integer, List<Object>> elements) { final Activity activity = getSherlockActivity(); final Resources res = activity.getResources(); final int interval = getInterval(); freqWheel.setViewAdapter(new ArrayWheelAdapter<String>(activity, new String[] { res.getQuantityText(R.plurals.g_year, interval).toString(), res.getQuantityText(R.plurals.g_month, interval).toString(), res.getQuantityText(R.plurals.g_week, interval).toString(), res.getQuantityText(R.plurals.g_day, interval).toString() })); if (elements != null) { Integer freq = getPatternElement(elements, RecurrencePatternParser.OP_FREQ, Integer.class); if (freq != null) { switch (freq.intValue()) { case RecurrencePatternParser.VAL_YEARLY: freqWheel.setCurrentItem(0); break; case RecurrencePatternParser.VAL_MONTHLY: freqWheel.setCurrentItem(1); break; case RecurrencePatternParser.VAL_WEEKLY: freqWheel.setCurrentItem(2); break; case RecurrencePatternParser.VAL_DAILY: freqWheel.setCurrentItem(3); break; default: freq = Integer.valueOf(-1); break; }/* ww w . ja va2 s.c om*/ } else { freq = Integer.valueOf(-1); } if (freq.intValue() == -1) freqWheel.setCurrentItem(0); } }
From source file:com.ramsofttech.adpushlibrary.fragment.GridFragment.java
/** * onActivityCreated/*from w w w. java2s . c o m*/ * When the activity is created, divide the usable space into columns * and put a grid of images in that area. */ @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Activity a = getActivity(); Resources res = a.getResources(); View rootView = getView(); GridView gridview = (GridView) rootView.findViewById(R.id.grid); DisplayMetrics metrics = new DisplayMetrics(); a.getWindowManager().getDefaultDisplay().getMetrics(metrics); // From the resource files, determine how many rows and columns are to be displayed. int numRows = res.getInteger(R.integer.grid_num_rows); int numCols = res.getInteger(R.integer.grid_num_cols); AppDataHolder dataHolder = ((AppDataHolder) getActivity().getApplicationContext()); if (dataHolder.getNumCols() != 0) numCols = dataHolder.getNumCols(); if (dataHolder.getNumRows() != 0) numRows = dataHolder.getNumRows(); // Figure out how much space is available for the N rows and M columns to be displayed. // We start with the root view for the fragment and adjust for the title, padding, etc. int titleHeight = res.getDimensionPixelSize(R.dimen.topic_title_height); int titlePadding = res.getDimensionPixelSize(R.dimen.topic_title_padding); int buttonAreaHeight = res.getDimensionPixelSize(R.dimen.button_area_height); int titleBarHeight = res.getDimensionPixelSize(R.dimen.title_bar_height); int gridHspacing = res.getDimensionPixelSize(R.dimen.image_grid_hspacing); int gridVSpacing = res.getDimensionPixelSize(R.dimen.image_grid_vspacing); int otherGridH = res.getDimensionPixelSize(R.dimen.other_grid_h); int otherGridW = res.getDimensionPixelSize(R.dimen.other_grid_w); int heightUsed = 2 * titleBarHeight + (numRows + 2) * gridVSpacing + (titleHeight + 2 * titlePadding) + otherGridH + buttonAreaHeight; int widthUsed = 40; // just a guess for now. int availableHeight = metrics.heightPixels - heightUsed; int availableWidth = metrics.widthPixels - widthUsed; int cellWidth = availableWidth / numCols; if (availableWidth > 1000) { cellWidth -= 20; } float cellHeight = numRows * (availableHeight / numRows) / 6; if (dataHolder.getCellHeight() != 0) { cellHeight = numRows * (availableHeight / numRows) / dataHolder.getCellHeight(); } // Put this back in to check the calculations for cell height and width. Log.d("Debug", "--- metrics h: " + metrics.heightPixels + " w: " + metrics.widthPixels); Log.d("Debug", " available h: " + availableHeight + " w: " + availableWidth); Log.d("Debug", " already used h: " + heightUsed + " w: " + widthUsed); Log.d("Debug", " cell h: " + cellHeight + " w: " + cellWidth); Log.d("Debug", "--- num rows: " + numRows + " cols: " + numCols); Log.d("Debug", "--- firstImage: " + mFirstImage + " image count: " + mImageCount); if (gridview == null) Log.d("DEBUG", "Unable to locate the gridview."); else { Log.i("Adapter", "--inside call appadapter"); // AppDataHolder dataHolder = ((AppDataHolder) getActivity().getApplication()); gridview.setNumColumns(numCols); // Connect the gridview with an adapter that fills up the space. // gridview.setAdapter (new GridImageAdapter (a, mTopicList, mFirstImage, mImageCount, cellWidth, cellHeight)); gridview.setAdapter(new AppAdapter(a, dataHolder.getApplicationList(), mFirstImage, mImageCount, cellWidth, cellHeight)); // Arrange it so a long click on an item in the grid shows the topic associated with the image. gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub //showTopic(mFirstImage + position); Toast.makeText(getActivity(), "" + (mFirstImage + position), Toast.LENGTH_LONG).show(); clickAsyncTask clickAsynctask = new clickAsyncTask(getActivity()); clickAsynctask.execute("" + (mFirstImage + position)); AppDataHolder dataHolder = ((AppDataHolder) getActivity().getApplication()); List<ApplicationData> applicationList = dataHolder.getApplicationList(); ApplicationData application = applicationList.get(mFirstImage + position); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + application.getPackageName()))); } }); } }
From source file:sg.com.utrix.skeleton.app.sample.util.ImageLoader.java
/** * Creates an ImageLoader with Bitmap memory cache and a default placeholder image while the * image is being fetched and loaded.//from w ww . j a v a 2s. c o m */ public ImageLoader(Activity activity, int defaultPlaceHolderResId) { super(newRequestQueue(activity), BitmapCache.getInstance(activity.getFragmentManager())); mResources = activity.getResources(); mPlaceHolderDrawables = new ArrayList<Drawable>(1); mPlaceHolderDrawables .add(defaultPlaceHolderResId == -1 ? null : mResources.getDrawable(defaultPlaceHolderResId)); }
From source file:sg.com.utrix.skeleton.app.sample.util.ImageLoader.java
/** * Creates an ImageLoader with Bitmap memory cache and a list of default placeholder drawables. *//*from w w w . ja v a 2 s .com*/ public ImageLoader(Activity activity, ArrayList<Drawable> placeHolderDrawables) { super(newRequestQueue(activity), BitmapCache.getInstance(activity.getFragmentManager())); mResources = activity.getResources(); mPlaceHolderDrawables = placeHolderDrawables; }
From source file:com.lovejoy777sarootool.rootool.preview.IconPreview.java
public IconPreview(Activity activity) { mContext = activity;//from ww w . ja v a 2s. c om mWidth = (int) mContext.getResources().getDimension(R.dimen.item_height); cache = new ConcurrentHashMap<String, Bitmap>(); pool = Executors.newFixedThreadPool(5); mResources = activity.getResources(); pm = mContext.getPackageManager(); if (mMimeTypeIconCache == null) { mMimeTypeIconCache = new DrawableLruCache<String>(); } }
From source file:com.tomeokin.lspush.biz.home.CollectionListAdapter.java
public CollectionListAdapter(Activity activity, @Nullable List<Collection> colList, @Nullable Callback callback) { final Resources resources = activity.getResources(); mMaxHeight = resources.getDimension(R.dimen.list_item_max_content) - resources.getDimension(R.dimen.row_vertical_padding); final View content = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT); mMaxWidth = content.getWidth() - 2 * resources.getDimension(R.dimen.page_vertical_margin); if (colList != null) { setColList(colList);/*from ww w .ja v a 2 s . c om*/ } setCallback(callback); }
From source file:br.com.brolam.cloudvision.ui.helpers.ImagesHelper.java
public ImagesHelper(Activity activity, CloudVisionProvider cloudVisionProvider) { this.activity = activity; Resources resources = activity.getResources(); this.noteVisionBackgroundWidth = resources.getInteger(R.integer.note_vision_background_width); this.noteVisionBackgroundHeight = resources.getInteger(R.integer.note_vision_background_height); this.cloudVisionProvider = cloudVisionProvider; this.firebaseStorage = FirebaseStorage.getInstance(); if (notesVisionUploadsReference == null) { notesVisionUploadsReference = new HashMap<>(); } else {//from www.ja v a 2 s . c om restoreStorageReference(); } }
From source file:com.google.plus.wigwamnow.social.GoogleProvider.java
/** * Share an interactive post using the native dialog. *//*from w ww. j a v a 2s. c om*/ @Override public boolean share(Wigwam wigwam, Activity activity) { if (!(activity instanceof PlusClientHostActivity)) { throw new IllegalArgumentException("Activity must host a PlusClient!"); } PlusClientHostActivity hostActivity = (PlusClientHostActivity) activity; String host = activity.getResources().getString(R.string.external_host); Uri wigwamLink = Uri.parse(host + "/wigwams/" + wigwam.getId()); String title = "Check out " + wigwam.getName() + "!"; Intent shareIntent = new PlusShare.Builder(activity, hostActivity.getPlusClient()).setType("text/plain") .setText(title).addCallToAction("RESERVE", wigwamLink, "/wigwams/" + wigwam.getId()) .setContentDeepLinkId("/wigwams/" + wigwam.getId(), title, wigwam.getDescription(), wigwamLink) .setContentUrl(wigwamLink).getIntent(); activity.startActivityForResult(shareIntent, 0); return false; }