com.socks.jiandan.R Java Examples

The following examples show how to use com.socks.jiandan.R. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShareUtil.java    From JianDanRxJava with Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String imgPath, String shareText) {

        Intent intent = new Intent(Intent.ACTION_SEND);
        File f = new File(imgPath);
        if (f != null && f.exists() && f.isFile()) {
            intent.setType("image/*");
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
        } else {
            ToastHelper.Short("分享图片不存在哦");
            return;
        }

        //GIF图片指明出处url,其他图片指向项目地址
        if (imgPath.endsWith(".gif")) {
            intent.putExtra(Intent.EXTRA_TEXT, shareText);
        }

        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(Intent.createChooser(intent, activity.getResources().getString(R
                .string.app_name)));
    }
 
Example #2
Source File: MainMenuFragment.java    From JianDan_OkHttpWithVolley with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_drawer, container, false);
    ButterKnife.inject(this, view);

    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    rl_container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), SettingActivity.class));
            mainActivity.closeDrawer();
        }
    });

    return view;
}
 
Example #3
Source File: MainMenuFragment.java    From JianDan with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final MenuItem menuItem = menuItems.get(position);

    holder.tv_title.setText(menuItem.getTitle());
    holder.img_menu.setImageResource(menuItem.getResourceId());
    holder.rl_container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            try {
                if (currentFragment != menuItem.getType()) {
                    Fragment fragment = (Fragment) Class.forName(menuItem.getFragment()
                            .getName()).newInstance();
                    mainActivity.replaceFragment(R.id.frame_container, fragment);
                    currentFragment = menuItem.getType();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            mainActivity.closeDrawer();
        }
    });
}
 
Example #4
Source File: MainMenuFragment.java    From JianDan_OkHttpWithVolley with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final MenuItem menuItem = menuItems.get(position);

    holder.tv_title.setText(menuItem.getTitle());
    holder.img_menu.setImageResource(menuItem.getResourceId());
    holder.rl_container.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            try {
                if (currentFragment != menuItem.getType()) {
                    Fragment fragment = (Fragment) Class.forName(menuItem.getFragment()
                            .getName()).newInstance();
                    mainActivity.replaceFragment(R.id.frame_container, fragment);
                    currentFragment = menuItem.getType();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            mainActivity.closeDrawer();
        }
    });
}
 
Example #5
Source File: VideoDetailActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.imgBtn_back:
            if (webview.canGoBack()) {
                webview.goBack();
            }
            break;
        case R.id.imgBtn_forward:
            if (webview.canGoForward()) {
                webview.goForward();
            }
            break;
        case R.id.imgBtn_control:

            if (isLoadFinish) {
                webview.reload();
                isLoadFinish = false;
            } else {
                webview.stopLoading();
            }
            break;
    }
}
 
