예제 #1
5
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.list_item_icon, parent, false);
      TextView textView = (TextView) rowView.findViewById(R.id.label);

      ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
      textView.setText(mValues[position]);

      // Set icons
      String s = mValues[position];
      if (s.equals("CPU")) {
        imageView.setImageResource(R.drawable.ic_drawer_cpu);
      } else if (s.equals("System")) {
        imageView.setImageResource(R.drawable.ic_drawer_system);
      } else if (s.equals("Disks")) {
        imageView.setImageResource(R.drawable.ic_drawer_disks);
      } else if (s.equals("Processes")) {
        imageView.setImageResource(R.drawable.ic_drawer_processes);
      } else if (s.equals("GPU")) {
        imageView.setImageResource(R.drawable.ic_drawer_gpu);
      } else if (s.equals("Overview")) {
        imageView.setImageResource(R.drawable.ic_drawer_overview);
      } else if (s.equals("History")) {
        imageView.setImageResource(R.drawable.ic_drawer_history);
      } else if (s.equals("Notifications")) {
        imageView.setImageResource(R.drawable.ic_drawer_notifications);
      }
      imageView.setContentDescription(s + " icon");

      return rowView;
    }
예제 #2
1
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    String title = (String) item.getTitle();
    if (title.equals("添加")) {
      final HashMap<String, String> add_journal = new HashMap<String, String>();
      LayoutInflater inflater = LayoutInflater.from(this);
      LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.journal_clickitem, null);
      AlertDialog.Builder builder = new AlertDialog.Builder(Record_Journal.this);
      final EditText titleEditText =
          (EditText) linearLayout.findViewById(R.id.journal_title_editText);
      final EditText contentEditText =
          (EditText) linearLayout.findViewById(R.id.journal_content_editText);
      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.
              add_journal.put("title", String.valueOf(titleEditText.getText()));
              add_journal.put("body", String.valueOf(contentEditText.getText()));
              String date = String.valueOf(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
              add_journal.put("time", date);
              add_journal.put("userID", Login.userID);
              if (myJournalNetwork.add(add_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();

    } else if (title.equals("帮助")) {
      Menu_Functions.helpMe(this);
    } else if (title.equals("联系")) {
      Menu_Functions.contactMe(this);
    }
    return super.onOptionsItemSelected(
        item); // To change body of overridden methods use File | Settings | File Templates.
  }
예제 #3
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
예제 #4
0
  private View createView(View reusableView, TModel model) {
    View view = reusableView;
    if (view == null) {
      LayoutInflater inflater =
          (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = inflater.inflate(LAYOUT_ID, null);
    }

    this.setupReusableView(view, model);

    return view;
  }
예제 #5
0
  private View getWorkingView(final View convertView) {
    View workingView = null;

    if (null == convertView) {
      final Context context = getContext();
      final LayoutInflater inflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      workingView = inflater.inflate(itemsItemLayoutResource, null);
    } else {
      workingView = convertView;
    }

    return workingView;
  }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View view = inflater.inflate(R.layout.activity_community_commentary, null);
   ButterKnife.bind(this, view);
   return view;
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.estadistica_view, container, false);

    int idEstadistica = this.mPageNumber;

    // Titulo y descripcion de estadistica
    TextView tituloEstadistica = (TextView) rootView.findViewById(R.id.TxtTituloEstadistica);
    TextView descEstadistica = (TextView) rootView.findViewById(R.id.TxtDescEstadistica);

    tituloEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getTitulo());
    descEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getDescripcion());

    rootView.addView(
        new EstadisticaViewLayout(Utilidades.getAppContext())
            .getView(RelacionEstadisticas.getRelacion().get(idEstadistica)));
    // }
    // catch (Exception e)
    // {
    //	Toast.makeText(Utilidades.getAppContext(), "error: " + e.getLocalizedMessage(),
    // Toast.LENGTH_LONG).show();
    //	Log.e("ERROR", e.getLocalizedMessage());
    // }
    // Set the title view to show the page number.
    /*((TextView) rootView.findViewById(android.R.id.text1)).setText(
    getString(R.string.title_template_step, mPageNumber + 1));*/

    return rootView;
  }
