Exemplo n.º 1
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View v = inflater.inflate(R.layout.fragment_feed, container, false);
   ButterKnife.inject(this, v);
   if (AppSharePreferences.getFollowFlag(getActivity())) {
     listLayout = mListViewStub.inflate();
     initListView(listLayout);
   } else {
     settingLayout = mSetting.inflate();
     initSettingView(settingLayout);
   }
   return v;
 }
Exemplo n.º 2
0
  /**
   * Inflates the video view layout, replacing the {@link ViewStub} with the correct backing
   * implementation.
   *
   * @param context The context to use for inflating the correct video view
   * @param attrs The attributes for retrieving custom backing implementations.
   */
  protected void inflateVideoView(@NonNull Context context, @Nullable AttributeSet attrs) {
    View.inflate(context, R.layout.exomedia_video_view_layout, this);
    ViewStub videoViewStub = (ViewStub) findViewById(R.id.video_view_api_impl_stub);

    videoViewStub.setLayoutResource(getVideoViewApiImplementation(context, attrs));
    videoViewStub.inflate();
  }
 public void setEmptyViewId(int id) {
   if (id == 0) return;
   emptyViewId = id;
   emptyContentContainer = (ViewStub) findViewById(R.id.rrv_empty_content_container);
   emptyContentContainer.setLayoutResource(emptyViewId);
   emptyContentContainer.inflate();
 }
Exemplo n.º 4
0
 protected void setupSimpleActionBar(String txtTitle) {
   stubNavigation.setLayoutResource(R.layout.nav_simple);
   layoutActionbar = (ViewGroup) stubNavigation.inflate();
   findViewById(R.id.btnBack).setOnClickListener(this);
   txtTitleBar = (TextView) findViewById(R.id.txtTitleBar);
   txtTitleBar.setText(txtTitle);
 }
 private void checkAndInitCurrentView(@State int state, String msg) {
   switch (state) {
     case STATE_LOADING:
       if (mLoadingView == null) {
         if (mLoadingLayoutId != 0) {
           mVsLoading.setLayoutResource(mLoadingLayoutId);
         }
         mLoadingView = mVsLoading.inflate();
       }
       prepareLoadingView(mLoadingView, msg);
       break;
     case STATE_DATA:
       if (mDataView == null) {
         if (mDataLayoutId != 0) {
           mVsData.setLayoutResource(mDataLayoutId);
         } else {
           // 显示数据的布局是必须的,如果没有抛出异常
           throw new RuntimeException(this.getClass().getSimpleName() + " need data layout id. ");
         }
         mDataView = mVsData.inflate();
       }
       prepareDataView(mDataView, msg);
       break;
     case STATE_EMPTY:
       if (mEmptyView == null) {
         if (mEmptyLayoutId != 0) {
           mVsEmpty.setLayoutResource(mEmptyLayoutId);
         }
         mEmptyView = mVsEmpty.inflate();
       }
       prepareEmptyView(mEmptyView, msg);
       break;
     case STATE_ERROR:
       if (mErrorView == null) {
         if (mErrorLayoutId != 0) {
           mVsError.setLayoutResource(mErrorLayoutId);
         }
         mErrorView = mVsError.inflate();
       }
       prepareErrorView(mErrorView, msg);
       break;
     case STATE_ALL_EMPTY: // 全空和默认一样,不需要break
     default:
       break;
   }
 }
Exemplo n.º 6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    if (getIntent().hasExtra(ARG_PARENT_CATEGORY_STYLE)) {
      int styleResId = getIntent().getIntExtra(ARG_PARENT_CATEGORY_STYLE, -1);
      if (styleResId > 0) {
        setTheme(styleResId);
      }
    }

    super.onCreate(savedInstanceState);

    mParentCategoryId = getIntent().getLongExtra(ARG_PARENT_CATEGORY_ID, 0);
    if (mParentCategoryId == 0) {
      Intent categoryIntent = new Intent(this, CategoriesActivity.class);
      startActivity(categoryIntent);
    }

    setContentView(R.layout.app_bar);

    ViewStub mainContent = (ViewStub) findViewById(R.id.main_content);
    mainContent.setLayoutResource(R.layout.content_fragment);
    mainContent.inflate();

    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
    }

    getSupportLoaderManager().initLoader(0, null, this);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent newCategoryIntent =
                new Intent(SubcategoriesActivity.this, ManageCategoryActivity.class);
            newCategoryIntent.putExtra(
                ManageCategoryActivity.ARG_PARENT_CATEGORY_ID, mParentCategoryId);
            startActivity(newCategoryIntent);
          }
        });
    fab.setVisibility(View.VISIBLE);

    if (savedInstanceState == null) {
      CategoriesFragment fragment = CategoriesFragment.newInstance(mParentCategoryId);
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      transaction.add(R.id.fragment, fragment);
      transaction.commit();
    }
  }