Example #6
Source File: MenuAdapter.java    From JianDanRxJava with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(MenuHolder holder, int position) {
    final MenuItem menuItem = menuItems.get(position);

    holder.tv_title.setText(menuItem.getTitle());
    holder.img_menu.setImageResource(menuItem.getResourceId());
    holder.rl_container.setOnClickListener(v -> {
        try {
            if (currentFragment != menuItem.getType()) {
                Fragment fragment = (Fragment) Class.forName(menuItem.getFragment()
                        .getName()).newInstance();
                mainView.replaceFragment(R.id.frame_container, fragment);
                currentFragment = menuItem.getType();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        mainView.closeDrawer();
    });
}
 
Example #7
Source File: VideoAdapter.java    From JianDan_OkHttpWithVolley with Apache License 2.0 6 votes vote down vote up
public VideoViewHolder(View contentView) {
    super(contentView);

    img = (ImageView) contentView.findViewById(R.id.img);
    tv_title = (TextView) contentView.findViewById(R.id.tv_title);
    tv_like = (TextView) contentView.findViewById(R.id.tv_like);
    tv_unlike = (TextView) contentView.findViewById(R.id.tv_unlike);

    tv_comment_count = (TextView) contentView.findViewById(R.id.tv_comment_count);
    tv_un_support_des = (TextView) contentView.findViewById(R.id.tv_unsupport_des);
    tv_support_des = (TextView) contentView.findViewById(R.id.tv_support_des);

    img_share = (ImageView) contentView.findViewById(R.id.img_share);
    ll_comment = (LinearLayout) contentView.findViewById(R.id.ll_comment);
    card = (CardView) contentView.findViewById(R.id.card);
}
 
Example #8
Source File: PictureFragment.java    From JianDanRxJava with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    Subscription subscribe = RxNetWorkEvent.toObserverable().subscribe(netWorkEvent -> {
        if (netWorkEvent.getType() == NetWorkEvent.AVAILABLE) {
            if (NetWorkUtil.isWifiConnected(getActivity())) {
                mAdapter.setIsWifi(true);
                if (!isFirstChange && (System.currentTimeMillis() - lastShowTime) > 3000) {
                    ToastHelper.Short(R.string.load_mode_wifi);
                    lastShowTime = System.currentTimeMillis();
                }
            } else {
                mAdapter.setIsWifi(false);
                if (!isFirstChange && (System.currentTimeMillis() - lastShowTime) > 3000) {
                    ToastHelper.Short(R.string.load_mode_3g);
                    lastShowTime = System.currentTimeMillis();
                }
            }
            isFirstChange = false;
        }
    });

    mRxBusComposite.add(subscribe);
}
 
Example #9
Source File: PushCommentActivity.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
protected void initView(@Nullable Bundle savedInstanceState) {
    setContentView(R.layout.activity_push_comment);
    ButterKnife.bind(this);
    mToolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle(R.string.reply);
    mToolbar.setNavigationIcon(R.drawable.ic_actionbar_back);
}
 
Example #10
Source File: PictureAdapter.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
private void setAnimation(View viewToAnimate, int position) {
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(viewToAnimate.getContext(), R
                .anim.item_bottom_in);
        viewToAnimate.startAnimation(animation);
        lastPosition = position;
    }
}
 
Example #11
Source File: FreshNewsAdapter.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    int layoutId = isLargeMode ? R.layout.item_fresh_news : R.layout.item_fresh_news_small;
    View v = LayoutInflater.from(parent.getContext())
            .inflate(layoutId, parent, false);
    return new ViewHolder(v);
}
 
Example #12
Source File: SettingFragment.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {

    String key = preference.getKey();

    if (key.equals(CLEAR_CACHE)) {
        ImageLoader.getInstance().clearDiskCache();
        ToastHelper.Short(R.string.clear_cache);
        clearCache.setSummary("缓存大小:0.00M");
    } else if (key.equals(ABOUT_APP)) {

        MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
                .title(getString(R.string.app_name))
                .backgroundColor(getResources().getColor(JDApplication.COLOR_OF_DIALOG))
                .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                .positiveColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                .negativeColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                .neutralColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                .titleColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                .content(R.string.person_info)
                .positiveText("GitHub")
                .negativeText("WeiBo")
                .neutralText("CSDN")
                .onPositive((dialog1, which) -> {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ZhaoKaiQiang/JianDan")));
                    dialog1.dismiss();
                })
                .onNegative((dialog1, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://weibo.com/zhaokaiqiang1992"))))
                .onNeutral((dialog1, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://weibo.com/zhaokaiqiang1992"))))
                .build();
        dialog.show();
    }
    return true;
}
 
Example #13
Source File: PictureFragment.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_auto_load, container, false);
    ButterKnife.inject(this, view);
    return view;
}
 
Example #14
Source File: PushCommentActivity.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void initView() {
    ButterKnife.inject(this);
    mToolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle("回复");
    mToolbar.setNavigationIcon(R.drawable.ic_actionbar_back);
}
 
Example #15
Source File: SettingActivity.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #16
Source File: CommentAdapter.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public CommentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    switch (viewType) {
        case Commentator.TYPE_HOT:
        case Commentator.TYPE_NEW:
            return new CommentViewHolder(mActivity.getLayoutInflater().inflate(R.layout
                    .item_comment_flag, parent, false));
        case Commentator.TYPE_NORMAL:
            return new CommentViewHolder(mActivity.getLayoutInflater().inflate(R.layout.item_comment, parent,
                    false));
        default:
            return null;
    }
}
 
Example #17
Source File: FreshNewsDetailActivity.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == android.R.id.home) {
        finish();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #18
Source File: VideoAdapter.java    From JianDan with Apache License 2.0 5 votes vote down vote up
private void setAnimation(View viewToAnimate, int position) {
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(viewToAnimate.getContext(), R
                .anim.item_bottom_in);
        viewToAnimate.startAnimation(animation);
        lastPosition = position;
    }
}
 
