Support compile config for flavors and build types.
[android/platform/tools/build.git] / testapps / flavorlib / lib1 / src / main / java / com / android / tests / flavorlib / lib / Lib.java
1 package com.android.tests.flavorlib.lib;
2
3 import android.app.Activity;
4 import android.widget.TextView;
5
6 import java.io.BufferedReader;
7 import java.io.IOException;
8 import java.io.InputStream;
9 import java.io.InputStreamReader;
10
11 public class Lib {
12     
13     public static void handleTextView(Activity a) {
14         TextView tv = (TextView) a.findViewById(R.id.lib_text2);
15         if (tv != null) {
16             tv.setText(getContent());
17         }
18     }
19
20     private static String getContent() {
21         InputStream input = Lib.class.getResourceAsStream("Lib.txt");
22         if (input == null) {
23             return "FAILED TO FIND Lib.txt";
24         }
25
26         BufferedReader reader = null;
27         try {
28             reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
29
30             return reader.readLine();
31         } catch (IOException e) {
32         } finally {
33             if (reader != null) {
34                 try {
35                     reader.close();
36                 } catch (IOException e) {
37                 }
38             }
39         }
40         
41         return "FAILED TO READ CONTENT";
42     }
43 }