Exemplo n.º 7
0
  private void inflateAutoLoginBar() {
    if (mAutoLogin != null) {
      return;
    }

    ViewStub stub = (ViewStub) findViewById(R.id.autologin_stub);
    mAutoLogin = (AutologinBar) stub.inflate();
    mAutoLogin.setTitleBar(this);
  }
Exemplo n.º 8
0
  private void inflateSnapshotBar() {
    if (mSnapshotBar != null) {
      return;
    }

    ViewStub stub = (ViewStub) findViewById(R.id.snapshotbar_stub);
    mSnapshotBar = (SnapshotBar) stub.inflate();
    mSnapshotBar.setTitleBar(this);
  }
Exemplo n.º 9
0
 @Override
 public void doShowloading() {
   if (view_loading == null) {
     view_loading = stub_loading.inflate();
   } else {
     view_loading.setVisibility(View.VISIBLE);
   }
   if (view_noData != null) {
     view_noData.setVisibility(View.GONE);
   }
 }
Exemplo n.º 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    super.onCreateDrawer();

    ViewStub stub = (ViewStub) findViewById(R.id.layout_stub);
    stub.setLayoutResource(R.layout.content_stamp);
    View inflated = stub.inflate();
    /* your logic here */

  }
  private void inflateImageView() {
    ViewStub viewStub = (ViewStub) mView.findViewById(R.id.media_listitem_details_stub);
    if (viewStub != null) {
      if (mIsLocal) viewStub.setLayoutResource(R.layout.media_grid_image_local);
      else viewStub.setLayoutResource(R.layout.media_grid_image_network);
      viewStub.inflate();
    }

    mImageView = (ImageView) mView.findViewById(R.id.media_listitem_details_image);

    // add a background color so something appears while image is downloaded
    mImageView.setImageDrawable(new ColorDrawable(getResources().getColor(R.color.grey_light)));
  }
Exemplo n.º 12
0
 public void onEventMainThread(SubscriptionAddActivity.FollowFlagEvent event) {
   if (event.flag) {
     if (mSetting != null) mSetting.setVisibility(View.GONE);
     if (listLayout == null) {
       listLayout = mListViewStub.inflate();
       initListView(listLayout);
     } else {
       listLayout.setVisibility(View.VISIBLE);
       data.clear();
       adapter.notifyDataSetChanged();
       mEmptyView.show(true);
       mEmptyView.onLoading();
       request(Urls.SERVER_PATH + "/user/feeds", 0);
     }
   } else {
     stopRefreshNews();
     if (mListViewStub != null) mListViewStub.setVisibility(View.GONE);
     if (settingLayout == null) {
       settingLayout = mSetting.inflate();
       initSettingView(settingLayout);
     } else settingLayout.setVisibility(View.VISIBLE);
   }
 }
Exemplo n.º 13
0
  private void updateUiFromCursor(Cursor c) {
    if ((c == null || c.getCount() == 0) && mEmptyView == null) {
      // Set empty page view. We delay this so that the empty view won't flash.
      final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub);
      mEmptyView = emptyViewStub.inflate();

      final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image);
      emptyIcon.setImageResource(R.drawable.icon_bookmarks_empty);

      final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text);
      emptyText.setText(R.string.home_bookmarks_empty);

      mList.setEmptyView(mEmptyView);
    }
  }
 private void showBanner() {
   if (m_bannerViewStub == null) {
     m_bannerViewStub = (ViewStub) findViewById(R.id.viewstub_banner);
     View v = m_bannerViewStub.inflate();
     m_closeButton = (ImageButton) v.findViewById(R.id.imagebutton_close);
     m_closeButton.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View arg0) {
             m_bannerViewStub.setVisibility(View.GONE);
           }
         });
   }
   m_bannerViewStub.setVisibility(View.VISIBLE);
 }
