@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.line_list);

    // Setup the list
    adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item);
    ListView list = (ListView) findViewById(R.id.list);
    list.setAdapter(adapter);
    list.setOnItemClickListener(this);

    // Load Directory
    if (savedInstanceState != null) {
      backStack = savedInstanceState.getParcelableArrayList("BACKSTACK");
    }

    if (backStack == null || backStack.size() == 0) {
      backStack = new ArrayList<BackStackItem>();
      String startPath =
          (startDirectory == null || startDirectory.isEmpty())
              ? Environment.getExternalStorageDirectory().getPath()
              : startDirectory;
      backStack.add(new BackStackItem(startPath, false));
    }

    wrapFiles();
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  }
示例#2
0
  /** Called when the activity is first created */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "LoaderActivity created");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.content);

    // Instantiate custom adapter
    mAdapter = new LoaderAdapter();

    // Handle listview and assign adapter
    mListView = (ListView) findViewById(R.id.content_list_view);
    mListView.setAdapter(mAdapter);
    mListView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
            selectItem(position);
            return true;
          }
        });

    mStatusLabel = (TextView) findViewById(R.id.content_status_label);
    mStatusLabel.setVisibility(View.VISIBLE);

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) showUserHashDialog();
    else refreshMapList();
  }
示例#3
0
 BookmarksAdapter(ListView listView, List<Bookmark> bookmarks, boolean currentBook) {
   myBookmarks = bookmarks;
   myCurrentBook = currentBook;
   listView.setAdapter(this);
   listView.setOnItemClickListener(this);
   listView.setOnCreateContextMenuListener(this);
 }
 void invalidateView() {
   if (!myAndroidViews.isEmpty()) {
     myAndroidViews.clear();
     myListView.setAdapter(new ViewAdapter());
     myListView.invalidate();
   }
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create a SQLite database holding event info
    DatabaseOpener dbopenhelper = new DatabaseOpener(this);
    db = dbopenhelper.getWritableDatabase();

    setContentView(R.layout.event_list);

    this.lv = (ListView) findViewById(R.id.eventListView);
    // Subclass CursorAdapter to read data from the database into the
    // ListView
    Cursor c =
        db.query(
            "event",
            new String[] {"_id", "isfavorite", "name", "starttime", "endtime"},
            null,
            null,
            null,
            null,
            "starttime asc");
    dbadapter = new EventListCursorAdapter(this, c, false);
    lv.setAdapter(dbadapter);
  }
 /** Updates the display */
 protected void updateDisplay() {
   // Use BookAdapter to display the data
   if (borrowedBooks != null) {
     adapter = new BookAdapter(getActivity(), R.layout.item_book_image, borrowedBooks);
     list.setAdapter(adapter); // assign the adapter to the listview
   }
   swipe.setRefreshing(false);
 }
示例#7
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.c09_overscroll);

    for (int i = 1001; i <= 1003; i++) {
      mItem.add(Integer.toString(i));
    }

    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mItem);

    mList = (ListView) findViewById(R.id.list);
    mList.setAdapter(mAdapter);
  }
 private void updateList() {
   View footerView = getFooterView();
   if (mListView.getFooterViewsCount() == 0) {
     mListView.addFooterView(footerView);
   }
   if (mSongAdapter == null) {
     mSongAdapter = new SongAdapter();
     mListView.setEmptyView(getEmptyView());
     mListView.setAdapter(mSongAdapter);
   } else {
     mSongAdapter.notifyDataSetChanged();
   }
 }
