国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|編程技術|正則表達式|

服務器之家 - 編程語言 - JAVA教程 - 基于RxPaparazzo實現圖片裁剪、圖片旋轉、比例放大縮小功能

基于RxPaparazzo實現圖片裁剪、圖片旋轉、比例放大縮小功能

2020-09-29 13:50曦笑大海 JAVA教程

這篇文章主要為大家詳細介紹了基于RxPaparazzo實現圖片裁剪、圖片旋轉、比例放大縮小功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

前言:基于RxPaparazzo的圖片裁剪圖片旋轉、比例放大|縮小。

效果:

 基于RxPaparazzo實現圖片裁剪、圖片旋轉、比例放大縮小功能

開發環境:AndroidStudio2.2.1+gradle-2.14.1 

涉及知識:

1.Material Design

(CardView+CoordinatorLayout+AppBarLayout+NestedScrollView+CollapsingToolbarLayout+Toolbar+FloatingActionButton)使用 

2.butterknife注解式開發 

3.基于RxJava+RxAndroid的RxPaparazzo使用 

引入依賴: 

?
1
2
3
4
5
6
7
8
9
10
11
12
compile 'com.android.support:appcompat-v7:24.+'
 //RxPaparazzo 拍照&相冊
// compile "com.github.miguelbcr:RxPaparazzo:0.4.2-2.x"
 compile ("com.github.miguelbcr:RxPaparazzo:0.5.2-2.x") {
 exclude module: 'okhttp'
 exclude module: 'okio'
 }
 compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
 compile 'com.android.support:cardview-v7:24.+'
// compile 'com.android.support:customtabs:24.+'
 compile 'com.android.support:design:24.+'
 compile 'com.jakewharton:butterknife:7.0.1'

部分代碼:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
public class MainActivity extends AppCompatActivity {
 
 @Bind(R.id.iv_appbar)
 ImageView iv_appbar;
 
 @Bind(R.id.main_toolbar)
 Toolbar toolbar;
 
