Skip to content

Commit

Permalink
撮影情報の数字の .0 が余計なので正規表現で除去した
Browse files Browse the repository at this point in the history
  • Loading branch information
tateisu committed Mar 12, 2017
1 parent a42adc5 commit 3c1de50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public void bind(
}
if( is != null ){
Rational rv;
String sv;
try{
if( isCancelled() ) return null;
ExifInterface exif = new ExifInterface();
Expand All @@ -244,20 +245,25 @@ public void bind(

rv = exif.getTagRationalValue( ExifInterface.TAG_FOCAL_LENGTH );
if( rv != null ){
exif_list.add( String.format( "%.1fmm", rv.toDouble() ) );
sv = String.format( "%.1f", rv.toDouble() ).replaceAll("\\.0*$","");
exif_list.add(sv+"mm" );
}

rv = exif.getTagRationalValue( ExifInterface.TAG_F_NUMBER );
if( rv != null ){
exif_list.add( String.format( "F%.1f", rv.toDouble() ) );
sv = String.format( "%.1f", rv.toDouble() ).replaceAll("\\.0*$","");
exif_list.add("F"+sv );
}

rv = exif.getTagRationalValue( ExifInterface.TAG_EXPOSURE_TIME );
if( rv != null ){
if( rv.getNumerator() == 1L ){
exif_list.add( String.format( "1/%ds", rv.getDenominator() ) );
double dv = rv.toDouble();
if( dv > 0.25d ){
sv = String.format( "%.1f", dv ).replaceAll("\\.0*$","");
exif_list.add( sv+"s");
}else{
exif_list.add( String.format( "%.1fs", rv.toDouble() ) );
sv = String.format( "%.1f", 1/dv ).replaceAll("\\.0*$","");
exif_list.add( "1/"+sv+"s");
}
}

Expand Down Expand Up @@ -289,7 +295,7 @@ public void bind(
}
}

String sv = exif.getTagStringValue( ExifInterface.TAG_MODEL );
sv = exif.getTagStringValue( ExifInterface.TAG_MODEL );
if( ! TextUtils.isEmpty( sv ) ){
exif_list.add( trimModelName( sv ) );
}
Expand Down Expand Up @@ -412,7 +418,7 @@ private String trimModelName( String sv ){
}
}
// 連続する空白を1文字にする。始端と終端の空白を除去する。
return sb.toString().replace( "\\s+", " " ).trim();
return sb.toString().replaceAll( "\\s+", " " ).trim();
}

private String joinList( String delimiter, LinkedList<String> exif_list ){
Expand Down Expand Up @@ -672,4 +678,5 @@ void action_send( DownloadRecord data ){
( (ActMain) activity ).showToast( true, LogWriter.formatError( ex, "send failed." ) );
}
}

}
2 changes: 2 additions & 0 deletions app/src/main/res/layout/lv_download_record.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
android:id="@+id/tvTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="4"
android:textSize="12sp"
/>
</LinearLayout>

Expand Down

0 comments on commit 3c1de50

Please sign in to comment.