Exemplo n.º 15
0
  protected View createGraphObjectView(T graphObject) {
    View result = inflater.inflate(getGraphObjectRowLayoutId(graphObject), null);

    ViewStub checkboxStub = (ViewStub) result.findViewById(R.id.com_facebook_picker_checkbox_stub);
    if (checkboxStub != null) {
      if (!getShowCheckbox()) {
        checkboxStub.setVisibility(View.GONE);
      } else {
        CheckBox checkBox = (CheckBox) checkboxStub.inflate();
        updateCheckboxState(checkBox, false);
      }
    }

    ViewStub profilePicStub =
        (ViewStub) result.findViewById(R.id.com_facebook_picker_profile_pic_stub);
    if (!getShowPicture()) {
      profilePicStub.setVisibility(View.GONE);
    } else {
      ImageView imageView = (ImageView) profilePicStub.inflate();
      imageView.setVisibility(View.VISIBLE);
    }

    return result;
  }
Exemplo n.º 16
0
 @Override
 public void doShowNodata(int drawId) {
   if (view_noData == null) {
     view_noData = stub_noData.inflate();
     iv_error = (ImageView) view_noData.findViewById(R.id.iv_error);
   } else {
     view_noData.setVisibility(View.VISIBLE);
   }
   if (view_loading != null) {
     view_loading.setVisibility(View.GONE);
   }
   if (iv_error != null) {
     iv_error.setImageResource(drawId);
   }
 }
  @SuppressWarnings("deprecation")
  private void inflateTitleBar(ViewGroup view) {
    ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub);
    if (stub != null) {
      View titleBar = stub.inflate();

      final RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
      layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);
      listView.setLayoutParams(layoutParams);

      if (titleBarBackground != null) {
        titleBar.setBackgroundDrawable(titleBarBackground);
      }

      doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button);
      if (doneButton != null) {
        doneButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                logAppEvents(true);
                appEventsLogged = true;

                if (onDoneButtonClickedListener != null) {
                  onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this);
                }
              }
            });

        if (getDoneButtonText() != null) {
          doneButton.setText(getDoneButtonText());
        }

        if (doneButtonBackground != null) {
          doneButton.setBackgroundDrawable(doneButtonBackground);
        }
      }

      titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
      if (titleTextView != null) {
        if (getTitleText() != null) {
          titleTextView.setText(getTitleText());
        }
      }
    }
  }
  private boolean attach() {

    final View attachView =
        mParentView == null
            ? mContext.findViewById(mAttachId)
            : mParentView.findViewById(mAttachId);
    if (attachView instanceof RecyclerView) {
      mRecyclerView = (RecyclerView) attachView;
    } else if (attachView instanceof ViewStub) {
      ViewStub stub = (ViewStub) attachView;
      stub.setLayoutResource(R.layout.weekdays_recycler_view);
      stub.setInflatedId(mAttachId);
      mRecyclerView = (RecyclerView) stub.inflate();
    } else {
      throw new IllegalStateException(
          "Weeekdays Buttons was unable to attach to your Layout, required [ViewStub],[recycleView] or ['parent' View] doesn't exist.");
    }

    if (mRecyclerView != null) {

      getDrawableProvider();

      if (mTextDrawableType == WeekdaysDrawableProvider.MW_MULTIPLE_LETTERS && mNumberOfLetters < 2)
        mNumberOfLetters = 2;

      int position = 0;
      for (Map.Entry<Integer, String> map : getDays().entrySet()) {
        String day = map.getValue();
        int calendarDayId = map.getKey();
        if (!TextUtils.isEmpty(day)) {
          WeekdaysDataItem item =
              itemFromType(position, calendarDayId, day, getSelectedDays().get(calendarDayId));
          if (getWeekdaysCount() == position) getWeekdaysItems().add(item);
          else getWeekdaysItems().set(position, item);

          position++;
        }
      }

      initRecyclerView(mContext);

      return true;
    }
    return false;
  }