예제 #8
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_song, null);
        holder.mTvName = (TextView) convertView.findViewById(R.id.tv_name);
        holder.mTvArtist = (TextView) convertView.findViewById(R.id.tv_artist);
        holder.mTvDuration = (TextView) convertView.findViewById(R.id.tv_duration);
        holder.aboveView = convertView.findViewById(R.id.item_root);
        holder.behindView = convertView.findViewById(R.id.behind);
        convertView.setTag(holder);
        convertViewList.add((PullRightLayout) convertView);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
      if (HideApplication.showListAnim) {
        startAnim(convertView);
      }

      SongInfo info = SongManager.with(getActivity()).getSongByIndex(position);
      holder.mTvName.setText(info.getTitle());
      holder.mTvArtist.setText(info.getArtist() + " - " + info.getAlbum());
      holder.mTvDuration.setText(
          CommonUtils.durationToString(info.getDuration())
              + " - "
              + CommonUtils.getFileSize(info.getPath()));

      setItemSelected(holder, info.getId() == playingId);

      convertView.setOnClickListener(new OnItemClick(position));
      holder.behindView.setOnClickListener(new OnBehindClick(position));

      return convertView;
    }
예제 #9
0
    public View getView(int position, View convertView, ViewGroup parent) {
      final View view =
          (convertView != null)
              ? convertView
              : LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.bookmark_item, parent, false);
      final ImageView imageView = (ImageView) view.findViewById(R.id.bookmark_item_icon);
      final TextView textView = (TextView) view.findViewById(R.id.bookmark_item_text);
      final TextView bookTitleView = (TextView) view.findViewById(R.id.bookmark_item_booktitle);

      final Bookmark bookmark = getItem(position);
      if (bookmark == null) {
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.ic_list_plus);
        textView.setText(ZLResource.resource("bookmarksView").getResource("new").getValue());
        bookTitleView.setVisibility(View.GONE);
      } else {
        imageView.setVisibility(View.GONE);
        textView.setText(bookmark.getText());
        if (myCurrentBook) {
          bookTitleView.setVisibility(View.GONE);
        } else {
          bookTitleView.setVisibility(View.VISIBLE);
          bookTitleView.setText(bookmark.getBookTitle());
        }
      }
      return view;
    }
예제 #10
0
 @Override
 public HomeListAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
   View view =
       LayoutInflater.from(viewGroup.getContext())
           .inflate(R.layout.listview_homemenu, viewGroup, false);
   ViewHolder vh = new ViewHolder(view);
   return vh;
 }
예제 #11
0
 @Override
 public View onCreateView(
     final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
   Log.i(TAG, "onCreateView");
   ret = inflater.inflate(R.layout.fragment_search, container, false);
   initView();
   refreshLocalFans();
   return ret;
 }
예제 #12
0
  @Override
  protected View inflateView(LayoutInflater inflater, ViewGroup container) {
    Intent playIntent = new Intent(getActivity(), PlayService.class);
    getActivity().startService(playIntent);
    getActivity().bindService(playIntent, playConn, Context.BIND_AUTO_CREATE);

    ThemeManager.with(getActivity()).registerListener(this);

    return inflater.inflate(R.layout.fragment_song, container, false);
  }
 private void initPagerItems() {
   for (int i = 0; i < bitmapList.size(); i++) {
     View v = LayoutInflater.from(this).inflate(R.layout.call_activity_itempage, null);
     ImageView imageView = (ImageView) v.findViewById(R.id.contactIv);
     TextView textView = (TextView) v.findViewById(R.id.contactTv);
     imageView.setImageBitmap(bitmapList.get(i));
     textView.setText(nameList.get(i));
     viewArrayList.add(v);
   }
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      PhotoGridHolder holder = null;

      if (row == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
        holder = new PhotoGridHolder();
        holder.itemImageView = (ImageView) row.findViewById(R.id.galleryGridImage);
        row.setTag(holder);
      } else {
        holder = (PhotoGridHolder) row.getTag();
      }
      String filename = getItem(position);
      String path = context.getFilesDir().getAbsolutePath() + "/images/" + filename;

      holder.itemImageView.setImageURI(Uri.parse(path));
      return row;
    }
  private void init() {
    mMyDrawer = new MyDrawer(this);
    mDrawerLayout = mMyDrawer.getDrawerLayout();

    // getActionBar().setDisplayHomeAsUpEnabled(false);
    LayoutInflater inflater = getLayoutInflater();
    RelativeLayout container = (RelativeLayout) findViewById(R.id.frame_container);
    inflater.inflate(R.layout.activity_main_two_way_grid, container);

    horzGridView = (TwoWayGridView) findViewById(R.id.horz_gridview);
    horzGridView.setPadding(0, 0, 0, 0);
    List<DataObject> horzData = generateGridViewObjects();

    horzGridViewAdapter = new TelepadGridViewAdapter(mContext, horzData);
    mList = (ListView) findViewById(R.id.list_slidermenu);

    horzGridView.setAdapter(horzGridViewAdapter);
    horzGridView.setOnItemClickListener(this);
    // horzGridView.requestFocus();
    mDrawerLayout.getChildAt(0).requestFocus();
  }
