Search in sources :

Example 41 with DisplayMetrics

use of android.util.DisplayMetrics in project libgdx by libgdx.

the class AndroidGraphics method updatePpi.

private void updatePpi() {
    DisplayMetrics metrics = new DisplayMetrics();
    app.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    ppiX = metrics.xdpi;
    ppiY = metrics.ydpi;
    ppcX = metrics.xdpi / 2.54f;
    ppcY = metrics.ydpi / 2.54f;
    density = metrics.density;
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Example 42 with DisplayMetrics

use of android.util.DisplayMetrics in project HTextView by hanks-zyh.

the class BurnText method init.

public void init(HTextView hTextView, AttributeSet attrs, int defStyle) {
    mHTextView = hTextView;
    mText = "";
    mOldText = "";
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(textColor);
    paint.setStyle(Paint.Style.FILL);
    oldPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    oldPaint.setColor(textColor);
    oldPaint.setStyle(Paint.Style.FILL);
    backPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    backPaint.setColor(((ColorDrawable) mHTextView.getBackground()).getColor());
    backPaint.setStyle(Paint.Style.FILL);
    metrics = new DisplayMetrics();
    WindowManager windowManger = (WindowManager) hTextView.getContext().getSystemService(Context.WINDOW_SERVICE);
    windowManger.getDefaultDisplay().getMetrics(metrics);
    textSize = hTextView.getTextSize();
    sparkBitmap = BitmapFactory.decodeResource(hTextView.getResources(), R.drawable.fire);
}
Also used : Paint(android.graphics.Paint) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Example 43 with DisplayMetrics

use of android.util.DisplayMetrics in project HTextView by hanks-zyh.

the class PixelateText method init.

public void init(HTextView hTextView, AttributeSet attrs, int defStyle) {
    mHTextView = hTextView;
    mText = "";
    mOldText = "";
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.BLACK);
    paint.setStyle(Paint.Style.FILL);
    paint.setTypeface(hTextView.getTypeface());
    oldPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    oldPaint.setColor(Color.BLACK);
    oldPaint.setStyle(Paint.Style.FILL);
    oldPaint.setTypeface(hTextView.getTypeface());
    pixPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    pixPaint.setColor(Color.BLACK);
    pixPaint.setStyle(Paint.Style.FILL);
    metrics = new DisplayMetrics();
    WindowManager windowManger = (WindowManager) hTextView.getContext().getSystemService(Context.WINDOW_SERVICE);
    windowManger.getDefaultDisplay().getMetrics(metrics);
    textSize = hTextView.getTextSize();
    bitmap = Bitmap.createBitmap(700, 200, Bitmap.Config.ARGB_4444);
    matrix = new Matrix();
    pixCanvas = new Canvas(bitmap);
}
Also used : Matrix(android.graphics.Matrix) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Example 44 with DisplayMetrics

use of android.util.DisplayMetrics in project AsymmetricGridView by felipecsl.

the class Utils method getDisplayMetrics.

/**
   * Returns a valid DisplayMetrics object
   *
   * @param context valid context
   * @return DisplayMetrics object
   */