Exemplo n.º 19
0
  @Override
  public ActionMode startActionMode(ActionMode.Callback callback) {
    if (DEBUG) Log.d(TAG, "[startActionMode] callback: " + callback);

    if (mActionMode != null) {
      mActionMode.finish();
    }

    final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
    ActionMode mode = null;

    // Emulate Activity's onWindowStartingActionMode:
    initActionBar();
    if (aActionBar != null) {
      mode = aActionBar.startActionMode(wrappedCallback);
    }

    if (mode != null) {
      mActionMode = mode;
    } else {
      if (mActionModeView == null) {
        ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub);
        if (stub != null) {
          mActionModeView = (ActionBarContextView) stub.inflate();
        }
      }
      if (mActionModeView != null) {
        mActionModeView.killMode();
        mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
        if (callback.onCreateActionMode(mode, mode.getMenu())) {
          mode.invalidate();
          mActionModeView.initForMode(mode);
          mActionModeView.setVisibility(View.VISIBLE);
          mActionMode = mode;
          mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        } else {
          mActionMode = null;
        }
      }
    }
    if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
      ((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode);
    }
    return mActionMode;
  }
Exemplo n.º 20
0
 public void showComboView(ComboViews startWith, Bundle extras) {
   if (mComboView == null) {
     ViewStub stub =
         (ViewStub) mActivity.getWindow().getDecorView().findViewById(R.id.combo_view_stub);
     mComboView = (ComboView) stub.inflate();
     mComboView.setVisibility(View.GONE);
     mComboView.setupViews(mActivity);
   }
   mNavBar.setVisibility(View.GONE);
   if (mActionBar != null) mActionBar.hide();
   Bundle b = new Bundle();
   b.putString(ComboViewActivity.EXTRA_INITIAL_VIEW, startWith.name());
   b.putBundle(ComboViewActivity.EXTRA_COMBO_ARGS, extras);
   Tab t = getActiveTab();
   if (t != null) {
     b.putString(ComboViewActivity.EXTRA_CURRENT_URL, t.getUrl());
   }
   mComboView.showViews(mActivity, b);
 }
Exemplo n.º 21
0
  private void updateUiFromCursor(Cursor c) {
    if (c != null && c.getCount() > 0) {
      return;
    }

    // Cursor is empty, so set the empty view if it hasn't been set already.
    if (mEmptyView == null) {
      // Set empty panel view. We delay this so that the empty view won't flash.
      final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub);
      mEmptyView = emptyViewStub.inflate();

      final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image);
      emptyIcon.setImageResource(R.drawable.icon_most_recent_empty);

      final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text);
      emptyText.setText(R.string.home_most_recent_empty);

      mList.setEmptyView(mEmptyView);
    }
  }
 private void inflateTwoPane(ViewStub stub) {
   stub.setLayoutResource(R.layout.preference_list_content);
   stub.inflate();
   mGroupList = (ListView) mRoot.findViewById(android.R.id.list);
   mPrefsContainer = (ViewGroup) mRoot.findViewById(R.id.prefs_frame);
   mFragmentBreadCrumbs = (FragmentBreadCrumbs) mRoot.findViewById(android.R.id.title);
   mFragmentBreadCrumbs.setMaxVisible(1);
   mFragmentBreadCrumbs.setActivity(getActivity());
   mPrefsContainer.setVisibility(View.VISIBLE);
   mGroupList.setAdapter(new HistoryGroupWrapper(mAdapter));
   mGroupList.setOnItemClickListener(mGroupItemClickListener);
   mGroupList.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
   mChildWrapper = new HistoryChildWrapper(mAdapter);
   mChildList = new ListView(getActivity());
   mChildList.setAdapter(mChildWrapper);
   mChildList.setOnItemClickListener(mChildItemClickListener);
   registerForContextMenu(mChildList);
   ViewGroup prefs = (ViewGroup) mRoot.findViewById(R.id.prefs);
   prefs.addView(mChildList);
 }
  /*
   * This handles hiding and showing various views depending on the privacy
   * settings of the app and the current state of the phone (keyguard on or off)
   */
  private final void refreshPrivacy() {
    if (Log.DEBUG) Log.v("refreshPrivacy()");
    messageViewed = true;

    if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_SMS) {
      if (privacyMode) {
        // We need to init the keyguard class so we can check if the keyguard is
        // on
        ManageKeyguard.initialize(getApplicationContext());

        if (ManageKeyguard.inKeyguardRestrictedInputMode()) {
          messageViewed = false;

          if (privacyView == null) {
            privacyView = privacyViewStub.inflate();

            // The view button (if in privacy mode)
            Button viewButton = (Button) privacyView.findViewById(R.id.ViewButton);
            viewButton.setOnClickListener(
                new OnClickListener() {
                  public void onClick(View v) {
                    viewMessage();
                  }
                });
          }
          messageScrollView.setVisibility(View.GONE);
        } else {
          if (privacyView != null) {
            privacyView.setVisibility(View.GONE);
          }
          messageScrollView.setVisibility(View.VISIBLE);
        }
      } else {
        if (privacyView != null) {
          privacyView.setVisibility(View.GONE);
        }
        messageScrollView.setVisibility(View.VISIBLE);
      }
    }
  }