예제 #16
0
  private void initViews(Context context, int customLeftMenuId, int customRightMenuId) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.residemenu_custom, this);

    if (customLeftMenuId >= 0) {
      scrollViewLeftMenu = inflater.inflate(customLeftMenuId, this, false);
    } else {
      scrollViewLeftMenu =
          inflater.inflate(R.layout.residemenu_custom_left_scrollview, this, false);
      layoutLeftMenu = (LinearLayout) scrollViewLeftMenu.findViewById(R.id.layout_left_menu);
    }

    if (customRightMenuId >= 0) {
      scrollViewRightMenu = inflater.inflate(customRightMenuId, this, false);
    } else {
      scrollViewRightMenu =
          inflater.inflate(R.layout.residemenu_custom_right_scrollview, this, false);
      layoutRightMenu = (LinearLayout) scrollViewRightMenu.findViewById(R.id.layout_right_menu);
    }

    imageViewShadow = (ImageView) findViewById(R.id.iv_shadow);
    imageViewBackground = (ImageView) findViewById(R.id.iv_background);

    RelativeLayout menuHolder = (RelativeLayout) findViewById(R.id.sv_menu_holder);
    menuHolder.addView(scrollViewLeftMenu);
    menuHolder.addView(scrollViewRightMenu);
  }
예제 #17
0
 public void setAccounts(int layoutResourceId, List<Account> accounts) {
   this.layoutResourceId = layoutResourceId;
   this.accounts = accounts;
   layoutInflater = LayoutInflater.from(getContext());
   for (int i = 0; i < accounts.size(); i++) {
     View view = getView(i, null, this);
     view.setVisibility(GONE);
     this.addView(view);
   }
   this.getChildAt(currentPosition).setVisibility(VISIBLE);
   this.gestureListener = new GestureListener();
   this.gesturedetector = new GestureDetector(getContext(), gestureListener);
 }
예제 #18
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.row, null);
   }
   Message m = items.get(position);
   // if (m != null) {
   m.createColorFromString(m.from);
   TextView tt = (TextView) v.findViewById(R.id.username);
   TextView bt = (TextView) v.findViewById(R.id.message);
   if (isMonospaced) {
     tt.setTypeface(Typeface.MONOSPACE);
     bt.setTypeface(Typeface.MONOSPACE);
   }
   tt.setText(m.getFrom());
   tt.setTextColor(m.color);
   bt.setText(m.getMessage());
   // }
   return v;
 }
  private void init() {
    setVerticalFadingEdgeEnabled(false);

    headerContainer =
        (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ptr_header, null);
    header = (RelativeLayout) headerContainer.findViewById(R.id.ptr_id_header);
    text = (TextView) header.findViewById(R.id.ptr_id_text);
    lastUpdatedTextView = (TextView) header.findViewById(R.id.ptr_id_last_updated);
    image = (ImageView) header.findViewById(R.id.ptr_id_image);
    spinner = (ProgressBar) header.findViewById(R.id.ptr_id_spinner);

    pullToRefreshText = getContext().getString(R.string.ptr_pull_to_refresh);
    releaseToRefreshText = getContext().getString(R.string.ptr_release_to_refresh);
    refreshingText = getContext().getString(R.string.ptr_refreshing);
    lastUpdatedText = getContext().getString(R.string.ptr_last_updated);

    flipAnimation =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    flipAnimation.setFillAfter(true);

    reverseFlipAnimation =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION);
    reverseFlipAnimation.setFillAfter(true);

    addHeaderView(headerContainer);
    setState(State.PULL_TO_REFRESH);
    scrollbarEnabled = isVerticalScrollBarEnabled();

    ViewTreeObserver vto = header.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new PTROnGlobalLayoutListener());

    super.setOnItemClickListener(new PTROnItemClickListener());
    super.setOnItemLongClickListener(new PTROnItemLongClickListener());
  }
