Java Code Examples for com.socks.jiandan.R

The following examples show how to use com.socks.jiandan.R. These examples are extracted from open source projects. 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 Project: JianDanRxJava   Source File: MenuAdapter.java    License: 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 2
Source Project: JianDan_OkHttpWithVolley   Source File: VideoAdapter.java    License: 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 3
Source Project: JianDan_OkHttpWithVolley   Source File: MainMenuFragment.java    License: 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 4
Source Project: JianDan_OkHttpWithVolley   Source File: MainMenuFragment.java    License: 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 Project: JianDanRxJava   Source File: ShareUtil.java    License: 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 6
Source Project: JianDanRxJava   Source File: PictureFragment.java    License: 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 7
@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 8
Source Project: JianDan   Source File: MainMenuFragment.java    License: 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 9
Source Project: JianDan_OkHttpWithVolley   Source File: SubFloorFactory.java    License: Apache License 2.0 5 votes vote down vote up
public View buildSubFloor ( Commentable cmt, ViewGroup group ) {
    LayoutInflater inflater = ( LayoutInflater ) group.getContext ().getSystemService ( Context.LAYOUT_INFLATER_SERVICE ) ;
    View view = inflater.inflate ( R.layout.item_comment_floor, null ) ;
    RelativeLayout show = ( RelativeLayout ) view.findViewById ( R.id.show_sub_floor_content ) ;
    RelativeLayout hide = ( RelativeLayout ) view.findViewById ( R.id.hide_sub_floor_content ) ;
    show.setVisibility ( View.VISIBLE ) ;
    hide.setVisibility ( View.GONE ) ;
    TextView floorNum = ( TextView ) view.findViewById ( R.id.sub_floor_num ) ;
    TextView username = ( TextView ) view.findViewById ( R.id.sub_floor_username ) ;
    TextView content = ( TextView ) view.findViewById ( R.id.sub_floor_content ) ;
    floorNum.setText ( String.valueOf ( cmt.getCommentFloorNum() ) ) ;
    username.setText ( cmt.getAuthorName() ) ;
    content.setText ( cmt.getCommentContent()) ;
    return view ;
}
 
Example 10
Source Project: JianDanRxJava   Source File: FreshNewsAdapter.java    License: 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 Project: JianDanRxJava   Source File: FreshNewsFragment.java    License: 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 12
Source Project: JianDan_OkHttpWithVolley   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
protected 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 13
Source Project: JianDan_OkHttpWithVolley   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public JokeViewHolder(View contentView) {
    super(contentView);

    tv_author = (TextView) contentView.findViewById(R.id.tv_author);
    tv_content = (TextView) contentView.findViewById(R.id.tv_content);
    tv_time = (TextView) contentView.findViewById(R.id.tv_time);
    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);

    img_share = (ImageView) contentView.findViewById(R.id.img_share);
    card = (CardView) contentView.findViewById(R.id.card);
    ll_comment = (LinearLayout) contentView.findViewById(R.id.ll_comment);
}
 
Example 14
Source Project: JianDan_OkHttpWithVolley   Source File: PictureAdapter.java    License: 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 15
Source Project: JianDanRxJava   Source File: FreshNewsAdapter.java    License: 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 16
Source Project: JianDan_OkHttpWithVolley   Source File: FreshNewsAdapter.java    License: 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 17
Source Project: JianDan_OkHttpWithVolley   Source File: FreshNewsAdapter.java    License: 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 18
Source Project: JianDanRxJava   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    mRxBusComposite = new CompositeSubscription();
    Subscription sub = RxNetWorkEvent.toObserverable()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(AndroidSchedulers.mainThread())
            .subscribe(netWorkEvent -> {
                if (netWorkEvent.getType() == NetWorkEvent.UNAVAILABLE) {
                    if (noNetWorkDialog == null) {
                        noNetWorkDialog = new MaterialDialog.Builder(MainActivity.this)
                                .title(R.string.no_network)
                                .content(R.string.open_network)
                                .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)
                                .titleColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                                .negativeText(R.string.no).positiveText(R.string.yes)
                                .onPositive((dialog, which) -> IntentHelper.toSettingActivity(mContext))
                                .cancelable(false)
                                .build();
                    }
                    if (!noNetWorkDialog.isShowing()) {
                        noNetWorkDialog.show();
                    }
                }
            });
    mRxBusComposite.add(sub);
}
 
Example 19
Source Project: JianDan_OkHttp   Source File: FreshNewsDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initView() {
    ButterKnife.inject(this);
    mToolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(mToolbar);
    mToolbar.setNavigationIcon(R.drawable.ic_actionbar_back);
}
 
Example 20
Source Project: JianDanRxJava   Source File: CommentAdapter.java    License: 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 21
Source Project: JianDan_OkHttp   Source File: ImageDetailActivity.java    License: 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 22
Source Project: JianDan_OkHttp   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public JokeViewHolder(View contentView) {
    super(contentView);

    tv_author = (TextView) contentView.findViewById(R.id.tv_author);
    tv_content = (TextView) contentView.findViewById(R.id.tv_content);
    tv_time = (TextView) contentView.findViewById(R.id.tv_time);
    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);

    img_share = (ImageView) contentView.findViewById(R.id.img_share);
    card = (CardView) contentView.findViewById(R.id.card);
    ll_comment = (LinearLayout) contentView.findViewById(R.id.ll_comment);
}
 
Example 23
Source Project: JianDanRxJava   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
protected 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 24
Source Project: JianDanRxJava   Source File: PictureFragment.java    License: 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 25
Source Project: JianDanRxJava   Source File: MainMenuFragment.java    License: Apache License 2.0 5 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.bind(this, view);

    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    return view;
}
 
Example 26
@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 27
Source Project: JianDanRxJava   Source File: PushCommentActivity.java    License: 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");
}
 
Example 28
Source Project: JianDan_OkHttp   Source File: MainMenuFragment.java    License: 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 29
Source Project: JianDanRxJava   Source File: JokeFragment.java    License: 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 30
Source Project: JianDan_OkHttp   Source File: PushCommentActivity.java    License: 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);
}