Exemplo n.º 24
0
  @Override
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ViewGroup view = (ViewGroup) getView();
    if (showSearchBox) {
      ViewStub stub =
          (ViewStub) view.findViewById(R.id.com_facebook_placepickerfragment_search_box_stub);
      if (stub != null) {
        searchBox = (EditText) stub.inflate();

        // Put the list under the search box
        RelativeLayout.LayoutParams layoutParams =
            new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
        layoutParams.addRule(RelativeLayout.BELOW, R.id.search_box);

        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
        listView.setLayoutParams(layoutParams);

        // If we need to, put the search box under the title bar.
        if (view.findViewById(R.id.com_facebook_picker_title_bar) != null) {
          layoutParams =
              new RelativeLayout.LayoutParams(
                  RelativeLayout.LayoutParams.FILL_PARENT,
                  RelativeLayout.LayoutParams.WRAP_CONTENT);
          layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);

          searchBox.setLayoutParams(layoutParams);
        }

        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
          searchBox.setText(searchText);
        }
      }
    }
  }
Exemplo n.º 25
0
  private void showLoadingView() {
    if (layLoadingFailed == null) {
      layLoadingFailed = (FrameLayout) stubLoadingFailed.inflate();
      layClickReload = (LinearLayout) layLoadingFailed.findViewById(R.id.layClickReload);
      loadingProgress = (ProgressBar) layLoadingFailed.findViewById(R.id.loadingProgress);
      layClickReload.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              startFragmentLoading();
            }
          });
    }
    layLoadingFailed.setVisibility(View.VISIBLE);
    layClickReload.setVisibility(View.INVISIBLE);
    loadingProgress.setVisibility(View.VISIBLE);

    if (contentView != null) {
      contentView.setVisibility(View.INVISIBLE);
    }
  }