static DisplayMetrics getDisplayMetrics(final Context context) {
    final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final DisplayMetrics metrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(metrics);
    return metrics;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Example 45 with DisplayMetrics

use of android.util.DisplayMetrics in project agera by google.

the class NotesFragment method onCreate.

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    notesStore = notesStore(getContext().getApplicationContext());
    pool = new RecycledViewPool();
    final RowHandler<NoteGroup, List<Note>> rowHandler = rowBinder(pool, (r) -> new LinearLayoutManager(getContext(), HORIZONTAL, false), NoteGroup::getId, NoteGroup::getNotes, (r) -> dataBindingRepositoryPresenterOf(Note.class).layout(R.layout.text_layout).itemId(BR.note).handler(BR.click, (Receiver<Note>) (note) -> {
        final EditText editText = new EditText(getContext());
        editText.setId(R.id.edit);
        editText.setText(note.getNote());
        new AlertDialog.Builder(getContext()).setTitle(R.string.edit_note).setView(editText).setPositiveButton(R.string.edit, (d, i) -> notesStore.updateNote(note, editText.getText().toString())).create().show();
    }).handler(BR.longClick, (Receiver<Note>) notesStore::deleteNote).stableIdForItem(Note::getId).forList());
    adapter = repositoryAdapter().addLayout(layout(R.layout.header)).add(notesStore.getNotesRepository(), repositoryPresenterOf(NoteGroup.class).layout(R.layout.note_group_layout).stableIdForItem(NoteGroup::getId).bindWith(rowHandler).recycleWith(rowHandler).forList()).addItem(getInstance().format(new Date()), dataBindingRepositoryPresenterOf(String.class).layout(R.layout.footer).itemId(BR.string).forItem()).build();
    adapter.setHasStableIds(true);
    final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    backgroundRepository = repositoryWithInitialValue(Result.<Bitmap>absent()).observe().onUpdatesPerLoop().goTo(networkExecutor).getFrom(() -> "http://www.gravatar.com/avatar/4df6f4fe5976df17deeea19443d4429d?s=" + Math.max(displayMetrics.heightPixels, displayMetrics.widthPixels)).transform(url -> httpGetRequest(url).compile()).attemptTransform(httpFunction()).orEnd(Result::failure).goTo(calculationExecutor).thenTransform(input -> {
        final byte[] body = input.getBody();
        return absentIfNull(decodeByteArray(body, 0, body.length));
    }).onDeactivation(SEND_INTERRUPT).compile();
}
Also used : Bundle(android.os.Bundle) RepositoryAdapter.repositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter.repositoryAdapter) Date(java.util.Date) HttpFunctions.httpFunction(com.google.android.agera.net.HttpFunctions.httpFunction) LayoutPresenters.layout(com.google.android.agera.rvadapter.LayoutPresenters.layout) ImageView(android.widget.ImageView) Result(com.google.android.agera.Result) Repository(com.google.android.agera.Repository) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore) RowHandler.rowBinder(com.google.android.agera.testapp.RowHandler.rowBinder) Result.absentIfNull(com.google.android.agera.Result.absentIfNull) DateFormat.getInstance(java.text.DateFormat.getInstance) View(android.view.View) Updatable(com.google.android.agera.Updatable) RepositoryAdapter(com.google.android.agera.rvadapter.RepositoryAdapter) Receiver(com.google.android.agera.Receiver) Executor(java.util.concurrent.Executor) DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf(com.google.android.agera.rvdatabinding.DataBindingRepositoryPresenters.dataBindingRepositoryPresenterOf) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Repositories.repositoryWithInitialValue(com.google.android.agera.Repositories.repositoryWithInitialValue) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) RepositoryPresenters.repositoryPresenterOf(com.google.android.agera.rvadapter.RepositoryPresenters.repositoryPresenterOf) AlertDialog(android.app.AlertDialog) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) BitmapFactory.decodeByteArray(android.graphics.BitmapFactory.decodeByteArray) Bitmap(android.graphics.Bitmap) SEND_INTERRUPT(com.google.android.agera.RepositoryConfig.SEND_INTERRUPT) HttpRequests.httpGetRequest(com.google.android.agera.net.HttpRequests.httpGetRequest) Nullable(android.support.annotation.Nullable) HORIZONTAL(android.support.v7.widget.LinearLayoutManager.HORIZONTAL) EditText(android.widget.EditText) EditText(android.widget.EditText) Receiver(com.google.android.agera.Receiver) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DisplayMetrics(android.util.DisplayMetrics) Date(java.util.Date) RecycledViewPool(android.support.v7.widget.RecyclerView.RecycledViewPool) List(java.util.List) NotesStore.notesStore(com.google.android.agera.testapp.NotesStore.notesStore)

Aggregations

DisplayMetrics (android.util.DisplayMetrics)772 WindowManager (android.view.WindowManager)107 Resources (android.content.res.Resources)99 Display (android.view.Display)78 Configuration (android.content.res.Configuration)61 Point (android.graphics.Point)57 View (android.view.View)52 SuppressLint (android.annotation.SuppressLint)47 Bitmap (android.graphics.Bitmap)42 Paint (android.graphics.Paint)42 Activity (android.app.Activity)32 ImageView (android.widget.ImageView)27 AssetManager (android.content.res.AssetManager)25 TypedArray (android.content.res.TypedArray)25 Context (android.content.Context)23 TypedValue (android.util.TypedValue)23 ViewGroup (android.view.ViewGroup)23 TextView (android.widget.TextView)22 Intent (android.content.Intent)21 RelativeLayout (android.widget.RelativeLayout)20