Example usage for android.content.res Resources getDisplayMetrics

List of usage examples for android.content.res Resources getDisplayMetrics

Introduction

In this page you can find the example usage for android.content.res Resources getDisplayMetrics.

Prototype

public DisplayMetrics getDisplayMetrics() 

Source Link

Document

Return the current display metrics that are in effect for this resource object.

Usage

From source file:com.esprit.droidcon.corruption.AutreListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;//  w  w w  . j  a va2 s  .  c om
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Autre");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(AutreListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(AutreListActivity.this, AutreListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:com.esprit.droidcon.corruption.SiteWebListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;// w w  w  . j  a va2 s . c  om
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Site Web");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(SiteWebListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(SiteWebListActivity.this, SiteWebListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:cz.muni.fi.japanesedictionary.fragments.DisplayCharacterInfo.java

@Override
public void kanjiVgLoaded(final List<SVG> svgs) {
    if (svgs == null || svgs.size() == 0) {
        Log.d(LOG_TAG, "svg is null");
        return;/* w  w  w. j  ava 2s .  c o m*/
    }
    if (getView() == null) {
        Log.d(LOG_TAG, "view is null");
        return;
    }
    if (getActivity() == null) {
        Log.d(LOG_TAG, "activity is null");
        return;
    }
    mSvgs = svgs;
    LinearLayout container = (LinearLayout) getView().findViewById(R.id.kanjidict_kanjivg_image_container);
    container.removeAllViews();
    /*
            int minSize;
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
    minSize = Math.min(width/2, height/2);
            }else {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    int width = display.getWidth();  // deprecated
    int height = display.getHeight();  // deprecated
    minSize = Math.min(width/2, height/2);
            }*/
    Resources r = getResources();
    int minSize = Math
            .round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, r.getDisplayMetrics()));

    mImageView = new SVGImageView(getActivity());
    mImageView.setMinimumHeight(minSize);
    mImageView.setMinimumWidth(minSize);
    mImageView.setSVG(mSvgs.get(mStep > mSvgs.size() - 1 ? 0 : mStep));
    container.addView(mImageView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    mTimerHandler.removeCallbacks(mTimerRunnable);
    mTimerHandler.postDelayed(mTimerRunnable, 0);
}

From source file:com.esprit.droidcon.corruption.EtatCivileListActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;//  w  w  w  .  j  a  v a  2  s .  c  o m
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Etat Civil");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(EtatCivileListActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("lat", corp.getLat());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(EtatCivileListActivity.this, EtatCivileListActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:com.forrestguice.suntimeswidget.TimeDateDialog.java