Exemplo n.º 26
0
  private View getHeaderView(int mode) {
    View header = null;
    switch (mode) {
      case QuickContact.MODE_SMALL:
        header = mWindow.findViewById(R.id.header_small);
        break;
      case QuickContact.MODE_MEDIUM:
        header = mWindow.findViewById(R.id.header_medium);
        break;
      case QuickContact.MODE_LARGE:
        header = mWindow.findViewById(R.id.header_large);
        break;
    }

    if (header instanceof ViewStub) {
      // Inflate actual header if we picked a stub
      final ViewStub stub = (ViewStub) header;
      header = stub.inflate();
    } else if (header != null) {
      header.setVisibility(View.VISIBLE);
    }

    return header;
  }
  /*
   * Populate all the main SMS/MMS views with content from the actual
   * SmsMmsMessage
   */
  private void populateViews(SmsMmsMessage newMessage) {

    // Store message
    message = newMessage;

    // If it's a MMS message, just show the MMS layout
    if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_MMS) {
      if (mmsView == null) {
        mmsView = mmsViewStub.inflate();
        mmsSubjectTV = (TextView) mmsView.findViewById(R.id.MmsSubjectTextView);

        // The ViewMMS button
        Button viewMmsButton = (Button) mmsView.findViewById(R.id.ViewMmsButton);
        viewMmsButton.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                replyToMessage();
              }
            });
      }
      messageScrollView.setVisibility(View.GONE);
      // privacyViewStub.setVisibility(View.GONE);
      mmsView.setVisibility(View.VISIBLE);

      // If no MMS subject, hide the subject text view
      if (TextUtils.isEmpty(message.getMessageBody())) {
        mmsSubjectTV.setVisibility(View.GONE);
      } else {
        mmsSubjectTV.setVisibility(View.VISIBLE);
      }
    } else {
      // Otherwise hide MMS layout
      if (mmsView != null) {
        mmsView.setVisibility(View.GONE);
      }

      // Refresh privacy settings (hide/show message) depending on privacy setting
      refreshPrivacy();
    }

    // Fetch contact photo in background
    if (contactPhoto == null) {
      setContactPhotoToDefault(photoImageView);
      new FetchContactPhotoTask().execute(message.getContactId());
    } else {
      setContactPhoto(photoImageView, contactPhoto);
    }

    // Show QuickContact card on photo imageview click (only available on eclair+)
    if (!SmsPopupUtils.PRE_ECLAIR) {

      contactLookupUri = null;
      String contactId = message.getContactId();
      if (contactId != null) {
        contactLookupUri =
            ContactWrapper.getLookupUri(Long.valueOf(contactId), message.getContactLookupKey());
      }

      photoImageView.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              if (contactLookupUri != null) {
                ContactWrapper.showQuickContact(
                    SmsPopupActivity.this,
                    v,
                    contactLookupUri,
                    ContactWrapper.QUICKCONTACT_MODE_MEDIUM,
                    null);
              }
            }
          });
    }

    // If only 1 unread message waiting
    if (message.getUnreadCount() <= 1) {
      if (unreadCountView != null) {
        unreadCountView.setVisibility(View.GONE);
      }
    } else { // More unread messages waiting, show the extra view
      if (unreadCountView == null) {
        unreadCountView = unreadCountViewStub.inflate();
      }
      unreadCountView.setVisibility(View.VISIBLE);
      TextView tv = (TextView) unreadCountView.findViewById(R.id.UnreadCountTextView);

      String textWaiting = getString(R.string.unread_text_waiting, message.getUnreadCount() - 1);
      tv.setText(textWaiting);

      // The inbox button
      Button inboxButton = (Button) unreadCountView.findViewById(R.id.InboxButton);
      inboxButton.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              gotoInbox();
            }
          });
    }

    // Update TextView that contains the timestamp for the incoming message
    String headerText = getString(R.string.new_text_at, message.getFormattedTimestamp().toString());

    // Set the from, message and header views
    fromTV.setText(message.getContactName());
    if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_SMS) {
      messageTV.setText(message.getMessageBody());
    } else {
      mmsSubjectTV.setText(getString(R.string.mms_subject) + " " + message.getMessageBody());
    }
    messageReceivedTV.setText(headerText);
  }
Exemplo n.º 28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);
    backView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            currentActivity.finish();
          }
        });

    ActionBar.LayoutParams params =
        new ActionBar.LayoutParams(
            ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid =
        LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
      String url =
          Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
      APIHelper.getInstance(currentActivity)
          .getRequest(
              currentActivity,
              url,
              new ApiListener() {
                @Override
                public void onApiSuccess(ApiResponse apiResponse) {
                  try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName =
                        location != null && location.has("name") ? location.getString("name") : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                      new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                      attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                  } catch (JSONException e) {

                  }
                }

                @Override
                public void onApiError(LIApiError apiError) {}
              });

      ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
      View viewOnLI = viewOnLIStub.inflate();
      Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
      viewOnLIButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              DeepLinkHelper.getInstance()
                  .openOtherProfile(
                      currentActivity,
                      person.getLinkedinId(),
                      new DeepLinkListener() {
                        @Override
                        public void onDeepLinkSuccess() {}

                        @Override
                        public void onDeepLinkError(LIDeepLinkError error) {}
                      });
            }
          });
    } else {
      attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
  }