示例#9
0
  private void UploadToDropBox() {
    Utilities.LogDebug("GpsMainActivity.UploadToDropBox");

    final DropBoxHelper dropBoxHelper = new DropBoxHelper(getApplicationContext(), this);

    if (!dropBoxHelper.IsLinked()) {
      startActivity(new Intent("com.mendhak.gpslogger.DROPBOX_SETUP"));
      return;
    }

    final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");

    if (gpxFolder.exists()) {

      String[] enumeratedFiles = gpxFolder.list();
      List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
      Collections.reverse(fileList);
      final String[] files = fileList.toArray(new String[fileList.size()]);

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.dropbox_upload);
      dialog.setContentView(R.layout.filelist);
      ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

      thelist.setAdapter(
          new ArrayAdapter<String>(
              getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

      thelist.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> av, View v, int index, long arg) {

              dialog.dismiss();
              String chosenFileName = files[index];
              Utilities.ShowProgress(
                  GpsMainActivity.this,
                  getString(R.string.dropbox_uploading),
                  getString(R.string.please_wait));
              dropBoxHelper.UploadFile(chosenFileName);
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }
示例#10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    setContentView(R.layout.main);

    inputView = (EditText) findViewById(R.id.input_view);
    inputView.setOnEditorActionListener(this);

    listAdapter = new ArrayAdapter<String>(this, R.layout.row);
    listAdapter.setNotifyOnChange(true);

    resultsView = (ListView) this.findViewById(R.id.results_view);
    resultsView.setAdapter(listAdapter);
    resultsView.setOnItemClickListener(this);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Create layout and drawer
    setContentView(R.layout.activity_main);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // Set listeners
    mDrawerList.setAdapter(new DrawerListArrayAdapter(this, mFragmentList));
    mDrawerList.setOnItemClickListener(this);

    // Drawer layout
    mDrawerLayout = ((DrawerLayout) findViewById(R.id.drawer_layout));

    mTabletLandscape = mDrawerLayout == null;

    if (!mTabletLandscape) {
      // Change actionbar toggle icon
      mDrawerToggle =
          new ActionBarDrawerToggle(
              this, /* host Activity */
              mDrawerLayout, /* DrawerLayout object */
              R.drawable.ic_navigation_drawer, /* nav drawer icon to replace 'Up' caret */
              R.string.open_drawer, /* "open drawer" description */
              R.string.close_drawer /* "close drawer" description */);

      mDrawerLayout.setDrawerListener(mDrawerToggle);
      getActionBar().setDisplayHomeAsUpEnabled(true);
      getActionBar().setHomeButtonEnabled(true);
    }

    // Set default view
    if (savedInstanceState == null) {
      switchContent(new OverviewFragment(), false);
      setTitle(mFragmentList[0]);
    }
  }
  public void setMeatToppingsView() {

    ListView list = (ListView) findViewById(R.id.meatToppingsView);
    String[] meat = {"Pepperoni", "Chicken", "Ground Beef", "Anchovies", "Bacon Bits"};
    List<String> meatList = Arrays.asList(meat);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, meatList);
    list.setAdapter(adapter);
    list.setClickable(true);
    list.setChoiceMode(list.CHOICE_MODE_MULTIPLE);
    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckedTextView item = (CheckedTextView) view;
            if (item.isChecked()) {
              numMeatToppings++;
            } else {
              numMeatToppings--;
            }
          }
        });
  }
示例#13
0
  /**
   * Allows user to send a GPX/KML file along with location, or location only using a provider.
   * 'Provider' means any application that can accept such an intent (Facebook, SMS, Twitter, Email,
   * K-9, Bluetooth)
   */
  private void Share() {
    Utilities.LogDebug("GpsMainActivity.Share");
    try {

      final String locationOnly = getString(R.string.sharing_location_only);
      final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");
      if (gpxFolder.exists()) {
        String[] enumeratedFiles = gpxFolder.list();
        List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
        Collections.reverse(fileList);
        fileList.add(0, locationOnly);
        final String[] files = fileList.toArray(new String[fileList.size()]);

        final Dialog dialog = new Dialog(this);
        dialog.setTitle(R.string.sharing_pick_file);
        dialog.setContentView(R.layout.filelist);
        ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

        thelist.setAdapter(
            new ArrayAdapter<String>(
                getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

        thelist.setOnItemClickListener(
            new OnItemClickListener() {

              public void onItemClick(AdapterView<?> av, View v, int index, long arg) {
                dialog.dismiss();
                String chosenFileName = files[index];

                final Intent intent = new Intent(Intent.ACTION_SEND);

                // intent.setType("text/plain");
                intent.setType("*/*");

                if (chosenFileName.equalsIgnoreCase(locationOnly)) {
                  intent.setType("text/plain");
                }

                intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.sharing_mylocation));
                if (Session.hasValidLocation()) {
                  String bodyText =
                      getString(
                          R.string.sharing_latlong_text,
                          String.valueOf(Session.getCurrentLatitude()),
                          String.valueOf(Session.getCurrentLongitude()));
                  intent.putExtra(Intent.EXTRA_TEXT, bodyText);
                  intent.putExtra("sms_body", bodyText);
                }

                if (chosenFileName.length() > 0 && !chosenFileName.equalsIgnoreCase(locationOnly)) {
                  intent.putExtra(
                      Intent.EXTRA_STREAM, Uri.fromFile(new File(gpxFolder, chosenFileName)));
                }

                startActivity(Intent.createChooser(intent, getString(R.string.sharing_via)));
              }
            });
        dialog.show();
      } else {
        Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
      }
    } catch (Exception ex) {
      Utilities.LogError("Share", ex);
    }
  }
