1010using System . IO ;
1111using Android . Provider ;
1212using System . Text ;
13+ using BasicPlainTextReaderApp . Library ;
1314
1415namespace BasicPlainTextReaderApp . Droid
1516{
@@ -25,9 +26,10 @@ protected override void OnCreate(Bundle savedInstanceState)
2526 {
2627 string action = Intent . Action ;
2728 string type = Intent . Type ;
28- StringBuilder sb = null ;
2929
30- if ( Intent . ActionView . Equals ( action ) && ! string . IsNullOrEmpty ( type ) )
30+ TextModel data = null ;
31+
32+ if ( Intent . ActionView . Equals ( action ) && ! string . IsNullOrEmpty ( type ) )
3133 {
3234 Android . Net . Uri fileUri = Intent . Data ;
3335 if ( fileUri != null )
@@ -40,17 +42,17 @@ protected override void OnCreate(Bundle savedInstanceState)
4042 using ( var bufferedReader = new Java . IO . BufferedReader ( reader ) )
4143 {
4244 string line ;
43- sb = new StringBuilder ( ) ;
45+ var sb = new StringBuilder ( ) ;
4446 while ( ( line = bufferedReader . ReadLine ( ) ) != null )
4547 {
4648 sb . AppendLine ( line ) ;
4749 }
50+ data = new TextModel ( sb . ToString ( ) , Intent . DataString , Intent . Type , Intent . Data . Path ) ;
4851 }
4952 }
5053 catch ( Exception e )
5154 {
52- sb = new StringBuilder ( ) ;
53- sb . AppendLine ( e . ToString ( ) ) ;
55+ data = new TextModel ( e . ToString ( ) , "error" , "error" , "error" ) ;
5456 }
5557 }
5658 }
@@ -62,7 +64,7 @@ protected override void OnCreate(Bundle savedInstanceState)
6264
6365 Xamarin . Essentials . Platform . Init ( this , savedInstanceState ) ;
6466 global ::Xamarin . Forms . Forms . Init ( this , savedInstanceState ) ;
65- LoadApplication ( new App ( sb . ToString ( ) ) ) ;
67+ LoadApplication ( new App ( data ) ) ;
6668 }
6769 public override void OnRequestPermissionsResult ( int requestCode , string [ ] permissions , [ GeneratedEnum ] Android . Content . PM . Permission [ ] grantResults )
6870 {
0 commit comments