Exemplo n.º 1
0
  @Override
  public void onCreate(Bundle savedInstance) {

    super.onCreate(savedInstance);
    subreddit = getIntent().getExtras().getString("subreddit", "");

    getTheme().applyStyle(new ColorPreferences(this).getThemeSubreddit(subreddit), true);
    getTheme().applyStyle(new FontPreferences(this).getFontStyle().getResId(), true);
    setContentView(R.layout.activity_slidetabs);

    StyleView.styleActivity(this);

    tabs = (TabLayout) findViewById(R.id.sliding_tabs);
    tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
    android.support.v7.widget.Toolbar toolbar =
        (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("/r/" + subreddit + " wiki");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    pager = (ViewPager) findViewById(R.id.contentView);
    findViewById(R.id.header).setBackgroundColor(Pallete.getColor(subreddit));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = getWindow();
      window.setStatusBarColor(Pallete.getDarkerColor(subreddit));
    }

    new AsyncGetWiki().execute();
  }
Exemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    v = inflater.inflate(R.layout.fragment_verticalcontent, container, false);

    rv = ((RecyclerView) v.findViewById(R.id.vertical_content));
    final PreCachingLayoutManager mLayoutManager;
    mLayoutManager = new PreCachingLayoutManager(getActivity());
    rv.setLayoutManager(mLayoutManager);

    mSwipeRefreshLayout =
        (SwipeRefreshLayout) v.findViewById(R.id.activity_main_swipe_refresh_layout);
    TypedValue typed_value = new TypedValue();
    getActivity()
        .getTheme()
        .resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, typed_value, true);
    mSwipeRefreshLayout.setProgressViewOffset(
        false, 0, getResources().getDimensionPixelSize(typed_value.resourceId));

    mSwipeRefreshLayout.setColorSchemeColors(Pallete.getColors(id, getActivity()));

    mSwipeRefreshLayout.setRefreshing(true);
    posts = new InboxMessages(id);
    adapter = new InboxAdapter(getContext(), posts, rv);
    rv.setAdapter(adapter);

    try {
      posts.bindAdapter(adapter, mSwipeRefreshLayout);
    } catch (ExecutionException | InterruptedException e) {
      e.printStackTrace();
    }
    // TODO catch errors
    mSwipeRefreshLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            posts.loadMore(adapter, id);

            // TODO catch errors
          }
        });
    return v;
  }
Exemplo n.º 3
0
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    getTheme().applyStyle(new ColorPreferences(this).getThemeSubreddit(""), true);

    getTheme().applyStyle(new FontPreferences(this).getFontStyle().getResId(), true);
    setContentView(R.layout.activity_submit);

    final Toolbar b = (Toolbar) findViewById(R.id.toolbar);
    b.setTitle(R.string.title_submit_post);
    b.setBackgroundColor(Pallete.getColor("alksfjalskjf"));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = this.getWindow();
      window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(Pallete.getDarkerColor(Pallete.getColor("asldkfj")));
    }
    setSupportActionBar(b);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();

    final String subreddit = intent.getStringExtra("subreddit");

    self = findViewById(R.id.selftext);
    subredditText = ((EditText) findViewById(R.id.subreddittext));
    image = findViewById(R.id.image);
    link = findViewById(R.id.url);

    image.setVisibility(View.GONE);
    link.setVisibility(View.GONE);

    subredditText.setText(subreddit);

    findViewById(R.id.selftextradio)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                self.setVisibility(View.VISIBLE);

                image.setVisibility(View.GONE);
                link.setVisibility(View.GONE);
              }
            });
    findViewById(R.id.imageradio)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                self.setVisibility(View.GONE);
                image.setVisibility(View.VISIBLE);
                link.setVisibility(View.GONE);
              }
            });
    findViewById(R.id.linkradio)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                self.setVisibility(View.GONE);
                image.setVisibility(View.GONE);
                link.setVisibility(View.VISIBLE);
              }
            });

    findViewById(R.id.selImage)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(
                    Intent.createChooser(intent, getString(R.string.editor_select_img)), 1);
              }
            });

    DoEditorActions.doActions(
        ((EditText) findViewById(R.id.bodytext)),
        findViewById(R.id.innersend2),
        getSupportFragmentManager());

    findViewById(R.id.send)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                ((FloatingActionButton) findViewById(R.id.send)).hide();
                new AsyncDo().execute();
              }
            });
  }