示例#14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // open up the DbAdaptor
    db.open();

    // gives us more screen space
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // need to do this because the camera doesn't do portrait mode
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    // initialize all our views.
    LayoutInflater inflater = getLayoutInflater();
    viewCaptureNote = inflater.inflate(R.layout.view_capture_note, null);
    viewNote = inflater.inflate(R.layout.view_note, null);
    viewTagList = inflater.inflate(R.layout.view_tag_list, null);
    viewNoteGallery = inflater.inflate(R.layout.view_note_gallery, null);

    // set the content view initially to save notes
    setContentView(viewCaptureNote);

    // set up the click listeners for the camera preview screen
    CameraPreview cameraPreview = (CameraPreview) findViewById(R.id.surface);
    findViewById(R.id.discard).setOnClickListener(cameraPreview);
    findViewById(R.id.take).setOnClickListener(cameraPreview);
    findViewById(R.id.save_untagged).setOnClickListener(cameraPreview);
    findViewById(R.id.save_and_tag).setOnClickListener(cameraPreview);

    // set up the 'view untagged' option in the list menu
    View someView = viewTagList.findViewById(R.id.tag_list_untagged);
    someView.findViewById(R.id.tag_subtags).setVisibility(View.GONE);
    ((TextView) someView.findViewById(R.id.tag_name)).setText("Click to view untagged notes");
    someView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
            g.setAdapter(new NoteGalleryImageAdaptor(SBActivity.this, db.getUntaggedNotes()));
            setContentView(viewNoteGallery);
          }
        });

    // set the list adaptor for our tag list
    final ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
    lv.setAdapter(new TagViewListAdaptor(this, db.getTagList()));
    registerForContextMenu(lv);
    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            TextView v = (TextView) view.findViewById(R.id.tag_subtags);
            v.setVisibility(v.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
            long tagId = (Long) view.findViewById(R.id.tag_name).getTag();
            if (v.getVisibility() == View.VISIBLE) {
              int subtagCount = 0;
              StringBuilder subTags = new StringBuilder("Sub-tags: ");
              Cursor c = db.getSubTags(tagId);
              while (c.moveToNext()) {
                subTags.append(c.getString(1) + " ");
                subtagCount++;
              }
              if (subtagCount > 0) v.setText(subTags);
              else v.setText("No sub-tags.");
            }
          }
        });
    lv.setOnCreateContextMenuListener(
        new View.OnCreateContextMenuListener() {
          public void onCreateContextMenu(
              ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.setHeaderIcon(android.R.drawable.ic_menu_info_details);
            ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
            Cursor listItem =
                (Cursor)
                    lv.getItemAtPosition(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
            String tagName = listItem.getString(1);
            menu.setHeaderTitle("Tag '" + tagName + "'");
            menu.add(0, CONTEXT_VIEW_NOTES, 0, "View notes tagged with '" + tagName + "'");
            menu.add(0, CONTEXT_DELETE_TAG, 0, "Delete tag");
          }
        });

    // set up click listeners for add tag
    viewTagList
        .findViewById(R.id.save_tag)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                EditText editText = (EditText) viewTagList.findViewById(R.id.tag_id);
                if (editText.getText().length() == 0) return;
                db.addNewTag(editText.getText());
                ((TagViewListAdaptor) lv.getAdapter()).refreshData();
                Toast.makeText(
                        SBActivity.this,
                        "Tag '" + editText.getText() + "' added.",
                        Toast.LENGTH_SHORT)
                    .show();
                editText.setText("");
              }
            });
    viewTagList.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
            Log.i(TAG, "Focus changed innit: " + b);
            if (b) ((TagViewListAdaptor) lv.getAdapter()).refreshData();
          }
        });

    // set up our note viewing gallery
    final Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
    g.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            // set the note number i.e. 1/3
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_number))
                .setText((i + 1) + " / " + g.getCount());

            // set the date field
            Date d = new Date(((Note) view.getTag()).getSaveTime());
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_date))
                .setText(DateFormat.getDateTimeInstance().format(d));

            // set the tag field
            Cursor c = db.getTagListForImg(l);
            StringBuilder sb = new StringBuilder();
            while (c.moveToNext()) {
              if (c.getInt(2) == 0) continue;
              sb.append(c.getString(1));
              sb.append(", ");
            }
            // delete the last 2 chars: ", "
            if (sb.length() > 0) sb.delete(sb.length() - 2, sb.length());
            else sb.append("none");
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_tags))
                .setText(sb.toString());
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });
    g.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

            return true;
          }
        });
    viewNoteGallery
        .findViewById(R.id.note_gallery_examine)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Note n = (Note) ((View) g.getSelectedView()).getTag();
                setViewSingleNote(n.getFileName());
              }
            });

    Handler btProgressHandler =
        new Handler() {
          public void handleMessage(Message msg) {
            if (btProgressDialog == null) return;
            switch (msg.what) {
              case BluetoothService.MSG_CONNECTED:
                btProgressDialog.setMessage("Bluetooth connected! Sending updates...");
                break;
              case BluetoothService.MSG_RECEIVING:
                btProgressDialog.setMessage("Receiving updates from computer..");
                break;
              case BluetoothService.MSG_PROGRESS:
                int cur = msg.arg1;
                int max = msg.arg2;
                btProgressDialog.setProgress(cur);
                btProgressDialog.setMax(max);
                break;
              case BluetoothService.MSG_DONE:
                btProgressDialog.dismiss();
                break;
            }
          }
        };
    bService.setProgressHandler(btProgressHandler);
  }
