Search in sources :

Example 1 with MetadataHelper

use of org.horaapps.leafpic.data.metadata.MetadataHelper in project LeafPic by HoraApps.

the class AlertDialogsHelper method getDetailsDialog.

public static AlertDialog getDetailsDialog(final ThemedActivity activity, final Media f) {
    AlertDialog.Builder detailsDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
    MetadataHelper mdhelper = new MetadataHelper();
    MediaDetailsMap<String, String> mainDetails = mdhelper.getMainDetails(activity, f);
    final View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_media_detail, null);
    ImageView imgMap = dialogLayout.findViewById(R.id.photo_map);
    dialogLayout.findViewById(org.horaapps.leafpic.R.id.details_title).setBackgroundColor(activity.getPrimaryColor());
    ((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.photo_details_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
    final GeoLocation location;
    if ((location = f.getGeoLocation()) != null) {
        StaticMapProvider staticMapProvider = StaticMapProvider.fromValue(Hawk.get(activity.getString(R.string.preference_map_provider), StaticMapProvider.GOOGLE_MAPS.getValue()));
        Glide.with(activity.getApplicationContext()).load(staticMapProvider.getUrl(location)).into(imgMap);
        imgMap.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                try {
                    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.ENGLISH, "geo:%f,%f?z=%d", location.getLatitude(), location.getLongitude(), 17))));
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(activity, R.string.no_app_to_perform, Toast.LENGTH_SHORT).show();
                }
            }
        });
        imgMap.setVisibility(View.VISIBLE);
        dialogLayout.findViewById(org.horaapps.leafpic.R.id.details_title).setVisibility(View.GONE);
    } else
        imgMap.setVisibility(View.GONE);
    final TextView showMoreText = dialogLayout.findViewById(R.id.details_showmore);
    showMoreText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showMoreDetails(dialogLayout, activity, f);
            showMoreText.setVisibility(View.GONE);
        }
    });
    detailsDialogBuilder.setView(dialogLayout);
    loadDetails(dialogLayout, activity, mainDetails);
    return detailsDialogBuilder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) CardView(android.support.v7.widget.CardView) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) MetadataHelper(org.horaapps.leafpic.data.metadata.MetadataHelper) ActivityNotFoundException(android.content.ActivityNotFoundException) TextView(android.widget.TextView) ImageView(android.widget.ImageView) GeoLocation(com.drew.lang.GeoLocation)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 AlertDialog (android.support.v7.app.AlertDialog)1 CardView (android.support.v7.widget.CardView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 GeoLocation (com.drew.lang.GeoLocation)1 MetadataHelper (org.horaapps.leafpic.data.metadata.MetadataHelper)1