Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LocaleUtil.initLocale(this);

    boolean shouldRefresh = getIntent().getBooleanExtra(EXTRA_SHOULD_REFRESH, false);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    DataBindingUtil.bind(binding.navView.getHeaderView(0));

    MainApplication.getComponent(this).inject(this);

    subscription.add(
        brokerProvider
            .get()
            .observe()
            .subscribe(
                page -> {
                  toggleToolbarElevation(page.shouldToggleToolbar());
                  changePage(page.getTitleResId(), page.createFragment());
                  binding.navView.setCheckedItem(page.getMenuId());
                }));

    initView();
    AppUtil.setTaskDescription(
        this, getString(R.string.all_sessions), AppUtil.getThemeColorPrimary(this));

    if (savedInstanceState == null) {
      replaceFragment(SessionsFragment.newInstance(shouldRefresh));
    } else {
      binding.toolbar.setTitle(savedInstanceState.getString(EXTRA_TITLE));
    }
    getSupportFragmentManager().addOnBackStackChangedListener(this);
  }
Esempio n. 2
0
 public ViewHolder(boolean isLeft, View v) {
   super(v);
   if (isLeft) {
     this.isLeft = true;
     bindingLeft = DataBindingUtil.bind(v);
   } else {
     bindingRight = DataBindingUtil.bind(v);
   }
 }
 @Override
 protected void addHeaderView(ListView listView) {
   Intent intent = getIntent();
   mForumInfo = intent.getParcelableExtra(AppConstants.PARCELABLE_KEY);
   mBlockInfo = intent.getParcelableExtra(AppConstants.PARCELABLE_KEY_TWO);
   if (null == mForumInfo) JumpManager.doJumpBack(mActivity);
   if (TextUtils.isEmpty(mForumInfo.getSectionname()))
     mForumInfo.setSectionname(
         null == mBlockInfo ? getString(R.string.string_history) : mBlockInfo.getSectionname());
   ReadHistoryManager.add(mForumInfo);
   HeaderForumDetailBinding inflate =
       DataBindingUtil.inflate(
           LayoutInflater.from(mActivity), R.layout.header_forum_detail, null, false);
   inflate.setImgInfo(
       new ImgBinding(
           mForumInfo.getUserImage(), R.drawable.ic_default_head, R.dimen.dimen_30, 10));
   inflate.tvName.setOnClickListener(
       v -> UserManager.jumpToOtherPeople(mActivity, mForumInfo.getPkUser()));
   inflate.setInfo(mForumInfo);
   String images = mForumInfo.getImages();
   if (!TextUtils.isEmpty(images)) {
     String[] split = images.split(",");
     inflate.llImgContent.removeAllViews();
     ArrayList<ImgInfo> imgList = new ArrayList<>();
     for (String url : split) {
       ImgInfo info = new ImgInfo();
       info.setPath(url);
       imgList.add(info);
     }
     for (int position = 0; position < imgList.size(); position++) {
       ItemForumImageBinding imgBinding =
           DataBindingUtil.inflate(
               LayoutInflater.from(mActivity), R.layout.item_forum_image, null, false);
       imgBinding.setImgInfo(
           new ImgBinding(imgList.get(position).getPath(), R.drawable.ic_default_img));
       final int currentPosition = position;
       imgBinding.ivInfo.setOnClickListener(
           v -> {
             Intent photoIntent = new Intent(mActivity, PhotoPreviewActivity.class);
             photoIntent.putParcelableArrayListExtra(AppConstants.PARCELABLE_KEY, imgList);
             photoIntent.putExtra(PhotoPreviewActivity.POSITION, currentPosition);
             photoIntent.putExtra(PhotoPreviewActivity.HIDENDELETE, true);
             JumpManager.doJumpForward(mActivity, photoIntent);
           });
       inflate.llImgContent.addView(imgBinding.getRoot());
     }
   }
   inflate.tvForumName.setText(
       mBlockInfo == null ? mForumInfo.getSectionname() : mBlockInfo.getSectionname());
   inflate.tvForumName.setOnClickListener(v -> JumpManager.doJumpBack(mActivity));
   inflate.ivShowAction.setOnClickListener(v -> showAction(inflate));
   listView.addHeaderView(inflate.getRoot());
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mEvent = mDbManager.getEventsTable().load(getIntent().getLongExtra(PARENT_ID, 0));

    if (mEvent == null) {
      finish();
    }

    binding = DataBindingUtil.setContentView(this, R.layout.layout_tab);
    binding.viewPager.setAdapter(mAdapter = new EventViewPagerAdapter());
    binding.tabLayout.setupWithViewPager(binding.viewPager);

    binding.viewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int position) {
            if (position == 0) {
              ((ListUpdateListener) mAdapter.getRegisteredFragment(0)).updateList();
            }
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });

    setSupportActionBar(binding.toolbar);
    setActionBarTitle(getString(R.string.event));
    setActionBarSubtitle(mEvent.getName());
  }