示例#15
0
 BookmarksAdapter(ListView listView, boolean showAddBookmarkItem) {
   myShowAddBookmarkItem = showAddBookmarkItem;
   listView.setAdapter(this);
   listView.setOnItemClickListener(this);
   listView.setOnCreateContextMenuListener(this);
 }
 protected void createListView(Context context) {
   myContext = context;
   myListView = new ListView(context);
   myListView.setAdapter(new ViewAdapter());
 }
  // Unchanged
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ActionBar ab = getActionBar();
    //            ab.setNavigationMode( ActionBar.NAVIGATION_MODE_TABS );

    // ViewPager and its adapters use support library
    // fragments, so use getSupportFragmentManager.
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mDemoCollectionPagerAdapter);

    // 1. Your data source
    List<Item> items = getItems();

    ItemAdapter itemAdapter = new ItemAdapter(this, R.layout.list_item_simple, items);
    SimpleSectionizer simpleSectionizer = new SimpleSectionizer();
    // 5. Wrap your adapter within the SimpleSectionAdapter
    SimpleSectionAdapter<Item> sectionAdapter =
        new SimpleSectionAdapter<Item>(
            this, itemAdapter, R.layout.section_header, R.id.title, simpleSectionizer);

    //        6. Set the adapter to your ListView
    //        setListAdapter(sectionAdapter);

    mTitle = mDrawerTitle = getTitle();
    //            mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    //            mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(sectionAdapter);
    //                new ArrayAdapter<String>(this,
    //                R.layout.drawer_list_item, mPlanetTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */) {
          public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }

          public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
      selectItem(0);
    }

    //            mViewPager = new ViewPager(this);
    //            mViewPager.setId(R.id.pager);
    //
    //            mTabsAdapter = new TabAdapter(this, mViewPager);
    //
    // mTabsAdapter.addTab(ab.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.ic_action_refresh)), Fragment1.class, null);
    //
    // mTabsAdapter.addTab(ab.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.ic_action_refresh)), Fragment1.class, null);
    //
    // mTabsAdapter.addTab(ab.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.ic_action_refresh)), Fragment1.class, null);
    //
    // mTabsAdapter.addTab(ab.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.ic_action_refresh)), Fragment1.class, null);
    //
    // mTabsAdapter.addTab(ab.newTab().setText("").setIcon(getResources().getDrawable(R.drawable.ic_action_refresh)), Fragment1.class, null);

    //            ActionBar.Tab tab = ab.newTab()
    //                    .setText( R.string.frag1 )
    //                    .setTabListener(
    //                            new MyTabListener( this,
    //                                    Fragment1.class.getName() ) );
    //            ab.addTab( tab );
    //
    //            tab = ab.newTab()
    //                    .setText( R.string.frag2 )
    //                    .setTabListener(
    //                            new MyTabListener( this,
    //                                    Fragment2.class.getName() ) );
    //            ab.addTab( tab );

    //            for (int i = 0; i < 3; i++) {
    //                ab.addTab(
    //                        ab.newTab()
    //                                .setText("Tab " + (i + 1))
    //                                .setTabListener(tabListener));
    //            }

    //            mViewPager.setOnPageChangeListener(
    //                    new ViewPager.SimpleOnPageChangeListener() {
    //                        @Override
    //                        public void onPageSelected(int position) {
    //                            // When swiping between pages, select the
    //                            // corresponding tab.
    //                            Log.d(TAG, "viewpage swipe");
    //                            getActionBar().setSelectedNavigationItem(position);
    //                        }
    //                    }
    //            );
    //        }

  }
