扫下面二维码,即可下载使用: (马云巴巴发福利,支付宝搜索619015079领红包)

个人想着过年了,要发祝福短信之类的,于是想着想着,就自己动手随便弄了一个小小的祝福软件,功能很简单,供大家开心发祝福使用,谢谢。 2019节日祝福多多,上千条祝福短信,精美的节日贺卡,节日分为农历节日和公历节日,可以通过短信微信等第三方应用发送节日祝福给家人和朋友,还可以通过分享功能分享到其他途径传播祝福信息。 【1】收集大量公历农历节日。 【2】支持复制分享。 【3】可作为节日祝福发送给朋友们。 【4】无注册和登录功能 【5】日常祝福实用小工具方便快捷使用 【6】专门提供给用户送家人和朋友节日祝福,送去温馨的问候

现在说一下该软件主要做法,做法很简单: 1】祝福内容数据,网上自己收集整理成json格式数据 2】然后对各个节日json格式文件编辑对应id保存在资源文件夹assets目录里

3】读取assets里面文件并转成String数据

public static String readData(Context context, String fileName) { InputStream inStream = null; String data = null; try { inStream = context.getAssets().open(fileName); //打开assets目录中的文本文件 byte[] bytes = new byte[inStream.available()]; //inStream.available()为文件中的总byte数 inStream.read(bytes); inStream.close(); data = new String(bytes, "utf-8"); //将bytes转为utf-8字符串 } catch (IOException e) { Log.e("AssetsHelper",e.toString()); e.printStackTrace(); } return data; }

	4】然后用gson解析它生成对应Bean类
	
	  String newyears = AssetsHelper.readData(getContext(), "newyears");
  TestBean  testBean = GsonUtil.buildGson().fromJson(newyears, TestBean.class);
		
	5】最后获取TestBean类对应容器List数据设置到RecyclerView控件里对应的item

布局layout上面进行展示

int pos = getArguments().getInt(POS); RecyclerView mRecyler = (RecyclerView) view.findViewById(R.id.recycle_view); LinearLayoutManager manager = new LinearLayoutManager(getContext()); manager.setOrientation(LinearLayout.VERTICAL); mRecyler.setLayoutManager(manager); mRecyler.setAdapter(new MyTAdapter(pos));

class MyTAdapter extends RecyclerView.Adapter<MyHolder>{


    private int pos;

    public MyTAdapter(int pos)
    {

        this.pos = pos;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.item_test, parent, false);
        MyHolder mVH = new MyHolder(view);
        return mVH;
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        String mtitle="空";
        switch (pos)
        {
            case 0:
                mtitle=testBean.getYears().get(position).getTitle();
                break;
            case 1:
                mtitle=testBean.getQrj().get(position).getTitle();
                break;
            case 2:
                mtitle=testBean.getYjj().get(position).getTitle();
                break;
            case 3:
                mtitle=testBean.getSr().get(position).getTitle();
                break;
            case 4:
                mtitle=testBean.getJh().get(position).getTitle();
                break;
            case 5:
                mtitle=testBean.getSdj().get(position).getTitle();
                break;
            case 6:
                mtitle=testBean.getLdj().get(position).getTitle();
                break;
            case 7:
                mtitle=testBean.getMqj().get(position).getTitle();
                break;
            case 8:
                mtitle=testBean.getFqj().get(position).getTitle();
                break;
            case 9:
                mtitle=testBean.getDwj().get(position).getTitle();
                break;
            case 10:
                mtitle=testBean.getZqj().get(position).getTitle();
                break;
        }

        holder.tvid.setText("第"+(position+1)+"条祝福语:");
        holder.tv_1.setText(mtitle);
        final String finalMtitle = mtitle;
        holder.share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                shareMsg(getContext(),"分享好友","分享祝福", finalMtitle);

            }
        });

        holder.copy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                copy(finalMtitle);

            }
        });


    }

    @Override
    public int getItemCount() {
        int p=0;
        switch (pos)
        {
            case 0:
                p=testBean.getYears().size();
                break;
            case 1:
                p=testBean.getQrj().size();
                break;
            case 2:
                p=testBean.getYjj().size();
                break;
            case 3:
                p=testBean.getSr().size();
                break;
            case 4:
                p=testBean.getJh().size();
                break;
            case 5:
                p=testBean.getSdj().size();
                break;
            case 6:
                p=testBean.getLdj().size();
                break;
            case 7:
                p=testBean.getMqj().size();
                break;
            case 8:
                p=testBean.getFqj().size();
                break;
            case 9:
                p=testBean.getDwj().size();
                break;
            case 10:
                p=testBean.getZqj().size();
                break;
        }
        return p;
    }
}

6】分享功能时是调用系统分享来实现的:

public static void shareMsg(Context context, String activityTitle, String msgTitle, String msgText) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // 纯文本 intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle); intent.putExtra(Intent.EXTRA_TEXT, msgText); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(intent, activityTitle)); }

7】文本复制功能调用android系统键盘管理ClipboardManager复制功能:

public void copy(String stext)
{
    ClipboardManager cm = (ClipboardManager)             getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData mClipData = ClipData.newPlainText("Label", stext);
    cm.setPrimaryClip(mClipData);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle("本条祝福语已复制成功").setNegativeButton("确定",null).show();
    //ToastUtil.toastShow(getContext(), "内容已复制到剪切板");

}
	
8】贺卡图片保存到android手机本地里,图库相册可以查看该图片,需要打开系统读写权限:

  <!-- #写入外部存储	android.permission.WRITE_EXTERNAL_STORAGE,允许程序写入外部存储,如SD卡上写文件 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- #可以读取设备外部存储空间(内置SDcard和外置SDCard)的文件 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
	
	 Bitmap  bitmap = BitmapFactory.decodeResource(this.getResources(), imgrid);
            boolean b = SavePicUtils.saveImageToGallery(this , bitmap);
            if (b)
            {
                Toast.makeText(this, "已成功保存到相册里", Toast.LENGTH_SHORT).show();
            }else
            {
                Toast.makeText(this, "保存失败!!", Toast.LENGTH_SHORT).show();
            }

//保存文件到指定路径 public static boolean saveImageToGallery(Context context, Bitmap bmp) { // 首先保存图片 String storePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "zhufudaquan"; File appDir = new File(storePath); if (!appDir.exists()) { appDir.mkdir(); } String fileName = System.currentTimeMillis() + ".jpg"; File file = new File(appDir, fileName); try { FileOutputStream fos = new FileOutputStream(file); //通过io流的方式来压缩保存图片 boolean isSuccess = bmp.compress(Bitmap.CompressFormat.JPEG, 60, fos); fos.flush(); fos.close(); //把文件插入到系统图库 MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), fileName, null); //保存图片后发送广播通知更新数据库 Uri uri = Uri.fromFile(file); context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri)); if (isSuccess) { return true; } else { return false; } } catch (IOException e) { e.printStackTrace(); } return false; }