예제 #20
0
  protected View getView(int position, View convertView, ViewGroup parent) {
    AccountHolder holder;
    if (convertView == null) {
      convertView = layoutInflater.inflate(layoutResourceId, parent, false);
      holder = new AccountHolder();
      holder.accountRow1 = (TextView) convertView.findViewById(R.id.accountRow1);
      holder.accountRow1.setTypeface(GothamFont.BOLD);
      holder.accountRow2 = (TextView) convertView.findViewById(R.id.accountRow2);
      convertView.setTag(holder);

    } else holder = (AccountHolder) convertView.getTag();

    Account account = getItem(position);

    holder.accountRow2.setText(getAccountRow2(account));
    holder.accountRow1.setText(getAccountRow1(account));

    return convertView;
  }
예제 #21
0
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    final SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);
    manager.setOnCancelListener(null);

    final TabHost host = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);

    myBook = SerializerUtil.deserializeBook(getIntent().getStringExtra(FBReader.BOOK_KEY));
  }
예제 #22
0
    public View getView(int position, View convertView, ViewGroup parent) {
      RelativeLayout rowLayout;
      ServiceAcctInfo acct = acctList[position];
      if (convertView == null) {
        rowLayout =
            (RelativeLayout)
                LayoutInflater.from(context).inflate(R.layout.realm_login_row, parent, false);
      } else {
        rowLayout = (RelativeLayout) convertView;
      }

      String acctType = msgsetNames[acct.type.ordinal()];
      if (acct.name.acctType != null) acctType = acctType + " (" + acct.name.acctType + ')';
      if (acct.name.acctId != null) acctType = acctType + "\nAccount: " + acct.name.acctId;
      ((TextView) rowLayout.findViewById(R.id.Name)).setText(acct.desc);
      ((TextView) rowLayout.findViewById(R.id.TaskList)).setText(acctType);

      return rowLayout;
    }
예제 #23
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView =
        inflater.inflate(R.layout.ext_cashila_payments_fragment_pending, container, false);
    ButterKnife.inject(this, rootView);

    mbw = MbwManager.getInstance(this.getActivity());
    cs = ((CashilaPaymentsActivity) getActivity()).getCashilaService();
    eventBus = mbw.getEventBus();

    getBillPays(true);

    lvPending.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {}

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });

    return rootView;
  }
예제 #24
0
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));

    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    final TabHost host = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);

    AllBooksBookmarks = Bookmark.bookmarks();
    Collections.sort(AllBooksBookmarks, new Bookmark.ByTimeComparator());
    final FBReader fbreader = (FBReader) FBReader.Instance();

    if (fbreader.Model != null) {
      final long bookId = fbreader.Model.Book.getId();
      for (Bookmark bookmark : AllBooksBookmarks) {
        if (bookmark.getBookId() == bookId) {
          myThisBookBookmarks.add(bookmark);
        }
      }

      myThisBookView = createTab("thisBook", R.id.this_book);
      new BookmarksAdapter(myThisBookView, myThisBookBookmarks, true);
    } else {
      findViewById(R.id.this_book).setVisibility(View.GONE);
    }

    myAllBooksView = createTab("allBooks", R.id.all_books);
    new BookmarksAdapter(myAllBooksView, AllBooksBookmarks, false);

    findViewById(R.id.search_results).setVisibility(View.GONE);
  }
