use of com.huetoyou.chatexchange.ui.frags.UserTileFragment in project ChatExchange by HueToYou.
the class TutorialStuff method showUsersTutorial.
public static void showUsersTutorial(final Activity activity) {
if (mSharedPreferences == null) {
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
}
if (mCategoryConfig == null) {
setCategoryConfig(activity);
}
if (mItemConfig == null) {
setItemConfig(activity);
}
Bundle args = new Bundle();
args.putString(USER_NAME_KEY, "Edwinksl");
args.putString(USER_AVATAR_URL_KEY, "https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fimages.clipshrine.com%2Fdownload%2Fdownloadpnglarge%2FBlack-Question-Mark-2269-large.png&f=1");
args.putString(USER_URL_KEY, "https://example.stackexchange.com");
args.putBoolean("IsExampleTile", true);
args.putInt("ExampleNum", 0);
args.putInt(USER_ID_KEY, 12345);
args.putInt(USER_LAST_POST_KEY, 0);
args.putInt(USER_REP_KEY, 123);
args.putBoolean(USER_IS_MOD_KEY, false);
args.putBoolean(USER_IS_OWNER_KEY, false);
final UserTileFragment userTileFragment = new UserTileFragment();
userTileFragment.setArguments(args);
args = new Bundle();
args.putString(USER_NAME_KEY, "Thomas Ward");
args.putString(USER_AVATAR_URL_KEY, "https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fimages.clipshrine.com%2Fdownload%2Fdownloadpnglarge%2FBlack-Question-Mark-2269-large.png&f=1");
args.putString(USER_URL_KEY, "https://example.stackexchange.com");
args.putBoolean("IsExampleTile", true);
args.putInt("ExampleNum", 1);
args.putInt(USER_ID_KEY, 12346);
args.putInt(USER_LAST_POST_KEY, 0);
args.putInt(USER_REP_KEY, 123);
args.putBoolean(USER_IS_MOD_KEY, true);
args.putBoolean(USER_IS_OWNER_KEY, false);
final UserTileFragment userTileFragment1 = new UserTileFragment();
userTileFragment1.setArguments(args);
args = new Bundle();
args.putString(USER_NAME_KEY, "Rinzwind");
args.putString(USER_AVATAR_URL_KEY, "https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fimages.clipshrine.com%2Fdownload%2Fdownloadpnglarge%2FBlack-Question-Mark-2269-large.png&f=1");
args.putString(USER_URL_KEY, "https://example.stackexchange.com");
args.putBoolean("IsExampleTile", true);
args.putInt("ExampleNum", 2);
args.putInt(USER_ID_KEY, 12347);
args.putInt(USER_LAST_POST_KEY, 0);
args.putInt(USER_REP_KEY, 123);
args.putBoolean(USER_IS_MOD_KEY, false);
args.putBoolean(USER_IS_OWNER_KEY, true);
final UserTileFragment userTileFragment2 = new UserTileFragment();
userTileFragment2.setArguments(args);
PreferencesManager manager = new PreferencesManager(activity);
LinearLayout users = activity.findViewById(R.id.users_scroll_slide);
if (!manager.isDisplayed(USERS_SLIDE_INTRO)) {
List<android.support.v4.app.Fragment> fragments = ((AppCompatActivity) activity).getSupportFragmentManager().getFragments();
for (int i = 0; i < fragments.size(); i++) {
((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().hide(fragments.get(i)).commit();
}
((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().add(R.id.users_scroll_slide, userTileFragment, "user_" + 12345).commit();
((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().add(R.id.users_scroll_slide, userTileFragment1, "user_" + 12346).commit();
((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().add(R.id.users_scroll_slide, userTileFragment2, "user_" + 12347).commit();
MainActivity.touchesBlocked = true;
}
SpotlightView usersOverview = new SpotlightView.Builder(activity).target(users).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_main)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text)).usageId(USERS_SLIDE_INTRO).targetPadding(Util.dpToPx(activity, 50)).show();
final SpotlightView.Builder overviewMore = new SpotlightView.Builder(activity).target(users).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_main)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_more)).usageId(USERS_SLIDE_INTRO_MORE).targetPadding(Util.dpToPx(activity, 50));
final SpotlightView.Builder user1 = new SpotlightView.Builder(activity).target(users.getChildAt(0)).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_user_normal)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_normalUser_tutorial_text)).usageId(USER_ONE);
final SpotlightView.Builder userMod = new SpotlightView.Builder(activity).target(users.getChildAt(1)).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_user_mod)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_modUser_tutorial_text)).usageId(USER_MOD);
final SpotlightView.Builder userOwner = new SpotlightView.Builder(activity).setConfiguration(mCategoryConfig).target(users.getChildAt(2)).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_user_owner)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_ROuser_tutorial_text)).usageId(USER_OWNER);
SpotlightListener listener = new SpotlightListener() {
@Override
public void onUserClicked(String s) {
Log.e("Which", s);
switch(s) {
case USERS_SLIDE_INTRO:
overviewMore.show();
MainActivity.touchesBlocked = true;
break;
case USERS_SLIDE_INTRO_MORE:
user1.show();
MainActivity.touchesBlocked = true;
break;
case USER_ONE:
userMod.show();
MainActivity.touchesBlocked = true;
break;
case USER_MOD:
userOwner.show();
MainActivity.touchesBlocked = true;
break;
case USER_OWNER:
List<android.support.v4.app.Fragment> fragments = ((AppCompatActivity) activity).getSupportFragmentManager().getFragments();
for (int i = 0; i < fragments.size(); i++) {
((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().show(fragments.get(i)).commit();
}
((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().remove(userTileFragment).remove(userTileFragment1).remove(userTileFragment2).commit();
MainActivity.touchesBlocked = false;
break;
}
}
@Override
public void onFinishedDrawingSpotlight() {
MainActivity.touchesBlocked = false;
}
@Override
public void onStartedDrawingSpotlight() {
MainActivity.touchesBlocked = false;
}
};
usersOverview.setListener(listener);
overviewMore.setListener(listener);
user1.setListener(listener);
userMod.setListener(listener);
userOwner.setListener(listener);
}
Aggregations