Refactoring

pull/147/head
M66B 6 years ago
parent 0bfc49c1e5
commit 15b56a671d

@ -129,6 +129,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
static final String ACTION_VIEW_FULL = BuildConfig.APPLICATION_ID + ".VIEW_FULL";
static final String ACTION_STORE_RAW = BuildConfig.APPLICATION_ID + ".STORE_RAW";
static final String ACTION_EDIT_FOLDER = BuildConfig.APPLICATION_ID + ".EDIT_FOLDER";
static final String ACTION_EDIT_ANSWERS = BuildConfig.APPLICATION_ID + ".EDIT_ANSWERS";
static final String ACTION_EDIT_ANSWER = BuildConfig.APPLICATION_ID + ".EDIT_ANSWER";
static final String ACTION_EDIT_RULES = BuildConfig.APPLICATION_ID + ".EDIT_RULES";
static final String ACTION_EDIT_RULE = BuildConfig.APPLICATION_ID + ".EDIT_RULE";
@ -475,6 +476,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
iff.addAction(ACTION_VIEW_FULL);
iff.addAction(ACTION_STORE_RAW);
iff.addAction(ACTION_EDIT_FOLDER);
iff.addAction(ACTION_EDIT_ANSWERS);
iff.addAction(ACTION_EDIT_ANSWER);
iff.addAction(ACTION_EDIT_RULES);
iff.addAction(ACTION_EDIT_RULE);
@ -1011,6 +1013,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
onStoreRaw(intent);
else if (ACTION_EDIT_FOLDER.equals(action))
onEditFolder(intent);
else if (ACTION_EDIT_ANSWERS.equals(action))
onEditAnswers(intent);
else if (ACTION_EDIT_ANSWER.equals(action))
onEditAnswer(intent);
else if (ACTION_EDIT_RULES.equals(action))
@ -1101,6 +1105,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
fragmentTransaction.commit();
}
private void onEditAnswers(Intent intent) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentAnswers()).addToBackStack("answers");
fragmentTransaction.commit();
}
private void onEditAnswer(Intent intent) {
FragmentAnswer fragment = new FragmentAnswer();
fragment.setArguments(intent.getExtras());

@ -95,8 +95,6 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
@ -114,7 +112,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private Context context;
private LayoutInflater inflater;
private LifecycleOwner owner;
private FragmentManager fragmentManager;
private ViewType viewType;
private boolean outgoing;
private boolean compact;
@ -1337,9 +1334,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentAnswers()).addToBackStack("answers");
fragmentTransaction.commit();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(new Intent(ActivityView.ACTION_EDIT_ANSWERS));
}
});
snackbar.show();
@ -2006,12 +2002,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
}
AdapterMessage(Context context, LifecycleOwner owner, FragmentManager fragmentManager,
AdapterMessage(Context context, LifecycleOwner owner,
ViewType viewType, boolean outgoing, boolean compact, int zoom, IProperties properties) {
this.context = context;
this.owner = owner;
this.inflater = LayoutInflater.from(context);
this.fragmentManager = fragmentManager;
this.viewType = viewType;
this.outgoing = outgoing;
this.compact = compact;

@ -268,7 +268,7 @@ public class FragmentMessages extends FragmentBase {
boolean compact = prefs.getBoolean("compact", false);
int zoom = prefs.getInt("zoom", compact ? 0 : 1);
adapter = new AdapterMessage(
getContext(), getViewLifecycleOwner(), getFragmentManager(),
getContext(), getViewLifecycleOwner(),
viewType, outgoing, compact, zoom, iProperties);
rvMessage.setAdapter(adapter);

Loading…
Cancel
Save