Exemplo n.º 1
0
  private void setDownloadedFilmsData() {
    this.mGridView.setAdapter(new FilmAdapter(getActivity(), sDOWNLOADED_FILMS));
    this.mSectionLabel.setText(getString(R.string.label_section_discover));

    if (sDOWNLOADED_FILMS.isEmpty()) {

      ConnectivityManager cm =
          (ConnectivityManager)
              getActivity().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
      boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

      if (!isConnected) {
        viewStub.setLayoutResource(R.layout.no_connection_layout);
        mGridView.setEmptyView(viewStub);
      } else {
        viewStub.setLayoutResource(R.layout.list_empty_layout);
        mGridView.setEmptyView(viewStub);
        /* Starting Download Service */
        DownloadResultReceiver mReceiver = new DownloadResultReceiver(new Handler());
        mReceiver.setReceiver(this);
        Intent intent =
            new Intent(Intent.ACTION_SYNC, null, this.getActivity(), FilmDownloadService.class);

        /* Send optional extras to Download IntentService */
        intent.putExtra(FilmDownloadService.RECEIVER_KEY, mReceiver);
        this.getActivity().startService(intent);
      }
    } else {
      setSecondFragmentContent(sDOWNLOADED_FILMS.get(0));
    }
  }
  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.º 3
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.º 5
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);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    mContext = getActivity();

    filter = false;

    mainActivity = (MainActivity) getActivity();

    mainListView = (LinearLayout) inflater.inflate(R.layout.fragment_main_list, container, false);
    stub = (ViewStub) mainListView.findViewById(android.R.id.empty);
    stub.setLayoutResource(R.layout.task_empty_stub);

    header = (TextView) mainListView.findViewById(R.id.header);
    header.setText(R.string.tasks);

    setHasOptionsMenu(true);
    taskListAdapter = new TaskListAdapter(mContext, null, "Mine");
    taskListAdapter.setAutoload(false);
    setListAdapter(taskListAdapter);
    taskListAdapter.addOnQueryLoadListener(this);
    taskListAdapter.loadObjects();

    return mainListView;
  }
Exemplo n.º 7
0
 private void setSavedFilmsData() {
   this.mGridView.setAdapter(new FilmAdapter(getActivity(), sSAVED_FILMS));
   this.mSectionLabel.setText(getString(R.string.label_section_favorites));
   if (sSAVED_FILMS.isEmpty()) {
     viewStub.setLayoutResource(R.layout.list_empty_layout);
     mGridView.setEmptyView(viewStub);
   }
 }
 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.º 9
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.º 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 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;
  }
 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);
 }
Exemplo n.º 13
0
  public void inflateContentStub() {
    contentStub.setLayoutResource(layoutResID);
    contentStub.inflate();

    ((DetailView) parent).contentInflated(contentType);
  }
Exemplo n.º 14
0
 public static SearchEntry inflateSearchEntry(ViewStub viewstub) {
   viewstub.setLayoutResource(com.amazon.retailsearch.R.layout.rs_action_bar_query_entry);
   return (SearchEntry) viewstub.inflate();
 }