Nextrek
@ 792
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
package nextrek.minstrek.activity; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import nextrek.minstrek.R; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.AssetManager; import android.os.Bundle; import android.text.Html; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class CreditsActivity extends Activity { static String credits; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.credits); Button closeButton = (Button) findViewById(R.id.closeButton); closeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent newPageIntent = new Intent(getApplicationContext(), BookPageActivity.class); // newPageIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(newPageIntent); finish(); overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); } }); if (credits == null) { credits = readCredits(); } TextView creditsText = (TextView) findViewById(R.id.creditsText); creditsText.setText(Html.fromHtml(credits)); } protected String readCredits() { Context context = getApplicationContext(); String bookName = null; try { String[] fileList = context.getAssets().list("book"); if (fileList.length > 0) { bookName = "book" + File.separatorChar + fileList[0]; } } catch (IOException e1) { e1.printStackTrace(); finish(); } return readStringFile(bookName + File.separatorChar + "credits.txt"); } protected String readStringFile(String filename) { Context context = getApplicationContext(); InputStream fis = null; try { fis = context.getAssets().open(filename, AssetManager.ACCESS_STREAMING); // context.openFileInput(strName); return readAsString(fis); } catch (IOException e) { e.printStackTrace(); finish(); } finally { try { if (fis != null) { fis.close(); } } catch (IOException e) { } } return null; } protected static String readAsString(InputStream in) throws IOException { StringBuilder sb = new StringBuilder(); InputStreamReader isr = new InputStreamReader(in); try { BufferedReader r = new BufferedReader(isr, 8192); try { for (String line = r.readLine(); line != null; line = r.readLine()) { sb.append(line); } return sb.toString(); } finally { if (r != null) { r.close(); r = null; } } } finally { if (isr != null) { isr.close(); isr = null; } } } } |
Commits for Nextrek/Android/Minstrek/MinstrekLib/app/src/main/java/nextrek/minstrek/activity/CreditsActivity.java
Revision | Author | Commited | Message |
---|---|---|---|
792 | MStefanelli | Fri 02 Oct, 2015 12:03:54 +0000 | New gradle version with ad |