/**
 *
 * @param savedInstanceState a bundle containing previously saved dialog state
 * @return a dialog instance ready to be shown
 *//*from   ww w. jav a 2 s.  com*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    final FragmentActivity myParent = getActivity();
    Resources r = getResources();

    LayoutInflater inflater = myParent.getLayoutInflater();
    @SuppressLint("InflateParams")
    View dialogContent = inflater.inflate(R.layout.layout_dialog_date, null);

    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, r.getDisplayMetrics());

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent, 0, padding, 0, 0);
    builder.setTitle(myParent.getString(R.string.timedate_dialog_title));

    AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(true);
    dialog.setCancelable(false);

    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, myParent.getString(R.string.timedate_dialog_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    if (onCanceled != null) {
                        onCanceled.onClick(dialog, which);
                    }
                }
            });

    dialog.setButton(DialogInterface.BUTTON_POSITIVE, myParent.getString(R.string.timedate_dialog_ok),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    saveSettings(myParent);
                    dialog.dismiss();
                    if (onAccepted != null) {
                        onAccepted.onClick(dialog, which);
                    }
                }
            });

    initViews(myParent, dialogContent);
    if (savedInstanceState != null) {
        //Log.d("DEBUG", "TimeDateDialog onCreate (restoreState)");
        loadSettings(savedInstanceState);

    } else {
        // no saved dialog state; load from preferences
        //Log.d("DEBUG", "TimeDateDialog onCreate (newState)");
        loadSettings(myParent);
    }

    if (!isInitialized()) {
        init();
    }

    return dialog;
}

From source file:com.esprit.droidcon.corruption.MusicNewsActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maillist_layout);
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    retry = (Button) findViewById(R.id.retry);
    ButterKnife.bind(this);
    mBackground = mImageView;/*from w w  w.  j av a  2  s  .  c  o m*/
    moveBackground();
    initToolbar();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    connexionlay = (RelativeLayout) findViewById(R.id.connexionlay);

    mang = new ArrayList<>();

    final ListView listView = (ListView) findViewById(R.id.list_view);

    final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
    if (activeNetwork != null && activeNetwork.isConnected()) {

        connexionlay.setVisibility(View.GONE);
        // notify user you are online
        final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption");
        query.whereEqualTo("Type", "Bureau d ordre");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> conThus, ParseException e) {
                if (e == null) {
                    //Log.d("score", "Retrieved " + scoreList.size() + " scores");
                    for (int i = conThus.size() - 1; i > 0; i--) {
                        ParseObject dong = conThus.get(i);
                        //System.out.println(dong.getParseFile("ImageFile").toString());
                        if (dong.getParseFile("AudioFile") != null) {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(),
                                    dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                            /*   SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                     new SwipeDismissAdapter(mGoogleCardsAdapter, this));
                               swingBottomInAnimationAdapter.setAbsListView(listView);*/
                        } else

                        {
                            mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"),
                                    dong.getString("Date"), dong.getString("Adress"),
                                    dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(),
                                    dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"),
                                    dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"),
                                    dong.getString("UserNom"), dong.getString("UserAdress"),
                                    dong.getString("UserTel"), dong.getString("UserMail"),
                                    dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat")

                            ));

                            mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang);
                            SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(
                                    mGoogleCardsAdapter);
                            swingBottomInAnimationAdapter.setAbsListView(listView);

                            assert swingBottomInAnimationAdapter.getViewAnimator() != null;
                            swingBottomInAnimationAdapter.getViewAnimator()
                                    .setInitialDelayMillis(INITIAL_DELAY_MILLIS);

                            listView.setClipToPadding(false);
                            listView.setDivider(null);
                            Resources r = getResources();
                            int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                                    r.getDisplayMetrics());
                            listView.setDividerHeight(px);
                            listView.setFadingEdgeLength(0);
                            listView.setFitsSystemWindows(true);
                            px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12,
                                    r.getDisplayMetrics());
                            listView.setPadding(px, px, px, px);
                            listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
                            listView.setAdapter(swingBottomInAnimationAdapter);

                        }
                    }

                } else {
                    Log.d("score", "Error: " + e.getMessage());
                    Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Corruption corp = (Corruption) parent.getItemAtPosition(position);
                SwipeImageAdapter.img1 = corp.getImage1();
                SwipeImageAdapter.img2 = corp.getImage2();
                SwipeImageAdapter.img3 = corp.getImage3();
                SwipeImageAdapter.title = corp.getTitle();
                SwipeImageAdapter.desc = corp.getDesc();
                //prodimg = prod.getProductImage();
                Intent i = new Intent(MusicNewsActivity.this, SingleCorruptionActivity.class);
                i.putExtra("audiourl", corp.getAudiofile());
                i.putExtra("longi", corp.getLongi());
                i.putExtra("title", corp.getTitle());
                i.putExtra("desc", corp.getDesc());
                i.putExtra("photourl", corp.getImage1());
                i.putExtra("lat", corp.getLat());
                i.putExtra("date", corp.getDate());
                i.putExtra("heure", corp.getHeure());
                i.putExtra("ville", corp.getVille());
                i.putExtra("usernom", corp.getUserNom());
                i.putExtra("useradress", corp.getUserAdress());
                i.putExtra("usertel", corp.getUserTel());
                i.putExtra("usermail", corp.getUserMail());
                i.putExtra("type", corp.getType());
                i.putExtra("videocode", corp.getVideo());
                i.putExtra("etat", corp.getEtat());

                startActivity(i);
                finish();

            }
        });

    } else {
        // notify user you are not online
        connexionlay.setVisibility(View.VISIBLE);
        retry.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // fabProgressCircle.show();
                //  startYourAsynchronousJob();
                Intent refresh = new Intent(MusicNewsActivity.this, MusicNewsActivity.class);
                startActivity(refresh);
                finish();

            }
        });

    }

}

From source file:org.mozilla.gecko.PromptService.java

PromptService() {
    mInflater = LayoutInflater.from(GeckoApp.mAppContext);
    Resources res = GeckoApp.mAppContext.getResources();
    mPaddingSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, PADDING_SIZE,
            res.getDisplayMetrics());
}

From source file:github.madmarty.madsonic.util.Util.java

public static void changeLanguage(Context context) {

    Resources res = context.getResources();
    DisplayMetrics dm = res.getDisplayMetrics();

    android.content.res.Configuration conf = res.getConfiguration();

    SharedPreferences prefs = getPreferences(context);
    String appLanguage = prefs.getString(Constants.PREFERENCES_KEY_LANGUAGE, "us");

    if ("auto".equalsIgnoreCase(appLanguage)) {
        conf.locale = new Locale("en");
        res.updateConfiguration(conf, dm);
    } else {/*from w ww .  java2s.  com*/
        conf.locale = new Locale(appLanguage);
        res.updateConfiguration(conf, dm);
    }
}

From source file:de.vanita5.twittnuker.fragment.support.AccountsDashboardFragment.java