示例#18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_drawer);
    CONTENT_VIEW_ID = R.id.content_frame;

    Utils.showUserGuardIfNeed(this, UserGuideActivity.START_FROM_SPLASH);

    mTitle = mDrawerTitle = getTitle();
    //        mDrawerItems = getResources().getStringArray(R.array.drawer_items_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    drawerListAdapter = new DrawerListAdapter(getApplicationContext());
    drawerItemArrayList = new ArrayList<Object>();
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_DASHBOARD, getString(R.string.menu_item_dashboard)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_PUSHUPS, getString(R.string.menu_item_pushup)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_MULTI, getString(R.string.menu_item_multi)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_WRIST, getString(R.string.menu_item_wrist)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_GOOGLE, getString(R.string.menu_item_google)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_LEADERBOARD, getString(R.string.menu_item_leaderboard)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_ARCHIEVEMENT, getString(R.string.menu_item_archievement)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_HELPER, getString(R.string.menu_item_helper)));
    drawerItemArrayList.add(
        new DrawerListAdapter.DrawerItem(
            Constants.DRAWER_ITEM_ABOUT, getString(R.string.menu_item_about)));

    drawerListAdapter.setDataList(drawerItemArrayList);
    mDrawerList.setAdapter(drawerListAdapter);

    //        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
    //                R.layout.drawer_list_item, mDrawerItems));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBarImpl().setDisplayHomeAsUpEnabled(true);
    getActionBarImpl().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */) {
          public void onDrawerClosed(View view) {
            getActionBarImpl().setTitle(mTitle);
            supportInvalidateOptionsMenu();
            //                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }

          public void onDrawerOpened(View drawerView) {
            getActionBarImpl().setTitle(mDrawerTitle);
            supportInvalidateOptionsMenu();
            //                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
      selectItem((DrawerListAdapter.DrawerItem) drawerListAdapter.getItem(0));
    } else {
      selectItem((DrawerListAdapter.DrawerItem) drawerListAdapter.getItem(0));
    }

    bus = ServiceProvider.getBus();
    bus.register(this);

    appPreference = AppPreference.getInstance(getApplicationContext());
    titlebarHelper =
        new TitlebarHelper(
            MainActivity.this,
            new TitlebarHelper.OnTitlebarClickListener() {
              @Override
              public void onClickIcon() {}

              @Override
              public void onClickTitle() {}
            });

    userIcon = (ImageView) findViewById(R.id.user_icon);
    userInfo = (TextView) findViewById(R.id.user_info);
    share = (TextView) findViewById(R.id.share_textview);

    userInfo.setOnClickListener(this);
    userIcon.setOnClickListener(this);
    share.setOnClickListener(this);
    findViewById(R.id.button_sign_in).setOnClickListener(this);
    findViewById(R.id.button_sign_out).setOnClickListener(this);

    getGamesClient()
        .registerConnectionCallbacks(
            new GooglePlayServicesClient.ConnectionCallbacks() {
              @Override
              public void onConnected(Bundle bundle) {
                submitScore();
              }

              @Override
              public void onDisconnected() {
                showAlert("Connect", "Disconnected!");
              }
            });

    getGamesClient().connect();

    //        if (!isSignedIn()) {
    //            beginUserInitiatedSignIn();
    //        }

    //        showDashboardFragment();
    initWeChat();
  }
示例#19
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.record_journal);
    Bundle bundle = getIntent().getExtras();
    String journalIDs = (String) bundle.get("journals");
    String recordID = (String) bundle.get("recordID");
    myJournalNetwork.requestList(journalIDs, recordID);
    final ArrayList<HashMap<String, String>> journalList = myJournalNetwork.getList();

    ListView listView = (ListView) findViewById(R.id.record_journal_listView);
    record_journal_adapter = new Record_Journal_Adapter(this, journalList);
    listView.setAdapter(record_journal_adapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            // To change body of implemented methods use File | Settings | File Templates.
            // LayoutInflater inflater = (LayoutInflater)
            // Record_Journal.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final int position = i;
            final HashMap<String, String> modified_journal = journalList.get(i);
            LayoutInflater inflater = LayoutInflater.from(adapterView.getContext());
            LinearLayout linearLayout =
                (LinearLayout) inflater.inflate(R.layout.journal_clickitem, null);
            AlertDialog.Builder builder = new AlertDialog.Builder(Record_Journal.this);

            // String type = (String) ((HashMap<String,
            // Object>)adapterView.getAdapter().getItem(i)).get("type");
            TextView titleTextView = (TextView) view.findViewById(R.id.journal_title_textView);
            String title = (String) titleTextView.getText();

            TextView contentTextView = (TextView) view.findViewById(R.id.journal_content_textView);
            String content = (String) contentTextView.getText();

            final EditText titleEditText =
                (EditText) linearLayout.findViewById(R.id.journal_title_editText);
            titleEditText.setText(title);

            final EditText contentEditText =
                (EditText) linearLayout.findViewById(R.id.journal_content_editText);
            contentEditText.setText(content);

            titleEditText.setEnabled(true);
            contentEditText.setEnabled(true);

            builder.setPositiveButton(
                "保 存",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    // To change body of implemented methods use File | Settings | File Templates.
                    modified_journal.put("title", String.valueOf(titleEditText.getText()));
                    modified_journal.put("body", String.valueOf(contentEditText.getText()));
                    String date =
                        String.valueOf(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                    modified_journal.put("time", date);
                    modified_journal.put("userID", Login.userID);
                    if (myJournalNetwork.modify(position, modified_journal)) {
                      Toast.makeText(Record_Journal.this, "修改成功", Toast.LENGTH_SHORT);
                    } else {
                      Toast.makeText(Record_Journal.this, "修改失败", Toast.LENGTH_SHORT);
                    }
                    record_journal_adapter.notifyDataSetChanged();
                  }
                });
            builder.setNegativeButton(
                "取 消",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    // To change body of implemented methods use File | Settings | File Templates.
                  }
                });

            builder.setTitle("编辑日志").setView(linearLayout);
            builder.show();
          }
        });
    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            // TODO delete journal
            return false; // To change body of implemented methods use File | Settings | File
                          // Templates.
          }
        });
  }