Esempio n. 5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DataBindingUtil.setContentView(this, R.layout.item_edit_activity);

    // item edit update fragment
    if (getIntent().hasExtra(INTENT_EXTRA_UPDATE_ITEM_ID)) {
      final String tag = ItemUpdateEditFragment.TAG;
      if (isFragmentAdded(tag)) {
        showExistingFragment(tag);
      } else {
        long itemId = getIntent().getLongExtra(INTENT_EXTRA_UPDATE_ITEM_ID, 1);
        itemEditFragment = ItemUpdateEditFragment.getNewInstance(itemId);
        addNewFragment(R.id.fragment_container, itemEditFragment, tag);
      }
    }
    // item edit new fragment
    else {
      final String tag = ItemNewEditFragment.TAG;
      if (isFragmentAdded(tag)) {
        showExistingFragment(tag);
      } else {
        itemEditFragment = new ItemNewEditFragment();
        addNewFragment(R.id.fragment_container, itemEditFragment, tag);
      }
    }
  }
Esempio n. 6
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   DataBindingUtil.setContentView(this, R.layout.activity_main);
   NavigationView navigation = (NavigationView) findViewById(R.id.main_nav);
   navigation.setNavigationItemSelectedListener(this);
   drawer = (DrawerLayout) findViewById(R.id.main_drawer);
   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   setSupportActionBar(toolbar);
   ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, 0, 0);
   drawer.setDrawerListener(toggle);
   toggle.syncState();
   FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
   chapter = new ChapterFragment();
   forum = new ForumFragment();
   game = new GameFragment();
   transaction
       .add(R.id.main_container, chapter)
       .add(R.id.main_container, forum)
       .add(R.id.main_container, game)
       .detach(forum)
       .detach(game)
       .detach(chapter)
       .attach(chapter)
       .commit();
 }
Esempio n. 7
0
 @Override
 public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
   switch (viewType) {
     case 1:
       MessageLeftBinding bindingLeft =
           DataBindingUtil.inflate(
               activity.getLayoutInflater(), R.layout.message_left, parent, false);
       return new ViewHolder(true, bindingLeft.getRoot());
     case 0:
       MessageRightBinding bindingRight =
           DataBindingUtil.inflate(
               activity.getLayoutInflater(), R.layout.message_right, parent, false);
       return new ViewHolder(false, bindingRight.getRoot());
   }
   return null;
 }
Esempio n. 8
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ActivityCounterMvvmBinding binding =
       DataBindingUtil.setContentView(this, R.layout.activity_counter_mvvm);
   binding.setData(new CounterViewModel(0));
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ActivityNdkBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_ndk);
   NdkJniUtils jni = new NdkJniUtils();
   binding.setNdk(jni.getCLanguageString());
 }
Esempio n. 10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mActivityFileSelectBinding =
        DataBindingUtil.setContentView(this, R.layout.activity_file_select);

    /*
       we are just created a result intent
       that can be sent back to any app that started this activity
    */
    mResultIntent = new Intent("com.example.myapp.ACTION_RETURN_FILE");
    // Get the files/ subdirectory of internal storage
    mPrivateRootDir = getFilesDir();
    // Get the files/images subdirectory;
    mImagesDir = new File(mPrivateRootDir, "images");
    // Get the files in the images subdirectory
    mImageFiles = mImagesDir.listFiles();
    // Set the Activity's result to null to begin with
    setResult(Activity.RESULT_CANCELED, null);

    /*
       Recycler view is used to create the image gallery
       ImageRecyclerViewAdapter class is where we are laying out images that were saved
       in the private folder of this app.

    */
    RecyclerView recyclerView = mActivityFileSelectBinding.recylcerView;
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
    recyclerView.setLayoutManager(gridLayoutManager);
    ImageRecyclerViewAdapter adapter = new ImageRecyclerViewAdapter();
    recyclerView.setAdapter(adapter);
  }