예제 #25
0
  @Override
  public View GetView(
      LayoutInflater inflater,
      ViewGroup container,
      SurveyActivity activityRef,
      SurveyAdapter surveyAdapter,
      int parentId) {

    View view = inflater.inflate(R.layout.gps_question, container, false);
    TextView label = (TextView) view.findViewById(R.id.description);
    label.setText(this.label);
    label.setTextSize(fontSize);

    Typeface tf = Typeface.createFromAsset(activityRef.getAssets(), "fonts/OpenSans-Regular.ttf");
    label.setTypeface(tf);

    try {
      label.setTextColor(Color.parseColor(color));
    } catch (Exception e) {
    }

    // SET LABELS
    TextView textlatlabel = (TextView) view.findViewById(R.id.lattext);
    textlatlabel.setText(latLabel);
    textlatlabel.setTypeface(tf);

    TextView textLonlabel = (TextView) view.findViewById(R.id.lontext);
    textLonlabel.setText(lonLabel);
    textLonlabel.setTypeface(tf);

    // GET GPS POSITION
    textLat = (TextView) view.findViewById(R.id.latitude);
    textLon = (TextView) view.findViewById(R.id.longitude);
    textLat.setTypeface(tf);
    textLon.setTypeface(tf);

    if (locationManager == null) {
      // Acquire a reference to the system Location Manager
      locationManager =
          (LocationManager) view.getContext().getSystemService(Context.LOCATION_SERVICE);

      // Define a listener that responds to location updates
      LocationListener locationListener =
          new LocationListener() {
            public void onLocationChanged(Location location) {

              if (LocationUtil.isBetterLocation(location, currentBestLocation)) {
                // Called when a new location is found by the network location provider.
                textLat.setText(String.valueOf(location.getLatitude()));
                textLon.setText(String.valueOf(location.getLongitude()));
                answer =
                    String.valueOf(location.getLatitude())
                        + "/"
                        + String.valueOf(location.getLongitude());

                // Remove the listener you previously added
                locationManager.removeUpdates(this);
              }
            }

            public void onProviderEnabled(String provider) {}

            public void onProviderDisabled(String provider) {}

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {
              // TODO Auto-generated method stub

            }
          };

      // Register the listener with the Location Manager to receive location updates
      locationManager.requestLocationUpdates(
          LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

      Criteria criteria = new Criteria();
      String provider = locationManager.getBestProvider(criteria, false);
      currentBestLocation = locationManager.getLastKnownLocation(provider);
    }

    // SET ORIENTATION
    LinearLayout layout = (LinearLayout) view.findViewById(R.id.layout);
    if (orientation.equals("horizontal")) layout.setOrientation(LinearLayout.HORIZONTAL);
    else layout.setOrientation(LinearLayout.VERTICAL);

    // SET ANSWER
    if (!answer.equals("")) {
      String[] parts = answer.split("/");
      textLat.setText(parts[0]);
      textLon.setText(parts[1]);
    }
    return view;
  }
예제 #26
0
  protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    switch (id) {
      case PROMPT_OAUTH:
        builder
            .setMessage(R.string.commentneedsinaoauth)
            .setCancelable(false)
            .setPositiveButton(
                R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    FlipdroidApplications application = (FlipdroidApplications) getApplication();
                    OAuth oauth = new OAuth();
                    application.setOauth(oauth);
                    //// System.out.println("OAuthHolder.oauth" + application + oauth);
                    oauth.RequestAccessToken(PageActivity.this, "flipdroid://SinaAccountSaver");
                  }
                })
            .setNegativeButton(
                R.string.cancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {}
                });
        this.dialog = builder.create();
        break;
      case NAVIGATION:
        LayoutInflater li = LayoutInflater.from(this);
        View v = li.inflate(R.layout.dialog_nav_title_view, null);

        // builder.setView(v);
        builder.setCustomTitle(v);

        builder.setAdapter(
            sourceAdapter,
            new DialogInterface.OnClickListener() {

              public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent(PageActivity.this, PageActivity.class);
                SourceItem cursor = sourceAdapter.getItem(i);
                intent.putExtra("type", cursor.getSourceType());
                intent.putExtra("sourceId", cursor.getSourceId());
                intent.putExtra("sourceImage", cursor.getSourceImage());
                intent.putExtra("sourceName", cursor.getSourceName());
                intent.putExtra("contentUrl", cursor.getSourceURL());
                if (dialog != null) dialog.dismiss();
                startActivity(intent);
                finishActivity();
              }
            });

        this.dialog = builder.create();
        Button btn_addshortcut = (Button) v.findViewById(R.id.btnaddshortcut);
        btn_addshortcut.setText("add shortcut");

        btn_addshortcut.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                addShortcut();
                dialog.cancel();
              }
            });

        dialog.setOnKeyListener(
            new DialogInterface.OnKeyListener() {
              public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_MENU) {
                  if (dialog != null) {
                    dialog.dismiss();
                    return true;
                  }
                }

                return false;
              }
            });
        break;
      default:
        this.dialog = null;
    }
    if (dialog != null) {
      dialog.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialogInterface) {
              dialog = null;
            }
          });
    }
    return this.dialog;
  }
 private MonthAdapter() {
   inflater = LayoutInflater.from(getContext());
 }
예제 #28
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);
  }