Exemplo n.º 29
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub

      if (items.get(position).type == 1) {

        if (items.get(position).smsType.equals("sms")) {

          convertView =
              LayoutInflater.from(MultiDeleteActivity.this)
                  .inflate(R.layout.multi_delete_item_recv, parent, false);

          TextView text = (TextView) convertView.findViewById(R.id.text_view_multidelete);

          TextView date = (TextView) convertView.findViewById(R.id.date_view_multidelete);

          CheckBox check = (CheckBox) convertView.findViewById(R.id.choose_multidelete);

          String mTimestamp =
              MessageUtils.formatTimeStampString(
                  MultiDeleteActivity.this, items.get(position).date);

          text.setText(items.get(position).mBody);
          date.setText(mTimestamp);

          if (isSelected.get(position)) {

            check.setChecked(true);

          } else if (!isSelected.get(position)) {

            check.setChecked(false);
          }

          convertView.setTag(check);
          return convertView;
        } else {

          convertView =
              LayoutInflater.from(MultiDeleteActivity.this)
                  .inflate(R.layout.multi_delete_item_recv, parent, false);

          TextView text = (TextView) convertView.findViewById(R.id.text_view_multidelete);

          TextView date = (TextView) convertView.findViewById(R.id.date_view_multidelete);

          CheckBox check = (CheckBox) convertView.findViewById(R.id.choose_multidelete);

          text.setText(items.get(position).mSubject);

          String mTimestamp =
              MessageUtils.formatTimeStampString(
                  MultiDeleteActivity.this, items.get(position).date * 1000);

          date.setText(mTimestamp);

          ViewStub mmsStub =
              (ViewStub) convertView.findViewById(R.id.mms_layout_view_stub_multidelete);
          View inflated = mmsStub.inflate();

          ImageView mImageView = (ImageView) inflated.findViewById(R.id.image_view);

          int mid = items.get(position).MsgId;

          Log.v(TAG, "mid :" + mid);

          Cursor curPart = null;
          try {
            curPart = initCursor(mid);
            if (curPart != null) {

              boolean isfind = false;
              if (curPart.getCount() >= 3) {
                while (curPart.moveToNext()) {

                  String contentType = curPart.getString(curPart.getColumnIndexOrThrow("ct"));
                  if (contentType.equalsIgnoreCase("text/x-vcard")) {

                    mImageView.setImageResource(R.drawable.mms_vcard);
                    isfind = true;
                    break;
                  }
                }

                if (!isfind) {
                  mImageView.setImageResource(R.drawable.mms_ppt);
                  isfind = false;
                }
              } else {
                curPart.moveToPosition(-1);

                while (curPart.moveToNext()) {

                  String contentType = curPart.getString(curPart.getColumnIndexOrThrow("ct"));

                  String[] types = splitToArray(contentType, "/");
                  if (types[0].equalsIgnoreCase("image")) {
                    mImageView.setImageResource(R.drawable.mms_image);
                    break;
                  } else if (types[0].equalsIgnoreCase("audio")) {
                    mImageView.setImageResource(R.drawable.mms_record);
                    break;
                  } else if (contentType.equalsIgnoreCase("text/x-vcard")) {

                    mImageView.setImageResource(R.drawable.mms_vcard);

                    break;

                  } else if (types[0].equalsIgnoreCase("video")) {
                    mImageView.setImageResource(R.drawable.mms_video);
                    break;
                  } else if (types[0].equalsIgnoreCase("text")) {
                    mImageView.setImageResource(R.drawable.mms_txt);
                    break;
                  } else if (contentType.equalsIgnoreCase("application/ogg")) {

                    mImageView.setImageResource(R.drawable.mms_record);
                    break;

                  } else {
                    mImageView.setImageResource(R.drawable.qiqiu2_200x200);
                  }

                  Log.v(
                      TAG,
                      "contentType :" + contentType + "curPart.getCount(): " + curPart.getCount());
                }
              }
            }

          } catch (Exception e) {

            e.printStackTrace();
            mImageView.setImageResource(R.drawable.qiqiu2_200x200);

          } finally {

            curPart.close();
          }

          if (isSelected.get(position)) {

            check.setChecked(true);

          } else if (!isSelected.get(position)) {

            check.setChecked(false);
          }

          convertView.setTag(check);
          return convertView;
        }

      } else if (items.get(position).type == 2) {

        if (items.get(position).smsType.equals("sms")) {
          convertView =
              LayoutInflater.from(MultiDeleteActivity.this)
                  .inflate(R.layout.multi_delete_item_send, parent, false);

          TextView text = (TextView) convertView.findViewById(R.id.text_view_multidelete);

          TextView date = (TextView) convertView.findViewById(R.id.date_view_multidelete);

          CheckBox check = (CheckBox) convertView.findViewById(R.id.choose_multidelete);

          String mTimestamp =
              MessageUtils.formatTimeStampString(
                  MultiDeleteActivity.this, items.get(position).date);

          text.setText(items.get(position).mBody);
          date.setText(mTimestamp);

          if (isSelected.get(position)) {

            check.setChecked(true);

          } else if (!isSelected.get(position)) {

            check.setChecked(false);
          }

          convertView.setTag(check);
          return convertView;
        } else {

          convertView =
              LayoutInflater.from(MultiDeleteActivity.this)
                  .inflate(R.layout.multi_delete_item_send, parent, false);

          TextView text = (TextView) convertView.findViewById(R.id.text_view_multidelete);

          TextView date = (TextView) convertView.findViewById(R.id.date_view_multidelete);

          text.setText(items.get(position).mSubject);

          CheckBox check = (CheckBox) convertView.findViewById(R.id.choose_multidelete);

          String mTimestamp =
              MessageUtils.formatTimeStampString(
                  MultiDeleteActivity.this, items.get(position).date * 1000);

          date.setText(mTimestamp);

          ViewStub mmsStub =
              (ViewStub) convertView.findViewById(R.id.mms_layout_view_stub_multidelete);
          View inflated = mmsStub.inflate();

          ImageView mImageView = (ImageView) inflated.findViewById(R.id.image_view);

          int mid = items.get(position).MsgId;

          Log.v(TAG, "mid :" + mid);

          Cursor curPart = null;
          try {
            curPart = initCursor(mid);
            if (curPart != null) {

              boolean isfind = false;
              if (curPart.getCount() >= 3) {
                while (curPart.moveToNext()) {

                  String contentType = curPart.getString(curPart.getColumnIndexOrThrow("ct"));
                  if (contentType.equalsIgnoreCase("text/x-vcard")) {

                    mImageView.setImageResource(R.drawable.mms_vcard);
                    isfind = true;
                    break;
                  }
                }

                if (!isfind) {
                  mImageView.setImageResource(R.drawable.mms_ppt);
                  isfind = false;
                }
              } else {
                curPart.moveToPosition(-1);

                while (curPart.moveToNext()) {

                  String contentType = curPart.getString(curPart.getColumnIndexOrThrow("ct"));

                  String[] types = splitToArray(contentType, "/");
                  if (types[0].equalsIgnoreCase("image")) {
                    mImageView.setImageResource(R.drawable.mms_image);
                    break;
                  } else if (types[0].equalsIgnoreCase("audio")) {
                    mImageView.setImageResource(R.drawable.mms_record);
                    break;
                  } else if (contentType.equalsIgnoreCase("text/x-vcard")) {

                    mImageView.setImageResource(R.drawable.mms_vcard);

                    break;

                  } else if (types[0].equalsIgnoreCase("video")) {
                    mImageView.setImageResource(R.drawable.mms_video);
                    break;
                  } else if (types[0].equalsIgnoreCase("text")) {
                    mImageView.setImageResource(R.drawable.mms_txt);
                    break;
                  } else if (contentType.equalsIgnoreCase("application/ogg")) {

                    mImageView.setImageResource(R.drawable.mms_record);
                    break;

                  } else {
                    mImageView.setImageResource(R.drawable.qiqiu2_200x200);
                  }

                  Log.v(
                      TAG,
                      "contentType :" + contentType + "curPart.getCount(): " + curPart.getCount());
                }
              }
            }

          } catch (Exception e) {

            e.printStackTrace();

            mImageView.setImageResource(R.drawable.qiqiu2_200x200);

          } finally {

            curPart.close();
          }

          // mImageView.setImageResource(R.drawable.qiqiu2_200x200);

          if (isSelected.get(position)) {

            check.setChecked(true);

          } else if (!isSelected.get(position)) {

            check.setChecked(false);
          }
          convertView.setTag(check);
          return convertView;
        }
      }

      return convertView;
    }
Exemplo n.º 30
0
  public void inflateContentStub() {
    contentStub.setLayoutResource(layoutResID);
    contentStub.inflate();

    ((DetailView) parent).contentInflated(contentType);
  }