Esempio n. 11
0
 @Override
 public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
   ItemRecyclerViewBinding binding =
       DataBindingUtil.inflate(
           LayoutInflater.from(parent.getContext()), R.layout.item_recycler_view, parent, false);
   return new Holder(binding);
 }
 /**
  * 创建加载成功后显示界面
  *
  * @return 显示界面
  */
 protected View createLoadedView(LayoutInflater inflater, ViewGroup container) {
   ViewDataBinding inflate = DataBindingUtil.inflate(inflater, getResLayout(), container, false);
   View view = inflate.getRoot();
   initView(view, inflate);
   initData();
   return view;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_project_details);
    ButterKnife.bind(this);
    KickMaterialApp.component.inject(this);
    binding.setProject(projectDetailsField.observable());
    supportPostponeEnterTransition();
    handleArguments();

    injectViewsAndSetUpToolbar();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false); // Hide default toolbar title
    binding.scrollView.addCallbacks(this);
    minTitlesMarginTop = ViewUtils.dpToPx(32, getApplicationContext());
    maxTitlesMarginTop =
        getResources().getDimensionPixelSize(R.dimen.titles_container_margin_top)
            - getResources().getDimensionPixelSize(R.dimen.status_bar_height);

    maxTitlesMarginLeft = ViewUtils.dpToPx(32, getApplicationContext());
    maxTitlePaddingRight = ViewUtils.dpToPx(72, getApplicationContext());
    maxParallaxValue =
        getResources().getDimensionPixelSize(R.dimen.project_details_photo_height) / 3;
    titleFontMaxSize = getResources().getDimensionPixelSize(R.dimen.font_21);
    titleFontMinSize = getResources().getDimensionPixelSize(R.dimen.font_16);
    imageHeight = getResources().getDimensionPixelSize(R.dimen.project_details_photo_height);
    imageWidth = (int) (imageHeight * ProjectsAdapter.IMAGE_RATIO);
    binding.detailsContainer.startAnimation(
        AnimationUtils.loadAnimation(ProjectDetailsActivity.this, R.anim.slide_from_bottom));
    loadProjectData();
    launchPostTransitionAnimations();
  }
  @NonNull
  private ViewBindingHolder<T> onCreateViewBindingHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());

    T binding = DataBindingUtil.inflate(inflater, layoutId, null, false);
    return new ViewBindingHolder<>(binding);
  }
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {

    binding =
        DataBindingUtil.inflate(
            LayoutInflater.from(getContext()), R.layout.set_location_dialog, null, false);
    binding.locationEdit.addTextChangedListener(
        new SimpleTextWatcher() {
          @Override
          public void afterTextChanged(Editable s) {
            updateFreeSpace(s.toString());
          }
        });
    binding.locationEdit.setText(initialLocation);

    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(R.string.choose_location);
    builder.setView(binding.getRoot());
    builder.setPositiveButton(
        R.string.apply,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            if (listener != null) {
              listener.onLocationSelected(
                  binding.locationEdit.getText().toString(), binding.moveDataCheckbox.isChecked());
            }
          }
        });
    builder.setNegativeButton(android.R.string.cancel, null);

    return builder.create();
  }
Esempio n. 16
0
 public NewsVH(Context context, View itemView, OnItemClickListener mOnItemClickListener) {
   super(itemView);
   dataBinding = DataBindingUtil.bind(itemView);
   dataBinding.itemView.setOnClickListener(this);
   this.mOnItemClickListener = mOnItemClickListener;
   this.context = context;
 }
Esempio n. 17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    user = new User("Freddy");
    binding.setUser(user);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   background = new ScriptContainer(this);
   ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
   adapter = new ActivityMainBindingAdapter(binding);
   binding.setAdapter(adapter);
   configureWebView(binding.webView, "content", this);
 }
Esempio n. 19
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   ViewDataBinding binding =
       DataBindingUtil.inflate(inflater, R.layout.fragment_play_song, container, false);
   binding.setVariable(BR.playingSong, song);
   controlButton = (FancyButton) binding.getRoot().findViewById(R.id.control);
   controlButton.setOnClickListener(this);
   return binding.getRoot();
 }
  @Override
  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ItemYkVideoCachedBinding binding =
        DataBindingUtil.inflate(
            LayoutInflater.from(parent.getContext()), R.layout.item_yk_video_cached, parent, false);
    VH holder = new VH(binding.getRoot());
    holder.setBinding(binding);

    return holder;
  }
Esempio n. 21
0
  @Override
  public BindingHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    int layout = mv.getLayout(viewType);

    ViewDataBinding binding =
        DataBindingUtil.inflate(
            LayoutInflater.from(viewGroup.getContext()), layout, viewGroup, false);
    BindingHolder holder = new BindingHolder(binding.getRoot());
    holder.setBinding(binding);
    return holder;
  }