Example #19
Source File: PictureFragment.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_refresh) {
        mSwipeRefreshLayout.setRefreshing(true);
        mAdapter.loadFirst();
        return true;
    }
    return false;
}
 
Example #20
Source File: CommentListActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public void initView() {
    ButterKnife.inject(this);

    mToolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle("评论");
    mToolbar.setNavigationIcon(R.drawable.ic_actionbar_back);

    mRecyclerView.setHasFixedSize(false);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (isFromFreshNews) {
                mAdapter.loadData4FreshNews();
            } else {
                mAdapter.loadData();
            }
        }
    });
}
 
Example #21
Source File: SettingActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #22
Source File: PushCommentActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public void initView() {
    ButterKnife.inject(this);
    mToolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(mToolbar);
    mToolbar.setTitle("回复");
    mToolbar.setNavigationIcon(R.drawable.ic_actionbar_back);
}
 
Example #23
Source File: PushCommentActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_push_comment);
    initView();
    initData();
}
 
Example #24
Source File: ImageDetailActivity.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_detail);
    initView();
    initData();
}
 
Example #25
Source File: VideoFragment.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.id.action_refresh) {
        mSwipeRefreshLayout.setRefreshing(true);
        mAdapter.loadFirst();
        return true;
    }
    return false;
}
 
Example #26
Source File: FreshNewsDetailActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == android.R.id.home) {
        finish();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #27
Source File: FreshNewsDetailActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fresh_news_detail);
    initView();
    initData();
}
 
Example #28
Source File: JokeFragment.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_auto_load, container, false);
    ButterKnife.bind(this, view);
    return view;
}
 
Example #29
Source File: MainMenuFragment.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
private void addMenuItemsNoSister(MenuAdapter mAdapter) {
    mAdapter.menuItems.clear();
    mAdapter.menuItems.add(new MenuItem("新鲜事", R.drawable.ic_explore_white_24dp, MenuItem.FragmentType.FreshNews,
            FreshNewsFragment.class));
    mAdapter.menuItems.add(new MenuItem("无聊图", R.drawable.ic_mood_white_24dp, MenuItem.FragmentType.BoringPicture,
            PictureFragment.class));
    mAdapter.menuItems.add(new MenuItem("段子", R.drawable.ic_chat_white_24dp, MenuItem.FragmentType.Joke, JokeFragment
            .class));
    mAdapter.menuItems.add(new MenuItem("小电影", R.drawable.ic_movie_white_24dp, MenuItem.FragmentType.Video,
            VideoFragment.class));
}
 
Example #30
Source File: PushCommentActivity.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
protected void loadData() {
    parent_name = getIntent().getStringExtra("parent_name");
    tv_title.setText(TextUtil.isNull(parent_name) ? getString(R.string.reply_colon) : getString(R.string.reply_colon) + parent_name);
    //新鲜事中 文章id=当前的thread_id=接口参数中的post_id
    thread_id = getIntent().getStringExtra("thread_id");
    parent_id = getIntent().getStringExtra("parent_id");
}