-
Notifications
You must be signed in to change notification settings - Fork 207
/
SlideUpViewActivity.java
100 lines (88 loc) · 3.29 KB
/
SlideUpViewActivity.java
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
package com.example.slideup;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.mancj.slideup.SlideUp;
import com.mancj.slideup.SlideUpBuilder;
public class SlideUpViewActivity extends AppCompatActivity {
private SlideUp slideUp;
private View dim;
private View sliderView;
private FloatingActionButton fab;
Toast toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slide_up_view);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
sliderView = findViewById(R.id.slideView);
sliderView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (toast != null){
toast.cancel();
}
toast = Toast.makeText(SlideUpViewActivity.this, "click", Toast.LENGTH_SHORT);
toast.show();
}
});
dim = findViewById(R.id.dim);
fab = (FloatingActionButton) findViewById(R.id.fab);
slideUp = new SlideUpBuilder(sliderView)
.withListeners(new SlideUp.Listener.Events() {
@Override
public void onSlide(float percent) {
dim.setAlpha(1 - (percent / 100));
if (fab.isShown() && percent < 100) {
fab.hide();
}
}
@Override
public void onVisibilityChanged(int visibility) {
if (visibility == View.GONE){
fab.show();
}
}
})
.withStartGravity(Gravity.BOTTOM)
.withLoggingEnabled(true)
.withGesturesEnabled(true)
.withStartState(SlideUp.State.HIDDEN)
.withSlideFromOtherView(findViewById(R.id.rootView))
.build();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
slideUp.show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_slide_up_view, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.action_slide_start:
startActivity(new Intent(this, SlideStartViewActivity.class));
break;
case R.id.action_slide_end:
startActivity(new Intent(this, SlideEndViewActivity.class));
break;
case R.id.action_slide_down:
startActivity(new Intent(this, SlideDownViewActivity.class));
break;
}
return super.onOptionsItemSelected(item);
}
}