Esempio n. 22
0
 /* Use this method to set the content view on your Activity. This method also handles
  * creating the binding, setting the view model on the binding and attaching the view. */
 protected final void setAndBindContentView(
     @LayoutRes int layoutResId, @Nullable Bundle savedInstanceState) {
   if (viewModel == null) {
     throw new IllegalStateException(
         "viewModel must not be null and should be injected via activityComponent().inject(this)");
   }
   binding = DataBindingUtil.setContentView(this, layoutResId);
   binding.setVariable(BR.vm, viewModel);
   //noinspection unchecked
   viewModel.attachView((MvvmView) this, savedInstanceState);
 }
Esempio n. 23
0
  @NonNull
  @Override
  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent) {
    ItemPostBinding itemPostBinding =
        DataBindingUtil.inflate(mLayoutInflater, R.layout.item_post, parent, false);
    itemPostBinding.setEventBus(mEventBus);
    itemPostBinding.setDownloadPreferencesManager(mDownloadPreferencesManager);
    itemPostBinding.setDrawableRequestBuilder(mAvatarRequestBuilder);
    itemPostBinding.setPostViewModel(new PostViewModel());

    return new ItemViewBindingHolder(itemPostBinding);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActivityConversionsBinding binding =
        DataBindingUtil.setContentView(this, R.layout.activity_conversions);

    mIsError.set(true);

    binding.setIsError(mIsError);
    binding.setHeight(ScreenUtils.dp2px(this, 200));
  }
Esempio n. 25
0
 @Override
 public void onClick(View v) {
   ChapterItemBinding bind = DataBindingUtil.getBinding(v);
   ChapterEntity chapter = bind.getChapter();
   Toast.makeText(getActivity(), chapter.getTitle(), Toast.LENGTH_SHORT).show();
   ActivityOptionsCompat options =
       ActivityOptionsCompat.makeSceneTransitionAnimation(
           getActivity(), v, getString(R.string.chapter_transition));
   Intent intent = new Intent(getContext(), ChapterContentActivity.class);
   intent.putExtra("chapterId", chapter.getId());
   ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
 }
Esempio n. 26
0
  @Override
  protected RecyclerView.ViewHolder onCreateContentItemViewHolder(
      ViewGroup parent, int contentViewType) {
    ViewArticleFeedBinding binding =
        DataBindingUtil.inflate(
            LayoutInflater.from(parent.getContext()), R.layout.view_article_feed, parent, false);

    SnapShotViewHolder holder = new SnapShotViewHolder(binding.getRoot());
    holder.setBinding(binding);
    binding.cardView.setOnClickListener(mOnClick);
    return holder;
  }
Esempio n. 27
0
 @Override
 public RecyclerView.ViewHolder onCreateViewHolder(
     LayoutInflater inflater, ViewGroup parent, int viewType) {
   if (viewType == TYPE_ITEM) {
     ItemNovelBinding dataBinding =
         DataBindingUtil.inflate(inflater, R.layout.item_novel, parent, false);
     NovelListViewHolder holder = new NovelListViewHolder(dataBinding.getRoot(), this);
     holder.setDataBinding(dataBinding);
     return holder;
   }
   return null;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActivityMenuBinding activityMenuBinding =
        DataBindingUtil.setContentView(this, R.layout.activity_menu);

    mPersona = new Persona();
    mPersona.status.set(true);
    mPersona.text.set("asdasd");

    activityMenuBinding.setPersona(mPersona);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MainBinding binding = DataBindingUtil.setContentView(this, R.layout.main);

    // Set the infos heading
    binding.setHeading(new ListHeading("List Heading"));

    // Set list items
    AndroidInfoList infos = new AndroidInfoList();
    binding.setInfos(infos);
  }
Esempio n. 30
0
  protected void init(Context context, ViewGroup viewGroup, boolean fromXML) {
    _binding =
        DataBindingUtil.inflate(
            LayoutInflater.from(context), R.layout.field_group_view, viewGroup, false);

    //        _cardView = (CardView) LayoutInflater.from(context).inflate(R.layout.field_group_view,
    // viewGroup, false);
    //        _collapsibleView = (CollapsibleView)
    // _cardView.findViewById(R.id.field_card_view_collapsible_view);
    _innerLayout = (LinearLayout) _binding.cardView.findViewById(R.id.field_card_view_layout);

    if (!fromXML) // otherwise done in onFinishInflate
    this.addView(_binding.cardView);
  }