Пример #1
0
    def __init__(self, context):

        LinearLayout.__init__(self, context)

        self.handler = None

        envDir = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_DOWNLOADS)
        self.fileAdapter = SpriteFileListAdapter(envDir,
                                                 [".spr", ",ff9", ".ff9"])

        self.fileView = ListView(context)
        self.fileView.setOnItemClickListener(self)
        self.fileView.setAdapter(self.fileAdapter)

        self.addView(
            self.fileView,
            ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                   ViewGroup.LayoutParams.WRAP_CONTENT))
Пример #2
0
    def readLocations(self):

        self.locations = {}
        self.order = []

        if Environment.getExternalStorageState() != Environment.MEDIA_MOUNTED:
            return

        storageDir = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_DOWNLOADS)

        subdir = File(storageDir, "WeatherForecast")
        if subdir.exists():

            f = File(subdir, "locations.txt")

            try:
                stream = BufferedReader(FileReader(f))
                while True:

                    line = stream.readLine()
                    if line == None:
                        break

                    spec = line.trim()
                    pieces = spec.split("/")

                    if len(pieces) < 3:
                        continue

                    place = pieces[len(pieces) - 1]
                    self.locations[place] = spec
                    self.order.add(place)

                stream.close()

            except FileNotFoundException:
                pass