예제 #29
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    this.deviceInfo = getDeviceInfoFromApplicationContext();

    StopWatch sw = new StopWatch();
    sw.start("create activity");

    createAnimation();
    buildFadeInPageViewAnimation();
    buildFadeOutPageViewAnimation();

    setProgressBarIndeterminateVisibility(false);
    System.out.println("debug on create");

    executor =
        new ThreadPoolExecutor(
            0, Integer.MAX_VALUE, 10L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
    sourceDB = new SourceDB(this);
    alarmSender = new AlarmSender(this);

    //        sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    //        acceleromererSensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    //        createShakeListener();

    Cursor sourceCursor = sourceDB.findAll();

    startManagingCursor(sourceCursor);

    sourceAdapter =
        new SourceItemArrayAdapter<SourceItem>(this, R.layout.source_item, sourceDB, deviceInfo);

    TelephonyManager tManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
    deviceId = tManager.getDeviceId();
    inflater = LayoutInflater.from(this);
    accountType = (String) getIntent().getExtras().get("type");
    sourceId = (String) getIntent().getExtras().get("sourceId");
    sourceImageURL = (String) getIntent().getExtras().get("sourceImage");
    sourceName = (String) getIntent().getExtras().get("sourceName");
    contentUrl = (String) getIntent().getExtras().get("contentUrl");

    //// System.out.println("sourceImageURL:" + sourceImageURL);
    setContentView(R.layout.main);
    container = (ViewGroup) findViewById(R.id.pageContainer);
    pageIndexView = (PageIndexView) findViewById(R.id.pageIndex);
    ViewSwitcher headerSwitcher = (ViewSwitcher) findViewById(R.id.flipper);
    header = (HeaderView) findViewById(R.id.header);
    contentImageButton = (ImageButton) findViewById(R.id.content);
    contentImageButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            overridePendingTransition(android.R.anim.slide_in_left, R.anim.fade);
            PageActivity.this.finish();
          }
        });
    //        pageInfo = (TextView)header.findViewById(R.id.pageInfo);
    headerText = (TextView) findViewById(R.id.headerText);
    headerImageView = (WebImageView) findViewById(R.id.headerImage);

    pageViewFactory = new WeiboPageViewFactory();

    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    this.browseMode = getBrowseMode();
    //        this.animationMode = getAnimationMode();
    refreshingSemaphore = new Semaphore(1, true);
    Log.v("accountType", accountType);
    reload();
  }
예제 #30
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.content_list_item, null);
      }
      TextView titleTextView = (TextView) view.findViewById(R.id.list_item_title);
      TextView stateTextView = (TextView) view.findViewById(R.id.list_item_state);
      TextView downTextView = (TextView) view.findViewById(R.id.list_item_downbar);
      Button downloadButton = (Button) view.findViewById(R.id.list_item_download_button);
      Button uploadButton = (Button) view.findViewById(R.id.list_item_upload_button);

      LocationInfo info = mInfoList.get(position);
      String titleText = info.title;
      String stateText = "";

      if (titleText.length() > 30) titleText = titleText.substring(0, 28) + "...";

      synchronized (mLoaderMap) {
        if (mLoaderMap.containsKey(info.title)) {
          LoaderState loader = mLoaderMap.get(info.title);
          if (loader.state < 100) stateText = String.format(Locale.ENGLISH, "%d%%", loader.state);
          else if (loader.state == 100) stateText = String.format(Locale.ENGLISH, "Done!");
          else stateText = String.format(Locale.ENGLISH, "Failed!");
        }
      }

      if (info.localVersion < 0) titleText += " (?)";
      else {
        if (info.localModified)
          titleText += String.format(Locale.ENGLISH, " (v. %d+)", info.localVersion);
        else titleText += String.format(Locale.ENGLISH, " (v. %d)", info.localVersion);
      }

      String mapFile = NavigineApp.Settings.getString("map_file", "");
      if (mapFile.equals(info.archiveFile)) {
        titleTextView.setTypeface(null, Typeface.BOLD);
        view.setBackgroundColor(Color.parseColor("#590E0E"));
      } else {
        titleTextView.setTypeface(null, Typeface.NORMAL);
        view.setBackgroundColor(Color.BLACK);
      }

      titleTextView.setText(titleText);
      stateTextView.setText(stateText);

      if (info.localModified) {
        downloadButton.setVisibility(View.GONE);
        uploadButton.setVisibility(View.VISIBLE);
        downTextView.setText("Version is modified. Upload?");
      } else if (info.serverVersion > info.localVersion) {
        downloadButton.setVisibility(View.VISIBLE);
        uploadButton.setVisibility(View.GONE);
        String downText =
            String.format(Locale.ENGLISH, "Version available: %d", info.serverVersion);
        downTextView.setText(downText);
      } else {
        downloadButton.setVisibility(View.INVISIBLE);
        uploadButton.setVisibility(View.GONE);
        downTextView.setText("Version is up to date");
      }

      downloadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startDownload(position);
            }
          });

      uploadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startUpload(position);
            }
          });

      return view;
    }