 /* @Bind(R.id.btn_float)
 FloatingActionButton btn_float;*/
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 ButterKnife.bind(this);
 initToolBar();
 }
 
 private void initToolBar() {
 this.setSupportActionBar(toolbar);
 toolbar.setTitle("我的");
 }
 
 @OnClick({R.id.main_toolbar, R.id.btn_float})
 public void onClick(View view) {
 final UCrop.Options options = new UCrop.Options();
 int color = ContextCompat.getColor(view.getContext(), R.color.colorPrimary);
 options.setToolbarColor(color);
 options.setStatusBarColor(ContextCompat.getColor(view.getContext(), R.color.colorPrimaryDark));
 options.setActiveWidgetColor(color);
 switch (view.getId()) {
  case R.id.main_toolbar:
  Toast.makeText(MainActivity.this, "Toolbar點擊", Toast.LENGTH_SHORT).show();
  break;
  case R.id.btn_float: {
  showDialog(view, options);
  break;
  }
 }
 }
 
 private void showDialog(View view, final UCrop.Options options) {
 final Context context = view.getContext();
 final AlertDialog.Builder builder = new AlertDialog.Builder(context);
 builder.setTitle("設置背景圖片:").setMessage("如何獲取圖片?")
  .setPositiveButton("相冊", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
   dialog.dismiss();
//   RxPaparazzo.takeImage(MainActivity.this)
   RxPaparazzo.single(MainActivity.this)
    .crop(options)
    .usingGallery()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Consumer<Response<MainActivity, FileData>>() {
     @Override
     public void accept(Response<MainActivity, FileData>
        response) throws Exception {
     if (response.resultCode() == Activity.RESULT_OK) {
 
      File filePath = response.data().getFile();
      Bitmap bitmap = BitmapFactory.
       decodeFile(filePath.getPath());
      iv_appbar.setImageBitmap(bitmap);
 
     } else if (response.resultCode() == Activity.RESULT_CANCELED) {
 
      Toast.makeText(MainActivity.this, "取消相冊訪問",
       Toast.LENGTH_SHORT).show();
 
     } else {
 
      Toast.makeText(MainActivity.this, "未知錯誤!",
       Toast.LENGTH_SHORT).show();
     }
     }
    });
   }
  })
  .setNeutralButton("取消", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
   dialog.dismiss();
   }
  })
  .setNegativeButton("拍照", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
   dialog.dismiss();
//   RxPaparazzo.takeImage(MainActivity.this)
   RxPaparazzo.single(MainActivity.this)
    .crop(options)
    .usingCamera()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Consumer<Response<MainActivity, FileData>>() {
     @Override
     public void accept(Response<MainActivity, FileData>
        response) throws Exception {
 
     if (response.resultCode() == Activity.RESULT_OK) {
      FileData filePath = response.data();
      Bitmap bitmap = BitmapFactory.
       decodeFile(filePath.getFile().getPath());
      iv_appbar.setImageBitmap(bitmap);
     } else if (response.resultCode() == Activity.RESULT_CANCELED) {
      Toast.makeText(MainActivity.this, "取消拍照",
       Toast.LENGTH_SHORT).show();
     } else {
      Toast.makeText(MainActivity.this, "未知錯誤!",
       Toast.LENGTH_SHORT).show();
     }
     }
    });
   /**
    * new Consumer<Response<MainActivity, String>>() {
   @Override public void accept(@NonNull Response<MainActivity, String> response) throws Exception {
   if (response.resultCode() == Activity.RESULT_OK) {
   String filePath = response.data();
   Bitmap bitmap = BitmapFactory.decodeFile(filePath);
   iv_appbar.setImageBitmap(bitmap);
   } else if (response.resultCode() == Activity.RESULT_CANCELED) {
   Toast.makeText(MainActivity.this, "取消拍照", Toast.LENGTH_SHORT).show();
   } else {
   Toast.makeText(MainActivity.this, "未知錯誤!", Toast.LENGTH_SHORT).show();
   }
   }
   }
    *
    */
   }
  });
 
 AlertDialog dialog = builder.create();
 dialog.show();
 
 dialog.getButton(DialogInterface.BUTTON_POSITIVE).
 
  setTextColor(ContextCompat.getColor(context, R.color.colorPrimary)
  );
 dialog.getButton(DialogInterface.BUTTON_NEGATIVE).
 
  setTextColor(ContextCompat.getColor(context, R.color.colorPrimary)
 
  );
 dialog.getButton(DialogInterface.BUTTON_NEUTRAL).
 
  setTextColor(ContextCompat.getColor(context, R.color.colorAccent)
 
  );
 }
 
 @Override
 protected void onDestroy() {
 super.onDestroy();
 ButterKnife.unbind(this);//解除綁定
 }
}

源碼下載

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 亚洲精品成a人 | 青娱乐网 | 国产精品久久久久久久久免费桃花 | 久久国产午夜 | 国产一区二区免费 | 互换娇妻呻吟hd中文字幕 | 日韩精品一区二 | 亚洲精品成人免费 | 超碰日韩 | 国产成人精品一区二区 | 日韩精品极品视频在线观看免费 | 青青草91青娱盛宴国产 | 49vv看片免费 | 成人免费视频视频 | 亚洲精品国产一区 | 久久久久久久久久久久国产 | 欧美成视频 | 一本一本久久a久久精品综合妖精 | 老司机av导航 | 国产精品毛片 | 亚洲一区二区av | 中文字幕高清视频 | 亚洲精品日韩激情在线电影 | 欧美一区二区三区在线观看视频 | 欧美一区| 久久久久999 | 99国产在线视频 | 久久成人免费视频 | 欧美在线视频一区二区 | 毛片在线视频 | 黄色免费看| 欧美精品一区二区三区一线天视频 | 婷婷久久综合 | 激情伊人 | 久久久国产一区 | 亚洲视频一区在线观看 | 亚洲综合首页 | 伊人久久精品久久亚洲一区 | 久久久亚洲综合 | 一区二区三区四区精品 | 国产伦精品一区二区三区四区视频_ |