示例#20
0
  /** Uploads a GPS Trace to OpenStreetMap.org. */
  private void UploadToOpenStreetMap() {
    Utilities.LogDebug("GpsMainactivity.UploadToOpenStreetMap");

    if (!OSMHelper.IsOsmAuthorized(getApplicationContext())) {
      startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext()));
      return;
    }

    final String goToOsmSettings = getString(R.string.menu_settings);

    final File gpxFolder = new File(Environment.getExternalStorageDirectory(), "GPSLogger");

    if (gpxFolder.exists()) {
      FilenameFilter select =
          new FilenameFilter() {

            public boolean accept(File dir, String filename) {
              return filename.toLowerCase().contains(".gpx");
            }
          };

      String[] enumeratedFiles = gpxFolder.list(select);
      List<String> fileList = new ArrayList<String>(Arrays.asList(enumeratedFiles));
      Collections.reverse(fileList);
      fileList.add(0, goToOsmSettings);
      final String[] files = fileList.toArray(new String[fileList.size()]);

      final Dialog dialog = new Dialog(this);
      dialog.setTitle(R.string.osm_pick_file);
      dialog.setContentView(R.layout.filelist);
      ListView thelist = (ListView) dialog.findViewById(R.id.listViewFiles);

      thelist.setAdapter(
          new ArrayAdapter<String>(
              getApplicationContext(), android.R.layout.simple_list_item_single_choice, files));

      thelist.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> av, View v, int index, long arg) {

              dialog.dismiss();
              String chosenFileName = files[index];

              if (chosenFileName.equalsIgnoreCase(goToOsmSettings)) {
                startActivity(OSMHelper.GetOsmSettingsIntent(getApplicationContext()));
              } else {
                OSMHelper osm = new OSMHelper(GpsMainActivity.this, GpsMainActivity.this);
                Utilities.ShowProgress(
                    GpsMainActivity.this,
                    getString(R.string.osm_uploading),
                    getString(R.string.please_wait));
                osm.UploadGpsTrace(chosenFileName);
              }
            }
          });
      dialog.show();
    } else {
      Utilities.MsgBox(getString(R.string.sorry), getString(R.string.no_files_found), this);
    }
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // TODO Auto-generated method stub
    setContentView(R.layout.coolers);

    /*
     *  Initialize listView_main
     */
    ListView coolers_lv = (ListView) findViewById(R.id.listView_coolers);
    List<String> items = new ArrayList<String>();

    File sys_class_thermal_dir = new File("/sys/class/thermal");
    if (!sys_class_thermal_dir.exists()) {
      Toast.makeText(this, "No coolers found!", Toast.LENGTH_LONG).show();
      return;
    }

    File[] thermal_dev_file_list = sys_class_thermal_dir.listFiles();
    if (null == thermal_dev_file_list) {
      Toast.makeText(this, "No coolers found!", Toast.LENGTH_LONG).show();
      return;
    }

    for (int i = 0; i < thermal_dev_file_list.length; i++) {
      if (thermal_dev_file_list[i].getName().contains("cooling_device")) {
        // get the type, cur_state, and max_state
        // compose it to type -- cur_state/max_state
        // add to list
        // items.add(thermal_dev_file_list[i].getName());
        String toshow = new String();

        // get type
        File a = new File(thermal_dev_file_list[i].getPath() + "/type");
        if (a.exists()) {
          try {
            FileInputStream fs = new FileInputStream(a);
            DataInputStream ds = new DataInputStream(fs);
            toshow += ds.readLine();
            ds.close();
            fs.close();
          } catch (Exception ex) {

          }
        }

        // get cur_state
        File b = new File(thermal_dev_file_list[i].getPath() + "/cur_state");
        if (b.exists()) {
          try {
            FileInputStream fs = new FileInputStream(b);
            DataInputStream ds = new DataInputStream(fs);
            toshow += " -- ";
            toshow += ds.readLine();
            toshow += " / ";
            ds.close();
            fs.close();
          } catch (Exception ex) {

          }
        }

        // get max_state
        File c = new File(thermal_dev_file_list[i].getPath() + "/max_state");
        if (c.exists()) {
          try {
            FileInputStream fs = new FileInputStream(c);
            DataInputStream ds = new DataInputStream(fs);
            toshow += ds.readLine();
            ds.close();
            fs.close();
          } catch (Exception ex) {

          }
        }

        items.add(toshow);
      }
    }

    coolers_lv.setAdapter(
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));
    coolers_lv.setOnItemClickListener(this);
  }