private void updateAccountOptionsSeparatorLabel() {
    final ParcelableAccount account = mAccountsAdapter.getSelectedAccount();
    if (account == null) {
        return;//w w  w .  ja va 2  s  .  c o  m
    }
    mAccountProfileNameView.setText(account.name);
    mAccountProfileScreenNameView.setText("@" + account.screen_name);
    mAccountsToggle.setChecked(account.is_activated);
    mImageLoader.displayProfileImage(mAccountProfileImageView, account.profile_image_url);
    final int bannerWidth = mAccountProfileBannerView.getWidth();
    final Resources res = getResources();
    final int defWidth = res.getDisplayMetrics().widthPixels;
    final int width = bannerWidth > 0 ? bannerWidth : defWidth;
    final String bannerUrl = Utils.getBestBannerUrl(account.profile_banner_url, width);
    final ImageView bannerView = mAccountProfileBannerView;
    if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) {
        mImageLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this);
    }
}

From source file:abanoubm.dayra.main.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (Utility.getArabicLang(getApplicationContext()) == 1) {
        Utility.setArabicLang(getApplicationContext(), 2);

        Locale myLocale = new Locale("ar");
        Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;// w ww. jav a2  s  .c o m
        res.updateConfiguration(conf, dm);

        finish();
        startActivity(new Intent(getIntent()));
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_main);
    ((TextView) findViewById(R.id.subhead1)).setText(R.string.app_name);
    ((TextView) findViewById(R.id.subhead2)).setText(BuildConfig.VERSION_NAME);
    findViewById(R.id.nav_back).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();

        }
    });
    ((TextView) findViewById(R.id.footer)).setText("dayra " + BuildConfig.VERSION_NAME + " @"
            + new SimpleDateFormat("yyyy", Locale.getDefault()).format(new Date()) + " Abanoub M.");

    if (!Utility.getDayraName(getApplicationContext()).equals("")) {
        startActivity(new Intent(getApplicationContext(), Home.class));
        finish();
    }

    ListView lv = (ListView) findViewById(R.id.home_list);

    mMenuItemAdapter = new MenuItemAdapter(getApplicationContext(),
            new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.sign_menu))), 1);
    lv.setAdapter(mMenuItemAdapter);

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                sign();
                break;
            case 1:
                register();
                break;
            case 2:
                if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this,
                        Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                    importDB();
                } else {
                    ActivityCompat.requestPermissions(Main.this,
                            new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, IMPORT_REQUEST);
                }
                break;
            case 3:
                startActivity(new Intent(Intent.ACTION_VIEW).setData(
                        Uri.parse("https://drive.google.com/file/d/0B1rNCm5K9cvwVXJTTzNqSFdrVk0/view")));
                break;
            case 4:
                startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(
                        "https://drive.google.com/open?id=1flSRdoiIT_hNd96Kxz3Ww3EhXDLZ45FhwFJ2hF9vl7g")));
                break;
            case 5: {

                AlertDialog.Builder builder = new AlertDialog.Builder(Main.this);
                builder.setTitle(R.string.label_choose_language);
                builder.setItems(getResources().getStringArray(R.array.language_menu),
                        new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String temp;
                                if (which == 1) {
                                    temp = "en";
                                    Utility.setArabicLang(getApplicationContext(), 0);
                                } else {
                                    temp = "ar";
                                    Utility.setArabicLang(getApplicationContext(), 2);
                                }
                                Locale myLocale = new Locale(temp);
                                Resources res = getResources();
                                DisplayMetrics dm = res.getDisplayMetrics();
                                Configuration conf = res.getConfiguration();
                                conf.locale = myLocale;
                                res.updateConfiguration(conf, dm);

                                finish();
                                startActivity(new Intent(getIntent()));
                            }

                        });
                builder.create().show();

            }
                break;
            case 6:
                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/453595434816965"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/dayraapp"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;

            case 7:

                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/1363784786"))
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (Exception e) {
                    startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/EngineeroBono"))
                                    .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                }
                break;
            case 8:
                Uri uri = Uri.parse("market://details?id=" + getPackageName());
                Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                try {
                    startActivity(goToMarket);
                } catch (Exception e) {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
                }
                break;
            case 9:
                if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this,
                        android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                    Intent intent = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.setDataAndType(Uri.fromFile(new File(Utility.getDayraFolder())), "*/*");
                    startActivity(
                            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
                } else {
                    ActivityCompat.requestPermissions(Main.this,
                            new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
                            FOLDER_REQUEST);
                }
                break;
            case 10:
                LayoutInflater li = LayoutInflater.from(getApplicationContext());
                final View aboutView = li.inflate(R.layout.dialogue_about, null, false);
                final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create();
                ad.setView(aboutView, 0, 0, 0, 0);
                ad.show();
                ((TextView) aboutView.findViewById(R.id.about))
                        .setText(String.format(getResources().getString(R.string.copyright),
                                Calendar.getInstance().get(Calendar.YEAR)));

                ((TextView) aboutView.findViewById(R.id.notice)).setText(GoogleApiAvailability.getInstance()
                        .getOpenSourceSoftwareLicenseInfo(getApplicationContext()));
                aboutView.findViewById(R.id.btn).setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        ad.cancel();
                    }
                });
                break;
            }
        }
    });

}