Skip to content

Commit

Permalink
reanme
Browse files Browse the repository at this point in the history
  • Loading branch information
hurshi1 committed Jul 10, 2018
1 parent e1dc78d commit 9b22654
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.github.hurshi.clickedwordslib.ClickedWords;
import com.github.hurshi.clickedwordslib.OnWordsClickedListener;

public class MainActivity extends AppCompatActivity {
private TextView textView;
Expand All @@ -22,7 +19,7 @@ protected void onCreate(Bundle savedInstanceState) {

new ClickedWords.Builder()
.setTextView(textView)
.setBottomDialog(wordDetailDialog)
.setWordDetailDialog(wordDetailDialog)
.setFragmentManager(getSupportFragmentManager())
.setFocusedBgColor(R.color.focusedBgColor)
.setFocusedFgColor(R.color.focusedFgColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.github.hurshi.clickedwordslib.BottomDialog;

public class WordDetailDialog extends BottomDialog {
public class WordDetailDialog extends com.github.hurshi.clickedwordslib.WordDetailDialog {
public WordDetailDialog() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
if (null != builder.getListener()) {
builder.getListener().wordsClicked(words);
}
if (null != builder.getBottomDialog()) {
if (null != builder.getWordDetailDialog()) {
showWordDetail(builder, positions, words);
}
}
Expand All @@ -62,14 +62,14 @@ private Pair<Integer, Integer> getWord(String string, int offset) {

private void showWordDetail(final Builder builder, Pair<Integer, Integer> positions, String words) {
setTextViewClicked(builder, positions);
builder.getBottomDialog().setWords(words);
builder.getBottomDialog().setListener(new BottomDialog.OnBottomDialogDismissListener() {
builder.getWordDetailDialog().setWords(words);
builder.getWordDetailDialog().setListener(new WordDetailDialog.OnBottomDialogDismissListener() {
@Override
public void onDismiss() {
setTextViewNormal(builder.getTextView());
}
});
builder.getBottomDialog().show(builder.getFragmentManager());
builder.getWordDetailDialog().show(builder.getFragmentManager());
}

private void setTextViewClicked(Builder builder, Pair<Integer, Integer> positions) {
Expand All @@ -93,7 +93,7 @@ public static class Builder {
private FragmentManager fragmentManager;
private TextView textView;
private OnWordsClickedListener listener;
private BottomDialog bottomDialog;
private WordDetailDialog wordDetailDialog;
private int focusedBgColor;
private int focusedFgColor;

Expand Down Expand Up @@ -124,12 +124,12 @@ public Builder setListener(OnWordsClickedListener listener) {
return this;
}

private BottomDialog getBottomDialog() {
return bottomDialog;
private WordDetailDialog getWordDetailDialog() {
return wordDetailDialog;
}

public Builder setBottomDialog(BottomDialog bottomDialog) {
this.bottomDialog = bottomDialog;
public Builder setWordDetailDialog(WordDetailDialog wordDetailDialog) {
this.wordDetailDialog = wordDetailDialog;
return this;
}

Expand All @@ -155,8 +155,8 @@ public ClickedWords build() {
if (null == textView) {
throw new IllegalArgumentException("TextView can not be null");
}
if (null == fragmentManager && null == bottomDialog) {
throw new IllegalArgumentException("BottomDialog need FragmentManager not be null");
if (null == fragmentManager && null == wordDetailDialog) {
throw new IllegalArgumentException("WordDetailDialog need FragmentManager not be null");
}
return new ClickedWords(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatDialogFragment;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

public abstract class BottomDialog extends AppCompatDialogFragment {
public abstract class WordDetailDialog extends AppCompatDialogFragment {
private OnBottomDialogDismissListener listener;
private String words;
private FragmentManager manager;

public BottomDialog() {
public WordDetailDialog() {
}

@Override
Expand Down Expand Up @@ -54,7 +53,7 @@ public void onStart() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
FragmentTransaction ft = manager.beginTransaction();
ft.hide(BottomDialog.this);
ft.hide(WordDetailDialog.this);
ft.commit();
// dismiss();
if (null != listener) {
Expand Down

0 comments on commit 9b22654

Please sign in to comment.